@vladisld Thanks for you advice. I thought about define custom data feed, but there are thousands of stocks when I run the strategy, and they share a same "my_ind_data" line(and "my_ind_data" is not the only custom data). so that will increase memory usage obviously.
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Latest posts made by DOM LEE
-
RE: How to get the first date of a datafeed?
-
RE: How to get the first date of a datafeed?
I try this , but fail
# Create a Stratey class TestStrategy(bt.Strategy): params = (('maperiod', 60), ) def log(self, txt, dt=None): ''' Logging function fot this strategy''' dt = dt or self.datas[0].datetime.date(0) print('%s, %s' % (dt.isoformat(), txt)) def __init__(self): # Keep a reference to the "close" line in the data[0] dataseries self.dataclose = self.datas[0].close self.sma = bt.indicators.SimpleMovingAverage( self.datas[0], period=self.params.maperiod) # my question is here first_date = self.datas[0][0] my_ind_data = mydb.get_my_data("news_hit").loc[first_data:] news_ind = bt.indicators.SimpleMovingAverage(my_ind_data,period=5)
-
How to get the first date of a datafeed?
In def init of a strategy, I need to get external data depend on the first day of data-feed. Is it possible to to that?
# Create a Stratey class TestStrategy(bt.Strategy): params = (('maperiod', 60), ) def log(self, txt, dt=None): ''' Logging function fot this strategy''' dt = dt or self.datas[0].datetime.date(0) print('%s, %s' % (dt.isoformat(), txt)) def __init__(self): # Keep a reference to the "close" line in the data[0] dataseries self.dataclose = self.datas[0].close self.sma = bt.indicators.SimpleMovingAverage( self.datas[0], period=self.params.maperiod) # my question is here first_date = ????? my_ind_data = mydb.get_my_data("news_hit").loc[start_day:] news_ind = bt.indicators.SimpleMovingAverage(my_ind_data,period=5)