As news are published in 24x7, there won't have the concept of "market session" for news data.
However, you can create a global variable to check current market session.
A simple example as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | from AlgoAPI import AlgoAPIUtil, AlgoAPI_Backtest class AlgoEvent: def __init__(self): self.isTradingSession = False def start(self, mEvt): self.evt = AlgoAPI_Backtest.AlgoEvtHandler(self, mEvt) self.evt.start() def on_marketdatafeed(self, md, ab): self.isTradingSession = False if md.session==0: self.isTradingSession = True def on_newsdatafeed(self, nd): if self.isTradingSession: # some order condition checking pass |
Original Posted by - b'admin':As news are published in 24x7, there won't have the concept of "market session" for news data.
However, you can create a global variable to check current market session.
A simple example as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 from AlgoAPI import AlgoAPIUtil, AlgoAPI_Backtest class AlgoEvent: def __init__(self): self.isTradingSession = False def start(self, mEvt): self.evt = AlgoAPI_Backtest.AlgoEvtHandler(self, mEvt) self.evt.start() def on_marketdatafeed(self, md, ab): self.isTradingSession = False if md.session==0: self.isTradingSession = True def on_newsdatafeed(self, nd): if self.isTradingSession: # some order condition checking pass