Move inline stdlib imports (copy, time) to module top in orb engine

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
I Luk Kim 4 months ago
parent 91efa04d4e
commit 6ae4588a62

@ -14,8 +14,10 @@ Stop management logic mirrors orb_simulator.py:477-580 exactly.
""" """
from __future__ import annotations from __future__ import annotations
import copy
import datetime as dt import datetime as dt
import logging import logging
import time
import uuid import uuid
from typing import Any from typing import Any
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
@ -347,7 +349,6 @@ class ORBTradingEngine:
for d in sorted(self._enrichment[ticker].keys(), reverse=True): for d in sorted(self._enrichment[ticker].keys(), reverse=True):
if d <= date_str: if d <= date_str:
# Create a date_str entry inheriting from latest # Create a date_str entry inheriting from latest
import copy
self._enrichment[ticker][date_str] = copy.copy( self._enrichment[ticker][date_str] = copy.copy(
self._enrichment[ticker][d] self._enrichment[ticker][d]
) )
@ -579,7 +580,6 @@ class ORBTradingEngine:
# Wait for fill (poll up to 30s) # Wait for fill (poll up to 30s)
fill_price = entry_price_est fill_price = entry_price_est
order_rejected = False order_rejected = False
import time
for _ in range(6): for _ in range(6):
time.sleep(5) time.sleep(5)
try: try:
@ -793,7 +793,6 @@ class ORBTradingEngine:
# (other sessions may hold the same ticker in the same Alpaca account). # (other sessions may hold the same ticker in the same Alpaca account).
exit_price = current_stop # fallback if fill poll fails exit_price = current_stop # fallback if fill poll fails
try: try:
import time
close_order = self._broker.close_position(ticker, qty=int(pos.shares)) close_order = self._broker.close_position(ticker, qty=int(pos.shares))
# Poll for actual broker fill price (captures gap-through losses) # Poll for actual broker fill price (captures gap-through losses)
for _ in range(4): for _ in range(4):
@ -863,7 +862,6 @@ class ORBTradingEngine:
try: try:
# Use qty so only this session's shares are closed # Use qty so only this session's shares are closed
close_order = self._broker.close_position(pos.ticker, qty=int(pos.shares)) close_order = self._broker.close_position(pos.ticker, qty=int(pos.shares))
import time
exit_price = pos.entry_price exit_price = pos.entry_price
for _ in range(4): for _ in range(4):
time.sleep(3) time.sleep(3)

Loading…
Cancel
Save