HedgeTech 0.2.0b1__py3-none-any.whl → 0.2.2b0__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.
- HedgeTech/Auth/__AuthAsyncClient.py +16 -12
- HedgeTech/Auth/__AuthSyncClient.py +18 -14
- HedgeTech/Auth/__utils/__RetriableAsyncClient.py +63 -0
- HedgeTech/Auth/__utils/__RetriableSyncClient.py +65 -0
- HedgeTech/Auth/__utils/__init__.py +2 -0
- HedgeTech/EmsEngine/__init__.py +1 -1
- HedgeTech/EmsEngine/__tse_ifb/__AsyncClient.py +543 -249
- HedgeTech/EmsEngine/__tse_ifb/__SyncClient.py +568 -245
- HedgeTech/EmsEngine/__tse_ifb/__init__.py +1 -1
- HedgeTech/EmsEngine/__tse_ifb/__io_types/__response.py +1 -1
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/METADATA +91 -9
- hedgetech-0.2.2b0.dist-info/RECORD +24 -0
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/WHEEL +1 -1
- hedgetech-0.2.0b1.dist-info/RECORD +0 -21
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/licenses/LICENSE +0 -0
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/licenses/NOTICE +0 -0
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/top_level.txt +0 -0
|
@@ -20,11 +20,25 @@ from io import BytesIO
|
|
|
20
20
|
|
|
21
21
|
class Order:
|
|
22
22
|
|
|
23
|
+
"""
|
|
24
|
+
Represents a single trading order in EMS Engine.
|
|
25
|
+
|
|
26
|
+
This class provides methods to send, edit, check status,
|
|
27
|
+
and delete an order after creation.
|
|
28
|
+
|
|
29
|
+
An Order instance is usually created via
|
|
30
|
+
`EmsEngine_TseIfb_SyncClient` methods.
|
|
31
|
+
"""
|
|
32
|
+
|
|
23
33
|
def __init__(
|
|
24
34
|
self,
|
|
25
35
|
*,
|
|
26
|
-
|
|
36
|
+
SendOrder_RequestInfo : dict,
|
|
27
37
|
AuthSyncClient : AuthSyncClient,
|
|
38
|
+
SymbolNameOrIsin : str,
|
|
39
|
+
Price : int,
|
|
40
|
+
Volume :int,
|
|
41
|
+
ValidityDate : int = 0,
|
|
28
42
|
Order_ValidityType : Literal[
|
|
29
43
|
'DAY',
|
|
30
44
|
'GTC', # Good Till Cancelled
|
|
@@ -32,14 +46,46 @@ class Order:
|
|
|
32
46
|
'FAK', # Fill And Kill
|
|
33
47
|
'FOK', # Fill Or Kill
|
|
34
48
|
] = 'DAY',
|
|
35
|
-
ValidityDate : int = 0,
|
|
36
|
-
SymbolNameOrIsin : str,
|
|
37
|
-
Price : int,
|
|
38
|
-
Volume :int,
|
|
39
49
|
):
|
|
40
50
|
|
|
51
|
+
"""
|
|
52
|
+
Initialize a new Order object.
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
SendOrder_RequestInfo : dict
|
|
57
|
+
HTTP request configuration for sending the order.
|
|
58
|
+
|
|
59
|
+
AuthSyncClient : AuthSyncClient
|
|
60
|
+
Authenticated HTTP client.
|
|
61
|
+
|
|
62
|
+
Order_ValidityType : Literal
|
|
63
|
+
Order validity type.
|
|
64
|
+
|
|
65
|
+
ValidityDate : int
|
|
66
|
+
Expiration date (for GTD orders).
|
|
67
|
+
|
|
68
|
+
SymbolNameOrIsin : str
|
|
69
|
+
Symbol name or ISIN code.
|
|
70
|
+
|
|
71
|
+
Price : int
|
|
72
|
+
Order price.
|
|
73
|
+
|
|
74
|
+
Volume : int
|
|
75
|
+
Order volume.
|
|
76
|
+
|
|
77
|
+
Examples
|
|
78
|
+
--------
|
|
79
|
+
>>> order = client.Buy_by_Name(
|
|
80
|
+
... symbolName="اهرم",
|
|
81
|
+
... Price=12000,
|
|
82
|
+
... Volume=1000
|
|
83
|
+
... )
|
|
84
|
+
"""
|
|
85
|
+
|
|
41
86
|
self.__AuthSyncClient = AuthSyncClient
|
|
42
|
-
self.
|
|
87
|
+
self.__SendOrder_RequestInfo = SendOrder_RequestInfo
|
|
88
|
+
|
|
43
89
|
self.ValidityType : str = Order_ValidityType
|
|
44
90
|
self.ValidityDate : int = ValidityDate
|
|
45
91
|
self.SymbolNameOrIsin : str = SymbolNameOrIsin
|
|
@@ -47,12 +93,57 @@ class Order:
|
|
|
47
93
|
self.Volume : int = Volume
|
|
48
94
|
self.is_deleted : bool = False
|
|
49
95
|
|
|
96
|
+
self.OrderId : HexUUID | None = None
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
100
|
+
|
|
101
|
+
def send(self)-> None:
|
|
102
|
+
|
|
103
|
+
"""
|
|
104
|
+
Send the order to the trading engine.
|
|
105
|
+
|
|
106
|
+
This method submits the order to EMS Engine
|
|
107
|
+
and assigns OrderId on success.
|
|
108
|
+
|
|
109
|
+
Returns
|
|
110
|
+
-------
|
|
111
|
+
None
|
|
112
|
+
|
|
113
|
+
Notes
|
|
114
|
+
-----
|
|
115
|
+
- Can be called only once.
|
|
116
|
+
- Subsequent calls have no effect.
|
|
117
|
+
|
|
118
|
+
Examples
|
|
119
|
+
--------
|
|
120
|
+
>>> order.send()
|
|
121
|
+
>>> print(order.OrderId)
|
|
122
|
+
'0xA23F...'
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
if self.OrderId is None :
|
|
126
|
+
|
|
127
|
+
SendOrder_Response = self.__AuthSyncClient.httpx_Client.post(**self.__SendOrder_RequestInfo)
|
|
128
|
+
|
|
129
|
+
match SendOrder_Response.status_code :
|
|
130
|
+
|
|
131
|
+
case 200 :
|
|
132
|
+
|
|
133
|
+
self.OrderId = SendOrder_Response.json()['Data']['order_uuid']
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
case _ : return None
|
|
137
|
+
|
|
138
|
+
else : return None
|
|
50
139
|
|
|
51
140
|
# +--------------------------------------------------------------------------------------+ #
|
|
52
141
|
|
|
53
142
|
def Edit(
|
|
54
143
|
self,
|
|
55
144
|
*,
|
|
145
|
+
Price : int,
|
|
146
|
+
Volume :int,
|
|
56
147
|
Order_ValidityType : Literal[
|
|
57
148
|
'DAY',
|
|
58
149
|
'GTC', # Good Till Cancelled
|
|
@@ -61,112 +152,230 @@ class Order:
|
|
|
61
152
|
'FOK', # Fill Or Kill
|
|
62
153
|
] = 'DAY',
|
|
63
154
|
ValidityDate : int = 0,
|
|
64
|
-
Price : int,
|
|
65
|
-
Volume :int,
|
|
66
155
|
)-> None:
|
|
67
156
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
157
|
+
"""
|
|
158
|
+
Edit an existing order.
|
|
159
|
+
|
|
160
|
+
Parameters
|
|
161
|
+
----------
|
|
162
|
+
Order_ValidityType : Literal
|
|
163
|
+
New validity type.
|
|
164
|
+
|
|
165
|
+
ValidityDate : int
|
|
166
|
+
New expiration date.
|
|
167
|
+
|
|
168
|
+
Price : int
|
|
169
|
+
New order price.
|
|
170
|
+
|
|
171
|
+
Volume : int
|
|
172
|
+
New order volume.
|
|
173
|
+
|
|
174
|
+
Returns
|
|
175
|
+
-------
|
|
176
|
+
None
|
|
177
|
+
|
|
178
|
+
Raises
|
|
179
|
+
------
|
|
180
|
+
None
|
|
181
|
+
|
|
182
|
+
Examples
|
|
183
|
+
--------
|
|
184
|
+
>>> order.Edit(Price=12500, Volume=800)
|
|
185
|
+
"""
|
|
186
|
+
|
|
187
|
+
if self.OrderId is not None:
|
|
188
|
+
|
|
189
|
+
Edit_response = self.__AuthSyncClient.httpx_Client.patch(
|
|
190
|
+
url='https://core.hedgetech.ir/ems-engine/tse-ifb/order/edit',
|
|
191
|
+
data={
|
|
192
|
+
'order_uuid' : self.OrderId,
|
|
193
|
+
'Order_ValidityType' : Order_ValidityType,
|
|
194
|
+
'ValidityDate' : ValidityDate,
|
|
195
|
+
'Price' : Price,
|
|
196
|
+
'Volume' : Volume
|
|
197
|
+
}
|
|
198
|
+
)
|
|
81
199
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
200
|
+
|
|
201
|
+
match Edit_response.status_code:
|
|
202
|
+
|
|
203
|
+
case 200:
|
|
204
|
+
|
|
205
|
+
Edit_response = Edit_response.json()
|
|
206
|
+
|
|
207
|
+
self.OrderId = Edit_response['Data']['order_uuid']
|
|
208
|
+
self.ValidityType = Edit_response['Data']['order_validity_type']
|
|
209
|
+
self.ValidityDate = ValidityDate
|
|
210
|
+
self.Price = Edit_response['Data']['order_price']
|
|
211
|
+
self.Volume = Edit_response['Data']['order_volume']
|
|
212
|
+
|
|
213
|
+
return None
|
|
214
|
+
|
|
215
|
+
case _ : return None
|
|
216
|
+
|
|
217
|
+
else : return None
|
|
100
218
|
|
|
101
219
|
# +--------------------------------------------------------------------------------------+ #
|
|
102
220
|
|
|
103
|
-
|
|
104
|
-
def Status(self)-> OrderStatus:
|
|
221
|
+
def Status(self)-> OrderStatus | None:
|
|
105
222
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
223
|
+
"""
|
|
224
|
+
Retrieve the current status of the order.
|
|
225
|
+
|
|
226
|
+
This method queries the EMS Engine and returns detailed
|
|
227
|
+
execution and lifecycle information of the order.
|
|
228
|
+
|
|
229
|
+
Returns
|
|
230
|
+
-------
|
|
231
|
+
OrderStatus | None
|
|
232
|
+
A dictionary containing order status information.
|
|
233
|
+
|
|
234
|
+
On success, the returned object contains the following fields:
|
|
235
|
+
|
|
236
|
+
- order_uuid : HexUUID
|
|
237
|
+
Unique identifier of the order.
|
|
238
|
+
|
|
239
|
+
- order_status : Literal['InQueue', 'Cancelled', 'Broken', 'Settled']
|
|
240
|
+
Current lifecycle state of the order.
|
|
241
|
+
|
|
242
|
+
* InQueue : Order is waiting for execution.
|
|
243
|
+
* Cancelled : Order was cancelled.
|
|
244
|
+
* Broken : Order was rejected or failed.
|
|
245
|
+
* Settled : Order fully executed.
|
|
246
|
+
|
|
247
|
+
- Price : int
|
|
248
|
+
Order price.
|
|
249
|
+
|
|
250
|
+
- Volume : int
|
|
251
|
+
Total requested volume.
|
|
252
|
+
|
|
253
|
+
- RemainedVolume : int
|
|
254
|
+
Remaining unexecuted volume.
|
|
255
|
+
|
|
256
|
+
- ExecutedVolume : int
|
|
257
|
+
Total executed volume.
|
|
258
|
+
|
|
259
|
+
- OrderSide : Literal['Buy', 'Sell']
|
|
260
|
+
Side of the order.
|
|
261
|
+
|
|
262
|
+
- ValidityType : Literal['DAY', 'GTC', 'GTD']
|
|
263
|
+
Order validity type.
|
|
264
|
+
|
|
265
|
+
- ValidityDate : int
|
|
266
|
+
Expiration date (for GTD orders).
|
|
267
|
+
|
|
268
|
+
Returns None if the request fails or if the order
|
|
269
|
+
has not been sent yet.
|
|
270
|
+
|
|
271
|
+
Raises
|
|
272
|
+
------
|
|
273
|
+
None
|
|
274
|
+
|
|
275
|
+
Notes
|
|
276
|
+
-----
|
|
277
|
+
- This method requires a valid OrderId.
|
|
278
|
+
- If OrderId is None, None is returned.
|
|
279
|
+
- Network or server errors are silently ignored.
|
|
280
|
+
|
|
281
|
+
Examples
|
|
282
|
+
--------
|
|
283
|
+
>>> status = order.Status()
|
|
284
|
+
>>> print(status["order_status"])
|
|
285
|
+
'Settled'
|
|
286
|
+
|
|
287
|
+
>>> print(status["ExecutedVolume"])
|
|
288
|
+
1000
|
|
289
|
+
|
|
290
|
+
>>> if status["RemainedVolume"] == 0:
|
|
291
|
+
... print("Order fully executed")
|
|
292
|
+
|
|
293
|
+
Example Output
|
|
294
|
+
--------------
|
|
295
|
+
{
|
|
296
|
+
"order_uuid": "0xA91F23BC...",
|
|
297
|
+
"order_status": "Settled",
|
|
298
|
+
"Price": 12000,
|
|
299
|
+
"Volume": 1000,
|
|
300
|
+
"RemainedVolume": 0,
|
|
301
|
+
"ExecutedVolume": 1000,
|
|
302
|
+
"OrderSide": "Buy",
|
|
303
|
+
"ValidityType": "DAY",
|
|
304
|
+
"ValidityDate": 0
|
|
305
|
+
}
|
|
306
|
+
"""
|
|
307
|
+
|
|
308
|
+
if self.OrderId is not None:
|
|
309
|
+
|
|
310
|
+
status_respnse = self.__AuthSyncClient.httpx_Client.get(
|
|
311
|
+
url='https://core.hedgetech.ir/ems-engine/tse-ifb/order/status',
|
|
312
|
+
params={'order_uuid' : self.OrderId}
|
|
313
|
+
)
|
|
112
314
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return status_respnse.json()['Data']
|
|
315
|
+
match status_respnse.status_code :
|
|
116
316
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
317
|
+
case 200:
|
|
318
|
+
|
|
319
|
+
return status_respnse.json()['Data']
|
|
320
|
+
|
|
321
|
+
case _ : return None
|
|
122
322
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
# +--------------------------------------------------------------------------------------+ #
|
|
126
|
-
|
|
127
|
-
@property
|
|
128
|
-
def order_is_valid(self)-> bool:
|
|
129
|
-
|
|
130
|
-
status = self.Status
|
|
131
|
-
|
|
132
|
-
if (status['Price'] == self.Price) and (
|
|
133
|
-
status['Volume'] == self.Volume
|
|
134
|
-
) and (status['ValidityType'] == self.ValidityType) and status['OrderInQueue']:
|
|
135
|
-
|
|
136
|
-
return True
|
|
137
|
-
|
|
138
|
-
else : return False
|
|
323
|
+
else : return None
|
|
139
324
|
|
|
140
325
|
# +--------------------------------------------------------------------------------------+ #
|
|
141
326
|
|
|
142
|
-
|
|
143
|
-
def Delete(self)-> bool :
|
|
144
|
-
|
|
145
|
-
Delete_respnse = self.__AuthSyncClient.httpx_Client.delete(
|
|
146
|
-
url= 'https://core.hedgetech.ir/ems-engine/tse-ifb/order/delete',
|
|
147
|
-
params={'order_uuid' : self.__order_uuid}
|
|
148
|
-
)
|
|
327
|
+
def Delete(self)-> None :
|
|
149
328
|
|
|
329
|
+
"""
|
|
330
|
+
Cancel/Delete the order.
|
|
331
|
+
|
|
332
|
+
Sends delete request to EMS Engine.
|
|
333
|
+
|
|
334
|
+
Returns
|
|
335
|
+
-------
|
|
336
|
+
None
|
|
337
|
+
|
|
338
|
+
Notes
|
|
339
|
+
-----
|
|
340
|
+
After deletion, `is_deleted` becomes True.
|
|
150
341
|
|
|
151
|
-
|
|
342
|
+
Examples
|
|
343
|
+
--------
|
|
344
|
+
>>> order.Delete()
|
|
345
|
+
>>> print(order.is_deleted)
|
|
346
|
+
True
|
|
347
|
+
"""
|
|
348
|
+
|
|
349
|
+
if self.OrderId is not None:
|
|
152
350
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
self.
|
|
351
|
+
Delete_respnse = self.__AuthSyncClient.httpx_Client.delete(
|
|
352
|
+
url= 'https://core.hedgetech.ir/ems-engine/tse-ifb/order/delete',
|
|
353
|
+
params={'order_uuid' : self.OrderId}
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
match Delete_respnse.status_code :
|
|
156
358
|
|
|
157
|
-
|
|
359
|
+
case 200:
|
|
360
|
+
|
|
361
|
+
self.is_deleted = True
|
|
362
|
+
return None
|
|
158
363
|
|
|
159
|
-
|
|
364
|
+
case _ : return None
|
|
160
365
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
raise ValueError(Delete_respnse.text)
|
|
164
|
-
|
|
366
|
+
else : return None
|
|
165
367
|
|
|
166
368
|
# ================================================================================= #
|
|
167
369
|
|
|
168
370
|
class EmsEngine_TseIfb_SyncClient:
|
|
169
371
|
|
|
372
|
+
"""
|
|
373
|
+
Synchronous EMS Engine client for TSE/IFB markets.
|
|
374
|
+
|
|
375
|
+
This client manages authentication, OMS login,
|
|
376
|
+
and order creation.
|
|
377
|
+
"""
|
|
378
|
+
|
|
170
379
|
def __init__(
|
|
171
380
|
self,
|
|
172
381
|
AuthSyncClient : AuthSyncClient,
|
|
@@ -190,6 +399,30 @@ class EmsEngine_TseIfb_SyncClient:
|
|
|
190
399
|
]
|
|
191
400
|
)-> ImageFile:
|
|
192
401
|
|
|
402
|
+
"""
|
|
403
|
+
Fetch captcha image for OMS login.
|
|
404
|
+
|
|
405
|
+
Parameters
|
|
406
|
+
----------
|
|
407
|
+
OMS : Literal
|
|
408
|
+
OMS provider name.
|
|
409
|
+
|
|
410
|
+
Returns
|
|
411
|
+
-------
|
|
412
|
+
ImageFile
|
|
413
|
+
Captcha image.
|
|
414
|
+
|
|
415
|
+
Raises
|
|
416
|
+
------
|
|
417
|
+
ValueError
|
|
418
|
+
If server returns error.
|
|
419
|
+
|
|
420
|
+
Examples
|
|
421
|
+
--------
|
|
422
|
+
>>> img = client.Get_Captcha("Omex | Parsian")
|
|
423
|
+
>>> img.show()
|
|
424
|
+
"""
|
|
425
|
+
|
|
193
426
|
Captcha = self.__AuthSyncClient.httpx_Client.get(
|
|
194
427
|
url='https://core.hedgetech.ir/ems-engine/tse-ifb/oms/login',
|
|
195
428
|
params={'oms' : OMS }
|
|
@@ -207,7 +440,34 @@ class EmsEngine_TseIfb_SyncClient:
|
|
|
207
440
|
password: str,
|
|
208
441
|
captcha_value: str,
|
|
209
442
|
) -> None :
|
|
443
|
+
"""
|
|
444
|
+
Authenticate user in OMS system.
|
|
210
445
|
|
|
446
|
+
Parameters
|
|
447
|
+
----------
|
|
448
|
+
username : str
|
|
449
|
+
Trading account username.
|
|
450
|
+
|
|
451
|
+
password : str
|
|
452
|
+
Trading account password.
|
|
453
|
+
|
|
454
|
+
captcha_value : str
|
|
455
|
+
Captcha solution.
|
|
456
|
+
|
|
457
|
+
Returns
|
|
458
|
+
-------
|
|
459
|
+
None
|
|
460
|
+
|
|
461
|
+
Raises
|
|
462
|
+
------
|
|
463
|
+
ValueError
|
|
464
|
+
If authentication fails.
|
|
465
|
+
|
|
466
|
+
Examples
|
|
467
|
+
--------
|
|
468
|
+
>>> client.oms_login("user1", "pass123", "A7B9")
|
|
469
|
+
"""
|
|
470
|
+
|
|
211
471
|
response = self.__AuthSyncClient.httpx_Client.post(
|
|
212
472
|
url='https://core.hedgetech.ir/ems-engine/tse-ifb/oms/login',
|
|
213
473
|
data={
|
|
@@ -245,6 +505,9 @@ class EmsEngine_TseIfb_SyncClient:
|
|
|
245
505
|
def Buy_by_Name(
|
|
246
506
|
self,
|
|
247
507
|
*,
|
|
508
|
+
symbolName : str,
|
|
509
|
+
Price : int,
|
|
510
|
+
Volume :int,
|
|
248
511
|
Order_ValidityType : Literal[
|
|
249
512
|
'DAY',
|
|
250
513
|
'GTC', # Good Till Cancelled
|
|
@@ -253,47 +516,60 @@ class EmsEngine_TseIfb_SyncClient:
|
|
|
253
516
|
'FOK', # Fill Or Kill
|
|
254
517
|
] = 'DAY',
|
|
255
518
|
ValidityDate : int = 0,
|
|
256
|
-
|
|
257
|
-
Price : int,
|
|
258
|
-
Volume :int,
|
|
259
|
-
)-> Order:
|
|
519
|
+
)-> Order | None:
|
|
260
520
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
521
|
+
"""
|
|
522
|
+
Create a buy order using symbol name.
|
|
523
|
+
|
|
524
|
+
Parameters
|
|
525
|
+
----------
|
|
526
|
+
symbolName : str
|
|
527
|
+
Trading symbol name.
|
|
528
|
+
|
|
529
|
+
Price : int
|
|
530
|
+
Order price.
|
|
531
|
+
|
|
532
|
+
Volume : int
|
|
533
|
+
Order volume.
|
|
534
|
+
|
|
535
|
+
Returns
|
|
536
|
+
-------
|
|
537
|
+
Order | None
|
|
538
|
+
Order instance if logged in, otherwise None.
|
|
539
|
+
|
|
540
|
+
Examples
|
|
541
|
+
--------
|
|
542
|
+
>>> order = client.Buy_by_Name(
|
|
543
|
+
... symbolName="اهرم",
|
|
544
|
+
... Price=12000,
|
|
545
|
+
... Volume=1000
|
|
546
|
+
... )
|
|
547
|
+
>>> order.send()
|
|
548
|
+
"""
|
|
549
|
+
|
|
550
|
+
if self.oms_session is not None:
|
|
551
|
+
|
|
552
|
+
return Order(
|
|
553
|
+
AuthSyncClient=self.__AuthSyncClient,
|
|
554
|
+
Order_ValidityType=Order_ValidityType,
|
|
555
|
+
ValidityDate=ValidityDate,
|
|
556
|
+
SymbolNameOrIsin = symbolName,
|
|
557
|
+
Price=Price,
|
|
558
|
+
Volume=Volume,
|
|
559
|
+
SendOrder_RequestInfo = {
|
|
560
|
+
'url' : 'https://core.hedgetech.ir/ems-engine/tse-ifb/order/new/buy/name',
|
|
561
|
+
'data' : {
|
|
562
|
+
'oms_session' : self.oms_session,
|
|
563
|
+
'Order_ValidityType' : Order_ValidityType,
|
|
564
|
+
'ValidityDate' : ValidityDate,
|
|
565
|
+
'symbolName' : symbolName,
|
|
566
|
+
'Price' : Price,
|
|
567
|
+
'Volume' : Volume
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
)
|
|
275
571
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
order_response = order_response.json()
|
|
279
|
-
|
|
280
|
-
return Order(
|
|
281
|
-
order_uuid=order_response['Data']['order_uuid'],
|
|
282
|
-
AuthSyncClient=self.__AuthSyncClient,
|
|
283
|
-
Order_ValidityType=Order_ValidityType,
|
|
284
|
-
ValidityDate=ValidityDate,
|
|
285
|
-
SymbolNameOrIsin = symbolName,
|
|
286
|
-
Price=Price,
|
|
287
|
-
Volume=Volume
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
case 400:
|
|
291
|
-
|
|
292
|
-
raise ValueError(order_response.json()['detail']['Status']['Description']['en'])
|
|
293
|
-
|
|
294
|
-
case _ :
|
|
295
|
-
|
|
296
|
-
raise ValueError(order_response.text)
|
|
572
|
+
else : return None
|
|
297
573
|
|
|
298
574
|
|
|
299
575
|
# +--------------------------------------------------------------------------------------+ #
|
|
@@ -302,6 +578,9 @@ class EmsEngine_TseIfb_SyncClient:
|
|
|
302
578
|
def Sell_by_Name(
|
|
303
579
|
self,
|
|
304
580
|
*,
|
|
581
|
+
symbolName : str,
|
|
582
|
+
Price : int,
|
|
583
|
+
Volume :int,
|
|
305
584
|
Order_ValidityType : Literal[
|
|
306
585
|
'DAY',
|
|
307
586
|
'GTC', # Good Till Cancelled
|
|
@@ -310,53 +589,69 @@ class EmsEngine_TseIfb_SyncClient:
|
|
|
310
589
|
'FOK', # Fill Or Kill
|
|
311
590
|
] = 'DAY',
|
|
312
591
|
ValidityDate : int = 0,
|
|
313
|
-
|
|
314
|
-
Price : int,
|
|
315
|
-
Volume :int,
|
|
316
|
-
)-> Order:
|
|
317
|
-
|
|
318
|
-
order_response = self.__AuthSyncClient.httpx_Client.post(
|
|
319
|
-
url='https://core.hedgetech.ir/ems-engine/tse-ifb/order/new/sell/name',
|
|
320
|
-
data={
|
|
321
|
-
'oms_session' : self.oms_session,
|
|
322
|
-
'Order_ValidityType' : Order_ValidityType,
|
|
323
|
-
'ValidityDate' : ValidityDate,
|
|
324
|
-
'symbolName' : symbolName,
|
|
325
|
-
'Price' : Price,
|
|
326
|
-
'Volume' : Volume
|
|
327
|
-
}
|
|
328
|
-
)
|
|
592
|
+
)-> Order | None:
|
|
329
593
|
|
|
330
|
-
|
|
331
|
-
|
|
594
|
+
"""
|
|
595
|
+
Create a sell order using symbol name.
|
|
596
|
+
|
|
597
|
+
Parameters
|
|
598
|
+
----------
|
|
599
|
+
symbolName : str
|
|
600
|
+
Trading symbol name.
|
|
601
|
+
|
|
602
|
+
Price : int
|
|
603
|
+
Order price.
|
|
604
|
+
|
|
605
|
+
Volume : int
|
|
606
|
+
Order volume.
|
|
607
|
+
|
|
608
|
+
Returns
|
|
609
|
+
-------
|
|
610
|
+
Order | None
|
|
611
|
+
Order instance if logged in, otherwise None.
|
|
612
|
+
|
|
613
|
+
Examples
|
|
614
|
+
--------
|
|
615
|
+
>>> order = client.Sell_by_Name(
|
|
616
|
+
... symbolName="اهرم",
|
|
617
|
+
... Price=12000,
|
|
618
|
+
... Volume=1000
|
|
619
|
+
... )
|
|
620
|
+
>>> order.send()
|
|
621
|
+
"""
|
|
622
|
+
|
|
623
|
+
if self.oms_session is not None:
|
|
624
|
+
|
|
625
|
+
return Order(
|
|
626
|
+
AuthSyncClient=self.__AuthSyncClient,
|
|
627
|
+
Order_ValidityType=Order_ValidityType,
|
|
628
|
+
ValidityDate=ValidityDate,
|
|
629
|
+
SymbolNameOrIsin = symbolName,
|
|
630
|
+
Price=Price,
|
|
631
|
+
Volume=Volume,
|
|
632
|
+
SendOrder_RequestInfo = {
|
|
633
|
+
'url' : 'https://core.hedgetech.ir/ems-engine/tse-ifb/order/new/sell/name',
|
|
634
|
+
'data' : {
|
|
635
|
+
'oms_session' : self.oms_session,
|
|
636
|
+
'Order_ValidityType' : Order_ValidityType,
|
|
637
|
+
'ValidityDate' : ValidityDate,
|
|
638
|
+
'symbolName' : symbolName,
|
|
639
|
+
'Price' : Price,
|
|
640
|
+
'Volume' : Volume
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
)
|
|
332
644
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
order_response = order_response.json()
|
|
336
|
-
|
|
337
|
-
return Order(
|
|
338
|
-
order_uuid=order_response['Data']['order_uuid'],
|
|
339
|
-
AuthSyncClient=self.__AuthSyncClient,
|
|
340
|
-
Order_ValidityType=Order_ValidityType,
|
|
341
|
-
ValidityDate=ValidityDate,
|
|
342
|
-
SymbolNameOrIsin = symbolName,
|
|
343
|
-
Price=Price,
|
|
344
|
-
Volume=Volume
|
|
345
|
-
)
|
|
346
|
-
|
|
347
|
-
case 400:
|
|
348
|
-
|
|
349
|
-
raise ValueError(order_response.json()['detail']['Status']['Description']['en'])
|
|
350
|
-
|
|
351
|
-
case _ :
|
|
352
|
-
|
|
353
|
-
raise ValueError(order_response.text)
|
|
645
|
+
else : return None
|
|
354
646
|
|
|
355
647
|
# +--------------------------------------------------------------------------------------+ #
|
|
356
648
|
|
|
357
649
|
def Buy_by_isin(
|
|
358
650
|
self,
|
|
359
651
|
*,
|
|
652
|
+
symbolIsin : str,
|
|
653
|
+
Price : int,
|
|
654
|
+
Volume :int,
|
|
360
655
|
Order_ValidityType : Literal[
|
|
361
656
|
'DAY',
|
|
362
657
|
'GTC', # Good Till Cancelled
|
|
@@ -365,54 +660,69 @@ class EmsEngine_TseIfb_SyncClient:
|
|
|
365
660
|
'FOK', # Fill Or Kill
|
|
366
661
|
] = 'DAY',
|
|
367
662
|
ValidityDate : int = 0,
|
|
368
|
-
|
|
369
|
-
Price : int,
|
|
370
|
-
Volume :int,
|
|
371
|
-
)-> Order:
|
|
372
|
-
|
|
373
|
-
order_response = self.__AuthSyncClient.httpx_Client.post(
|
|
374
|
-
url='https://core.hedgetech.ir/ems-engine/tse-ifb/order/new/buy/isin',
|
|
375
|
-
data={
|
|
376
|
-
'oms_session' : self.oms_session,
|
|
377
|
-
'Order_ValidityType' : Order_ValidityType,
|
|
378
|
-
'ValidityDate' : ValidityDate,
|
|
379
|
-
'symbolIsin' : symbolIsin,
|
|
380
|
-
'Price' : Price,
|
|
381
|
-
'Volume' : Volume
|
|
382
|
-
}
|
|
383
|
-
)
|
|
663
|
+
)-> Order | None:
|
|
384
664
|
|
|
385
|
-
|
|
386
|
-
|
|
665
|
+
"""
|
|
666
|
+
Create a buy order using symbol isin.
|
|
667
|
+
|
|
668
|
+
Parameters
|
|
669
|
+
----------
|
|
670
|
+
symbolIsin : str
|
|
671
|
+
Trading symbol isin.
|
|
672
|
+
|
|
673
|
+
Price : int
|
|
674
|
+
Order price.
|
|
675
|
+
|
|
676
|
+
Volume : int
|
|
677
|
+
Order volume.
|
|
678
|
+
|
|
679
|
+
Returns
|
|
680
|
+
-------
|
|
681
|
+
Order | None
|
|
682
|
+
Order instance if logged in, otherwise None.
|
|
683
|
+
|
|
684
|
+
Examples
|
|
685
|
+
--------
|
|
686
|
+
>>> order = client.Buy_by_isin(
|
|
687
|
+
... symbolName="اهرم",
|
|
688
|
+
... Price=12000,
|
|
689
|
+
... Volume=1000
|
|
690
|
+
... )
|
|
691
|
+
>>> order.send()
|
|
692
|
+
"""
|
|
693
|
+
|
|
694
|
+
if self.oms_session is not None:
|
|
695
|
+
|
|
696
|
+
return Order(
|
|
697
|
+
AuthSyncClient=self.__AuthSyncClient,
|
|
698
|
+
Order_ValidityType=Order_ValidityType,
|
|
699
|
+
ValidityDate=ValidityDate,
|
|
700
|
+
SymbolNameOrIsin = symbolIsin,
|
|
701
|
+
Price=Price,
|
|
702
|
+
Volume=Volume,
|
|
703
|
+
SendOrder_RequestInfo = {
|
|
704
|
+
'url' : 'https://core.hedgetech.ir/ems-engine/tse-ifb/order/new/buy/isin',
|
|
705
|
+
'data' : {
|
|
706
|
+
'oms_session' : self.oms_session,
|
|
707
|
+
'Order_ValidityType' : Order_ValidityType,
|
|
708
|
+
'ValidityDate' : ValidityDate,
|
|
709
|
+
'symbolIsin' : symbolIsin,
|
|
710
|
+
'Price' : Price,
|
|
711
|
+
'Volume' : Volume
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
)
|
|
387
715
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
order_response = order_response.json()
|
|
391
|
-
|
|
392
|
-
return Order(
|
|
393
|
-
order_uuid=order_response['Data']['order_uuid'],
|
|
394
|
-
AuthSyncClient=self.__AuthSyncClient,
|
|
395
|
-
Order_ValidityType=Order_ValidityType,
|
|
396
|
-
ValidityDate=ValidityDate,
|
|
397
|
-
SymbolNameOrIsin = symbolIsin,
|
|
398
|
-
Price=Price,
|
|
399
|
-
Volume=Volume
|
|
400
|
-
)
|
|
401
|
-
|
|
402
|
-
case 400:
|
|
403
|
-
|
|
404
|
-
raise ValueError(order_response.json()['detail']['Status']['Description']['en'])
|
|
405
|
-
|
|
406
|
-
case _ :
|
|
407
|
-
|
|
408
|
-
raise ValueError(order_response.text)
|
|
409
|
-
|
|
716
|
+
else : return None
|
|
410
717
|
|
|
411
718
|
# +--------------------------------------------------------------------------------------+ #
|
|
412
719
|
|
|
413
720
|
def Sell_by_isin(
|
|
414
721
|
self,
|
|
415
722
|
*,
|
|
723
|
+
symbolIsin : str,
|
|
724
|
+
Price : int,
|
|
725
|
+
Volume :int,
|
|
416
726
|
Order_ValidityType : Literal[
|
|
417
727
|
'DAY',
|
|
418
728
|
'GTC', # Good Till Cancelled
|
|
@@ -421,47 +731,60 @@ class EmsEngine_TseIfb_SyncClient:
|
|
|
421
731
|
'FOK', # Fill Or Kill
|
|
422
732
|
] = 'DAY',
|
|
423
733
|
ValidityDate : int = 0,
|
|
424
|
-
|
|
425
|
-
Price : int,
|
|
426
|
-
Volume :int,
|
|
427
|
-
)-> Order:
|
|
428
|
-
|
|
429
|
-
order_response = self.__AuthSyncClient.httpx_Client.post(
|
|
430
|
-
url='https://core.hedgetech.ir/ems-engine/tse-ifb/order/new/sell/isin',
|
|
431
|
-
data={
|
|
432
|
-
'oms_session' : self.oms_session,
|
|
433
|
-
'Order_ValidityType' : Order_ValidityType,
|
|
434
|
-
'ValidityDate' : ValidityDate,
|
|
435
|
-
'symbolIsin' : symbolIsin,
|
|
436
|
-
'Price' : Price,
|
|
437
|
-
'Volume' : Volume
|
|
438
|
-
}
|
|
439
|
-
)
|
|
734
|
+
)-> Order | None:
|
|
440
735
|
|
|
441
|
-
|
|
442
|
-
|
|
736
|
+
"""
|
|
737
|
+
Create a sell order using symbol isin.
|
|
738
|
+
|
|
739
|
+
Parameters
|
|
740
|
+
----------
|
|
741
|
+
symbolIsin : str
|
|
742
|
+
Trading symbol isin.
|
|
743
|
+
|
|
744
|
+
Price : int
|
|
745
|
+
Order price.
|
|
746
|
+
|
|
747
|
+
Volume : int
|
|
748
|
+
Order volume.
|
|
749
|
+
|
|
750
|
+
Returns
|
|
751
|
+
-------
|
|
752
|
+
Order | None
|
|
753
|
+
Order instance if logged in, otherwise None.
|
|
754
|
+
|
|
755
|
+
Examples
|
|
756
|
+
--------
|
|
757
|
+
>>> order = client.Sell_by_isin(
|
|
758
|
+
... symbolName="اهرم",
|
|
759
|
+
... Price=12000,
|
|
760
|
+
... Volume=1000
|
|
761
|
+
... )
|
|
762
|
+
>>> order.send()
|
|
763
|
+
"""
|
|
764
|
+
|
|
765
|
+
if self.oms_session is not None:
|
|
766
|
+
|
|
767
|
+
return Order(
|
|
768
|
+
AuthSyncClient=self.__AuthSyncClient,
|
|
769
|
+
Order_ValidityType=Order_ValidityType,
|
|
770
|
+
ValidityDate=ValidityDate,
|
|
771
|
+
SymbolNameOrIsin = symbolIsin,
|
|
772
|
+
Price=Price,
|
|
773
|
+
Volume=Volume,
|
|
774
|
+
SendOrder_RequestInfo = {
|
|
775
|
+
'url' : 'https://core.hedgetech.ir/ems-engine/tse-ifb/order/new/sell/isin',
|
|
776
|
+
'data' : {
|
|
777
|
+
'oms_session' : self.oms_session,
|
|
778
|
+
'Order_ValidityType' : Order_ValidityType,
|
|
779
|
+
'ValidityDate' : ValidityDate,
|
|
780
|
+
'symbolIsin' : symbolIsin,
|
|
781
|
+
'Price' : Price,
|
|
782
|
+
'Volume' : Volume
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
)
|
|
443
786
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
order_response = order_response.json()
|
|
447
|
-
|
|
448
|
-
return Order(
|
|
449
|
-
order_uuid=order_response['Data']['order_uuid'],
|
|
450
|
-
AuthSyncClient=self.__AuthSyncClient,
|
|
451
|
-
Order_ValidityType=Order_ValidityType,
|
|
452
|
-
ValidityDate=ValidityDate,
|
|
453
|
-
SymbolNameOrIsin = symbolIsin,
|
|
454
|
-
Price=Price,
|
|
455
|
-
Volume=Volume
|
|
456
|
-
)
|
|
457
|
-
|
|
458
|
-
case 400:
|
|
459
|
-
|
|
460
|
-
raise ValueError(order_response.json()['detail']['Status']['Description']['en'])
|
|
461
|
-
|
|
462
|
-
case _ :
|
|
463
|
-
|
|
464
|
-
raise ValueError(order_response.text)
|
|
787
|
+
else : return None
|
|
465
788
|
|
|
466
789
|
# +--------------------------------------------------------------------------------------+ #
|
|
467
790
|
|