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

Uploaded Python 3

File details

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

File metadata

  • Download URL: cyqnt_trd-0.1.5.tar.gz
  • Upload date:
  • Size: 126.4 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.5.tar.gz
Algorithm Hash digest
SHA256 b93a5322b543c50d2b26df5f34cce89a90bde82c84f314f9c7f1d11277e4508b
MD5 b1617ec761a0d6dfec4ed9b1052c2dc1
BLAKE2b-256 6e9b99482b3e4b3ffd70beb33e828cfc0242d02cc894338b9abfdc7180aaa016

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cyqnt_trd-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 287.2 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7bedce40384b4f434d0f9ceef2a9b2adf89a23d36bfb83ffcc5e727d226cf059
MD5 12a8b767997ac0ec8db10379eb1e3bd5
BLAKE2b-256 488730bedc7f045473644ea285898bb74a21c416fccf600f57378c49ad5e6495

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