Replace trade filter condition with an assertion

This commit is contained in:
moshferatu 2024-03-03 05:42:35 -08:00
parent 8a0355cc98
commit 0bebd31c26

View File

@ -31,8 +31,7 @@ if __name__ == '__main__':
assert connection_successful(), 'Cannot connect to IBKR. Ensure that TWS or Gateway is running.' assert connection_successful(), 'Cannot connect to IBKR. Ensure that TWS or Gateway is running.'
now = datetime.now(timezone(eastern_timezone)) now = datetime.now(timezone(eastern_timezone))
if all(filter.trade_allowed(now) for filter in trade_filters): assert all(filter.trade_allowed(now) for filter in trade_filters), 'Trade filters prevent trading today.'
print('Trade filters allow for trading today.')
entry_times = getenv('ENTRY_TIMES').split(',') entry_times = getenv('ENTRY_TIMES').split(',')
for entry_time in entry_times: for entry_time in entry_times:
@ -51,5 +50,3 @@ if __name__ == '__main__':
while True: while True:
schedule.run_pending() schedule.run_pending()
time.sleep(1) time.sleep(1)
else:
print('Trade filters prevent trading today.')