pmt5api 1.2.0__tar.gz → 1.3.0__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.
Files changed (38) hide show
  1. {pmt5api-1.2.0 → pmt5api-1.3.0}/CHANGELOG.md +25 -0
  2. {pmt5api-1.2.0 → pmt5api-1.3.0}/LICENSE.txt +0 -0
  3. {pmt5api-1.2.0 → pmt5api-1.3.0}/PKG-INFO +2 -2
  4. {pmt5api-1.2.0 → pmt5api-1.3.0}/README.md +0 -0
  5. {pmt5api-1.2.0 → pmt5api-1.3.0}/examples/bars.py +0 -0
  6. {pmt5api-1.2.0 → pmt5api-1.3.0}/examples/connect.py +0 -0
  7. {pmt5api-1.2.0 → pmt5api-1.3.0}/examples/pnl.py +0 -0
  8. pmt5api-1.3.0/examples/rotate_view_password.py +20 -0
  9. {pmt5api-1.2.0 → pmt5api-1.3.0}/examples/servers.py +0 -0
  10. {pmt5api-1.2.0 → pmt5api-1.3.0}/examples/sizing.py +0 -0
  11. {pmt5api-1.2.0 → pmt5api-1.3.0}/examples/stream_async.py +0 -0
  12. {pmt5api-1.2.0 → pmt5api-1.3.0}/examples/stream_quotes.py +0 -0
  13. {pmt5api-1.2.0 → pmt5api-1.3.0}/examples/trade_demo.py +0 -0
  14. {pmt5api-1.2.0 → pmt5api-1.3.0}/hatch_build.py +0 -0
  15. {pmt5api-1.2.0 → pmt5api-1.3.0}/pyproject.toml +1 -1
  16. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/__init__.py +3 -3
  17. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/__main__.py +0 -0
  18. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_account.py +19 -1
  19. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_base.py +0 -0
  20. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_coverage.py +15 -0
  21. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_events.py +0 -0
  22. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_market.py +0 -0
  23. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_risk.py +0 -0
  24. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_runtime.py +0 -0
  25. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_session.py +71 -0
  26. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_streams.py +0 -0
  27. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_trading.py +0 -0
  28. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/_util.py +0 -0
  29. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/bars.py +0 -0
  30. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/client.py +0 -0
  31. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/diagnostics.py +0 -0
  32. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/docs/API.md +59 -0
  33. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/docs/FROM-CSHARP.md +12 -0
  34. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/errors.py +0 -0
  35. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/frames.py +0 -0
  36. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/models.py +30 -1
  37. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/py.typed +0 -0
  38. {pmt5api-1.2.0 → pmt5api-1.3.0}/src/pmt5api/servers.py +0 -0
@@ -1,5 +1,30 @@
1
1
  # Changelog — pmt5api
2
2
 
3
+ ## [1.3.0] — 2026-11-29
4
+
5
+ Bundles **wmt5api 4.2.0** (up from 3.2.1): modern broker builds, the trader-grade `Order` fields, and account
6
+ password management. All additive over 1.2.0.
7
+
8
+ ### Added
9
+ - **`change_view_password(new_view_password)`** — change the read-only investor ("view") password (live read-only
10
+ visibility without trade rights). **`roll_view_password(length=12)`** — rotate it to a freshly generated strong
11
+ password and return the new value (schedule this yourself; persist the returned value before relying on it).
12
+ **`change_password_timeout`** — how long to wait for the server's acknowledgement (ms).
13
+ - **`Order.net_profit`**, **`Order.open_time_utc` / `Order.close_time_utc`** (UTC-kinded),
14
+ **`Order.open_timestamp_utc` / `Order.close_timestamp_utc`** (Unix seconds), and
15
+ **`Order.is_buy` / `is_sell` / `is_pending` / `is_ledger_entry`**.
16
+ - **`get_position_deals(position_ticket, opened_after=None, timeout_ms=0)`** — every deal that makes up a position.
17
+ - **`reconcile()`** → **`ReconcileSnapshot`** (orders, sequence, session, server_time): a consistent snapshot of the
18
+ open positions and pending orders for an event-driven client.
19
+ - **`announce_build`**, **`auto_upgrade_on_old_version`**, **`connect_retries`**, **`connect_retry_base_delay`**
20
+ (connect tuning) and read-only **`last_handshake_build`**, **`server_new_form`** (handshake diagnostics).
21
+ - Status **Production/Stable** (classifier `5 - Production/Stable`).
22
+
23
+ ### Changed
24
+ - **`change_password` now works on modern broker builds and confirms the result** — it waits for the server's
25
+ acknowledgement and raises on a broker-side rejection (e.g. `INVALID_PASSWORD`, `NOT_PERMISSION`) instead of
26
+ failing silently. Call it on a session authenticated with the main password.
27
+
3
28
  ## [1.2.0] — 2026-11-06
