|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +QUANTAXIS is a quantitative financial framework written in Python that provides a comprehensive suite of tools for financial data analysis, backtesting, and trading strategy development. The project is organized into multiple modular components for different aspects of quantitative finance. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +The codebase is structured into distinct modules under the `QUANTAXIS/` package: |
| 12 | + |
| 13 | +- **QAFetch**: Multi-market data acquisition and storage (MongoDB/ClickHouse) |
| 14 | +- **QAUtil**: Trading time utilities, calendars, market identification, and dataframe conversions |
| 15 | +- **QIFI/QAMarket**: Unified multi-market, multi-language account system |
| 16 | + - `qifiaccount`: Standard account system consistent across languages (Python/Rust/C++) |
| 17 | + - `qifimanager`: Multi-account management system |
| 18 | + - `qaposition`: Single asset position management for precise long/short control |
| 19 | + - `marketpreset`: Market preset classes for futures/stocks/crypto metadata |
| 20 | +- **QAFactor**: Factor research suite for factor analysis, management, and combination |
| 21 | +- **QAData**: Multi-asset, multi-market data structures for real-time and backtesting |
| 22 | +- **QAIndicator**: Custom indicator framework with batch market-wide application |
| 23 | +- **QAEngine**: Custom thread/process base classes for async and distributed computing |
| 24 | +- **QAPubSub**: MQ-based message queue supporting 1-1, 1-n, n-n message distribution |
| 25 | +- **QAStrategy**: CTA/arbitrage backtesting suite with QIFI mode support |
| 26 | +- **QAWebServer**: Tornado-based web server for microservice architecture |
| 27 | +- **QASchedule**: Background task scheduling built on QAWebServer |
| 28 | +- **QAAnalysis**: Analysis and reporting tools |
| 29 | +- **QACmd**: Command-line interface and utilities |
| 30 | +- **QASU**: System utilities and maintenance tools |
| 31 | + |
| 32 | +## Development Commands |
| 33 | + |
| 34 | +### Installation |
| 35 | +```bash |
| 36 | +pip install -e . |
| 37 | +# Or install requirements first: |
| 38 | +pip install -r requirements.txt |
| 39 | +``` |
| 40 | + |
| 41 | +### Code Quality |
| 42 | +```bash |
| 43 | +# Linting (uses pylint with configuration in .pylintrc) |
| 44 | +pylint QUANTAXIS/ |
| 45 | + |
| 46 | +# The project has a comprehensive .pylintrc configuration file |
| 47 | +``` |
| 48 | + |
| 49 | +### Console Commands |
| 50 | +The package provides several console entry points: |
| 51 | +- `quantaxis` - Main CLI command |
| 52 | +- `quantaxisq` - TDX data fetching |
| 53 | +- `qarun` - Strategy runner |
| 54 | +- `qawebserver` - Web server launcher |
| 55 | + |
| 56 | +### Data Management |
| 57 | +```bash |
| 58 | +# Update market data (various scripts in config/) |
| 59 | +python config/update_data.py |
| 60 | +python config/update_all.py |
| 61 | +python config/update_future.py |
| 62 | +python config/update_fin.py |
| 63 | +``` |
| 64 | + |
| 65 | +## Key Dependencies |
| 66 | + |
| 67 | +- **Database**: MongoDB (pymongo 3.11.2), ClickHouse (clickhouse-driver) |
| 68 | +- **Data Processing**: pandas ≥1.1.5, numpy ≥1.12.0, pyarrow ≥6.0.1 |
| 69 | +- **Web**: tornado ≥6.3.2, flask ≥0.12.2 |
| 70 | +- **Financial**: tushare, pytdx ≥1.67, empyrical, pyfolio, alphalens |
| 71 | +- **Async/Messaging**: pika (RabbitMQ), motor (async MongoDB), gevent-websocket |
| 72 | +- **Analysis**: matplotlib, seaborn ≥0.11.1, statsmodels ≥0.12.1, scipy |
| 73 | + |
| 74 | +## Multi-Language Integration |
| 75 | + |
| 76 | +The project supports integration with QUANTAXIS Rust version through: |
| 77 | +- Apache Arrow format (pyarrow) for cross-language data exchange |
| 78 | +- Consistent QIFI account structures across Python/Rust/C++ |
| 79 | +- Arrow-based communication with arrow-rs and datafusion-rs |
| 80 | + |
| 81 | +## Database Architecture |
| 82 | + |
| 83 | +- **MongoDB**: Primary data storage for market data and account information |
| 84 | +- **ClickHouse**: High-performance analytics database for large-scale data analysis |
| 85 | +- Support for tick/L2 order/transaction data formats |
| 86 | + |
| 87 | +## Configuration Files |
| 88 | + |
| 89 | +- `.pylintrc`: Comprehensive linting configuration |
| 90 | +- `requirements.txt`: Core dependencies |
| 91 | +- `config/`: Directory containing data update and maintenance scripts |
| 92 | +- `docker/`: Docker configurations for various deployment scenarios |
| 93 | + |
| 94 | +## Examples and Usage |
| 95 | + |
| 96 | +Check the `examples/` directory for: |
| 97 | +- `qifiaccountexample.py`: QIFI account system usage |
| 98 | +- `factoranalysis.py`: Factor analysis workflows |
| 99 | +- `scheduleserver.py`: Task scheduling examples |
| 100 | +- `featureanalysis.ipynb`: Jupyter notebook examples |
| 101 | + |
| 102 | +## Version Support |
| 103 | + |
| 104 | +Python 3.5-3.10 supported (see setup.py for version validation). |
0 commit comments