import backtrader as bt
from backtrader_ccxt.ccxtstore import CCXTStore
# create an instance of the CCXTStore class
store = CCXTStore(exchange='binance', timeframe=bt.TimeFrame.Minutes, compression=1)
# create an instance of the Cerebro class
cerebro = bt.Cerebro()
# add the datafeed to Cerebro
cerebro.adddata(store)
# run the strategy
cerebro.run()
import backtrader as bt
from backtrader_ccxt.ccxtstore import CCXTStore
# create an instance of the CCXTStore class for the 1-minute timeframe
store1min = CCXTStore(exchange='binance', timeframe=bt.TimeFrame.Minutes, compression=1)
# create an instance of the CCXTStore class for the 5-minute timeframe
store5min = CCXTStore(exchange='binance', timeframe=bt.TimeFrame.Minutes, compression=5)
# create an instance of the CCXTStore class for the 1-hour timeframe
store1hour = CCXTStore(exchange='binance', timeframe=bt.TimeFrame.Hours, compression=1)
# create an instance of the Cerebro class
cerebro = bt.Cerebro()
# add the datafeeds to Cerebro
cerebro.adddata(store1min)
cerebro.adddata(store5min)
cerebro.adddata(store1hour)
# run the strategy
cerebro.run()
1条答案
按热度按时间pqwbnv8z1#
如需使用CCXTStore向Cerebro添加额外的数据馈送,可使用Cerebro对象的adddata方法,该方法接受一个数据参数,该参数可以是配置了所需交换和时间帧的CCXTStore类的示例。
例如:
要添加多个时间帧,您只需创建具有不同时间帧的CCXTStore类的其他示例,并使用adddata方法将其添加到Cerebro对象。
例如: