def __init__(self, scheduler: HistoricNetworkScheduler, azure_connect_str: str): self.scheduler = scheduler self.azure_connect_str = azure_connect_str self.subscribed_instruments = MutableSignal() self.scheduler.get_network().attach(self.subscribed_instruments) self.start_time = scheduler.get_clock().get_start_time() self.end_time = scheduler.get_clock().get_end_time() self.all_subscribed = set() self.book_signal_by_symbol = {} self.trade_signal_by_symbol = {}
def __init__(self, scheduler: HistoricNetworkScheduler): self.scheduler = scheduler self.subscribed_instruments = MutableSignal() self.scheduler.get_network().attach(self.subscribed_instruments) self.start_time = scheduler.get_clock().get_start_time() self.end_time = scheduler.get_clock().get_end_time() self.all_subscribed = set() self.book_signal_by_symbol = {} self.trade_signal_by_symbol = {} self.credential = DeviceCodeCredential(client_id=get_global_defaults()['azure']['client_id'], tenant_id=get_global_defaults()['azure']['tenant_id'])
def test_repeating_timer(): # run for one minute scheduler = HistoricNetworkScheduler(0, 60 * 1000) tz = pytz.timezone('US/Eastern') timer = RepeatingTimer(scheduler, datetime.timedelta(seconds=15)) timestamps = list() Do(scheduler.get_network(), timer, lambda: timestamps.append(scheduler.get_clock().get_time(tz))) scheduler.run() assert len(timestamps) == 4 assert str(timestamps[3]) == '1969-12-31 19:01:00-05:00'
def test_alarm(): # run for one day scheduler = HistoricNetworkScheduler(0, 60 * 60 * 24 * 1000) # schedule at 4pm US/Eastern tz = pytz.timezone('US/Eastern') alarm = Alarm(scheduler, datetime.time(16, 00, 00), tz) timestamps = list() Do(scheduler.get_network(), alarm, lambda: timestamps.append(scheduler.get_clock().get_time(tz))) scheduler.run() assert len(timestamps) == 1