数字货币量化交易CCXT库介绍
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">CCXT是一个开源的Python/Javascript/PHP 数字货币量化交易框架,对接超过130多个交易所,<span style="color: black;">包含</span><span style="color: black;">大众</span>熟知的币安,火币,OKEX等等。CCXT将如交易所API正则替换整合成统一格式,<span style="color: black;">因此</span><span style="color: black;">运用</span>起来很方便,<span style="color: black;">然则</span>CCXT对合约交易不太友好,<span style="color: black;">另一</span>CCXT只是一个整合各数字货币交易所API的框架,<span style="color: black;">倘若</span>要基于它<span style="color: black;">研发</span>量化交易系统,需要另写信息推送、日志、回测、实盘的交易代码,且<span style="color: black;">意见</span><span style="color: black;">运用</span>时再次封装。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">基于CCXT框架,<span style="color: black;">能够</span><span style="color: black;">研发</span>简单的多交易所对冲搬砖策略、三角套利策略、现货网格交易策略,<span style="color: black;">包含</span>已分享过的反资金费率套利策略等等,我会在后面对CCXT的二次封装及应用做简单示例,感兴趣的<span style="color: black;">伴侣</span><span style="color: black;">能够</span>点个关注点个赞,谢谢~</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">首要</span>是安装问题,只需要在命令行格式中输入:</p><span style="color: black;">pip</span> install ccxt<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">CCXT库的<span style="color: black;">运用</span><span style="color: black;">亦</span>非常简单,需要导入库,实例化交易所,<span style="color: black;">而后</span>会有统一的调用<span style="color: black;">办法</span>供<span style="color: black;">运用</span>。</p><span style="color: black;"># 导入CCXT模块</span>
import ccxt
<span style="color: black;"># 实例化交易所,以币安和火币为示例:</span>binance = ccxt.binance()
huobi = ccxt.huobipro()<span style="color: black;"># 统一的行情<span style="color: black;">查找</span>示例:</span>
<span style="color: black;"># 1.<span style="color: black;">查找</span>ETH/USDT最新成交价格</span>
ba_ethusdt_ticker = binance.fetch_tickers(<span style="color: black;">ETH/USDT</span>)
<span style="color: black;">print</span>(ba_ethusdt_ticker)
hb_ethusdt_ticker = huobi.fetch_tickers(<span style="color: black;">ETH/USDT</span>)
<span style="color: black;">print</span>(hb_ethusdt_ticker)
<span style="color: black;"># 2.<span style="color: black;">查找</span>100条,ETH/USDT 5分钟K线数据</span>
ba_5min_kline = binance.fetch_ohlcv(<span style="color: black;">ETH/USDT</span>,<span style="color: black;">5m</span>,<span style="color: black;">limit</span>=100)
<span style="color: black;">print</span>(ba_5min_kline)
<span style="color: black;"># 3.<span style="color: black;">查找</span>订单薄数据,<span style="color: black;">表示</span>10条,即买1到买10,卖1到卖10的数据</span>
order_book_data = binance.fetch_order_book(<span style="color: black;">ETH/USDT</span>,<span style="color: black;">limit</span>=10)
<span style="color: black;">print</span>(order_book_data)
楼主发的这篇帖子,我觉得非常有道理。
页:
[1]