4
29
 
5
30
  Bundles **wmt5api 3.2.1**. A minor release with a **Breaking** section, like the core's: history is always asked for
File without changes
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pmt5api
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Complete Python interface to the wmt5api MetaTrader 5 client library (market data, account, sizing, order entry, events).
5
5
  Project-URL: Homepage, https://mtapi.one
6
6
  Author: Sen Trading
7
7
  License-File: LICENSE.txt
8
8
  Keywords: market-data,metatrader,mt5,trading,wmt5api
9
- Classifier: Development Status :: 4 - Beta
9
+ Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Intended Audience :: Financial and Insurance Industry
12
12
  Classifier: License :: Other/Proprietary License
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,20 @@
1
+ """Rotate the read-only investor ("view") password — share live, read-only account access without trade rights.
2
+
3
+ Set WMTAPI_DLL and WMTAPI_KEY, then (on a session authenticated with the MAIN password):
4
+ PMT5_LOGIN=12345678 PMT5_PASSWORD=<main> PMT5_HOST=broker-access-host python rotate_view_password.py
5
+
6
+ Schedule this on your OWN timer/cron; PERSIST the returned value before you rely on it, or the investor login is lost.
7
+ """
8
+ import os
9
+
10
+ from pmt5api import Client, WmtError
11
+
12
+ with Client(int(os.environ["PMT5_LOGIN"]), os.environ["PMT5_PASSWORD"], os.environ["PMT5_HOST"],
13
+ int(os.environ.get("PMT5_PORT", "443"))) as c:
14
+ try:
15
+ new_view = c.roll_view_password() # generate + set a fresh strong password; waits for the server ack
16
+ # store_investor_password(new_view) # <- persist it FIRST (your secret store / DB)
17
+ print("investor/view password rolled to:", new_view)
18
+ except WmtError as e: # a broker-side rejection surfaces here, not silently
19
+ print("view-password change was rejected:", e)
20
+ # ...or set a specific value: c.change_view_password("View!Pass_2026")
File without changes
File without changes
File without changes
File without changes
@@ -11,7 +11,7 @@ requires-python = ">=3.9"
11
11
  authors = [{ name = "Sen Trading" }]
12
12
  keywords = ["metatrader", "mt5", "trading", "market-data", "wmt5api"]
