Skip to content

Commit 4c01b2e

Browse files
committed
updates
1 parent 916fee1 commit 4c01b2e

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "project-x-py"
3-
version = "1.0.8"
3+
version = "1.0.9"
44
description = "Professional Python client for TopStepX ProjectX Gateway API - futures trading, real-time data, and market analysis"
55
readme = "README.md"
66
license = { text = "MIT" }

src/project_x_py/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from typing import Any, Optional
1717

18-
__version__ = "1.0.8"
18+
__version__ = "1.0.9"
1919
__author__ = "TexasCoding"
2020

2121
# Core client classes

src/project_x_py/indicators/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
)
133133

134134
# Version info
135-
__version__ = "1.0.8"
135+
__version__ = "1.0.9"
136136
__author__ = "TexasCoding"
137137

138138

src/project_x_py/position_manager.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ def _on_position_update(self, data: dict):
196196
def _on_position_closed(self, data: dict):
197197
"""Handle real-time position closure notifications."""
198198
try:
199+
data = data.get("data", {})
200+
if not data:
201+
self.logger.error(f"No position data found in {data}")
202+
return
203+
199204
contract_id = data.get("contractId")
200205
if contract_id:
201206
with self.position_lock:
@@ -215,8 +220,11 @@ def _on_account_update(self, data: dict):
215220
def _process_position_data(self, position_data: dict):
216221
"""Process individual position data update."""
217222
try:
223+
position_data = position_data.get("data", {})
224+
218225
contract_id = position_data.get("contractId")
219226
if not contract_id:
227+
self.logger.error(f"No contract ID found in {position_data}")
220228
return
221229

222230
# Create or update position
@@ -821,14 +829,14 @@ def close_position_direct(
821829
Close an entire position using the direct position close API.
822830
823831
Args:
824-
contract_id: ID of the position to close
832+
contract_id: Contract ID of the position to close
825833
account_id: Account ID. Uses default account if None.
826834
827835
Returns:
828836
Dict with closure response details
829837
830838
Example:
831-
>>> result = position_manager.close_position_direct(12345)
839+
>>> result = position_manager.close_position_direct("MGC")
832840
>>> if result["success"]:
833841
... print(f"Position closed: {result.get('orderId', 'N/A')}")
834842
"""
@@ -866,7 +874,7 @@ def close_position_direct(
866874
positions_to_remove = [
867875
contract_id
868876
for contract_id, pos in self.tracked_positions.items()
869-
if pos.id == contract_id
877+
if pos.contractId == contract_id
870878
]
871879
for contract_id in positions_to_remove:
872880
del self.tracked_positions[contract_id]
@@ -892,7 +900,7 @@ def partially_close_position(
892900
Partially close a position by reducing its size.
893901
894902
Args:
895-
contract_id: ID of the position to partially close
903+
contract_id: Contract ID of the position to partially close
896904
close_size: Number of contracts to close (must be less than position size)
897905
account_id: Account ID. Uses default account if None.
898906
@@ -901,7 +909,7 @@ def partially_close_position(
901909
902910
Example:
903911
>>> # Close 5 contracts from a 10 contract position
904-
>>> result = position_manager.partially_close_position(12345, 5)
912+
>>> result = position_manager.partially_close_position("MGC", 5)
905913
>>> if result["success"]:
906914
... print(f"Partially closed: {result.get('orderId', 'N/A')}")
907915
"""
@@ -922,7 +930,7 @@ def partially_close_position(
922930
payload = {
923931
"accountId": account_id,
924932
"contractId": contract_id,
925-
"size": close_size,
933+
"closeSize": close_size,
926934
}
927935

928936
try:

0 commit comments

Comments
 (0)