Skip to content

Commit 68f0cb8

Browse files
committed
fix: resolve final diagnostic issues in OrderManager module
- Fixed _unlink_oco_orders call with proper hasattr check - Fixed type annotation for _validate_trade_data parameter - All IDE diagnostics now passing - All 33 OrderManager tests passing
1 parent a7125a0 commit 68f0cb8

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/project_x_py/order_manager/tracking.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,20 @@ async def cancel_oco_order() -> None:
753753
)
754754

755755
# Clean up OCO group using safe unlinking
756-
linked_id = self._unlink_oco_orders(order_id_int)
757-
if linked_id != other_order_id:
758-
logger.warning(
759-
f"OCO cleanup: expected {other_order_id}, got {linked_id}"
756+
if hasattr(self, "_unlink_oco_orders"):
757+
linked_id = self._unlink_oco_orders(
758+
order_id_int
760759
)
760+
if linked_id != other_order_id:
761+
logger.warning(
762+
f"OCO cleanup: expected {other_order_id}, got {linked_id}"
763+
)
764+
else:
765+
# Just remove from OCO groups directly
766+
if order_id_int in self.oco_groups:
767+
del self.oco_groups[order_id_int]
768+
if other_order_id in self.oco_groups:
769+
del self.oco_groups[other_order_id]
761770
else:
762771
logger.warning(
763772
f"OCO group entry for {order_id_int} is None"
@@ -878,12 +887,12 @@ def _extract_trade_data(
878887
logger.error(f"Error extracting trade data: {e}")
879888
return None
880889

881-
def _validate_trade_data(self, trade_data: dict[str, Any]) -> dict[str, Any] | None:
890+
def _validate_trade_data(self, trade_data: Any) -> dict[str, Any] | None:
882891
"""
883892
Validate trade execution data structure.
884893
885894
Args:
886-
trade_data: Dictionary containing trade information
895+
trade_data: Data containing trade information (expected to be a dict)
887896
888897
Returns:
889898
Validated trade data or None if invalid

0 commit comments

Comments
 (0)