HedgeTech 0.2.5__tar.gz → 0.3.0b2__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.
- hedgetech-0.3.0b2/HedgeTech/DataEngine/__ime/__AsyncClient.py +349 -0
- hedgetech-0.3.0b2/HedgeTech/DataEngine/__ime/__SyncClient.py +337 -0
- hedgetech-0.3.0b2/HedgeTech/DataEngine/__ime/__init__.py +2 -0
- hedgetech-0.3.0b2/HedgeTech/DataEngine/__ime/__io_types/__init__.py +12 -0
- hedgetech-0.3.0b2/HedgeTech/DataEngine/__ime/__io_types/__response.py +1311 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/DataEngine/__init__.py +4 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/DataEngine/__tse_ifb/__io_types/__response.py +64 -45
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech.egg-info/PKG-INFO +5 -5
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech.egg-info/SOURCES.txt +5 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/PKG-INFO +5 -5
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/README.md +1 -1
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/pyproject.toml +4 -4
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/Auth/__AuthAsyncClient.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/Auth/__AuthSyncClient.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/Auth/__init__.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/Auth/__utils/__RetriableAsyncClient.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/Auth/__utils/__RetriableSyncClient.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/Auth/__utils/__init__.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/DataEngine/__tse_ifb/__AsyncClient.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/DataEngine/__tse_ifb/__SyncClient.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/DataEngine/__tse_ifb/__init__.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/DataEngine/__tse_ifb/__io_types/__init__.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/EmsEngine/__init__.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/EmsEngine/__tse_ifb/__AsyncClient.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/EmsEngine/__tse_ifb/__SyncClient.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/EmsEngine/__tse_ifb/__init__.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/EmsEngine/__tse_ifb/__io_types/__init__.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech/EmsEngine/__tse_ifb/__io_types/__response.py +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech.egg-info/dependency_links.txt +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech.egg-info/requires.txt +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/HedgeTech.egg-info/top_level.txt +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/LICENSE +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/NOTICE +0 -0
- {hedgetech-0.2.5 → hedgetech-0.3.0b2}/setup.cfg +0 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# ========================================|======================================== #
|
|
2
|
+
# Imports #
|
|
3
|
+
# ========================================|======================================== #
|
|
4
|
+
|
|
5
|
+
from asyncio import (
|
|
6
|
+
Event,
|
|
7
|
+
wait_for,
|
|
8
|
+
TimeoutError,
|
|
9
|
+
sleep,
|
|
10
|
+
)
|
|
11
|
+
from websockets.asyncio.client import connect
|
|
12
|
+
from json import loads
|
|
13
|
+
from HedgeTech.Auth import AuthAsyncClient
|
|
14
|
+
from typing import (
|
|
15
|
+
Literal,
|
|
16
|
+
List,
|
|
17
|
+
AsyncGenerator,
|
|
18
|
+
)
|
|
19
|
+
from .__io_types import (
|
|
20
|
+
WebsocketBase_contractName,
|
|
21
|
+
WebsocketBase_contractId,
|
|
22
|
+
|
|
23
|
+
OverviewResponse,
|
|
24
|
+
Contracts,
|
|
25
|
+
|
|
26
|
+
ContractInfoResponse,
|
|
27
|
+
AllowedPriceRangeResponse,
|
|
28
|
+
AggregateResponse,
|
|
29
|
+
BestLimitResponse,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# ========================================|======================================== #
|
|
33
|
+
# Class Definitions #
|
|
34
|
+
# ========================================|======================================== #
|
|
35
|
+
|
|
36
|
+
class DataEngine_Ime_AsyncClient:
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
AuthAsyncClient : AuthAsyncClient,
|
|
41
|
+
):
|
|
42
|
+
|
|
43
|
+
self.__AuthAsyncClient = AuthAsyncClient
|
|
44
|
+
|
|
45
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
46
|
+
|
|
47
|
+
async def search_contracts(
|
|
48
|
+
self,
|
|
49
|
+
market : Literal[
|
|
50
|
+
"IMEDepositCertificate",
|
|
51
|
+
"IMEFutures",
|
|
52
|
+
"IMEOption",
|
|
53
|
+
],
|
|
54
|
+
Search_char : str,
|
|
55
|
+
)-> Contracts :
|
|
56
|
+
|
|
57
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
58
|
+
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/search',
|
|
59
|
+
params={
|
|
60
|
+
'market' : market,
|
|
61
|
+
'Search_char' : Search_char
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if data.is_success :
|
|
66
|
+
|
|
67
|
+
return data.json()
|
|
68
|
+
|
|
69
|
+
else :
|
|
70
|
+
|
|
71
|
+
raise ValueError(data.json().get('detail'))
|
|
72
|
+
|
|
73
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
74
|
+
|
|
75
|
+
async def contracts_static_info_by_name(self,contract_names : List[str])-> Contracts:
|
|
76
|
+
|
|
77
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
78
|
+
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/name',
|
|
79
|
+
params=[('contract_names', name) for name in contract_names]
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if data.is_success :
|
|
83
|
+
|
|
84
|
+
return data.json()
|
|
85
|
+
|
|
86
|
+
else :
|
|
87
|
+
|
|
88
|
+
raise ValueError(data.json().get('detail'))
|
|
89
|
+
|
|
90
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
91
|
+
|
|
92
|
+
async def contracts_static_info_by_id(self,contract_ids : List[str | int])-> Contracts:
|
|
93
|
+
|
|
94
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
95
|
+
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/id',
|
|
96
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
if data.is_success :
|
|
100
|
+
|
|
101
|
+
return data.json()
|
|
102
|
+
|
|
103
|
+
else :
|
|
104
|
+
|
|
105
|
+
raise ValueError(data.json().get('detail'))
|
|
106
|
+
|
|
107
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
108
|
+
|
|
109
|
+
async def live_overview_by_name(self,contract_names : List[str])-> OverviewResponse:
|
|
110
|
+
|
|
111
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
112
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/overview/contract/name',
|
|
113
|
+
params=[('contract_names', name) for name in contract_names]
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
if data.is_success :
|
|
117
|
+
|
|
118
|
+
return data.json()
|
|
119
|
+
|
|
120
|
+
else :
|
|
121
|
+
|
|
122
|
+
raise ValueError(data.json().get('detail'))
|
|
123
|
+
|
|
124
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
125
|
+
|
|
126
|
+
async def live_overview_by_id(self,contract_ids : List[str | int])-> OverviewResponse:
|
|
127
|
+
|
|
128
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
129
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/overview/contract/id',
|
|
130
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
if data.is_success :
|
|
134
|
+
|
|
135
|
+
return data.json()
|
|
136
|
+
|
|
137
|
+
else :
|
|
138
|
+
|
|
139
|
+
raise ValueError(data.json().get('detail'))
|
|
140
|
+
|
|
141
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
142
|
+
|
|
143
|
+
async def live_best_limit_by_name(self,contract_names : List[str])-> BestLimitResponse:
|
|
144
|
+
|
|
145
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
146
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/best-limit/contract/name',
|
|
147
|
+
params=[('contract_names', name) for name in contract_names]
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
if data.is_success :
|
|
151
|
+
|
|
152
|
+
return data.json()
|
|
153
|
+
|
|
154
|
+
else :
|
|
155
|
+
|
|
156
|
+
raise ValueError(data.json().get('detail'))
|
|
157
|
+
|
|
158
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
159
|
+
|
|
160
|
+
async def live_best_limit_by_id(self,contract_ids : List[str | int])-> BestLimitResponse:
|
|
161
|
+
|
|
162
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
163
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/best-limit/contract/id',
|
|
164
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
if data.is_success :
|
|
168
|
+
|
|
169
|
+
return data.json()
|
|
170
|
+
|
|
171
|
+
else :
|
|
172
|
+
|
|
173
|
+
raise ValueError(data.json().get('detail'))
|
|
174
|
+
|
|
175
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
176
|
+
|
|
177
|
+
async def live_aggregate_by_name(self,contract_names : List[str])-> AggregateResponse:
|
|
178
|
+
|
|
179
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
180
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/aggregate/contract/name',
|
|
181
|
+
params=[('contract_names', name) for name in contract_names]
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
if data.is_success :
|
|
185
|
+
|
|
186
|
+
return data.json()
|
|
187
|
+
|
|
188
|
+
else :
|
|
189
|
+
|
|
190
|
+
raise ValueError(data.json().get('detail'))
|
|
191
|
+
|
|
192
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
async def live_aggregate_by_id(self,contract_ids : List[str | int])-> AggregateResponse :
|
|
196
|
+
|
|
197
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
198
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/aggregate/contract/id',
|
|
199
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
if data.is_success :
|
|
203
|
+
|
|
204
|
+
return data.json()
|
|
205
|
+
|
|
206
|
+
else :
|
|
207
|
+
|
|
208
|
+
raise ValueError(data.json().get('detail'))
|
|
209
|
+
|
|
210
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
211
|
+
|
|
212
|
+
async def live_contract_info_by_name(self,contract_names : List[str])-> ContractInfoResponse:
|
|
213
|
+
|
|
214
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
215
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/contract-info/contract/name',
|
|
216
|
+
params=[('contract_names', name) for name in contract_names]
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
if data.is_success :
|
|
220
|
+
|
|
221
|
+
return data.json()
|
|
222
|
+
|
|
223
|
+
else :
|
|
224
|
+
|
|
225
|
+
raise ValueError(data.json().get('detail'))
|
|
226
|
+
|
|
227
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
async def live_contract_info_by_id(self,contract_ids : List[str | int])-> ContractInfoResponse :
|
|
231
|
+
|
|
232
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
233
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/contract-info/contract/id',
|
|
234
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
if data.is_success :
|
|
238
|
+
|
|
239
|
+
return data.json()
|
|
240
|
+
|
|
241
|
+
else :
|
|
242
|
+
|
|
243
|
+
raise ValueError(data.json().get('detail'))
|
|
244
|
+
|
|
245
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
246
|
+
|
|
247
|
+
async def live_allowed_price_range_by_name(self,contract_names : List[str])-> AllowedPriceRangeResponse:
|
|
248
|
+
|
|
249
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
250
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/allowed-price-range/contract/name',
|
|
251
|
+
params=[('contract_names', name) for name in contract_names]
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
if data.is_success :
|
|
255
|
+
|
|
256
|
+
return data.json()
|
|
257
|
+
|
|
258
|
+
else :
|
|
259
|
+
|
|
260
|
+
raise ValueError(data.json().get('detail'))
|
|
261
|
+
|
|
262
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
async def live_allowed_price_range_by_id(self,contract_ids : List[str | int])-> AllowedPriceRangeResponse :
|
|
266
|
+
|
|
267
|
+
data = await self.__AuthAsyncClient.httpx_Client.get(
|
|
268
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/allowed-price-range/contract/id',
|
|
269
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
if data.is_success :
|
|
273
|
+
|
|
274
|
+
return data.json()
|
|
275
|
+
|
|
276
|
+
else :
|
|
277
|
+
|
|
278
|
+
raise ValueError(data.json().get('detail'))
|
|
279
|
+
|
|
280
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
async def websocket_by_name(
|
|
284
|
+
self,
|
|
285
|
+
contract_names: List[str],
|
|
286
|
+
event: Event | None = None,
|
|
287
|
+
)-> AsyncGenerator[
|
|
288
|
+
WebsocketBase_contractName,
|
|
289
|
+
None
|
|
290
|
+
]:
|
|
291
|
+
|
|
292
|
+
if not isinstance(event,Event):
|
|
293
|
+
event = Event()
|
|
294
|
+
event.set()
|
|
295
|
+
|
|
296
|
+
async with connect(
|
|
297
|
+
uri=(
|
|
298
|
+
f"wss://core.hedgetech.ir/data-engine/ime/live/data/websocket/contract/name?"
|
|
299
|
+
+ "&".join(f"contract_name={s}" for s in contract_names)
|
|
300
|
+
),
|
|
301
|
+
additional_headers=self.__AuthAsyncClient.token
|
|
302
|
+
) as ws:
|
|
303
|
+
|
|
304
|
+
while event.is_set():
|
|
305
|
+
|
|
306
|
+
try : yield loads(await wait_for(ws.recv(), timeout=2))
|
|
307
|
+
|
|
308
|
+
except TimeoutError:
|
|
309
|
+
await sleep(0)
|
|
310
|
+
continue
|
|
311
|
+
|
|
312
|
+
except Exception:
|
|
313
|
+
await ws.close()
|
|
314
|
+
break
|
|
315
|
+
|
|
316
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
317
|
+
|
|
318
|
+
async def websocket_by_id(
|
|
319
|
+
self,
|
|
320
|
+
contract_ids: List[str | int],
|
|
321
|
+
event: Event | None = None,
|
|
322
|
+
)-> AsyncGenerator[
|
|
323
|
+
WebsocketBase_contractId,
|
|
324
|
+
None
|
|
325
|
+
]:
|
|
326
|
+
|
|
327
|
+
if not isinstance(event,Event):
|
|
328
|
+
event = Event()
|
|
329
|
+
event.set()
|
|
330
|
+
|
|
331
|
+
async with connect(
|
|
332
|
+
uri=(
|
|
333
|
+
f"wss://core.hedgetech.ir/data-engine/ime/live/data/websocket/contract/id?"
|
|
334
|
+
+ "&".join(f"contract_id={s}" for s in contract_ids)
|
|
335
|
+
),
|
|
336
|
+
additional_headers=self.__AuthAsyncClient.token
|
|
337
|
+
) as ws:
|
|
338
|
+
|
|
339
|
+
while event.is_set():
|
|
340
|
+
|
|
341
|
+
try : yield loads(await wait_for(ws.recv(), timeout=2))
|
|
342
|
+
|
|
343
|
+
except TimeoutError:
|
|
344
|
+
await sleep(0)
|
|
345
|
+
continue
|
|
346
|
+
|
|
347
|
+
except Exception:
|
|
348
|
+
await ws.close()
|
|
349
|
+
break
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# ========================================|======================================== #
|
|
2
|
+
# Imports #
|
|
3
|
+
# ========================================|======================================== #
|
|
4
|
+
|
|
5
|
+
from threading import Event
|
|
6
|
+
from websockets.sync.client import connect
|
|
7
|
+
from json import loads
|
|
8
|
+
from HedgeTech.Auth import AuthSyncClient
|
|
9
|
+
from typing import (
|
|
10
|
+
Literal,
|
|
11
|
+
List,
|
|
12
|
+
Generator,
|
|
13
|
+
)
|
|
14
|
+
from .__io_types import (
|
|
15
|
+
WebsocketBase_contractName,
|
|
16
|
+
WebsocketBase_contractId,
|
|
17
|
+
|
|
18
|
+
OverviewResponse,
|
|
19
|
+
Contracts,
|
|
20
|
+
|
|
21
|
+
ContractInfoResponse,
|
|
22
|
+
AllowedPriceRangeResponse,
|
|
23
|
+
AggregateResponse,
|
|
24
|
+
BestLimitResponse,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# ========================================|======================================== #
|
|
28
|
+
# Class Definitions #
|
|
29
|
+
# ========================================|======================================== #
|
|
30
|
+
|
|
31
|
+
class DataEngine_Ime_SyncClient:
|
|
32
|
+
|
|
33
|
+
def __init__(
|
|
34
|
+
self,
|
|
35
|
+
AuthSyncClient : AuthSyncClient,
|
|
36
|
+
):
|
|
37
|
+
|
|
38
|
+
self.__AuthSyncClient = AuthSyncClient
|
|
39
|
+
|
|
40
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
41
|
+
|
|
42
|
+
def search_contracts(
|
|
43
|
+
self,
|
|
44
|
+
market : Literal[
|
|
45
|
+
"IMEDepositCertificate",
|
|
46
|
+
"IMEFutures",
|
|
47
|
+
"IMEOption",
|
|
48
|
+
],
|
|
49
|
+
Search_char : str,
|
|
50
|
+
)-> Contracts :
|
|
51
|
+
|
|
52
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
53
|
+
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/search',
|
|
54
|
+
params={
|
|
55
|
+
'market' : market,
|
|
56
|
+
'Search_char' : Search_char
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if data.is_success :
|
|
61
|
+
|
|
62
|
+
return data.json()
|
|
63
|
+
|
|
64
|
+
else :
|
|
65
|
+
|
|
66
|
+
raise ValueError(data.json().get('detail'))
|
|
67
|
+
|
|
68
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
69
|
+
|
|
70
|
+
def contracts_static_info_by_name(self,contract_names : List[str])-> Contracts:
|
|
71
|
+
|
|
72
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
73
|
+
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/name',
|
|
74
|
+
params=[('contract_names', name) for name in contract_names]
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
if data.is_success :
|
|
78
|
+
|
|
79
|
+
return data.json()
|
|
80
|
+
|
|
81
|
+
else :
|
|
82
|
+
|
|
83
|
+
raise ValueError(data.json().get('detail'))
|
|
84
|
+
|
|
85
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
86
|
+
|
|
87
|
+
def contracts_static_info_by_id(self,contract_ids : List[str | int])-> Contracts:
|
|
88
|
+
|
|
89
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
90
|
+
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/id',
|
|
91
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if data.is_success :
|
|
95
|
+
|
|
96
|
+
return data.json()
|
|
97
|
+
|
|
98
|
+
else :
|
|
99
|
+
|
|
100
|
+
raise ValueError(data.json().get('detail'))
|
|
101
|
+
|
|
102
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
103
|
+
|
|
104
|
+
def live_overview_by_name(self,contract_names : List[str])-> OverviewResponse:
|
|
105
|
+
|
|
106
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
107
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/overview/contract/name',
|
|
108
|
+
params=[('contract_names', name) for name in contract_names]
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
if data.is_success :
|
|
112
|
+
|
|
113
|
+
return data.json()
|
|
114
|
+
|
|
115
|
+
else :
|
|
116
|
+
|
|
117
|
+
raise ValueError(data.json().get('detail'))
|
|
118
|
+
|
|
119
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
120
|
+
|
|
121
|
+
def live_overview_by_id(self,contract_ids : List[str | int])-> OverviewResponse:
|
|
122
|
+
|
|
123
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
124
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/overview/contract/id',
|
|
125
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
if data.is_success :
|
|
129
|
+
|
|
130
|
+
return data.json()
|
|
131
|
+
|
|
132
|
+
else :
|
|
133
|
+
|
|
134
|
+
raise ValueError(data.json().get('detail'))
|
|
135
|
+
|
|
136
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
137
|
+
|
|
138
|
+
def live_best_limit_by_name(self,contract_names : List[str])-> BestLimitResponse:
|
|
139
|
+
|
|
140
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
141
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/best-limit/contract/name',
|
|
142
|
+
params=[('contract_names', name) for name in contract_names]
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
if data.is_success :
|
|
146
|
+
|
|
147
|
+
return data.json()
|
|
148
|
+
|
|
149
|
+
else :
|
|
150
|
+
|
|
151
|
+
raise ValueError(data.json().get('detail'))
|
|
152
|
+
|
|
153
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
154
|
+
|
|
155
|
+
def live_best_limit_by_id(self,contract_ids : List[str | int])-> BestLimitResponse:
|
|
156
|
+
|
|
157
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
158
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/best-limit/contract/id',
|
|
159
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
if data.is_success :
|
|
163
|
+
|
|
164
|
+
return data.json()
|
|
165
|
+
|
|
166
|
+
else :
|
|
167
|
+
|
|
168
|
+
raise ValueError(data.json().get('detail'))
|
|
169
|
+
|
|
170
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
171
|
+
|
|
172
|
+
def live_aggregate_by_name(self,contract_names : List[str])-> AggregateResponse:
|
|
173
|
+
|
|
174
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
175
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/aggregate/contract/name',
|
|
176
|
+
params=[('contract_names', name) for name in contract_names]
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
if data.is_success :
|
|
180
|
+
|
|
181
|
+
return data.json()
|
|
182
|
+
|
|
183
|
+
else :
|
|
184
|
+
|
|
185
|
+
raise ValueError(data.json().get('detail'))
|
|
186
|
+
|
|
187
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def live_aggregate_by_id(self,contract_ids : List[str | int])-> AggregateResponse :
|
|
191
|
+
|
|
192
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
193
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/aggregate/contract/id',
|
|
194
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
if data.is_success :
|
|
198
|
+
|
|
199
|
+
return data.json()
|
|
200
|
+
|
|
201
|
+
else :
|
|
202
|
+
|
|
203
|
+
raise ValueError(data.json().get('detail'))
|
|
204
|
+
|
|
205
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
206
|
+
|
|
207
|
+
def live_contract_info_by_name(self,contract_names : List[str])-> ContractInfoResponse:
|
|
208
|
+
|
|
209
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
210
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/contract-info/contract/name',
|
|
211
|
+
params=[('contract_names', name) for name in contract_names]
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
if data.is_success :
|
|
215
|
+
|
|
216
|
+
return data.json()
|
|
217
|
+
|
|
218
|
+
else :
|
|
219
|
+
|
|
220
|
+
raise ValueError(data.json().get('detail'))
|
|
221
|
+
|
|
222
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def live_contract_info_by_id(self,contract_ids : List[str | int])-> ContractInfoResponse :
|
|
226
|
+
|
|
227
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
228
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/contract-info/contract/id',
|
|
229
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
if data.is_success :
|
|
233
|
+
|
|
234
|
+
return data.json()
|
|
235
|
+
|
|
236
|
+
else :
|
|
237
|
+
|
|
238
|
+
raise ValueError(data.json().get('detail'))
|
|
239
|
+
|
|
240
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
241
|
+
|
|
242
|
+
def live_allowed_price_range_by_name(self,contract_names : List[str])-> AllowedPriceRangeResponse:
|
|
243
|
+
|
|
244
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
245
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/allowed-price-range/contract/name',
|
|
246
|
+
params=[('contract_names', name) for name in contract_names]
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
if data.is_success :
|
|
250
|
+
|
|
251
|
+
return data.json()
|
|
252
|
+
|
|
253
|
+
else :
|
|
254
|
+
|
|
255
|
+
raise ValueError(data.json().get('detail'))
|
|
256
|
+
|
|
257
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def live_allowed_price_range_by_id(self,contract_ids : List[str | int])-> AllowedPriceRangeResponse :
|
|
261
|
+
|
|
262
|
+
data = self.__AuthSyncClient.httpx_Client.get(
|
|
263
|
+
url='https://core.hedgetech.ir/data-engine/ime/live/data/allowed-price-range/contract/id',
|
|
264
|
+
params=[('contract_ids', id) for id in contract_ids]
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
if data.is_success :
|
|
268
|
+
|
|
269
|
+
return data.json()
|
|
270
|
+
|
|
271
|
+
else :
|
|
272
|
+
|
|
273
|
+
raise ValueError(data.json().get('detail'))
|
|
274
|
+
|
|
275
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
276
|
+
|
|
277
|
+
def websocket_by_name(
|
|
278
|
+
self,
|
|
279
|
+
contract_names: List[str],
|
|
280
|
+
event: Event | None = None,
|
|
281
|
+
)-> Generator[
|
|
282
|
+
WebsocketBase_contractName,
|
|
283
|
+
None
|
|
284
|
+
]:
|
|
285
|
+
|
|
286
|
+
if not isinstance(event,Event):
|
|
287
|
+
event = Event()
|
|
288
|
+
event.set()
|
|
289
|
+
|
|
290
|
+
with connect(
|
|
291
|
+
uri=(
|
|
292
|
+
f"wss://core.hedgetech.ir/data-engine/ime/live/data/websocket/contract/name?"
|
|
293
|
+
+ "&".join(f"contract_name={s}" for s in contract_names)
|
|
294
|
+
),
|
|
295
|
+
additional_headers=self.__AuthSyncClient.token
|
|
296
|
+
) as ws:
|
|
297
|
+
|
|
298
|
+
while event.is_set():
|
|
299
|
+
|
|
300
|
+
try : yield loads(ws.recv(timeout=2))
|
|
301
|
+
except TimeoutError : continue
|
|
302
|
+
except Exception:
|
|
303
|
+
ws.close()
|
|
304
|
+
break
|
|
305
|
+
|
|
306
|
+
# +--------------------------------------------------------------------------------------+ #
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
def websocket_by_id(
|
|
310
|
+
self,
|
|
311
|
+
contract_ids: List[str | int],
|
|
312
|
+
event: Event | None = None,
|
|
313
|
+
)-> Generator[
|
|
314
|
+
WebsocketBase_contractId,
|
|
315
|
+
None
|
|
316
|
+
]:
|
|
317
|
+
|
|
318
|
+
if not isinstance(event,Event):
|
|
319
|
+
event = Event()
|
|
320
|
+
event.set()
|
|
321
|
+
|
|
322
|
+
with connect(
|
|
323
|
+
uri=(
|
|
324
|
+
f"wss://core.hedgetech.ir/data-engine/ime/live/data/websocket/contract/id?"
|
|
325
|
+
+ "&".join(f"contract_id={s}" for s in contract_ids)
|
|
326
|
+
),
|
|
327
|
+
additional_headers=self.__AuthSyncClient.token
|
|
328
|
+
) as ws:
|
|
329
|
+
|
|
330
|
+
while event.is_set():
|
|
331
|
+
|
|
332
|
+
try : yield loads(ws.recv(timeout=2))
|
|
333
|
+
except TimeoutError : continue
|
|
334
|
+
except Exception:
|
|
335
|
+
ws.close()
|
|
336
|
+
break
|
|
337
|
+
|