pdmt5 0.0.6__tar.gz → 0.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pdmt5-0.0.6 → pdmt5-0.0.8}/CLAUDE.md +6 -2
- {pdmt5-0.0.6 → pdmt5-0.0.8}/PKG-INFO +29 -15
- {pdmt5-0.0.6 → pdmt5-0.0.8}/README.md +28 -14
- {pdmt5-0.0.6 → pdmt5-0.0.8}/docs/api/trading.md +18 -24
- {pdmt5-0.0.6 → pdmt5-0.0.8}/docs/api/utils.md +1 -1
- {pdmt5-0.0.6 → pdmt5-0.0.8}/docs/index.md +26 -12
- {pdmt5-0.0.6 → pdmt5-0.0.8}/pdmt5/__init__.py +2 -1
- {pdmt5-0.0.6 → pdmt5-0.0.8}/pdmt5/dataframe.py +88 -86
- {pdmt5-0.0.6 → pdmt5-0.0.8}/pdmt5/mt5.py +133 -78
- {pdmt5-0.0.6 → pdmt5-0.0.8}/pdmt5/utils.py +1 -1
- {pdmt5-0.0.6 → pdmt5-0.0.8}/pyproject.toml +2 -2
- {pdmt5-0.0.6 → pdmt5-0.0.8}/test/test_dataframe.py +78 -141
- {pdmt5-0.0.6 → pdmt5-0.0.8}/test/test_init.py +6 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/test/test_mt5.py +21 -16
- {pdmt5-0.0.6 → pdmt5-0.0.8}/test/test_trading.py +1 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/test/test_utils.py +39 -5
- {pdmt5-0.0.6 → pdmt5-0.0.8}/uv.lock +1 -1
- {pdmt5-0.0.6 → pdmt5-0.0.8}/.claude/settings.json +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/.github/FUNDING.yml +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/.github/copilot-instructions.md +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/.github/dependabot.yml +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/.github/workflows/ci.yml +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/.gitignore +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/LICENSE +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/docs/api/dataframe.md +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/docs/api/index.md +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/docs/api/mt5.md +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/mkdocs.yml +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/pdmt5/trading.py +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/renovate.json +0 -0
- {pdmt5-0.0.6 → pdmt5-0.0.8}/test/__init__.py +0 -0
|
@@ -63,11 +63,13 @@ uv run mkdocs gh-deploy
|
|
|
63
63
|
### Package Structure
|
|
64
64
|
|
|
65
65
|
- `pdmt5/`: Main package directory
|
|
66
|
-
- `__init__.py`: Package initialization and exports (Mt5Client, Mt5Config, Mt5DataClient, Mt5RuntimeError)
|
|
66
|
+
- `__init__.py`: Package initialization and exports (Mt5Client, Mt5Config, Mt5DataClient, Mt5RuntimeError, Mt5TradingClient)
|
|
67
67
|
- `mt5.py`: MT5 terminal client with context manager support (`Mt5Client`, `Mt5RuntimeError`)
|
|
68
68
|
- `dataframe.py`: MT5 data client with pandas DataFrame conversion (`Mt5Config`, `Mt5DataClient`)
|
|
69
|
+
- `trading.py`: Trading operations client (`Mt5TradingClient`, `Mt5TradingError`)
|
|
70
|
+
- `utils.py`: Utility decorators and functions for time conversion and DataFrame indexing
|
|
69
71
|
- `test/`: Comprehensive test suite (pytest-based)
|
|
70
|
-
- `test_init.py`, `test_mt5.py`, `test_dataframe.py`
|
|
72
|
+
- `test_init.py`, `test_mt5.py`, `test_dataframe.py`, `test_trading.py`, `test_utils.py`
|
|
71
73
|
- `docs/`: MkDocs documentation with API reference
|
|
72
74
|
- `docs/api/`: Auto-generated API documentation for all modules
|
|
73
75
|
- Modern Python packaging with `pyproject.toml` and uv dependency management
|
|
@@ -99,6 +101,8 @@ Uses MkDocs with Material theme for API documentation built from Google-style do
|
|
|
99
101
|
- `docs/api/`: Auto-generated API reference
|
|
100
102
|
- `mt5.md`: Mt5Client and Mt5RuntimeError
|
|
101
103
|
- `dataframe.md`: Mt5Config and Mt5DataClient
|
|
104
|
+
- `trading.md`: Mt5TradingClient and Mt5TradingError
|
|
105
|
+
- `utils.md`: Utility decorators and helper functions
|
|
102
106
|
|
|
103
107
|
### Workflow
|
|
104
108
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pdmt5
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: Pandas-based data handler for MetaTrader 5
|
|
5
5
|
Project-URL: Repository, https://github.com/dceoy/pdmt5.git
|
|
6
6
|
Author-email: dceoy <dceoy@users.noreply.github.com>
|
|
@@ -84,12 +84,12 @@ config = Mt5Config(
|
|
|
84
84
|
|
|
85
85
|
# Use as context manager
|
|
86
86
|
with Mt5DataClient(config=config) as client:
|
|
87
|
-
# Get account information
|
|
88
|
-
account_info = client.
|
|
87
|
+
# Get account information as DataFrame
|
|
88
|
+
account_info = client.get_account_info_as_df()
|
|
89
89
|
print(account_info)
|
|
90
90
|
|
|
91
|
-
# Get OHLCV data
|
|
92
|
-
rates = client.
|
|
91
|
+
# Get OHLCV data as DataFrame
|
|
92
|
+
rates = client.copy_rates_from_as_df(
|
|
93
93
|
symbol="EURUSD",
|
|
94
94
|
timeframe=mt5.TIMEFRAME_H1,
|
|
95
95
|
date_from=datetime(2024, 1, 1),
|
|
@@ -97,17 +97,29 @@ with Mt5DataClient(config=config) as client:
|
|
|
97
97
|
)
|
|
98
98
|
print(rates.head())
|
|
99
99
|
|
|
100
|
-
# Get current positions
|
|
101
|
-
positions = client.
|
|
100
|
+
# Get current positions as DataFrame
|
|
101
|
+
positions = client.get_positions_as_df()
|
|
102
102
|
print(positions)
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
## Core Components
|
|
106
106
|
|
|
107
|
+
### Mt5Client
|
|
108
|
+
|
|
109
|
+
The base client for MT5 operations with context manager support:
|
|
110
|
+
|
|
111
|
+
- **Connection Management**: `initialize()`, `login()`, `shutdown()`
|
|
112
|
+
- **Account & Terminal Info**: Access account details and terminal information
|
|
113
|
+
- **Symbol Operations**: Get symbol information and market data
|
|
114
|
+
- **Trading Operations**: Execute orders, manage positions and deals
|
|
115
|
+
- **History Access**: Retrieve historical orders and deals
|
|
116
|
+
|
|
107
117
|
### Mt5DataClient
|
|
108
118
|
|
|
109
|
-
|
|
119
|
+
Extends Mt5Client with pandas DataFrame conversions:
|
|
110
120
|
|
|
121
|
+
- **DataFrame Methods**: All data methods have `_as_df` variants returning DataFrames
|
|
122
|
+
- **Dictionary Methods**: All data methods have `_as_dict` variants returning dictionaries
|
|
111
123
|
- **Account Operations**: `get_account_info()`, `get_terminal_info()`
|
|
112
124
|
- **Market Data**: `copy_rates_*()` methods for OHLCV data
|
|
113
125
|
- **Tick Data**: `copy_ticks_*()` methods for tick-level data
|
|
@@ -116,7 +128,7 @@ The main interface for interacting with MetaTrader 5:
|
|
|
116
128
|
|
|
117
129
|
### Mt5TradingClient
|
|
118
130
|
|
|
119
|
-
|
|
131
|
+
Advanced trading operations interface that extends Mt5DataClient:
|
|
120
132
|
|
|
121
133
|
- **Position Management**: `close_open_positions()` - Close positions by symbol
|
|
122
134
|
- **Order Filling Modes**: IOC (Immediate or Cancel), FOK (Fill or Kill), or RETURN
|
|
@@ -146,8 +158,8 @@ import MetaTrader5 as mt5
|
|
|
146
158
|
from datetime import datetime
|
|
147
159
|
|
|
148
160
|
with Mt5DataClient(config=config) as client:
|
|
149
|
-
# Get last 1000 H1 bars for EURUSD
|
|
150
|
-
df = client.
|
|
161
|
+
# Get last 1000 H1 bars for EURUSD as DataFrame
|
|
162
|
+
df = client.copy_rates_from_as_df(
|
|
151
163
|
symbol="EURUSD",
|
|
152
164
|
timeframe=mt5.TIMEFRAME_H1,
|
|
153
165
|
date_from=datetime.now(),
|
|
@@ -162,9 +174,11 @@ with Mt5DataClient(config=config) as client:
|
|
|
162
174
|
### Working with Tick Data
|
|
163
175
|
|
|
164
176
|
```python
|
|
177
|
+
from datetime import datetime, timedelta
|
|
178
|
+
|
|
165
179
|
with Mt5DataClient(config=config) as client:
|
|
166
|
-
# Get ticks for the last hour
|
|
167
|
-
ticks = client.
|
|
180
|
+
# Get ticks for the last hour as DataFrame
|
|
181
|
+
ticks = client.copy_ticks_from_as_df(
|
|
168
182
|
symbol="EURUSD",
|
|
169
183
|
date_from=datetime.now() - timedelta(hours=1),
|
|
170
184
|
count=10000,
|
|
@@ -179,8 +193,8 @@ with Mt5DataClient(config=config) as client:
|
|
|
179
193
|
|
|
180
194
|
```python
|
|
181
195
|
with Mt5DataClient(config=config) as client:
|
|
182
|
-
# Get all open positions
|
|
183
|
-
positions = client.
|
|
196
|
+
# Get all open positions as DataFrame
|
|
197
|
+
positions = client.get_positions_as_df()
|
|
184
198
|
|
|
185
199
|
if not positions.empty:
|
|
186
200
|
# Calculate summary statistics
|
|
@@ -61,12 +61,12 @@ config = Mt5Config(
|
|
|
61
61
|
|
|
62
62
|
# Use as context manager
|
|
63
63
|
with Mt5DataClient(config=config) as client:
|
|
64
|
-
# Get account information
|
|
65
|
-
account_info = client.
|
|
64
|
+
# Get account information as DataFrame
|
|
65
|
+
account_info = client.get_account_info_as_df()
|
|
66
66
|
print(account_info)
|
|
67
67
|
|
|
68
|
-
# Get OHLCV data
|
|
69
|
-
rates = client.
|
|
68
|
+
# Get OHLCV data as DataFrame
|
|
69
|
+
rates = client.copy_rates_from_as_df(
|
|
70
70
|
symbol="EURUSD",
|
|
71
71
|
timeframe=mt5.TIMEFRAME_H1,
|
|
72
72
|
date_from=datetime(2024, 1, 1),
|
|
@@ -74,17 +74,29 @@ with Mt5DataClient(config=config) as client:
|
|
|
74
74
|
)
|
|
75
75
|
print(rates.head())
|
|
76
76
|
|
|
77
|
-
# Get current positions
|
|
78
|
-
positions = client.
|
|
77
|
+
# Get current positions as DataFrame
|
|
78
|
+
positions = client.get_positions_as_df()
|
|
79
79
|
print(positions)
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
## Core Components
|
|
83
83
|
|
|
84
|
+
### Mt5Client
|
|
85
|
+
|
|
86
|
+
The base client for MT5 operations with context manager support:
|
|
87
|
+
|
|
88
|
+
- **Connection Management**: `initialize()`, `login()`, `shutdown()`
|
|
89
|
+
- **Account & Terminal Info**: Access account details and terminal information
|
|
90
|
+
- **Symbol Operations**: Get symbol information and market data
|
|
91
|
+
- **Trading Operations**: Execute orders, manage positions and deals
|
|
92
|
+
- **History Access**: Retrieve historical orders and deals
|
|
93
|
+
|
|
84
94
|
### Mt5DataClient
|
|
85
95
|
|
|
86
|
-
|
|
96
|
+
Extends Mt5Client with pandas DataFrame conversions:
|
|
87
97
|
|
|
98
|
+
- **DataFrame Methods**: All data methods have `_as_df` variants returning DataFrames
|
|
99
|
+
- **Dictionary Methods**: All data methods have `_as_dict` variants returning dictionaries
|
|
88
100
|
- **Account Operations**: `get_account_info()`, `get_terminal_info()`
|
|
89
101
|
- **Market Data**: `copy_rates_*()` methods for OHLCV data
|
|
90
102
|
- **Tick Data**: `copy_ticks_*()` methods for tick-level data
|
|
@@ -93,7 +105,7 @@ The main interface for interacting with MetaTrader 5:
|
|
|
93
105
|
|
|
94
106
|
### Mt5TradingClient
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
Advanced trading operations interface that extends Mt5DataClient:
|
|
97
109
|
|
|
98
110
|
- **Position Management**: `close_open_positions()` - Close positions by symbol
|
|
99
111
|
- **Order Filling Modes**: IOC (Immediate or Cancel), FOK (Fill or Kill), or RETURN
|
|
@@ -123,8 +135,8 @@ import MetaTrader5 as mt5
|
|
|
123
135
|
from datetime import datetime
|
|
124
136
|
|
|
125
137
|
with Mt5DataClient(config=config) as client:
|
|
126
|
-
# Get last 1000 H1 bars for EURUSD
|
|
127
|
-
df = client.
|
|
138
|
+
# Get last 1000 H1 bars for EURUSD as DataFrame
|
|
139
|
+
df = client.copy_rates_from_as_df(
|
|
128
140
|
symbol="EURUSD",
|
|
129
141
|
timeframe=mt5.TIMEFRAME_H1,
|
|
130
142
|
date_from=datetime.now(),
|
|
@@ -139,9 +151,11 @@ with Mt5DataClient(config=config) as client:
|
|
|
139
151
|
### Working with Tick Data
|
|
140
152
|
|
|
141
153
|
```python
|
|
154
|
+
from datetime import datetime, timedelta
|
|
155
|
+
|
|
142
156
|
with Mt5DataClient(config=config) as client:
|
|
143
|
-
# Get ticks for the last hour
|
|
144
|
-
ticks = client.
|
|
157
|
+
# Get ticks for the last hour as DataFrame
|
|
158
|
+
ticks = client.copy_ticks_from_as_df(
|
|
145
159
|
symbol="EURUSD",
|
|
146
160
|
date_from=datetime.now() - timedelta(hours=1),
|
|
147
161
|
count=10000,
|
|
@@ -156,8 +170,8 @@ with Mt5DataClient(config=config) as client:
|
|
|
156
170
|
|
|
157
171
|
```python
|
|
158
172
|
with Mt5DataClient(config=config) as client:
|
|
159
|
-
# Get all open positions
|
|
160
|
-
positions = client.
|
|
173
|
+
# Get all open positions as DataFrame
|
|
174
|
+
positions = client.get_positions_as_df()
|
|
161
175
|
|
|
162
176
|
if not positions.empty:
|
|
163
177
|
# Calculate summary statistics
|
|
@@ -34,16 +34,18 @@ from pdmt5 import Mt5TradingClient, Mt5Config
|
|
|
34
34
|
config = Mt5Config(
|
|
35
35
|
login=123456,
|
|
36
36
|
password="your_password",
|
|
37
|
-
server="broker_server"
|
|
37
|
+
server="broker_server",
|
|
38
|
+
timeout=60000,
|
|
39
|
+
portable=False
|
|
38
40
|
)
|
|
39
41
|
|
|
40
42
|
# Create client with dry run mode for testing
|
|
41
|
-
client = Mt5TradingClient(
|
|
43
|
+
client = Mt5TradingClient(config=config, dry_run=True)
|
|
42
44
|
|
|
43
45
|
# Use as context manager
|
|
44
46
|
with client:
|
|
45
|
-
# Get current positions
|
|
46
|
-
positions_df = client.
|
|
47
|
+
# Get current positions as DataFrame
|
|
48
|
+
positions_df = client.get_positions_as_df()
|
|
47
49
|
print(f"Open positions: {len(positions_df)}")
|
|
48
50
|
|
|
49
51
|
# Close positions for specific symbol
|
|
@@ -55,7 +57,7 @@ with client:
|
|
|
55
57
|
|
|
56
58
|
```python
|
|
57
59
|
# Create client for live trading (dry_run=False)
|
|
58
|
-
client = Mt5TradingClient(
|
|
60
|
+
client = Mt5TradingClient(config=config, dry_run=False)
|
|
59
61
|
|
|
60
62
|
with client:
|
|
61
63
|
# Close all positions for multiple symbols
|
|
@@ -71,21 +73,18 @@ with client:
|
|
|
71
73
|
# Configure different order filling modes
|
|
72
74
|
# IOC (Immediate or Cancel) - default
|
|
73
75
|
client_ioc = Mt5TradingClient(
|
|
74
|
-
mt5=mt5,
|
|
75
76
|
config=config,
|
|
76
77
|
order_filling_mode="IOC"
|
|
77
78
|
)
|
|
78
79
|
|
|
79
80
|
# FOK (Fill or Kill)
|
|
80
81
|
client_fok = Mt5TradingClient(
|
|
81
|
-
mt5=mt5,
|
|
82
82
|
config=config,
|
|
83
83
|
order_filling_mode="FOK"
|
|
84
84
|
)
|
|
85
85
|
|
|
86
86
|
# RETURN (Return if not filled)
|
|
87
87
|
client_return = Mt5TradingClient(
|
|
88
|
-
mt5=mt5,
|
|
89
88
|
config=config,
|
|
90
89
|
order_filling_mode="RETURN"
|
|
91
90
|
)
|
|
@@ -120,19 +119,14 @@ except Mt5TradingError as e:
|
|
|
120
119
|
|
|
121
120
|
```python
|
|
122
121
|
with client:
|
|
123
|
-
#
|
|
124
|
-
|
|
125
|
-
"action": mt5.TRADE_ACTION_DEAL,
|
|
126
|
-
"symbol": "EURUSD",
|
|
127
|
-
"volume": 1.0,
|
|
128
|
-
"type": mt5.ORDER_TYPE_BUY,
|
|
129
|
-
"type_filling": mt5.ORDER_FILLING_IOC,
|
|
130
|
-
"type_time": mt5.ORDER_TIME_GTC
|
|
131
|
-
}
|
|
122
|
+
# Check order (note: send_or_check_order is an internal method)
|
|
123
|
+
# For trading operations, use the provided methods like close_open_positions
|
|
132
124
|
|
|
133
|
-
#
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
# Example: Check if we can close a position
|
|
126
|
+
positions = client.get_positions_as_df()
|
|
127
|
+
if not positions.empty:
|
|
128
|
+
# Close specific position
|
|
129
|
+
results = client.close_open_positions("EURUSD")
|
|
136
130
|
```
|
|
137
131
|
|
|
138
132
|
## Position Management Features
|
|
@@ -151,10 +145,10 @@ Dry run mode is essential for testing trading strategies:
|
|
|
151
145
|
|
|
152
146
|
```python
|
|
153
147
|
# Test mode - validates orders without execution
|
|
154
|
-
test_client = Mt5TradingClient(
|
|
148
|
+
test_client = Mt5TradingClient(config=config, dry_run=True)
|
|
155
149
|
|
|
156
150
|
# Production mode - executes real orders
|
|
157
|
-
prod_client = Mt5TradingClient(
|
|
151
|
+
prod_client = Mt5TradingClient(config=config, dry_run=False)
|
|
158
152
|
```
|
|
159
153
|
|
|
160
154
|
In dry run mode:
|
|
@@ -207,9 +201,9 @@ The `close_open_positions()` method returns a dictionary with symbols as keys:
|
|
|
207
201
|
Since Mt5TradingClient inherits from Mt5DataClient, all data retrieval methods are available:
|
|
208
202
|
|
|
209
203
|
```python
|
|
210
|
-
with Mt5TradingClient(
|
|
204
|
+
with Mt5TradingClient(config=config) as client:
|
|
211
205
|
# Get current positions as DataFrame
|
|
212
|
-
positions_df = client.
|
|
206
|
+
positions_df = client.get_positions_as_df()
|
|
213
207
|
|
|
214
208
|
# Analyze positions
|
|
215
209
|
if not positions_df.empty:
|
|
@@ -68,7 +68,7 @@ These utilities enable Mt5DataClient to provide user-friendly data:
|
|
|
68
68
|
|
|
69
69
|
```python
|
|
70
70
|
# Time values are automatically converted
|
|
71
|
-
df = client.
|
|
71
|
+
df = client.get_symbols_as_df(convert_time=True)
|
|
72
72
|
# Returns DataFrame with datetime objects instead of Unix timestamps
|
|
73
73
|
|
|
74
74
|
# DataFrames can have custom indexes
|
|
@@ -19,7 +19,7 @@ pdmt5 is a Python library that provides a pandas-based interface for handling Me
|
|
|
19
19
|
pip install pdmt5
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
### Quick Start
|
|
23
23
|
|
|
24
24
|
```python
|
|
25
25
|
from pdmt5 import Mt5Client, Mt5Config, Mt5DataClient, Mt5TradingClient
|
|
@@ -27,24 +27,37 @@ import MetaTrader5 as mt5
|
|
|
27
27
|
from datetime import datetime
|
|
28
28
|
|
|
29
29
|
# Configure connection
|
|
30
|
-
config = Mt5Config(
|
|
30
|
+
config = Mt5Config(
|
|
31
|
+
login=12345678,
|
|
32
|
+
password="your_password",
|
|
33
|
+
server="YourBroker-Server",
|
|
34
|
+
timeout=60000,
|
|
35
|
+
portable=False
|
|
36
|
+
)
|
|
31
37
|
|
|
32
38
|
# Low-level API access with context manager
|
|
33
|
-
with Mt5Client(
|
|
39
|
+
with Mt5Client() as client:
|
|
34
40
|
client.initialize()
|
|
41
|
+
client.login(config.login, config.password, config.server)
|
|
35
42
|
account = client.account_info()
|
|
36
43
|
rates = client.copy_rates_from("EURUSD", mt5.TIMEFRAME_H1, datetime.now(), 100)
|
|
37
44
|
|
|
38
45
|
# Pandas-friendly interface with automatic initialization
|
|
39
|
-
with Mt5DataClient(
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
with Mt5DataClient(config=config) as client:
|
|
47
|
+
# Get symbol information as DataFrame
|
|
48
|
+
symbols_df = client.get_symbols_as_df()
|
|
49
|
+
# Get OHLCV data as DataFrame
|
|
50
|
+
rates_df = client.copy_rates_from_as_df(
|
|
51
|
+
"EURUSD", mt5.TIMEFRAME_H1, datetime.now(), 100
|
|
52
|
+
)
|
|
53
|
+
# Get account info as DataFrame
|
|
54
|
+
account_df = client.get_account_info_as_df()
|
|
42
55
|
|
|
43
56
|
# Trading operations with dry run support
|
|
44
|
-
with Mt5TradingClient(
|
|
45
|
-
# Check open positions
|
|
46
|
-
positions_df = client.
|
|
47
|
-
# Close positions for specific symbol
|
|
57
|
+
with Mt5TradingClient(config=config, dry_run=True) as client:
|
|
58
|
+
# Check open positions as DataFrame
|
|
59
|
+
positions_df = client.get_positions_as_df()
|
|
60
|
+
# Close positions for specific symbol (dry run)
|
|
48
61
|
results = client.close_open_positions("EURUSD")
|
|
49
62
|
```
|
|
50
63
|
|
|
@@ -58,9 +71,10 @@ with Mt5TradingClient(mt5=mt5, config=config, dry_run=True) as client:
|
|
|
58
71
|
|
|
59
72
|
Browse the API documentation to learn about available modules and functions:
|
|
60
73
|
|
|
61
|
-
- [Mt5Client](api/mt5.md) - Base client for low-level MT5 API access
|
|
62
|
-
- [Mt5DataClient & Mt5Config](api/dataframe.md) - Pandas-friendly data client
|
|
74
|
+
- [Mt5Client](api/mt5.md) - Base client for low-level MT5 API access with context manager support
|
|
75
|
+
- [Mt5DataClient & Mt5Config](api/dataframe.md) - Pandas-friendly data client with DataFrame conversions
|
|
63
76
|
- [Mt5TradingClient](api/trading.md) - Advanced trading operations with position management
|
|
77
|
+
- [Utility Functions](api/utils.md) - Helper decorators and functions for data processing
|
|
64
78
|
|
|
65
79
|
## Development
|
|
66
80
|
|
|
@@ -4,7 +4,7 @@ from importlib.metadata import version
|
|
|
4
4
|
|
|
5
5
|
from .dataframe import Mt5Config, Mt5DataClient
|
|
6
6
|
from .mt5 import Mt5Client, Mt5RuntimeError
|
|
7
|
-
from .trading import Mt5TradingClient
|
|
7
|
+
from .trading import Mt5TradingClient, Mt5TradingError
|
|
8
8
|
|
|
9
9
|
__version__ = version(__package__) if __package__ else None
|
|
10
10
|
|
|
@@ -14,4 +14,5 @@ __all__ = [
|
|
|
14
14
|
"Mt5DataClient",
|
|
15
15
|
"Mt5RuntimeError",
|
|
16
16
|
"Mt5TradingClient",
|
|
17
|
+
"Mt5TradingError",
|
|
17
18
|
]
|