INNER CODE UNIT · Python
cls_update
pe049395/IMC-Prosperity-2024 · submissions/round5.py:175
def cls_update(cls, state: TradingState) -> None:
"""Update trading state.
Args:
state (TradingState): trading state
"""
# Update TradingState
cls._state = state
# Update realtime position
for product, posit in state.position.items():
cls._realtime_position[product] = posit
# Update historical order_depths
for product, orderdepth in state.order_depths.items():
cnt = 1
for prc, amt in sorted(orderdepth.sell_orders.items(), reverse=False):
cls._hist_order_depths[product][f'askamt{cnt}'].append(amt)
cls._hist_order_depths[product][f'askprc{cnt}'].append(prc)