SkillAgentSearch skills...

Cryptoquant

An Quantatitive trading library for mutiple-assets 量化交易框架

Install / Use

/learn @studyquant/Cryptoquant
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Cryptoquant- An Quantatitive trading library for various Assets 开源量化交易框架

<p style="align:"center""> <img src ="https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg"/> <img src ="https://img.shields.io/badge/python-3.6-blue.svg"/> <img src ="https://img.shields.io/badge/python-3.7-blue.svg"/> <img src ="https://img.shields.io/badge/python-3.8-blue.svg"/> <img src ="https://img.shields.io/badge/python-3.9-blue.svg"/> <img src ="https://img.shields.io/badge/python-3.10-blue.svg"/> </p>

Cryptoquant

CryptoQuant is an algorithmic trading library for Quantatitive trading written in Python. It allows trading strategies to be easily expressed and backtested against historical data (with daily and minute resolution), providing analytics and insights regarding a particular strategy's performance. cryptoquant also supportslive-trading of crypto-assets starting with many exchanges (Okex,Binance,Bitmex etc) with more being added over time.

CryptoQuant是一套基于Python的量化交易框架,帮助个人/机构量化人员进行量化交易。支持对接多种接口, 框架具有回测/实盘交易功能。 策略框架支持多个平台切换回测。 并提供交易所实盘交易接口(如OKEX) 。

全新的《Python数字货币量化投资实战》等系列在线课程,已经在微信公众号[StudyQuant]上线,一整套数字货币量化解决方案。覆盖CTA等策略(已完成)等内容。

| 版本介绍 | 说明 | 产品与服务 | 适合人群 | | --- | --- | --- | --- | | public(开源版) | 当前开源仓库 | <br />- 开源代码可自行学习<br /> | | | pro(专业版) | Python数字货币量化投资实战课程专属量化系统版本<br /><br />(年费,更新代码) | <br />- python量化投资与CryptoQuant教学视频课程<br />- 提供封装好的现货量化接口 (支持Binance等现货)<br />- 封装好的接口示例、系统源码开发示例<br />- 策略示例<br />- 基于类的量化交易系统,更清晰的架构。<br />- 社群答疑服务<br /> | <br />- 个人量化交易员<br />- 希望快速学习量化并在crypto市场实现量化交易的<br /> | | vip   | 量化训练营/定制版本的量化系统 | <br />- Python量化投资训练营视频课程<br />(年费,每年更新代码)<br />- 最新的量化交易系统 <br />- 提供封装好的现货和合约量化接口 (支持Binance现货、合约) <br />- 多个经典量化策略示例 <br />- 远程技术支持和服务 <br /> | <br />- 量化交易员<br />- 希望快速学习量化并在相关市场实现量化交易的<br />- 定制相关市场接口<br /> | | 更多信息 | 针对专业量化的需求<br />精心架构设计并封装好的代码<br />开箱即用,帮助你更快的实现量化交易 | 添加微信 studyquant88后,领取更多示例代码 | <br /> |

版本介绍

目前主要分为 public(开源版), pro(专业版) 和 vip 3个版本。 每个版本代码不一样。供用户学习,用户可自行迭代升级。

public(开源版)

当前开源仓库

pro(专业版)(Python量化与CryptoQuant课程)

专业版提供

  • python量化投资与CryptoQuant教学视频课程
  • 提供封装好的现货量化接口 (支持Binance等现货)
  • 封装好的接口示例、系统源码开发示例
  • 策略示例
  • 基于类的量化交易系统,更清晰的架构。
  • 社群答疑服务

并提供专业版的量化交易框架源码学习。 在架构上由多个库组成,开发者花费了大量的时间, 整理构建的自用量化交易框架,非常适合个人量化交易员学习并实践使用。

vip(量化训练营课程)

  • Python量化投资训练营视频课程 (年费,包更新代码)
  • 自用的量化交易系统,经常更新代码。
  • 提供封装好的现货和合约量化接口 (支持Binance现货、合约)
  • 多个经典量化策略示例
  • 更高频率的量化交易系统
  • 远程技术支持和服务

更多详情: wechat: studyquant88

Features

  • Ease of Use: CryptoQuant tries to get out of your way so that you can focus on algorithm development.
  • 开箱即用 : CryptoQuant提供一套量化框架帮助您专注策略开发
  • 回测:回测框架支持数据导入,自定义交易订单号,多线程回测、遗传算法寻优等功能
  • 实盘交易: 框架提供数字货币交易所接口DEMO
  • 文档支持:官方社区论坛

环境准备

  • 支持的系统版本:Windows 7以上/Windows Server 2008以上/Ubuntu 18.04 LTS
  • 支持的Python版本:Python 3.6 64位/ 3.7+

Installation

Windows 使用要安装Python,激活环境,进入cryptoquant/install目录下的运行install.bat 安装依赖库 安装dependencies 中的依赖库

Quickstart

如何导入数据

from cryptoquant.trader.constant import Direction, Exchange, Interval, Offset, Status, Product, OptionType, OrderType
import pandas as pd
from cryptoquant.app.data_manage.data_manager import save_data_to_cryptoquant

if __name__ == '__main__':
    df = pd.read_csv('IF9999.csv')
    symbol = 'IF9999'
    save_data_to_cryptoquant(symbol, df, Exchange.CFFEX)
    

如何回测

from datetime import datetime
from cryptoquant.app.cta_backtester.engine import BacktestingEngine, OptimizationSetting
from cryptoquant.app.cta_strategy.strategies.atr_rsi_strategy import (
    AtrRsiStrategy,
)
#%%
engine = BacktestingEngine()

