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.8.tar.gz (177.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.8-py3-none-any.whl (341.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cyqnt_trd-0.1.8.tar.gz
Algorithm Hash digest
SHA256 d34db14336eef3546e9c439862c7c1e6274e264400f30eb401486ace0495474d
MD5 78828d0594e560c1017bd941ff33c791
BLAKE2b-256 d84634013967530f1da7b0b1ef7b187be81ca87b74f7c2fab010469e25de61d2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cyqnt_trd-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9ab4833d6c871bfd84a5cf5c0c3945b3568efed7a341606e9a2216448b03c1d4
MD5 fad09d16a91d8fd80c772a76501870d2
BLAKE2b-256 f706c1b7c227d481cbcf587bb01894d1f6f9abc3333cbb46202ad489ec66c134

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