INNER CODE UNIT · Python
Logger
pe049395/IMC-Prosperity-2024 · submissions/round5.py:12
class Logger:
def __init__(self) -> None:
self.logs = ""
self.max_log_length = 3750
def print(self, *objects: Any, sep: str = " ", end: str = "\n") -> None:
self.logs += sep.join(map(str, objects)) + end
def flush(self, state: TradingState, orders: dict[Symbol, list[Order]], conversions: int, trader_data: str) -> None:
base_length = len(self.to_json([
self.compress_state(state, ""),
self.compress_orders(orders),
conversions,
"",
"",
]))
# We truncate state.traderData, trader_data, and self.logs to the same max. length to fit the log limit