Skip to main content

A cryptocurrency trading toolkit with data fetching, signal generation, and backtesting capabilities

Project description

cyqnt_trd

一个用于加密货币交易的工具包,包含数据获取、交易信号生成和回测功能。

功能特性

  • 数据获取: 从 Binance 获取期货和现货K线数据
  • 交易信号: 提供多种技术指标因子和信号策略
  • 回测框架: 支持因子测试和策略回测

安装

方式1: 作为可编辑包安装(推荐用于开发)

cd /path/to/cyqnt_trd
pip install -e .

方式2: 直接安装

cd /path/to/cyqnt_trd
pip install .

方式3: 从源码安装

cd /path/to/cyqnt_trd
python setup.py install

依赖

主要依赖包:

  • pandas >= 1.5.0
  • numpy >= 1.23.0
  • matplotlib >= 3.5.0
  • requests >= 2.28.0

Binance SDK 依赖(需要单独安装):

  • binance-sdk-spot
  • binance-sdk-derivatives-trading-usds-futures
  • binance-sdk-algo
  • binance-common

安装依赖:

pip install -r requirements.txt

使用方法

作为 Python Package 使用

安装后,可以直接导入使用:

# 导入数据获取模块
from cyqnt_trd.get_data import get_and_save_futures_klines, get_and_save_klines

# 导入交易信号模块
from cyqnt_trd.trading_signal.factor import ma_factor, rsi_factor
from cyqnt_trd.trading_signal.signal import ma_signal, factor_based_signal

# 导入回测框架
from cyqnt_trd.backtesting import BacktestFramework, FactorTester, StrategyBacktester

# 使用示例
data = get_and_save_futures_klines("BTCUSDT", interval="1h", limit=100)
framework = BacktestFramework(data_path="data/BTCUSDT_1h.json")
result = framework.test_factor(ma_factor, short_window=5, long_window=20)

运行示例脚本

# 作为模块运行
python -m cyqnt_trd.trading_signal.example_usage

# 运行测试脚本
python -m cyqnt_trd.test_script.realtime_price_tracker

项目结构

cyqnt_trd/
├── cyqnt_trd/          # 主包目录
│   ├── __init__.py         # 包初始化文件
│   ├── get_data/           # 数据获取模块
│   │   ├── __init__.py
│   │   ├── get_futures_data.py
│   │   └── get_trending_data.py
│   ├── trading_signal/     # 交易信号模块
│   │   ├── __init__.py
│   │   ├── factor/         # 因子模块
│   │   ├── signal/         # 信号策略模块
│   │   └── selected_alpha/ # Alpha因子模块
│   ├── backtesting/        # 回测框架
│   │   ├── __init__.py
│   │   ├── framework.py
│   │   ├── factor_test.py
│   │   └── strategy_backtest.py
│   └── test_script/        # 测试脚本
├── pyproject.toml          # 包配置文件
├── requirements.txt        # 依赖列表
└── README.md              # 说明文档

许可证

MIT License

Copyright (c) 2025 Haowen Wang

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cyqnt_trd-0.1.0.tar.gz (68.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cyqnt_trd-0.1.0-py3-none-any.whl (86.1 kB view details)

Uploaded Python 3

File details

Details for the file cyqnt_trd-0.1.0.tar.gz.

File metadata

  • Download URL: cyqnt_trd-0.1.0.tar.gz
  • Upload date:
  • Size: 68.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for cyqnt_trd-0.1.0.tar.gz
Algorithm Hash digest
SHA256 193c98ca54cca58f9c72be98b218113dfc25266828ab572eba9e28fb2e9c366c
MD5 0ea82acbaafaef0641b10dc2d3e4e980
BLAKE2b-256 9ddcdeac68d59bfb813040fcf1cac32ef29325b49d2e39f9a2f0888cbb9fbafa

See more details on using hashes here.

File details

Details for the file cyqnt_trd-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cyqnt_trd-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 86.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for cyqnt_trd-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43dc4392920850a040d1a66d091d1dcbe96a1412af2715514623b3434f687a68
MD5 d0df56801fa26f969373d6bcb06369ed
BLAKE2b-256 6d518bcf59b184ebff7f1f5b403c40ee64dcf7b4218408c42fe35a8a9442e556

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page