engine.set_parameters(
    vt_symbol="IF9999.CFFEX",
    interval="1m",
    start=datetime(2020, 1, 1),
    end=datetime(2020, 4, 30),
    rate=0.3/10000,
    slippage=0.5,
    size=300,
    pricetick=0.2,
    capital=1_000_0,
)
setting = {}
engine.add_strategy(AtrRsiStrategy,setting)
# 导入数据
engine.load_data()
# 开始回测
engine.run_backtesting()
#计算收益
df = engine.calculate_result()
# 开始统计
engine.calculate_statistics()
# 开始画图
engine.show_chart()

实盘交易- 接口调用示例

(cryptoquant_example/3 CCXT tutorial/4_api_demo.py)


from cryptoquant.config.config import ok_api_key, ok_seceret_key, ok_passphrase,binance_api_key,binance_secret_key
from cryptoquant import get_exchange

"""
Attention:
to run this code file , your python may need to be python3.9. It can be run by my environment
of  python 3.9. Hope you can run it successfully. Many Thanks 
"""

if __name__ == "__main__":
    setting ={
        'symbol':"EOS/USDT",
        'api_key':binance_api_key,
        'secret':binance_secret_key,
        'base_asset':'EOS',
        'quote_asset':'USDT',
        'sleep_time':5,
        'time_frame':'5m'
    }

    apikey = binance_api_key
    secret = binance_secret_key
    symbol = "EOS/USDT"
    time_frame = '5m'
    strategy_name = 'apidemo'

    exchange = get_exchange(symbol, apikey, secret, time_frame, strategy_name, setting)

    print('GEt Trades', exchange.GetTrades())
    print('GEt Ticker',exchange.GetTicker())
    print('GEt Depth',exchange.GetDepth())
    print('GetAccount',exchange.GetAccount())
    print('获取K线',exchange.GetKline(time_frame))
    print('get Orders',exchange.GetOrders())
    print('get open Orders',exchange.GetOpenOrders())

    # 买单
    buy_order = exchange.Buy(Price = 3,Amount = 4)
    print(f"获取订单{exchange.GetOrder(buy_order.id)}")

    # 撤单
    cancel_order = exchange.CancelOrder(buy_order.id)
    print(f"取消订单{cancel_order}")

    # 卖单
    sell_order = exchange.Sell(Price = 5,Amount = 4)
    print(f"获取订单{exchange.GetOrder(buy_order.id)}")

    # 撤单
    cancel_order = exchange.CancelOrder(sell_order.id)
    print(f"取消订单{cancel_order}")


Result

CCXT GateWay Init
GEt Trades [Trade(Id='170714627', Time=1658938662633, Price=1.138, Amount=1933.3, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714628', Time=1658938664640, Price=1.138, Amount=28.8, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714629', Time=1658938666927, Price=1.138, Amount=563.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714630', Time=1658938666957, Price=1.138, Amount=9.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714631', Time=1658938670567, Price=1.138, Amount=77.4, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714632', Time=1658938670708, Price=1.139, Amount=22.6, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714633', Time=1658938675419, Price=1.138, Amount=656.2, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714634', Time=1658938676114, Price=1.139, Amount=13.1, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714635', Time=1658938676165, Price=1.139, Amount=9.2, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714636', Time=1658938677508, Price=1.138, Amount=154.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714637', Time=1658938685393, Price=1.138, Amount=38.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714638', Time=1658938688941, Price=1.139, Amount=770.2, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714639', Time=1658938688987, Price=1.139, Amount=9.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714640', Time=1658938689216, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714641', Time=1658938689341, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714642', Time=1658938689553, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714643', Time=1658938689679, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714644', Time=1658938689769, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714645', Time=1658938689839, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714646', Time=1658938689924, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714647', Time=1658938690156, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714648', Time=1658938690217, Price=1.139, Amount=13.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714649', Time=1658938691346, Price=1.139, Amount=17.6, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714650', Time=1658938692970, Price=1.139, Amount=47.6, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714651', Time=1658938693362, Price=1.139, Amount=587.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714652', Time=1658938693375, Price=1.139, Amount=384.3, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714653', Time=1658938693383, Price=1.139, Amount=720.0, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714654', Time=1658938693432, Price=1.139, Amount=471.6, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714655', Time=1658938694004, Price=1.139, Amount=8074.9, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714656', Time=1658938694004, Price=1.14, Amount=11770.8, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714657', Time=1658938694030, Price=1.139, Amount=413.6, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714658', Time=1658938694130, Price=1.139, Amount=656.2, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714659', Time=1658938695121, Price=1.139, Amount=11.4, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714660', Time=1658938695201, Price=1.139, Amount=83.3, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714661', Time=1658938695349, Price=1.138, Amount=59.2, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714662', Time=1658938695713, Price=1.138, Amount=32.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714663', Time=1658938695783, Price=1.138, Amount=46.0, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714664', Time=1658938696299, Price=1.138, Amount=32.7, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714665', Time=1658938696552, Price=1.138, Amount=20.3, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id='170714666', Time=1658938697141, Price=1.138, Amount=26.5, Type=<Direction.ORDER_TYPE_BUY: 0>), Trade(Id
View on GitHub
GitHub Stars294
CategoryDevelopment
Updated23h ago
Forks48

Languages

Python

Security Score

85/100

Audited on Mar 24, 2026

No findings