Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _scan(self):
"""Look for opportunities to open a position.
Returns:
[] if there is an opportunity.
Empty list if no opportunities.
None on failure.
"""
for iid in self.instrument_ids:
now = broker.get_time()
spread = broker.get_spread(iid)
price = broker.get_price(iid)
goal = spread # goal profit per trade
# always update the price history
if self.last_history_update == None or now - self.last_history_update >= timedelta(minutes=1):
self.last_history_update = now
# shift everything by one
for i in range(len(self.price_history)-1, 0, -1):
self.price_history[i] = self.price_history[i-1]
self.price_history[0] = price
# check for opp
go = False
# only if price history completely filled
if not None in self.price_history:
smooth = True
for i in range(0, len(self.price_history)-1):