diff --git a/src/main.py b/src/main.py index 44fadfa..2f119a4 100644 --- a/src/main.py +++ b/src/main.py @@ -1031,19 +1031,10 @@ def _maybe_queue_order_intent( price: float, source: str, ) -> bool: - def _coerce_nonnegative_int(value: Any) -> int: - try: - parsed = int(value) - except (TypeError, ValueError): - return 0 - return max(0, parsed) - if not BLACKOUT_ORDER_MANAGER.in_blackout(): return False - before_overflow_drops = _coerce_nonnegative_int( - getattr(BLACKOUT_ORDER_MANAGER, "overflow_drop_count", 0) - ) + before_overflow_drops = BLACKOUT_ORDER_MANAGER.overflow_drop_count queued = BLACKOUT_ORDER_MANAGER.enqueue( _build_queued_order_intent( market=market, @@ -1055,9 +1046,7 @@ def _maybe_queue_order_intent( ) ) if queued: - after_overflow_drops = _coerce_nonnegative_int( - getattr(BLACKOUT_ORDER_MANAGER, "overflow_drop_count", 0) - ) + after_overflow_drops = BLACKOUT_ORDER_MANAGER.overflow_drop_count logger.warning( ( "Blackout active: queued order intent %s %s (%s) " diff --git a/tests/test_main.py b/tests/test_main.py index c24c6c6..5c83d9e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -6502,6 +6502,7 @@ async def test_blackout_queues_order_and_skips_submission() -> None: blackout_manager.in_blackout.return_value = True blackout_manager.enqueue.return_value = True blackout_manager.pending_count = 1 + blackout_manager.overflow_drop_count = 0 with patch("src.main.BLACKOUT_ORDER_MANAGER", blackout_manager): await trading_cycle(