一、RQalpha
github 地址 https://github.com/ricequant/rqalpha
1、运行test.py文件,显示 No module named 'logbook.base'。
解决先卸载再安装: pip uninstall logbook pip install logbook
2、出现:RuntimeError: 请设置账户及初始资金。
解决:
二、Zipline
github地址 https://github.com/quantopian/zipline Zipline学习资料 http://www.zipline.io/
zipline代码比较多,不好复制
三、qstrade
github地址 https://github.com/mhallsmoore/qstrader
听从朋友建议,暂时学习qstrade。代码少,上手快。
测试:
Could not subscribe ticker SPY as no data CSV found for pricing.
Could not subscribe ticker AGG as no data CSV found for pricing.
Traceback (most recent call last):
File "E:/qstrader-master/examples/monthly_liquidate_rebalance_backtest.py", line 108, in <module>
run(config, testing, tickers, filename)
File "E:/qstrader-master/examples/monthly_liquidate_rebalance_backtest.py", line 94, in run
在策略代码后面添加如下即可:
import os from munch import munchify os.chdir('E:\\qstrader-master') config = munchify({ "CSV_DATA_DIR": "data", "OUTPUT_DIR": "out", 'testing': True})
保存图片需要修改:
将trading_session.py文件最后部分,倒数第二行self.statistics.plot_results()-------->self.statistics.save()
将tearsheet.py文件最后部分,self.plot_results()---------->self.plot_results(filename)
学习问题汇总:
1、运行buy_and_hold_backtest.py文件时出错。
File "E:\qstrader-master\qstrader\price_handler\yahoo_daily_csv_bar.py", line 68, in _merge_sort_ticker_data
df = pd.concat(self.tickers_data.values()).sort_index()
File "D:\Anaconda3\lib\site-packages\pandas\core\reshape\concat.py", line 206, in concat
copy=copy)
File "D:\Anaconda3\lib\site-packages\pandas\core\reshape\concat.py", line 239, in __init__
raise ValueError('No objects to concatenate')
ValueError: No objects to concatenate
1、self.tickers_data 是什么内容?-->self.csv_dir=csv_dir,csv_dir在哪里?-->
2、出错位置在:backtest=TradingSession(config,strategy,tickers,initial_equity,start_date,end_date,events_queue,title=title) 为实例化,
参数如下:
config --> TEST