Got it sorted! Thanks.
def notify_timer(self, timer, when, timername, *args, **kwargs):
if timername=='buytimer':
self.buy_stocks()
if timername=='selltimer':
self.sell_stocks()
Got it sorted! Thanks.
def notify_timer(self, timer, when, timername, *args, **kwargs):
if timername=='buytimer':
self.buy_stocks()
if timername=='selltimer':
self.sell_stocks()
The timers reference had some obvious errors, it's meant to be this:
def notify_timer(self, timer, when, *args, **kwargs):
if timername=='buytimer':
self.buy_stocks()
if timername=='selltimer':
self.sell_stocks()
OK, so I tried this:
self.add_timer(
when=bt.Timer.SESSION_START,
weekdays=[self.params.buy_day],
weekcarry=True,
timername='buytimer',
)
self.add_timer(
when=bt.Timer.SESSION_START,
weekdays=[self.params.sell_day],
weekcarry=True,
timername='selltimer',
)
and then referred to these timers here:
def notify_timer1(self, timer1, when, *args, **kwargs):
if timername=='buytimer':
self.buy_stocks()
def notify_timer2(self, timer2, when, *args, **kwargs):
if timername=='selltimer':
self.sell_stocks()
Is this what you mean? Something's not quite working.
I have a question about timers. I want to create two timers, one to initiate some sell activities on a Monday and another to initiate buy activities on a Wednesday. I understand how to create two timers, but how do I associate each timer with a different activity/function?