You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add data_manager parameter to ManagedTrade constructor
- Implement market price fetching with multi-timeframe fallback
- Update TradingSuite to pass data manager to ManagedTrade
- Enable risk-managed trades without explicit entry prices
- Add comprehensive error handling and helpful error messages
Fixes NotImplementedError when entering positions without entry_price
in ManagedTrade context. The implementation tries multiple timeframes
(1sec, 15sec, 1min, 5min) and falls back to get_current_price().
🤖 Generated with Claude Code
Co-Authored-By: Claude <[email protected]>
This release fixes a critical issue in the Risk Manager's ManagedTrade class where the `_get_market_price()` method was not implemented, preventing users from entering risk-managed trades without explicitly providing an entry price.
7
+
8
+
### What's Fixed
9
+
10
+
#### ManagedTrade Market Price Implementation
11
+
-**Problem**: When using `ManagedTrade.enter_long()` or `enter_short()` without an explicit `entry_price`, the system would fail with `NotImplementedError`
12
+
-**Solution**: Fully implemented `_get_market_price()` method that fetches current market prices from the data manager
13
+
-**Impact**: Risk-managed trades can now be entered using current market prices automatically
14
+
15
+
### Technical Details
16
+
17
+
#### Implementation Features
18
+
-**Smart Timeframe Fallback**: Tries multiple timeframes in order (1sec → 15sec → 1min → 5min) to get the most recent price
19
+
-**Direct Price Access**: Falls back to `get_current_price()` if bar data isn't available
20
+
-**Data Manager Integration**: ManagedTrade now receives data manager from TradingSuite automatically
21
+
-**Clear Error Messages**: Provides helpful error messages when market price cannot be fetched
22
+
23
+
#### Code Changes
24
+
```python
25
+
# Before (would fail)
26
+
asyncwith suite.managed_trade(max_risk_percent=0.01) as trade:
27
+
result =await trade.enter_long(
28
+
stop_loss=current_price -50, # Would throw NotImplementedError
29
+
take_profit=current_price +100
30
+
)
31
+
32
+
# After (works perfectly)
33
+
asyncwith suite.managed_trade(max_risk_percent=0.01) as trade:
Copy file name to clipboardExpand all lines: pyproject.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
[project]
2
2
name = "project-x-py"
3
-
version = "3.1.10"
3
+
version = "3.1.11"
4
4
description = "High-performance Python SDK for futures trading with real-time WebSocket data, technical indicators, order management, and market depth analysis"
0 commit comments