-
Notifications
You must be signed in to change notification settings - Fork 52
Description
class TestStrategy(bt.Strategy):
params = (('pfast', 50), ('pslow', 200),)
max_days = 24
bar_data = 0
def __init__(self):
self.pfast = bt.indicators.MovingAverageSimple(period=self.p.pfast)
self.pslow = bt.indicators.MovingAverageSimple(period=self.p.pslow)
def next(self):
pass
if name == 'main':
cerebro = bt.Cerebro()
startcash = 10000
broker = store.getbroker(broker_mapping=broker_mapping)
cerebro.setbroker(broker)
hist_start_date = datetime.utcnow() - timedelta(days=180)
hist_end_date = datetime.utcnow() - timedelta(days=0)
hist_start_date = datetime.utcnow() - timedelta(minutes=9000)
data = store.getdata(dataname='ETH/USD', name="eth_usd_min",
timeframe=bt.TimeFrame.Minutes, fromdate=hist_start_date,
drop_newest=True, historical=False, compression=1)
cerebro.adddata(data, name='1M')
cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=60, name='2M')
cerebro.run()
When I use the above code, the online transaction runs on the basis of one minute bar execution, not one hour compression.
In addition, I'm trading in bitmex. Can I compress the transaction for 4 hours?