13
13
  classifiers = [
14
- "Development Status :: 4 - Beta",
14
+ "Development Status :: 5 - Production/Stable",
15
15
  "Intended Audience :: Developers",
16
16
  "Intended Audience :: Financial and Insurance Industry",
17
17
  "License :: Other/Proprietary License",
@@ -14,16 +14,16 @@ from .errors import (BusyError, ConnectError, NoQuoteError, ConnectionLostError,
14
14
  from .frames import to_frame
15
15
  from .models import (AccountInfo, AccountSummary, BaseInfo, CommissionInfo, CommissionTier, ConnectEvent, Deal,
16
16
  DemoAccount, DemoAccountRequest, EquityPoint, History, LotSizing, Order, OrderProgress,
17
- OrderUpdate, Quote, ServerRecord, SymbolInfo, SymbolSessions, TradingSession)
17
+ OrderUpdate, Quote, ReconcileSnapshot, ServerRecord, SymbolInfo, SymbolSessions, TradingSession)
18
18
  from .servers import load_servers_dat, request_demo_account, save_servers_dat, tick_value_from_deal
19
19
 
20
- __version__ = "1.2.0"
20
+ __version__ = "1.3.0"
21
21
 
22
22
  __all__ = [
23
23
  "Client", "Proxy",
24
24
  "Quote", "SymbolInfo", "SymbolSessions", "TradingSession", "CommissionInfo", "CommissionTier", "BaseInfo",
25
25
  "AccountInfo", "AccountSummary", "EquityPoint", "LotSizing", "Order", "Deal", "History",
26
- "OrderUpdate", "OrderProgress", "ConnectEvent", "QuoteHistoryEvent",
26
+ "OrderUpdate", "OrderProgress", "ConnectEvent", "QuoteHistoryEvent", "ReconcileSnapshot",
27
27
  "ServerRecord", "DemoAccountRequest", "DemoAccount",
28
28
  "Bar", "TIMEFRAMES", "aggregate", "to_frame",
29
29
  "load_servers_dat", "save_servers_dat", "request_demo_account", "tick_value_from_deal", "enable_core_logging",
File without changes
@@ -7,7 +7,7 @@ from typing import Any, List, Optional
7
7
  from ._base import _Base
8
8
  from ._util import enum_value, to_core_time, translated
9
9
  from .errors import InvalidRequestError, NotConnectedError
10
- from .models import AccountInfo, AccountSummary, EquityPoint, History, Order
10
+ from .models import AccountInfo, AccountSummary, Deal, EquityPoint, History, Order, ReconcileSnapshot
11
11
 
12
12
 
13
13
  def _history_days(days: Any) -> int:
@@ -112,6 +112,24 @@ class _AccountMixin(_Base):
112
112
  self._require_connected()
113
113
  return History._from_core(self._api.RequestDealHistory(int(year), int(month)))
114
114
 
115
+ @translated
116
+ def get_position_deals(self, position_ticket: int, opened_after: Optional[datetime] = None,
117
+ timeout_ms: int = 0) -> List[Deal]:
118
+ """Every deal that makes up one position — the entry, any partial closes, and the close — oldest first.
119
+ ``opened_after`` optionally keeps only deals from that time on; ``timeout_ms`` 0 uses the default wait."""
120
+ self._require_connected()
121
+ from System import DateTime
122
+ after = to_core_time(opened_after) if opened_after is not None else DateTime.MinValue
123
+ result = self._api.GetPositionDeals(int(position_ticket), after, int(timeout_ms))
124
+ return [Deal._from_core(d) for d in (result or ())]
125
+
126
+ @translated
127
+ def reconcile(self) -> ReconcileSnapshot:
128
+ """A consistent snapshot of the open positions and pending orders right now, with the update sequence it is
129
+ current to — for an event-driven client: replace your state with the snapshot, then apply the later updates."""
130
+ self._require_connected()
131
+ return ReconcileSnapshot._from_core(self._api.Reconcile())
132
+
115
133
  @translated
116
134
  def request_history(self, start: datetime, end: datetime) -> None:
117
135
  """Ask for history without waiting; it arrives through :meth:`on_history`. The server's answer is not trimmed
File without changes
@@ -43,6 +43,19 @@ COVERAGE: Dict[str, str] = {
43
43
  "AuthTagsSeen": "not applicable: protocol diagnostics for the ops sentinel, of no use to an application",
44
44
  "AuthUnknownTags": "not applicable: protocol diagnostics for the ops sentinel, of no use to an application",
45
45
  "ChangePassword": "Client.change_password",
46
+ "ChangeViewPassword": "Client.change_view_password",
47
+ "RollViewPassword": "Client.roll_view_password",
48
+ "ChangePasswordTimeout": "Client.change_password_timeout",
49
+ "GetPositionDeals": "Client.get_position_deals",
50
+ # ---- connect tuning, diagnostics, reconcile ----
51
+ "AnnounceBuild": "Client.announce_build",
52
+ "AutoUpgradeOnOldVersion": "Client.auto_upgrade_on_old_version",
53
+ "ConnectRetries": "Client.connect_retries",
54
+ "ConnectRetryBaseDelay": "Client.connect_retry_base_delay",
55
+ "LastHandshakeBuild": "Client.last_handshake_build",
56
+ "ServerNewForm": "Client.server_new_form",
57
+ "Reconcile": "Client.reconcile",
58
+ "OnReconcile": "not applicable: the reconcile snapshot event; applications call reconcile() and use the order-update callbacks",
46
59
  # ---- configuration ----
47
60
  "ApiKey": "Client(api_key)",
48
61
  "TokenServiceUrl": "Client(token_url)",
@@ -164,6 +177,8 @@ TYPES: Dict[str, str] = {
164
177
  "ConnectException": "pmt5api.ConnectError",
165
178
  "ConnectionException": "pmt5api.ConnectionLostError",
166
179
  "Deal": "pmt5api.Deal",
180
+ "OnReconcile": "not applicable: the delegate type for the advanced reconcile event (not exposed)",
181
+ "ReconcileEventArgs": "pmt5api.ReconcileSnapshot",
167
182
  "Diag": "pmt5api.enable_core_logging",
168
183
  "EquityPoint": "pmt5api.EquityPoint",
169
184
  "Expiration": "Client.place_order(expiration)",
File without changes
File without changes
File without changes
File without changes
@@ -91,6 +91,77 @@ class _SessionMixin(_Base):
91
91
  self._require_connected()
92
92
  self._api.ChangePassword(new_password, bool(investor))
93
93
 
94
+ @translated
95
+ def change_view_password(self, new_view_password: str) -> None:
96
+ """Change the account's read-only investor ("view") password — it grants live, read-only visibility of the
97
+ account (copy-trade followers, auditors, dashboards) without trading rights. Call on a session authenticated
98
+ with the main password. Convenience wrapper over :meth:`change_password` with ``investor=True``."""
99
+ self._require_connected()
100
+ self._api.ChangeViewPassword(new_view_password)
101
+
102
+ @translated
103
+ def roll_view_password(self, length: int = 12) -> str:
104
+ """Rotate the investor ("view") password to a freshly generated strong password and return the new value,
105
+ for periodically rotating a read-only credential shared with third parties. Persist the returned value
106
+ before relying on it, or the investor login is lost."""
107
+ self._require_connected()
108
+ return str(self._api.RollViewPassword(int(length)))
109
+
110
+ @property
111
+ def change_password_timeout(self) -> int:
112
+ """Milliseconds to wait for the server to acknowledge a password change on modern builds (default 15000)."""
113
+ return int(self._api.ChangePasswordTimeout)
114
+
115
+ @change_password_timeout.setter
116
+ def change_password_timeout(self, milliseconds: int) -> None:
117
+ self._api.ChangePasswordTimeout = int(milliseconds)
118
+
119
+ @property
120
+ def announce_build(self) -> int:
121
+ """The protocol build the SDK announces to the broker; 0 lets it negotiate automatically (advanced)."""
122
+ return int(self._api.AnnounceBuild)
123
+
124
+ @announce_build.setter
125
+ def announce_build(self, build: int) -> None:
126
+ self._api.AnnounceBuild = build
127
+
128
+ @property
129
+ def auto_upgrade_on_old_version(self) -> bool:
130
+ """Whether the SDK upgrades the protocol build automatically when the server reports OLD_VERSION (default True)."""
131
+ return bool(self._api.AutoUpgradeOnOldVersion)
132
+
133
+ @auto_upgrade_on_old_version.setter
134
+ def auto_upgrade_on_old_version(self, enabled: bool) -> None:
135
+ self._api.AutoUpgradeOnOldVersion = bool(enabled)
136
+
137
+ @property
138
+ def connect_retries(self) -> int:
139
+ """How many times connect retries a transient failure before giving up (default 2)."""
140
+ return int(self._api.ConnectRetries)
141
+
142
+ @connect_retries.setter
143
+ def connect_retries(self, count: int) -> None:
144
+ self._api.ConnectRetries = int(count)
145
+
146
+ @property
147
+ def connect_retry_base_delay(self) -> int:
148
+ """Base backoff in milliseconds between connect retries; it grows per attempt with jitter (default 1500)."""
149
+ return int(self._api.ConnectRetryBaseDelay)
150
+
151
+ @connect_retry_base_delay.setter
152
+ def connect_retry_base_delay(self, milliseconds: int) -> None:
153
+ self._api.ConnectRetryBaseDelay = int(milliseconds)
154
+
155
+ @property
156
+ def last_handshake_build(self) -> int:
157
+ """The broker build the last handshake negotiated (0 before the first connect)."""
158
+ return int(self._api.LastHandshakeBuild)
159
+
160
+ @property
161
+ def server_new_form(self) -> bool:
162
+ """True when the broker negotiated the modern (raised-build) handshake form on this connection."""
163
+ return bool(self._api.ServerNewForm)
164
+
94
165
  # ---- information -------------------------------------------------------------------------------------------
95
166
 
96
167
  @property
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -58,6 +58,14 @@ Awaitable `connect`; the blocking connect runs on a worker thread.
58
58
 
59
59
  Awaitable `disconnect`.
60
60
 
61
+ #### `announce_build` *(property)*
62
+
63
+ The protocol build the SDK announces to the broker; 0 lets it negotiate automatically (advanced).
64
+
65
+ #### `auto_upgrade_on_old_version` *(property)*
66
+
67
+ Whether the SDK upgrades the protocol build automatically when the server reports OLD_VERSION (default True).
68
+
61
69
  #### `base_info()`
62
70
 
63
71
  The server's own description of itself and of the account mode.
@@ -71,6 +79,16 @@ This login may place trades: not investor, not disabled on the server, confirmed
71
79
  Change the account password; with `investor=True` the read-only investor password instead of the main
72
80
  one. The new password applies from the next connection.
73
81
 
82
+ #### `change_password_timeout` *(property)*
83
+
84
+ Milliseconds to wait for the server to acknowledge a password change on modern builds (default 15000).
85
+
86
+ #### `change_view_password(new_view_password)`
87
+
88
+ Change the account's read-only investor ("view") password — it grants live, read-only visibility of the
89
+ account (copy-trade followers, auditors, dashboards) without trading rights. Call on a session authenticated
90
+ with the main password. Convenience wrapper over `change_password` with `investor=True`.
91
+
74
92
  #### `company` *(property)*
75
93
 
76
94
  The broker's company name, as the server reports it.
@@ -84,6 +102,14 @@ Raises `LicenseError` / `TokenServiceError` when the licence is refused or unrea
84
102
  `LoginRejectedError` when the broker rejects the account or password, and `ConnectError` when
85
103
  no access server could be reached within `connect_timeout`.
86
104
 
105
+ #### `connect_retries` *(property)*
106
+
107
+ How many times connect retries a transient failure before giving up (default 2).
108
+
109
+ #### `connect_retry_base_delay` *(property)*
110
+
111
+ Base backoff in milliseconds between connect retries; it grows per attempt with jitter (default 1500).
112
+
87
113
  #### `connect_time` *(property)*
88
114
 
89
115
  When this session connected, by the local clock.
@@ -113,6 +139,10 @@ False while the broker has not yet confirmed the account (trading is blocked unt
113
139
 
114
140
  The login is the read-only investor password.
115
141
 
142
+ #### `last_handshake_build` *(property)*
143
+
144
+ The broker build the last handshake negotiated (0 before the first connect).
145
+
116
146
  #### `last_quote_time` *(property)*
117
147
 
118
148
  The server timestamp of the last quote received (server time, not the local clock): compare it with
@@ -135,11 +165,21 @@ The access-server port.
135
165
  The underlying core object, for anything this layer does not wrap. Calls made on it raise the core's own
136
166
  exceptions, not pmt5api's.
137
167
 
168
+ #### `roll_view_password(length=12)`
169
+
170
+ Rotate the investor ("view") password to a freshly generated strong password and return the new value,
171
+ for periodically rotating a read-only credential shared with third parties. Persist the returned value
172
+ before relying on it, or the investor login is lost.
173
+
138
174
  #### `server_name` *(property)*
139
175
 
140
176
  The name of the trade server the session logged in to (for example `ICMarketsSC-Demo`), as the server
141
177
  reports it while connecting; `None` before the first connect. The address dialled is `host`.
142
178
 
179
+ #### `server_new_form` *(property)*
180
+
181
+ True when the broker negotiated the modern (raised-build) handshake form on this connection.
182
+
143
183
  #### `server_time` *(property)*
144
184
 
145
185
  The server's clock, kept current by incoming quotes (server time, naive); `None` before the first
@@ -291,6 +331,11 @@ consecutive points with an unchanged balance and equity are dropped. A window wi
291
331
  at the balance (never empty); the last point is the live balance and equity. Downloads deals and per-symbol
292
332
  bars, so it blocks.
293
333
 
334
+ #### `get_position_deals(position_ticket, opened_after=None, timeout_ms=0)`
335
+
336
+ Every deal that makes up one position — the entry, any partial closes, and the close — oldest first.
337
+ `opened_after` optionally keeps only deals from that time on; `timeout_ms` 0 uses the default wait.
338
+
294
339
  #### `history(start, end, timeout=None)`
295
340
 
296
341
  Orders and deals between `start` and `end`. Blocks until the server has sent everything, up to
@@ -322,6 +367,11 @@ Open positions only (pending orders excluded).
322
367
  A position is an order of type `Buy` or `Sell`; pending orders are the `*Limit` and `*Stop` types. The
323
368
  order's `state` is not used: the core can leave a freshly opened position in `Started` for a long time.
324
369
 
370
+ #### `reconcile()`
371
+
372
+ A consistent snapshot of the open positions and pending orders right now, with the update sequence it is
373
+ current to — for an event-driven client: replace your state with the snapshot, then apply the later updates.
374
+
325
375
  #### `request_history(start, end)`
326
376
 
327
377
  Ask for history without waiting; it arrives through `on_history`. The server's answer is not trimmed
@@ -747,6 +797,15 @@ An open position, a pending order, or a historical order.
747
797
  | `expiration_type` | `str` | a pending order's lifetime: GTC, today, specified, specified day |
748
798
  | `expiration_time` | `Optional[datetime]` | when a pending order expires, if it has a date |
749
799
  | `fill_policy` | `str` | how the order may fill: fill-or-kill, immediate-or-cancel, flash or any |
800
+ | `net_profit` | `float` | |
801
+ | `open_time_utc` | `Optional[datetime]` | |
802
+ | `close_time_utc` | `Optional[datetime]` | |
803
+ | `open_timestamp_utc` | `int` | |
804
+ | `close_timestamp_utc` | `int` | |
805
+ | `is_buy` | `bool` | |
806
+ | `is_sell` | `bool` | |
807
+ | `is_pending` | `bool` | |
808
+ | `is_ledger_entry` | `bool` | |
750
809
 
751
810
  #### `Deal`
752
811
 
@@ -17,21 +17,27 @@ Every public member of the C# `MT5API` class and where it went. Generated from `
17
17
  | `AccountMethod` | `Client.account_method` |
18
18
  | `AccountProfit` | `Client.account` |
19
19
  | `AccountSwap` | `Client.account` |
20
+ | `AnnounceBuild` | `Client.announce_build` |
20
21
  | `ApiKey` | `Client(api_key)` |
21
22
  | `AuthTagsSeen` | not applicable: protocol diagnostics for the ops sentinel, of no use to an application |
22
23
  | `AuthUnknownTags` | not applicable: protocol diagnostics for the ops sentinel, of no use to an application |
23
24
  | `AutoReconnect` | `Client(auto_reconnect)` |
25
+ | `AutoUpgradeOnOldVersion` | `Client.auto_upgrade_on_old_version` |
24
26
  | `CalculateEquityHistory` | `Client.equity_history` |
25
27
  | `CalculateLots` | `Client.lots_for_risk` |
26
28
  | `CalculateOrderProfit` | `Client.order_profit` |
27
29
  | `CalibrateMoneyScale` | `Client.calibrate_money_scale` |
28
30
  | `ChangePassword` | `Client.change_password` |
31
+ | `ChangePasswordTimeout` | `Client.change_password_timeout` |
32
+ | `ChangeViewPassword` | `Client.change_view_password` |
29
33
  | `ClosedOrders` | `Client.closed_orders` |
30
34
  | `ClusterMemberConnectTimeout` | `Client(cluster_member_timeout)` |
31
35
  | `CommonKey` | `Client(common_key)` |
32
36
  | `ComputeTickValueFromDeal` | `pmt5api.tick_value_from_deal` |
33
37
  | `Connect` | `Client.connect` |
34
38
  | `Connected` | `Client.connected` |
39
+ | `ConnectRetries` | `Client.connect_retries` |
40
+ | `ConnectRetryBaseDelay` | `Client.connect_retry_base_delay` |
35
41
  | `ConnectTime` | `Client.connect_time` |
36
42
  | `ConnectTimeout` | `Client(connect_timeout)` |
37
43
  | `ConvertToTimeframe` | `pmt5api.aggregate` |
@@ -48,6 +54,7 @@ Every public member of the C# `MT5API` class and where it went. Generated from `
48
54
  | `GetBidTickValue` | `Client.tick_value` |
49
55
  | `GetContractSize` | `Client.contract_size` |
50
56
  | `GetOpenedOrders` | `Client.orders` |
57
+ | `GetPositionDeals` | `Client.get_position_deals` |
51
58
  | `GetQuote` | `Client.quote` |
52
59
  | `GetQuoteTask` | `Client.aquote` |
53
60
  | `GetQuoteTimeoutMs` | `Client(quote_timeout)` |
@@ -62,6 +69,7 @@ Every public member of the C# `MT5API` class and where it went. Generated from `
62
69
  | `IsTradeAllowed` | `Client.can_trade` |
63
70
  | `IsTradeDisableOnServer` | `Client.trading_disabled_by_server` |
64
71
  | `IsTradeSession` | `Client.is_trade_session` |
72
+ | `LastHandshakeBuild` | `Client.last_handshake_build` |
65
73
  | `LastQuoteTime` | `Client.last_quote_time` |
66
74
  | `LastServerMessageTime` | `Client.last_server_message_time` |
67
75
  | `LedgerValuePerUnitLot` | `Client.ledger_value_per_lot` |
@@ -77,6 +85,7 @@ Every public member of the C# `MT5API` class and where it went. Generated from `
77
85
  | `OnOrderUpdate` | `Client.on_order_update` |
78
86
  | `OnQuote` | `Client.on_quote` |
79
87
  | `OnQuoteHistory` | `Client.on_quote_history` |
88
+ | `OnReconcile` | not applicable: the reconcile snapshot event; applications call reconcile() and use the order-update callbacks |
80
89
  | `OnSymbolsUpdate` | `Client.on_symbols_update` |
81
90
  | `OnSymbolUpdate` | `Client.on_symbol_update` |
82
91
  | `OrderCancel` | `Client.cancel` |
@@ -105,6 +114,7 @@ Every public member of the C# `MT5API` class and where it went. Generated from `
105
114
  | `ProxyPort` | `Client(proxy)` |
106
115
  | `ProxyType` | `Client(proxy)` |
107
116
  | `ProxyUser` | `Client(proxy)` |
117
+ | `Reconcile` | `Client.reconcile` |
108
118
  | `ReconnectBackoffMs` | `Client(reconnect_backoff)` |
109
119
  | `ReconnectMaxAttempts` | `Client(reconnect_max_attempts)` |
110
120
  | `ReconnectMaxBackoffMs` | `Client(reconnect_max_backoff)` |
@@ -114,8 +124,10 @@ Every public member of the C# `MT5API` class and where it went. Generated from `
114
124
  | `RequestQuoteHistoryMonth` | `Client.request_bars` |
115
125
  | `RequestQuoteHistoryToday` | `Client.request_bars` |
116
126
  | `RequiredMargin` | `Client.required_margin` |
127
+ | `RollViewPassword` | `Client.roll_view_password` |
117
128
  | `SaveServersDat` | `pmt5api.save_servers_dat` |
118
129
  | `Server` | `Client.server_name` |
130
+ | `ServerNewForm` | `Client.server_new_form` |
119
131
  | `ServerSymBuild` | `Client.symbol_build` |
120
132
  | `ServerTime` | `Client.server_time` |
121
133
  | `ServerTimeZoneInMinutes` | `Client.server_utc_offset` |
File without changes
File without changes
@@ -332,6 +332,15 @@ class Order:
332
332
  expiration_type: str = ""
333
333
  expiration_time: Optional[datetime] = None
334
334
  fill_policy: str = ""
335
+ net_profit: float = 0.0 # profit + swap + commission + fee (the figure that reaches the balance)
336
+ open_time_utc: Optional[datetime] = None # open time as a UTC-kinded value (open_time is kind-unspecified)
337
+ close_time_utc: Optional[datetime] = None
338
+ open_timestamp_utc: int = 0 # open time as Unix seconds (UTC); 0 when unset
339
+ close_timestamp_utc: int = 0
340
+ is_buy: bool = False
341
+ is_sell: bool = False
342
+ is_pending: bool = False # a resting pending order (not yet filled)
343
+ is_ledger_entry: bool = False # a non-trade history row (balance/credit/other account operation)
335
344
 
336
345
  @classmethod
337
346
  def _from_core(cls, o: Any) -> "Order":
@@ -345,7 +354,11 @@ class Order:
345
354
  placed_type=_name(o.PlacedType), request_id=int(o.RequestId),
346
355
  stop_limit_price=float(o.StopLimitPrice), profit_rate=float(o.ProfitRate),
347
356
  expiration_type=_name(o.ExpirationType), expiration_time=_time(o.ExpirationTime),
348
- fill_policy=_name(o.FillPolicy))
357
+ fill_policy=_name(o.FillPolicy),
358
+ net_profit=_m(o.NetProfit), open_time_utc=_time(o.OpenTimeUtc), close_time_utc=_time(o.CloseTimeUtc),
359
+ open_timestamp_utc=int(o.OpenTimestampUtc), close_timestamp_utc=int(o.CloseTimestampUtc),
360
+ is_buy=bool(o.IsBuy), is_sell=bool(o.IsSell), is_pending=bool(o.IsPending),
361
+ is_ledger_entry=bool(o.IsLedgerEntry))
349
362
 
350
363
 
351
364
  @dataclass(frozen=True)
@@ -655,3 +668,19 @@ SymbolInfo.FIELD_DOC = {
655
668
  "initial_margin": "the initial margin of one lot, as the server publishes it (0 = by the formula)",
656
669
  "maintenance_margin": "the maintenance margin of one lot, as the server publishes it",
657
670
  }
671
+
672
+
673
+ @dataclass(frozen=True)
674
+ class ReconcileSnapshot:
675
+ """A consistent snapshot of the open positions and pending orders (from :meth:`pmt5api.Client.reconcile`), with
676
+ the update sequence it is current to — an event-driven client replaces its state with :attr:`orders` and then
677
+ applies the updates whose sequence is greater than :attr:`sequence`."""
678
+ orders: Tuple["Order", ...]
679
+ sequence: int # the last OrderUpdate sequence contained in this snapshot
680
+ session: int # 1 on the first connect, 2 on the first reconnect, and so on
681
+ server_time: Optional[datetime]
682
+
683
+ @classmethod
684
+ def _from_core(cls, s: Any) -> "ReconcileSnapshot":
685
+ return cls(orders=tuple(Order._from_core(o) for o in (s.Orders or ())),
686
+ sequence=int(s.Sequence), session=int(s.Session), server_time=_time(s.ServerTime))
File without changes
File without changes