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

Uploaded Python 3

File details

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

File metadata

  • Download URL: cyqnt_trd-0.1.3.tar.gz
  • Upload date:
  • Size: 126.2 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.3.tar.gz
Algorithm Hash digest
SHA256 b61cd4da9b3a4e2703e297ad414b814792a84681faf2055a1908a1f2ee2e6773
MD5 ebd6a5f9f9a905c0025aa66b17114880
BLAKE2b-256 03676fe0d86c3a098c5d362264bfe7805f56961843126a5b4916b575d28a5031

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cyqnt_trd-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cfc16a369be56d138284b14287a4222ada3b9247a2e3fd3db87e93cd8a8340b0
MD5 4fac51dba9d949e691108427cbcbb321
BLAKE2b-256 fb320ea277bc7575c7bfabea9613ef2335045a9d2bcd2c37e60bb7f21b8ec8fb

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