I am using two datafeed one of minute basis and one of daily basis. I am generating signals(buy-sell) using only minute data feed and daily data feed is for other analysis.
So when my model generates signal at the starting time of day or at the closing time of day same signal gets generated twice with different Order Ref.(Because at the starting time or closing time of day it account the information of daily data as well and thus it generates same signal twice).
I want to avoid this. How can I do it ?
Example:
I am using two data feeds like this:
data0 = bt.feeds.GenericCSVData(dataname=inFilePath0,
fromdate=self.startDate,
todate=self.endDate,
datetime=0,
open=1,
high=2,
low=3,
close=4,
volume=5,
openinterest=-1,
timeframe=bt.TimeFrame.Ticks,
dtformat="%m/%d/%Y %H:%M",
tmformat='%H:%M'
)
# Resample the data
backtester.resampledata(
dataname=data0,
timeframe=timeFrameInfo.tframes[timeframe],
compression=compression)
# Add Daily Data
data1 = bt.feeds.GenericCSVData(dataname=inFilePath0,
fromdate=self.startDate,
todate=self.endDate,
datetime=0,
open=1,
high=2,
low=3,
close=4,
volume=5,
openinterest=-1,
timeframe=bt.TimeFrame.Ticks,
dtformat="%m/%d/%Y %H:%M",
tmformat='%H:%M',
)
# Resample the data
backtester.resampledata(
dataname=data1,
timeframe=timeFrameInfo.tframes["daily"],
compression=1)
After run i got this:
Starting Portfolio Value: 100000000.00
2010-03-16 - 15:30:00, BUY CREATE, Market Order, Price: 5210.00
2010-03-16 - 15:30:00, BUY CREATE, Market Order, Price: 5210.00
2010-03-17 - 09:10:00, REF : 1 PRICE : 5229.000 SIZE : 75.00 COMM : 187.50
2010-03-17 - 09:10:00, REF : 2 PRICE : 5229.000 SIZE : 75.00 COMM : 187.50
So same order is generating twice. But when I remove the daily data feed there is no problem
@backtrader