pipsocket 0.1.0__py3-none-any.whl
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.
- pipsocket/__init__.py +68 -0
- pipsocket/_core.py +712 -0
- pipsocket/_generated/__init__.py +1 -0
- pipsocket/_generated/operations.py +35 -0
- pipsocket/_generated/tables.py +95 -0
- pipsocket/_generated/types.py +542 -0
- pipsocket/_http.py +235 -0
- pipsocket/_stream_core.py +916 -0
- pipsocket/_version.py +1 -0
- pipsocket/aio.py +702 -0
- pipsocket/client.py +680 -0
- pipsocket/errors.py +275 -0
- pipsocket/models.py +151 -0
- pipsocket/py.typed +0 -0
- pipsocket/stream.py +713 -0
- pipsocket/types.py +48 -0
- pipsocket-0.1.0.dist-info/METADATA +358 -0
- pipsocket-0.1.0.dist-info/RECORD +20 -0
- pipsocket-0.1.0.dist-info/WHEEL +4 -0
- pipsocket-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Generated by scripts/generate.py from openapi.json. Do not edit.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Generated by scripts/generate.py from openapi.json. Do not edit.
|
|
2
|
+
|
|
3
|
+
"""Every operation in the document: its id, method, path under the account and key."""
|
|
4
|
+
|
|
5
|
+
from typing import Final, NamedTuple
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Operation(NamedTuple):
|
|
9
|
+
id: str
|
|
10
|
+
method: str
|
|
11
|
+
path: str
|
|
12
|
+
keyed: bool
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
OPERATIONS: Final[tuple[Operation, ...]] = (
|
|
16
|
+
Operation("account", "GET", "/", False),
|
|
17
|
+
Operation("pending_orders", "GET", "/orders", False),
|
|
18
|
+
Operation("place_order", "POST", "/orders", True),
|
|
19
|
+
Operation("check_order", "POST", "/orders/check", False),
|
|
20
|
+
Operation("modify_order", "PATCH", "/orders/{order}", True),
|
|
21
|
+
Operation("cancel_order", "DELETE", "/orders/{order}", True),
|
|
22
|
+
Operation("positions", "GET", "/positions", False),
|
|
23
|
+
Operation("set_position_levels", "PATCH", "/positions/{position}", True),
|
|
24
|
+
Operation("close_position", "POST", "/positions/{position}/close", True),
|
|
25
|
+
Operation("close_by", "POST", "/positions/{position}/close-by", True),
|
|
26
|
+
Operation("request", "GET", "/requests/{request}", False),
|
|
27
|
+
Operation("symbols", "GET", "/symbols", False),
|
|
28
|
+
Operation("symbol", "GET", "/symbols/{symbol}", False),
|
|
29
|
+
Operation("tick", "GET", "/symbols/{symbol}/tick", False),
|
|
30
|
+
Operation("history_deals", "GET", "/history/deals", False),
|
|
31
|
+
Operation("history_orders", "GET", "/history/orders", False),
|
|
32
|
+
Operation("kill_switch", "GET", "/kill-switch", False),
|
|
33
|
+
Operation("engage_kill_switch", "POST", "/kill-switch", False),
|
|
34
|
+
Operation("lift_kill_switch", "DELETE", "/kill-switch", False),
|
|
35
|
+
)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Generated by scripts/generate.py from openapi.json. Do not edit.
|
|
2
|
+
|
|
3
|
+
"""Tables from the document's `x-pipsocket` extension and its request states."""
|
|
4
|
+
|
|
5
|
+
from typing import Final
|
|
6
|
+
|
|
7
|
+
# Every error code the API answers with, and its HTTP status.
|
|
8
|
+
ERROR_STATUS: Final[dict[str, int]] = {
|
|
9
|
+
"missing_api_key": 401,
|
|
10
|
+
"invalid_api_key": 401,
|
|
11
|
+
"no_such_account": 404,
|
|
12
|
+
"no_such_order": 404,
|
|
13
|
+
"no_such_position": 404,
|
|
14
|
+
"no_such_request": 404,
|
|
15
|
+
"no_such_symbol": 404,
|
|
16
|
+
"invalid_request": 422,
|
|
17
|
+
"magic_reserved": 422,
|
|
18
|
+
"trade_rejected": 422,
|
|
19
|
+
"not_executed": 409,
|
|
20
|
+
"symbol_busy": 409,
|
|
21
|
+
"range_too_large": 422,
|
|
22
|
+
"kill_switch_engaged": 423,
|
|
23
|
+
"billing_hold": 423,
|
|
24
|
+
"account_not_connected": 503,
|
|
25
|
+
"bridge_outdated": 503,
|
|
26
|
+
"account_restarting": 503,
|
|
27
|
+
"not_sent": 503,
|
|
28
|
+
"bad_command": 503,
|
|
29
|
+
"terminal_error": 503,
|
|
30
|
+
"symbol_too_large": 503,
|
|
31
|
+
"no_price": 503,
|
|
32
|
+
"engine_busy": 503,
|
|
33
|
+
"engine_unavailable": 503,
|
|
34
|
+
"terminal_timeout": 504,
|
|
35
|
+
"engine_timeout": 504,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# MT5's retcodes: the name the API sends in `retcode_name`, and what it means.
|
|
39
|
+
RETCODES: Final[dict[int, tuple[str, str]]] = {
|
|
40
|
+
0: ("OK", "The request passed the check."),
|
|
41
|
+
10004: ("TRADE_RETCODE_REQUOTE", "The broker requoted the price."),
|
|
42
|
+
10006: ("TRADE_RETCODE_REJECT", "The trade server rejected the request."),
|
|
43
|
+
10007: ("TRADE_RETCODE_CANCEL", "The request was cancelled by the trader."),
|
|
44
|
+
10008: ("TRADE_RETCODE_PLACED", "The order was placed; execution is not confirmed yet."),
|
|
45
|
+
10009: ("TRADE_RETCODE_DONE", "The request was completed."),
|
|
46
|
+
10010: ("TRADE_RETCODE_DONE_PARTIAL", "Only part of the request was completed."),
|
|
47
|
+
10011: ("TRADE_RETCODE_ERROR", "The trade server could not process the request."),
|
|
48
|
+
10012: ("TRADE_RETCODE_TIMEOUT", "The request was cancelled by a timeout."),
|
|
49
|
+
10013: ("TRADE_RETCODE_INVALID", "The request is invalid."),
|
|
50
|
+
10014: ("TRADE_RETCODE_INVALID_VOLUME", "The volume is invalid for this symbol."),
|
|
51
|
+
10015: ("TRADE_RETCODE_INVALID_PRICE", "The price is invalid."),
|
|
52
|
+
10016: ("TRADE_RETCODE_INVALID_STOPS", "The stop loss or take profit is invalid for this symbol or too close to the price."),
|
|
53
|
+
10017: ("TRADE_RETCODE_TRADE_DISABLED", "Trading is disabled."),
|
|
54
|
+
10018: ("TRADE_RETCODE_MARKET_CLOSED", "The market is closed."),
|
|
55
|
+
10019: ("TRADE_RETCODE_NO_MONEY", "There is not enough money for the request."),
|
|
56
|
+
10020: ("TRADE_RETCODE_PRICE_CHANGED", "The price changed."),
|
|
57
|
+
10021: ("TRADE_RETCODE_PRICE_OFF", "There are no quotes to process the request."),
|
|
58
|
+
10022: ("TRADE_RETCODE_INVALID_EXPIRATION", "The order expiration is invalid."),
|
|
59
|
+
10023: ("TRADE_RETCODE_ORDER_CHANGED", "The order changed state."),
|
|
60
|
+
10024: ("TRADE_RETCODE_TOO_MANY_REQUESTS", "Too many requests in a short time."),
|
|
61
|
+
10025: ("TRADE_RETCODE_NO_CHANGES", "The request changes nothing."),
|
|
62
|
+
10026: ("TRADE_RETCODE_SERVER_DISABLES_AT", "Automated trading is disabled by the server."),
|
|
63
|
+
10027: ("TRADE_RETCODE_CLIENT_DISABLES_AT", "Automated trading is disabled in the terminal."),
|
|
64
|
+
10028: ("TRADE_RETCODE_LOCKED", "The request is locked for processing."),
|
|
65
|
+
10029: ("TRADE_RETCODE_FROZEN", "The order or position is frozen."),
|
|
66
|
+
10030: ("TRADE_RETCODE_INVALID_FILL", "The filling mode is not allowed for this symbol."),
|
|
67
|
+
10031: ("TRADE_RETCODE_CONNECTION", "There is no connection to the trade server."),
|
|
68
|
+
10032: ("TRADE_RETCODE_ONLY_REAL", "This is only allowed for live accounts."),
|
|
69
|
+
10033: ("TRADE_RETCODE_LIMIT_ORDERS", "The account has reached its limit of pending orders."),
|
|
70
|
+
10034: ("TRADE_RETCODE_LIMIT_VOLUME", "The symbol has reached its volume limit for orders and positions."),
|
|
71
|
+
10035: ("TRADE_RETCODE_INVALID_ORDER", "The order type is incorrect or not allowed."),
|
|
72
|
+
10036: ("TRADE_RETCODE_POSITION_CLOSED", "The position is already closed."),
|
|
73
|
+
10038: ("TRADE_RETCODE_INVALID_CLOSE_VOLUME", "The close volume is more than the position's volume."),
|
|
74
|
+
10039: ("TRADE_RETCODE_CLOSE_ORDER_EXIST", "A close order already exists for the position."),
|
|
75
|
+
10040: ("TRADE_RETCODE_LIMIT_POSITIONS", "The account has reached its limit of open positions."),
|
|
76
|
+
10041: ("TRADE_RETCODE_REJECT_CANCEL", "The pending order's activation was rejected and the order cancelled."),
|
|
77
|
+
10042: ("TRADE_RETCODE_LONG_ONLY", "Only long positions are allowed for this symbol."),
|
|
78
|
+
10043: ("TRADE_RETCODE_SHORT_ONLY", "Only short positions are allowed for this symbol."),
|
|
79
|
+
10044: ("TRADE_RETCODE_CLOSE_ONLY", "Only closing positions is allowed for this symbol."),
|
|
80
|
+
10045: ("TRADE_RETCODE_FIFO_CLOSE", "Positions may only be closed first in, first out."),
|
|
81
|
+
10046: ("TRADE_RETCODE_HEDGE_PROHIBITED", "Opposite positions on one symbol are not allowed."),
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# The states a recorded request can be in.
|
|
85
|
+
REQUEST_STATES: Final[tuple[str, ...]] = (
|
|
86
|
+
"completed",
|
|
87
|
+
"placed",
|
|
88
|
+
"partial",
|
|
89
|
+
"rejected",
|
|
90
|
+
"pending",
|
|
91
|
+
"unknown",
|
|
92
|
+
"not_sent",
|
|
93
|
+
"not_executed",
|
|
94
|
+
"executed",
|
|
95
|
+
)
|
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
# Generated by scripts/generate.py from openapi.json. Do not edit.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from typing import TYPE_CHECKING, Literal, TypeAlias, TypedDict
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from typing_extensions import NotRequired
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Action: TypeAlias = (
|
|
11
|
+
Literal["deal", "pending", "sltp", "modify", "remove", "close_by"] | str
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Blocking(TypedDict):
|
|
16
|
+
request: str
|
|
17
|
+
state: str
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class CheckResult(TypedDict):
|
|
21
|
+
passed: bool
|
|
22
|
+
retcode: int
|
|
23
|
+
retcode_name: (
|
|
24
|
+
Literal[
|
|
25
|
+
"OK",
|
|
26
|
+
"TRADE_RETCODE_REQUOTE",
|
|
27
|
+
"TRADE_RETCODE_REJECT",
|
|
28
|
+
"TRADE_RETCODE_CANCEL",
|
|
29
|
+
"TRADE_RETCODE_PLACED",
|
|
30
|
+
"TRADE_RETCODE_DONE",
|
|
31
|
+
"TRADE_RETCODE_DONE_PARTIAL",
|
|
32
|
+
"TRADE_RETCODE_ERROR",
|
|
33
|
+
"TRADE_RETCODE_TIMEOUT",
|
|
34
|
+
"TRADE_RETCODE_INVALID",
|
|
35
|
+
"TRADE_RETCODE_INVALID_VOLUME",
|
|
36
|
+
"TRADE_RETCODE_INVALID_PRICE",
|
|
37
|
+
"TRADE_RETCODE_INVALID_STOPS",
|
|
38
|
+
"TRADE_RETCODE_TRADE_DISABLED",
|
|
39
|
+
"TRADE_RETCODE_MARKET_CLOSED",
|
|
40
|
+
"TRADE_RETCODE_NO_MONEY",
|
|
41
|
+
"TRADE_RETCODE_PRICE_CHANGED",
|
|
42
|
+
"TRADE_RETCODE_PRICE_OFF",
|
|
43
|
+
"TRADE_RETCODE_INVALID_EXPIRATION",
|
|
44
|
+
"TRADE_RETCODE_ORDER_CHANGED",
|
|
45
|
+
"TRADE_RETCODE_TOO_MANY_REQUESTS",
|
|
46
|
+
"TRADE_RETCODE_NO_CHANGES",
|
|
47
|
+
"TRADE_RETCODE_SERVER_DISABLES_AT",
|
|
48
|
+
"TRADE_RETCODE_CLIENT_DISABLES_AT",
|
|
49
|
+
"TRADE_RETCODE_LOCKED",
|
|
50
|
+
"TRADE_RETCODE_FROZEN",
|
|
51
|
+
"TRADE_RETCODE_INVALID_FILL",
|
|
52
|
+
"TRADE_RETCODE_CONNECTION",
|
|
53
|
+
"TRADE_RETCODE_ONLY_REAL",
|
|
54
|
+
"TRADE_RETCODE_LIMIT_ORDERS",
|
|
55
|
+
"TRADE_RETCODE_LIMIT_VOLUME",
|
|
56
|
+
"TRADE_RETCODE_INVALID_ORDER",
|
|
57
|
+
"TRADE_RETCODE_POSITION_CLOSED",
|
|
58
|
+
"TRADE_RETCODE_INVALID_CLOSE_VOLUME",
|
|
59
|
+
"TRADE_RETCODE_CLOSE_ORDER_EXIST",
|
|
60
|
+
"TRADE_RETCODE_LIMIT_POSITIONS",
|
|
61
|
+
"TRADE_RETCODE_REJECT_CANCEL",
|
|
62
|
+
"TRADE_RETCODE_LONG_ONLY",
|
|
63
|
+
"TRADE_RETCODE_SHORT_ONLY",
|
|
64
|
+
"TRADE_RETCODE_CLOSE_ONLY",
|
|
65
|
+
"TRADE_RETCODE_FIFO_CLOSE",
|
|
66
|
+
"TRADE_RETCODE_HEDGE_PROHIBITED",
|
|
67
|
+
"UNKNOWN",
|
|
68
|
+
]
|
|
69
|
+
| str
|
|
70
|
+
)
|
|
71
|
+
comment: str
|
|
72
|
+
balance: float
|
|
73
|
+
equity: float
|
|
74
|
+
profit: float
|
|
75
|
+
margin: float
|
|
76
|
+
margin_free: float
|
|
77
|
+
margin_level: float
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class CloseBy(TypedDict):
|
|
81
|
+
position_by: int
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class DealView(TypedDict):
|
|
85
|
+
ticket: int
|
|
86
|
+
order: int
|
|
87
|
+
position: int
|
|
88
|
+
symbol: str
|
|
89
|
+
type: NotRequired[
|
|
90
|
+
Literal[
|
|
91
|
+
"buy",
|
|
92
|
+
"sell",
|
|
93
|
+
"balance",
|
|
94
|
+
"credit",
|
|
95
|
+
"charge",
|
|
96
|
+
"correction",
|
|
97
|
+
"bonus",
|
|
98
|
+
"commission",
|
|
99
|
+
"commission_daily",
|
|
100
|
+
"commission_monthly",
|
|
101
|
+
"commission_agent_daily",
|
|
102
|
+
"commission_agent_monthly",
|
|
103
|
+
"interest",
|
|
104
|
+
"buy_canceled",
|
|
105
|
+
"sell_canceled",
|
|
106
|
+
"dividend",
|
|
107
|
+
"dividend_franked",
|
|
108
|
+
"tax",
|
|
109
|
+
]
|
|
110
|
+
| str
|
|
111
|
+
| None
|
|
112
|
+
]
|
|
113
|
+
entry: Literal["in", "out", "inout", "out_by"] | str
|
|
114
|
+
reason: (
|
|
115
|
+
Literal["client", "mobile", "web", "expert", "sl", "tp", "so", "other"] | str
|
|
116
|
+
)
|
|
117
|
+
volume: float
|
|
118
|
+
price: float
|
|
119
|
+
profit: float
|
|
120
|
+
commission: float
|
|
121
|
+
swap: float
|
|
122
|
+
fee: float
|
|
123
|
+
magic: int
|
|
124
|
+
comment: str
|
|
125
|
+
time_msc: int
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class EngageKillSwitch(TypedDict):
|
|
129
|
+
deviation: NotRequired[int | None]
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class ErrorBody(TypedDict):
|
|
133
|
+
error: str
|
|
134
|
+
message: str
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
Filling: TypeAlias = Literal["fok", "ioc", "return", "boc"] | str
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class HandSettlement(TypedDict):
|
|
141
|
+
outcome: str
|
|
142
|
+
settled_by: str
|
|
143
|
+
reason: str
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class KillSwitchView(TypedDict):
|
|
147
|
+
engaged: bool
|
|
148
|
+
since: NotRequired[int | None]
|
|
149
|
+
deviation: NotRequired[int | None]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
OrderType: TypeAlias = (
|
|
153
|
+
Literal[
|
|
154
|
+
"buy",
|
|
155
|
+
"sell",
|
|
156
|
+
"buy_limit",
|
|
157
|
+
"sell_limit",
|
|
158
|
+
"buy_stop",
|
|
159
|
+
"sell_stop",
|
|
160
|
+
"buy_stop_limit",
|
|
161
|
+
"sell_stop_limit",
|
|
162
|
+
"close_by",
|
|
163
|
+
]
|
|
164
|
+
| str
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class PendingOrderView(TypedDict):
|
|
169
|
+
ticket: int
|
|
170
|
+
symbol: str
|
|
171
|
+
type: NotRequired[OrderType | None]
|
|
172
|
+
volume_initial: float
|
|
173
|
+
volume_current: float
|
|
174
|
+
price_open: float
|
|
175
|
+
sl: float
|
|
176
|
+
tp: float
|
|
177
|
+
magic: int
|
|
178
|
+
comment: str
|
|
179
|
+
position: int
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class PositionLevels(TypedDict):
|
|
183
|
+
sl: float
|
|
184
|
+
tp: float
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class PositionView(TypedDict):
|
|
188
|
+
ticket: int
|
|
189
|
+
identifier: int
|
|
190
|
+
symbol: str
|
|
191
|
+
type: Literal["buy", "sell"] | str
|
|
192
|
+
volume: float
|
|
193
|
+
price_open: float
|
|
194
|
+
sl: float
|
|
195
|
+
tp: float
|
|
196
|
+
magic: int
|
|
197
|
+
comment: str
|
|
198
|
+
time_msc: int
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class Remaining(TypedDict):
|
|
202
|
+
positions: int
|
|
203
|
+
orders: int
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
RequestState: TypeAlias = (
|
|
207
|
+
Literal[
|
|
208
|
+
"completed",
|
|
209
|
+
"placed",
|
|
210
|
+
"partial",
|
|
211
|
+
"rejected",
|
|
212
|
+
"pending",
|
|
213
|
+
"unknown",
|
|
214
|
+
"not_sent",
|
|
215
|
+
"not_executed",
|
|
216
|
+
"executed",
|
|
217
|
+
]
|
|
218
|
+
| str
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
Settlement: TypeAlias = Literal["evidence", "operator"] | str
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class SymbolBusy(TypedDict):
|
|
226
|
+
error: str
|
|
227
|
+
message: str
|
|
228
|
+
not_sent: bool
|
|
229
|
+
blocking: list[Blocking]
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class SymbolSummaryView(TypedDict):
|
|
233
|
+
name: str
|
|
234
|
+
description: str
|
|
235
|
+
path: str
|
|
236
|
+
available: bool
|
|
237
|
+
digits: int
|
|
238
|
+
contract_size: float
|
|
239
|
+
currency_base: str
|
|
240
|
+
currency_profit: str
|
|
241
|
+
currency_margin: str
|
|
242
|
+
trading: NotRequired[
|
|
243
|
+
Literal["disabled", "long_only", "short_only", "close_only", "full"]
|
|
244
|
+
| str
|
|
245
|
+
| None
|
|
246
|
+
]
|
|
247
|
+
volume_min: float
|
|
248
|
+
volume_max: float
|
|
249
|
+
volume_step: float
|
|
250
|
+
in_market_watch: bool
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
class SymbolView(TypedDict):
|
|
254
|
+
name: str
|
|
255
|
+
available: bool
|
|
256
|
+
description: str
|
|
257
|
+
digits: int
|
|
258
|
+
point: float
|
|
259
|
+
tick_size: float
|
|
260
|
+
tick_value: float
|
|
261
|
+
contract_size: float
|
|
262
|
+
volume_min: float
|
|
263
|
+
volume_max: float
|
|
264
|
+
volume_step: float
|
|
265
|
+
stops_level: int
|
|
266
|
+
freeze_level: int
|
|
267
|
+
filling_mode: int
|
|
268
|
+
trade_mode: int
|
|
269
|
+
execution_mode: int
|
|
270
|
+
order_mode: int
|
|
271
|
+
expiration_mode: int
|
|
272
|
+
currency_base: str
|
|
273
|
+
currency_profit: str
|
|
274
|
+
currency_margin: str
|
|
275
|
+
filling_modes: list[Literal["fok", "ioc", "boc"] | str]
|
|
276
|
+
execution: NotRequired[
|
|
277
|
+
Literal["request", "instant", "market", "exchange"] | str | None
|
|
278
|
+
]
|
|
279
|
+
order_types: list[
|
|
280
|
+
Literal["market", "limit", "stop", "stop_limit", "sl", "tp", "close_by"] | str
|
|
281
|
+
]
|
|
282
|
+
expirations: list[Literal["gtc", "day", "specified", "specified_day"] | str]
|
|
283
|
+
trading: NotRequired[
|
|
284
|
+
Literal["disabled", "long_only", "short_only", "close_only", "full"]
|
|
285
|
+
| str
|
|
286
|
+
| None
|
|
287
|
+
]
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class TickView(TypedDict):
|
|
291
|
+
symbol: str
|
|
292
|
+
bid: float
|
|
293
|
+
ask: float
|
|
294
|
+
time_msc: NotRequired[int | None]
|
|
295
|
+
last: NotRequired[float | None]
|
|
296
|
+
volume: NotRequired[float | None]
|
|
297
|
+
flags: NotRequired[int | None]
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
class TradeResult(TypedDict):
|
|
301
|
+
retcode: int
|
|
302
|
+
retcode_name: (
|
|
303
|
+
Literal[
|
|
304
|
+
"OK",
|
|
305
|
+
"TRADE_RETCODE_REQUOTE",
|
|
306
|
+
"TRADE_RETCODE_REJECT",
|
|
307
|
+
"TRADE_RETCODE_CANCEL",
|
|
308
|
+
"TRADE_RETCODE_PLACED",
|
|
309
|
+
"TRADE_RETCODE_DONE",
|
|
310
|
+
"TRADE_RETCODE_DONE_PARTIAL",
|
|
311
|
+
"TRADE_RETCODE_ERROR",
|
|
312
|
+
"TRADE_RETCODE_TIMEOUT",
|
|
313
|
+
"TRADE_RETCODE_INVALID",
|
|
314
|
+
"TRADE_RETCODE_INVALID_VOLUME",
|
|
315
|
+
"TRADE_RETCODE_INVALID_PRICE",
|
|
316
|
+
"TRADE_RETCODE_INVALID_STOPS",
|
|
317
|
+
"TRADE_RETCODE_TRADE_DISABLED",
|
|
318
|
+
"TRADE_RETCODE_MARKET_CLOSED",
|
|
319
|
+
"TRADE_RETCODE_NO_MONEY",
|
|
320
|
+
"TRADE_RETCODE_PRICE_CHANGED",
|
|
321
|
+
"TRADE_RETCODE_PRICE_OFF",
|
|
322
|
+
"TRADE_RETCODE_INVALID_EXPIRATION",
|
|
323
|
+
"TRADE_RETCODE_ORDER_CHANGED",
|
|
324
|
+
"TRADE_RETCODE_TOO_MANY_REQUESTS",
|
|
325
|
+
"TRADE_RETCODE_NO_CHANGES",
|
|
326
|
+
"TRADE_RETCODE_SERVER_DISABLES_AT",
|
|
327
|
+
"TRADE_RETCODE_CLIENT_DISABLES_AT",
|
|
328
|
+
"TRADE_RETCODE_LOCKED",
|
|
329
|
+
"TRADE_RETCODE_FROZEN",
|
|
330
|
+
"TRADE_RETCODE_INVALID_FILL",
|
|
331
|
+
"TRADE_RETCODE_CONNECTION",
|
|
332
|
+
"TRADE_RETCODE_ONLY_REAL",
|
|
333
|
+
"TRADE_RETCODE_LIMIT_ORDERS",
|
|
334
|
+
"TRADE_RETCODE_LIMIT_VOLUME",
|
|
335
|
+
"TRADE_RETCODE_INVALID_ORDER",
|
|
336
|
+
"TRADE_RETCODE_POSITION_CLOSED",
|
|
337
|
+
"TRADE_RETCODE_INVALID_CLOSE_VOLUME",
|
|
338
|
+
"TRADE_RETCODE_CLOSE_ORDER_EXIST",
|
|
339
|
+
"TRADE_RETCODE_LIMIT_POSITIONS",
|
|
340
|
+
"TRADE_RETCODE_REJECT_CANCEL",
|
|
341
|
+
"TRADE_RETCODE_LONG_ONLY",
|
|
342
|
+
"TRADE_RETCODE_SHORT_ONLY",
|
|
343
|
+
"TRADE_RETCODE_CLOSE_ONLY",
|
|
344
|
+
"TRADE_RETCODE_FIFO_CLOSE",
|
|
345
|
+
"TRADE_RETCODE_HEDGE_PROHIBITED",
|
|
346
|
+
"UNKNOWN",
|
|
347
|
+
]
|
|
348
|
+
| str
|
|
349
|
+
)
|
|
350
|
+
comment: str
|
|
351
|
+
order: int
|
|
352
|
+
deal: int
|
|
353
|
+
position: int
|
|
354
|
+
volume: float
|
|
355
|
+
price: float
|
|
356
|
+
bid: float
|
|
357
|
+
ask: float
|
|
358
|
+
retcode_external: int
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
TypeTime: TypeAlias = Literal["gtc", "day", "specified", "specified_day"] | str
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
class SentRequest(TypedDict):
|
|
365
|
+
action: Action
|
|
366
|
+
symbol: str
|
|
367
|
+
type: OrderType
|
|
368
|
+
volume: float
|
|
369
|
+
price: float
|
|
370
|
+
stoplimit: float
|
|
371
|
+
sl: float
|
|
372
|
+
tp: float
|
|
373
|
+
deviation: int
|
|
374
|
+
type_filling: Filling
|
|
375
|
+
type_time: TypeTime
|
|
376
|
+
expiration: int
|
|
377
|
+
order: int
|
|
378
|
+
position: int
|
|
379
|
+
position_by: int
|
|
380
|
+
magic: int
|
|
381
|
+
comment: str
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
FillingParam: TypeAlias = Literal["fok", "ioc", "return", "boc"]
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
OrderTypeParam: TypeAlias = Literal[
|
|
388
|
+
"buy",
|
|
389
|
+
"sell",
|
|
390
|
+
"buy_limit",
|
|
391
|
+
"sell_limit",
|
|
392
|
+
"buy_stop",
|
|
393
|
+
"sell_stop",
|
|
394
|
+
"buy_stop_limit",
|
|
395
|
+
"sell_stop_limit",
|
|
396
|
+
"close_by",
|
|
397
|
+
]
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
TypeTimeParam: TypeAlias = Literal["gtc", "day", "specified", "specified_day"]
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
class AccountView(TypedDict):
|
|
404
|
+
id: str
|
|
405
|
+
login: int
|
|
406
|
+
server: str
|
|
407
|
+
status: str
|
|
408
|
+
connected: bool
|
|
409
|
+
trade_allowed: NotRequired[bool | None]
|
|
410
|
+
company: NotRequired[str | None]
|
|
411
|
+
currency: NotRequired[str | None]
|
|
412
|
+
leverage: NotRequired[int | None]
|
|
413
|
+
margin_mode: NotRequired[str | None]
|
|
414
|
+
trade_mode: NotRequired[str | None]
|
|
415
|
+
balance: NotRequired[float | None]
|
|
416
|
+
equity: NotRequired[float | None]
|
|
417
|
+
credit: NotRequired[float | None]
|
|
418
|
+
margin: NotRequired[float | None]
|
|
419
|
+
margin_free: NotRequired[float | None]
|
|
420
|
+
server_time: NotRequired[int | None]
|
|
421
|
+
kill_switch: KillSwitchView
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
class CheckView(TypedDict):
|
|
425
|
+
sent: SentRequest
|
|
426
|
+
result: CheckResult
|
|
427
|
+
message: str
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
class ClosePosition(TypedDict):
|
|
431
|
+
volume: float
|
|
432
|
+
type_filling: FillingParam
|
|
433
|
+
price: NotRequired[float | None]
|
|
434
|
+
deviation: NotRequired[int | None]
|
|
435
|
+
magic: NotRequired[int | None]
|
|
436
|
+
comment: NotRequired[str | None]
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
class HistoryOrderView(TypedDict):
|
|
440
|
+
ticket: int
|
|
441
|
+
symbol: str
|
|
442
|
+
type: NotRequired[OrderType | None]
|
|
443
|
+
state: NotRequired[
|
|
444
|
+
Literal[
|
|
445
|
+
"started",
|
|
446
|
+
"placed",
|
|
447
|
+
"canceled",
|
|
448
|
+
"partial",
|
|
449
|
+
"filled",
|
|
450
|
+
"rejected",
|
|
451
|
+
"expired",
|
|
452
|
+
"request_add",
|
|
453
|
+
"request_modify",
|
|
454
|
+
"request_cancel",
|
|
455
|
+
]
|
|
456
|
+
| str
|
|
457
|
+
| None
|
|
458
|
+
]
|
|
459
|
+
volume_initial: float
|
|
460
|
+
volume_current: float
|
|
461
|
+
price_open: float
|
|
462
|
+
magic: int
|
|
463
|
+
comment: str
|
|
464
|
+
position: int
|
|
465
|
+
time_setup_msc: int
|
|
466
|
+
time_done_msc: int
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
class KillSwitchNotConnected(TypedDict):
|
|
470
|
+
error: str
|
|
471
|
+
kill_switch: KillSwitchView
|
|
472
|
+
message: str
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
KillSwitchUnavailable: TypeAlias = ErrorBody | KillSwitchNotConnected
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
class ModifyOrder(TypedDict):
|
|
479
|
+
price: float
|
|
480
|
+
sl: float
|
|
481
|
+
tp: float
|
|
482
|
+
type_time: TypeTimeParam
|
|
483
|
+
stoplimit: NotRequired[float | None]
|
|
484
|
+
expiration: NotRequired[int | None]
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
class PlaceOrder(TypedDict):
|
|
488
|
+
symbol: str
|
|
489
|
+
type: OrderTypeParam
|
|
490
|
+
volume: float
|
|
491
|
+
type_filling: FillingParam
|
|
492
|
+
price: NotRequired[float | None]
|
|
493
|
+
stoplimit: NotRequired[float | None]
|
|
494
|
+
sl: NotRequired[float | None]
|
|
495
|
+
tp: NotRequired[float | None]
|
|
496
|
+
deviation: NotRequired[int | None]
|
|
497
|
+
type_time: NotRequired[TypeTimeParam | None]
|
|
498
|
+
expiration: NotRequired[int | None]
|
|
499
|
+
magic: NotRequired[int | None]
|
|
500
|
+
comment: NotRequired[str | None]
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
RequestResult: TypeAlias = TradeResult | ErrorBody | HandSettlement
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
class RequestView(TypedDict):
|
|
507
|
+
request: str
|
|
508
|
+
state: RequestState
|
|
509
|
+
sent: SentRequest
|
|
510
|
+
result: NotRequired[RequestResult | None]
|
|
511
|
+
message: str
|
|
512
|
+
error: NotRequired[str | None]
|
|
513
|
+
settlement: NotRequired[Settlement | None]
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
class SweptOrder(TypedDict):
|
|
517
|
+
order: int
|
|
518
|
+
request: RequestView
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
class SweptPosition(TypedDict):
|
|
522
|
+
position: int
|
|
523
|
+
request: RequestView
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
TradeConflict: TypeAlias = SymbolBusy | RequestView
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
TradeRejected: TypeAlias = ErrorBody | RequestView
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
TradeUnavailable: TypeAlias = ErrorBody | RequestView
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
class KillSwitchOutcome(TypedDict):
|
|
536
|
+
flat: bool
|
|
537
|
+
cancelled: list[SweptOrder]
|
|
538
|
+
closed: list[SweptPosition]
|
|
539
|
+
remaining: NotRequired[Remaining | None]
|
|
540
|
+
unanswered: list[str]
|
|
541
|
+
kill_switch: KillSwitchView
|
|
542
|
+
message: str
|