Metadata-Version: 2.4
Name: cyqnt-trd
Version: 0.1.9.dev4
Summary: A cryptocurrency trading toolkit centered on the standard_bot backtesting, paper signal, and execution workflow
Author-email: Haowen Wang <wanghw@zju.edu.cn>
License-Expression: MIT
Project-URL: Homepage, https://github.com/nthu-chung/crypto_trading
Project-URL: Repository, https://github.com/nthu-chung/crypto_trading
Project-URL: Issues, https://github.com/nthu-chung/crypto_trading/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: <3.12,>=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas==2.3.3
Requires-Dist: numpy==1.24.4
Requires-Dist: polars==1.0.0
Requires-Dist: numba==0.60.0
Requires-Dist: pyarrow==21.0.0
Requires-Dist: matplotlib==3.7.5
Requires-Dist: scipy==1.10.1
Requires-Dist: requests==2.32.5
Requires-Dist: websockets<17,>=15.0.1
Requires-Dist: binance-sdk-spot==8.2.1
Requires-Dist: binance-sdk-derivatives-trading-usds-futures==10.0.1
Requires-Dist: binance-sdk-algo==2.6.0
Requires-Dist: binance-common==3.8.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-cov<5.0.0,>=4.0.0; extra == "dev"
Requires-Dist: black<24.0.0,>=22.0.0; extra == "dev"
Requires-Dist: ruff<0.2.0,>=0.1.0; extra == "dev"
Provides-Extra: market-data
Requires-Dist: yfinance>=0.2.38; extra == "market-data"
Dynamic: license-file

# cyqnt-trd

`cyqnt-trd` is a cryptocurrency trading toolkit centered on the `standard_bot` workflow for:

- historical data download to local parquet
- local resample from `1m` into higher timeframes
- Numba-accelerated backtesting
- paper signal generation
- monitor / run-manager driven execution flows

The current recommended path is:

`historical parquet -> local resample -> standard_bot signal -> NumbaBacktestRunner`

## Install

### From PyPI

```bash
pip install cyqnt-trd
```

The package supports Python `>=3.8,<3.12`, which includes Binance AI's Python `3.11.2`.

For HTTPS requests, `cyqnt-trd` resolves the CA bundle in this order:

1. `REQUESTS_CA_BUNDLE`
2. `SSL_CERT_FILE`
3. `CURL_CA_BUNDLE`
4. Linux system CA bundle: `/etc/ssl/certs/ca-certificates.crt`
5. `certifi`
6. `requests` default verification behavior

For special Linux deployments where Binance endpoints are signed by an internal CA that exists only in the
system trust store, set the deployment CA bundle via environment variables, for example:

```bash
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
```

### For development

```bash
git clone https://github.com/nthu-chung/crypto_trading
cd crypto_trading
python3 -m venv .venv-standard-bot
source .venv-standard-bot/bin/activate
python -m pip install -U pip
python -m pip install -r requirements.txt -r requirements-standard-bot-mvp.txt
```

## Recommended Standard Bot Entry Points

### Backtest

```bash
python -m cyqnt_trd.standard_bot.entrypoints.mvp_backtest \
  --engine numba \
  --market-type futures \
  --strategy multi_timeframe_ma_spread \
  --symbol BTCUSDT \
  --interval 5m \
  --secondary-interval 1h \
  --primary-ma-period 20 \
  --reference-ma-period 20 \
  --spread-threshold-bps 0 \
  --historical-dir data/mtf_90d \
  --start-ts 1768003200000 \
  --end-ts 1775779200000 \
  --download-missing \
  --output-json docs/backtests/btc_mtf_ma_cross_5m_1h_20_20_90d.json
```

### Paper Signal

```bash
python -m cyqnt_trd.standard_bot.entrypoints.mvp_paper \
  --market-type futures \
  --strategy multi_timeframe_ma_spread \
  --symbol BTCUSDT \
  --interval 5m \
  --secondary-interval 1h \
  --primary-ma-period 20 \
  --reference-ma-period 20 \
  --spread-threshold-bps 0 \
  --historical-dir data/mtf_90d \
  --dry-run
```

### Monitor / Background Session

```bash
python -m cyqnt_trd.standard_bot.entrypoints.mvp_monitor_http \
  --broker paper \
  --host 127.0.0.1 \
  --port 8787
```

## Data Workflow

The preferred data workflow is:

1. Download Binance K bars into local parquet
2. Store the finest useful granularity, usually `1m`
3. Resample locally into `5m`, `15m`, `1h`, etc.
4. Run `standard_bot` on local parquet instead of using raw API responses as final backtest input

This keeps:

- point-in-time alignment clearer
- local backtests repeatable
- paper signal and backtest logic consistent

## Current Strategy Families On The Mainline

The `standard_bot` mainline currently includes Numba-backed support for:

- `moving_average_cross`
- `price_moving_average`
- `rsi_reversion`
- `multi_timeframe_ma_spread`
- `donchian_breakout`

## Package Notes

- The preferred historical backtest engine is `NumbaBacktestRunner`
- The preferred CLI entrypoint is `cyqnt_trd.standard_bot.entrypoints.mvp_backtest`
- Legacy `cyqnt_trd/backtesting/*` still exists for compatibility, but is not the recommended path for new work

## Requirements

Key dependencies include:

- `pandas==2.3.3`
- `polars==1.0.0`
- `numba==0.60.0`
- `pyarrow==21.0.0`
- `requests==2.32.5`

Binance SDK dependencies:

- `binance-sdk-spot==8.2.1`
- `binance-sdk-derivatives-trading-usds-futures==10.0.1`
- `binance-sdk-algo==2.6.0`
- `binance-common==3.8.0`
- `binance-common`

## License

MIT License
