INNER CODE UNIT · Python
future_price
keanekwa/Optiver-Ready-Trader-Go · arbitrage.py:63
future_price = (self.last_future_asks[0] + self.last_future_bids[0]) // 2
etf_price = (ask_prices[0] + bid_prices[0]) // 2
new_bid_price = bid_prices[0] + 100 if bid_prices[0] != 0 else 0
new_ask_price = ask_prices[0] - 100 if ask_prices[0] != 0 else 0
if self.bid_id != 0 and new_bid_price not in (self.bid_price, 0):
self.send_cancel_order(self.bid_id)
self.bid_id = 0
if self.ask_id != 0 and new_ask_price not in (self.ask_price, 0):
self.send_cancel_order(self.ask_id)
self.ask_id = 0
# Buy the underpriced instrument and sell the overpriced instrument
if self.bid_id == 0 and new_bid_price != 0 and etf_price < future_price and self.position <= POSITION_LIMIT - (LOT_SIZE * len(self.bids) + LOT_SIZE):
bid_size = LOT_SIZE
if self.position < 0: