A comprehensive Python project demonstrating real-time and historical cryptocurrency data aggregation, analysis, and visualization for quantitative trading applications.
- Real-time Data Streaming: Connect to BitMEX WebSocket for live tick and orderbook data
- Historical Data Analysis: Process CSV files with date range filtering
- Multiple Aggregation Methods:
- OHLCV Candlesticks: Open, High, Low, Close, Volume data
- VWAP: Volume Weighted Average Price calculations
- Volume Buckets: Aggregated trades based on volume thresholds
- Order Flow Analysis: Buy/sell volume, net flow, and imbalance ratios
- Summary Statistics: Comprehensive tick data metrics
- Data Visualization: Beautiful charts using matplotlib and seaborn
- Modular Architecture: Clean, focused classes for each aggregation type
- Teaching Materials: Simple examples for learning quantitative concepts
Intro to quant/
├── aggregations_examples/ # Example scripts for each aggregator
├── data/ # Historical CSV data files
├── data_aggregator/ # Individual aggregation classes
├── exchange/ # Exchange connectivity modules
├── tick_queue_module/ # Real-time tick data queue
├── visualization/ # Data visualization functions
├── main.py # Main entry point
└── requirements.txt # Python dependencies
-
Clone the repository:
git clone git@github.com:FarhanKardan/intoToQuant.git cd intoToQuant -
Install dependencies:
pip install -r requirements.txt
Generates traditional candlestick data with open, high, low, close, and volume information.
from data_aggregator.ohlcv_aggregator import OHLCVAggregator
agg = OHLCVAggregator("BTCUSDT")
agg.add_ticks(tick_data)
ohlcv_data = agg.generate_ohlcv('5min')Calculates Volume Weighted Average Price for accurate price analysis.
from data_aggregator.vwap_aggregator import VWAPAggregator
agg = VWAPAggregator("BTCUSDT")
agg.add_ticks(tick_data)
vwap_data = agg.generate_vwap('5min')Groups trades into volume-based buckets for large trade analysis.
from data_aggregator.volume_bucket_aggregator import VolumeBucketAggregator
agg = VolumeBucketAggregator("BTCUSDT")
agg.add_ticks(tick_data)
buckets = agg.generate_volume_buckets(bucket_size=1000.0)Analyzes buy/sell pressure and market microstructure.
from data_aggregator.order_flow_aggregator import OrderFlowAggregator
agg = OrderFlowAggregator("BTCUSDT")
agg.add_ticks(tick_data)
orderflow = agg.generate_order_flow('5min')Provides comprehensive summary statistics for tick data.
from data_aggregator.stats_aggregator import StatsAggregator
agg = StatsAggregator("BTCUSDT")
agg.add_ticks(tick_data)
stats = agg.get_summary_stats()python main.py# OHLCV Example
python aggregations_examples/ohlcv_example.py
# VWAP Example
python aggregations_examples/vwap_example.py
# Volume Buckets Example
python aggregations_examples/volume_buckets_example.py
# Order Flow Example
python aggregations_examples/order_flow_example.py
# Order Flow / Volume Profile Example
python aggregations_examples/volume_profile_example.py --timeframe 1H --limit 10000 --style classic
# Order Flow / Footprint Example
python aggregations_examples\footprint_example.py --limit 100000
python aggregations_examples\footprint_example.py --mode range --range_levels 10 --bin_size 10 --limit 50000python aggregations_examples/run_all_examples.pypython tick_queue_module/main.pyThe project includes comprehensive visualization capabilities:
from visualization.visualization import plot_ohlcv, plot_vwap, plot_volume_buckets
# Plot OHLCV candlesticks
plot_ohlcv(ohlcv_data, "BTCUSDT OHLCV Analysis")
# Plot VWAP analysis
plot_vwap(vwap_data, "BTCUSDT VWAP Analysis")
# Plot volume buckets
plot_volume_buckets(bucket_data, "BTCUSDT Volume Buckets")- Testnet: Set
testnet=Truein BitmexWebSocket for testing - Production: Use
testnet=Falsefor live data
- Real-time: BitMEX WebSocket API
- Historical: CSV files in the
data/directory
- Python 3.8+
- pandas==2.0.3
- pyarrow==12.0.0
- websockets==12.0
- matplotlib==3.7.2
- seaborn==0.12.2
This project is designed to teach:
- Real-time Data Processing: Handling live market data streams
- Data Aggregation: Converting tick data into meaningful time series
- Market Microstructure: Understanding order flow and volume analysis
- Technical Analysis: OHLCV and VWAP calculations
- Data Visualization: Creating professional trading charts
- Modular Design: Building maintainable, focused components
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is for educational purposes. Please ensure compliance with BitMEX API terms of service when using live data.
This software is for educational purposes only. It is not financial advice. Trading cryptocurrencies involves substantial risk of loss. Always do your own research and consider consulting with a financial advisor.