Metadata-Version: 2.5
Name: django-quant-tick
Version: 0.2.2
Summary: Django Quant Tick aggregates candlesticks from high frequency tick data from S3 and REST APIs
Project-URL: Homepage, https://github.com/globophobe/django-quant-tick
Project-URL: Repository, https://github.com/globophobe/django-quant-tick
Author-email: Alex <globophobe@gmail.com>
License: MIT
License-File: LICENSE
Keywords: binance,bitfinex,bybit,candlesticks,coinbase,cryptocurrency,deribit,django,quant,trading,trading-strategies
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Requires-Dist: django-polymorphic>=3.1.0
Requires-Dist: django>=4.2
Requires-Dist: httpx2>=2.12.0
Requires-Dist: pandas>=2.2.3
Requires-Dist: pyarrow>=18.1.0
Requires-Dist: randomname>=0.2.1
Description-Content-Type: text/markdown

# Django Quant Tick

Django Quant Tick collects exchange market data and builds time-based and
event-based candlesticks from trade-level data.

## Why event-based candles?

Markets do not process information at a constant rate. A fixed-time candle
represents the same wall-clock interval during both quiet and active markets,
whereas an event-based candle closes after a configured amount of trading
activity. It therefore produces more observations when the market is active and
fewer when it is quiet.

Django Quant Tick supports:

- fixed-window time candles;
- constant-threshold candles sampled by ticks, quote-value volume, or physical
  quantity; and
- adaptive candles whose threshold targets a configured number of candles per
  day from recent activity.

The motivation is discussed in
[Low-Frequency Traders in a High-Frequency World: A Survival Guide](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2150876)
and
[The Volume Clock: Insights into the High Frequency Paradigm](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2034858).
Event-based sampling is an alternative representation, not a guarantee of
better statistical or trading results.

## Trade-data pipeline

1. Download trades from a public archive when available, otherwise from the
   venue REST API.
2. Optionally combine consecutive executions with the same symbol, timestamp,
   nanoseconds, and tick direction.
3. Optionally retain significant quote-value trades while folding intervening
   activity into high/low and buy/total fields. A final integrity row preserves
   the remainder of every one-minute window.
4. Check that raw, aggregated, and filtered representations preserve volume and
   physical quantity, then compare their one-minute totals with venue candles.
5. Store trade frames as parquet through Django file storage and keep coverage,
   validation, and candle state in the database.

See [Data and aggregation notes](NOTES.md) for the precise field conventions,
compression semantics, validation limits, candle behavior, and storage model.

The reusable application also collects venue candles and, for supported
perpetual markets, funding and market-statistics observations.

## Supported exchanges

Trade and venue-candle adapters are available for:

- Binance spot and futures;
- Bitfinex;
- Bybit spot, linear, and inverse markets;
- Coinbase;
- Deribit; and
- Hyperliquid.

Funding adapters are available for Binance Futures, Bitfinex, Bybit linear and
inverse markets, Deribit, and Hyperliquid. Perpetual market-statistics adapters
are available for Binance Futures and Bybit derivatives.

## Installation

Install the reusable Django application from PyPI:

```bash
pip install django-quant-tick
```

## Deployment

The repository includes a Dockerfile and Invoke tasks for Google Cloud Run and
Cloud Workflows. The demo can also run against a conventional VPS or another
container platform.

For Google Cloud development, the included proxy task can connect local
management commands to the production database:

```bash
cd demo
invoke start-proxy
python proxy.py trades
```

Inspect all available tasks with:

```bash
cd demo
invoke --list
```

## Environment

Copy `demo/env.sample` to the local environment file used by the demo and fill
in the required database and deployment settings.
