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

Uploaded Python 3

File details

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

File metadata

  • Download URL: cyqnt_trd-0.1.7.tar.gz
  • Upload date:
  • Size: 142.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.7.tar.gz
Algorithm Hash digest
SHA256 3a7dee090cacae3a5f6484df8ced84ea88d273e0f802c9bc60ceabf140191f31
MD5 1ce82f609e95d51df7a2ab4a11862b46
BLAKE2b-256 4766c0f4187c458d91d96b3872917e2b7fa0463bd168348d2032fd315c725148

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cyqnt_trd-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 302.7 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 315b2cc2553b7a82a8fe92924bcc9d703038433fbcd14bcfdbd5abcde258e282
MD5 c0ce93872747b84da32fdeb232c39079
BLAKE2b-256 cacc287f1245cb00db2362b37203eac5da0a4736ef703c34213494be6a96a221

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