Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d775e9000 | ||
|
|
6c943a559c | ||
|
|
ed991a3035 | ||
|
|
52367d54e1 | ||
|
|
c8090ba334 | ||
|
|
854bee9f9e | ||
|
|
3a603db3cf | ||
|
|
3906a203a6 | ||
|
|
a49db4397c | ||
|
|
3d947bc558 | ||
|
|
2af7dfd648 | ||
|
|
bde8c980ef | ||
|
|
e63dcddbea | ||
|
|
cedbd76d0e | ||
|
|
52be955e6e | ||
|
|
ecc1070f1c | ||
|
|
126eab66f7 | ||
|
|
8a5f3142ef | ||
|
|
9cfd36a891 | ||
|
|
034c9a50ea | ||
|
|
17bea4f2a3 | ||
|
|
747b257432 | ||
|
|
e6bd5852c2 | ||
|
|
88359c882f | ||
|
|
420ebda323 | ||
|
|
83314e0074 |
No files matched your search
@@ -209,3 +209,5 @@ __marimo__/
|
||||
*.ipynb
|
||||
requirements.txt
|
||||
*test*.py
|
||||
|
||||
.vscode
|
||||
@@ -0,0 +1,349 @@
|
||||
# ========================================|======================================== #
|
||||
# Imports #
|
||||
# ========================================|======================================== #
|
||||
|
||||
from asyncio import (
|
||||
Event,
|
||||
wait_for,
|
||||
TimeoutError,
|
||||
sleep,
|
||||
)
|
||||
from websockets.asyncio.client import connect
|
||||
from json import loads
|
||||
from HedgeTech.Auth import AuthAsyncClient
|
||||
from typing import (
|
||||
Literal,
|
||||
List,
|
||||
AsyncGenerator,
|
||||
)
|
||||
from .__io_types import (
|
||||
WebsocketBase_contractName,
|
||||
WebsocketBase_contractId,
|
||||
|
||||
OverviewResponse,
|
||||
Contracts,
|
||||
|
||||
ContractInfoResponse,
|
||||
AllowedPriceRangeResponse,
|
||||
AggregateResponse,
|
||||
BestLimitResponse,
|
||||
)
|
||||
|
||||
# ========================================|======================================== #
|
||||
# Class Definitions #
|
||||
# ========================================|======================================== #
|
||||
|
||||
class DataEngine_Ime_AsyncClient:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
AuthAsyncClient : AuthAsyncClient,
|
||||
):
|
||||
|
||||
self.__AuthAsyncClient = AuthAsyncClient
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def search_contracts(
|
||||
self,
|
||||
market : Literal[
|
||||
"IMEDepositCertificate",
|
||||
"IMEFutures",
|
||||
"IMEOption",
|
||||
],
|
||||
Search_char : str,
|
||||
)-> Contracts :
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/search',
|
||||
params={
|
||||
'market' : market,
|
||||
'Search_char' : Search_char
|
||||
}
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def contracts_static_info_by_name(self,contract_names : List[str])-> Contracts:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def contracts_static_info_by_id(self,contract_ids : List[str | int])-> Contracts:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def live_overview_by_name(self,contract_names : List[str])-> OverviewResponse:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/overview/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def live_overview_by_id(self,contract_ids : List[str | int])-> OverviewResponse:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/overview/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def live_best_limit_by_name(self,contract_names : List[str])-> BestLimitResponse:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/best-limit/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def live_best_limit_by_id(self,contract_ids : List[str | int])-> BestLimitResponse:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/best-limit/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def live_aggregate_by_name(self,contract_names : List[str])-> AggregateResponse:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/aggregate/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
async def live_aggregate_by_id(self,contract_ids : List[str | int])-> AggregateResponse :
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/aggregate/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def live_contract_info_by_name(self,contract_names : List[str])-> ContractInfoResponse:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/contract-info/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
async def live_contract_info_by_id(self,contract_ids : List[str | int])-> ContractInfoResponse :
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/contract-info/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def live_allowed_price_range_by_name(self,contract_names : List[str])-> AllowedPriceRangeResponse:
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/allowed-price-range/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
async def live_allowed_price_range_by_id(self,contract_ids : List[str | int])-> AllowedPriceRangeResponse :
|
||||
|
||||
data = await self.__AuthAsyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/allowed-price-range/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
async def websocket_by_name(
|
||||
self,
|
||||
contract_names: List[str],
|
||||
event: Event | None = None,
|
||||
)-> AsyncGenerator[
|
||||
WebsocketBase_contractName,
|
||||
None
|
||||
]:
|
||||
|
||||
if not isinstance(event,Event):
|
||||
event = Event()
|
||||
event.set()
|
||||
|
||||
async with connect(
|
||||
uri=(
|
||||
f"wss://core.hedgetech.ir/data-engine/ime/live/data/websocket/contract/name?"
|
||||
+ "&".join(f"contract_name={s}" for s in contract_names)
|
||||
),
|
||||
additional_headers=self.__AuthAsyncClient.token
|
||||
) as ws:
|
||||
|
||||
while event.is_set():
|
||||
|
||||
try : yield loads(await wait_for(ws.recv(), timeout=2))
|
||||
|
||||
except TimeoutError:
|
||||
await sleep(0)
|
||||
continue
|
||||
|
||||
except Exception:
|
||||
await ws.close()
|
||||
break
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def websocket_by_id(
|
||||
self,
|
||||
contract_ids: List[str | int],
|
||||
event: Event | None = None,
|
||||
)-> AsyncGenerator[
|
||||
WebsocketBase_contractId,
|
||||
None
|
||||
]:
|
||||
|
||||
if not isinstance(event,Event):
|
||||
event = Event()
|
||||
event.set()
|
||||
|
||||
async with connect(
|
||||
uri=(
|
||||
f"wss://core.hedgetech.ir/data-engine/ime/live/data/websocket/contract/id?"
|
||||
+ "&".join(f"contract_id={s}" for s in contract_ids)
|
||||
),
|
||||
additional_headers=self.__AuthAsyncClient.token
|
||||
) as ws:
|
||||
|
||||
while event.is_set():
|
||||
|
||||
try : yield loads(await wait_for(ws.recv(), timeout=2))
|
||||
|
||||
except TimeoutError:
|
||||
await sleep(0)
|
||||
continue
|
||||
|
||||
except Exception:
|
||||
await ws.close()
|
||||
break
|
||||
@@ -0,0 +1,339 @@
|
||||
# ========================================|======================================== #
|
||||
# Imports #
|
||||
# ========================================|======================================== #
|
||||
|
||||
from threading import Event
|
||||
from websockets.sync.client import connect
|
||||
from json import loads
|
||||
from HedgeTech.Auth import AuthSyncClient
|
||||
from typing import (
|
||||
Literal,
|
||||
List,
|
||||
Generator,
|
||||
)
|
||||
from .__io_types import (
|
||||
WebsocketBase_contractName,
|
||||
WebsocketBase_contractId,
|
||||
|
||||
OverviewResponse,
|
||||
Contracts,
|
||||
|
||||
ContractInfoResponse,
|
||||
AllowedPriceRangeResponse,
|
||||
AggregateResponse,
|
||||
BestLimitResponse,
|
||||
)
|
||||
|
||||
# ========================================|======================================== #
|
||||
# Class Definitions #
|
||||
# ========================================|======================================== #
|
||||
|
||||
class DataEngine_Ime_SyncClient:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
AuthSyncClient : AuthSyncClient,
|
||||
):
|
||||
|
||||
self.__AuthSyncClient = AuthSyncClient
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def search_contracts(
|
||||
self,
|
||||
market : Literal[
|
||||
"IMEDepositCertificate",
|
||||
"IMEFutures",
|
||||
"IMEOption",
|
||||
],
|
||||
Search_char : str,
|
||||
)-> Contracts :
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/search',
|
||||
params={
|
||||
'market' : market,
|
||||
'Search_char' : Search_char
|
||||
}
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def contracts_static_info_by_name(self,contract_names : List[str])-> Contracts:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def contracts_static_info_by_id(self,contract_ids : List[str | int])-> Contracts:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/static/data/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def live_overview_by_name(self,contract_names : List[str])-> OverviewResponse:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/overview/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def live_overview_by_id(self,contract_ids : List[str | int])-> OverviewResponse:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/overview/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def live_best_limit_by_name(self,contract_names : List[str])-> BestLimitResponse:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/best-limit/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def live_best_limit_by_id(self,contract_ids : List[str | int])-> BestLimitResponse:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/best-limit/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def live_aggregate_by_name(self,contract_names : List[str])-> AggregateResponse:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/aggregate/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
def live_aggregate_by_id(self,contract_ids : List[str | int])-> AggregateResponse :
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/aggregate/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def live_contract_info_by_name(self,contract_names : List[str])-> ContractInfoResponse:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/contract-info/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
def live_contract_info_by_id(self,contract_ids : List[str | int])-> ContractInfoResponse :
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/contract-info/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def live_allowed_price_range_by_name(self,contract_names : List[str])-> AllowedPriceRangeResponse:
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/allowed-price-range/contract/name',
|
||||
params=[('contract_names', name) for name in contract_names]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
def live_allowed_price_range_by_id(self,contract_ids : List[str | int])-> AllowedPriceRangeResponse :
|
||||
|
||||
data = self.__AuthSyncClient.httpx_Client.get(
|
||||
url='https://core.hedgetech.ir/data-engine/ime/live/data/allowed-price-range/contract/id',
|
||||
params=[('contract_ids', id) for id in contract_ids]
|
||||
)
|
||||
|
||||
if data.is_success :
|
||||
|
||||
return data.json()
|
||||
|
||||
else :
|
||||
|
||||
raise ValueError(data.json().get('detail'))
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def websocket_by_name(
|
||||
self,
|
||||
contract_names: List[str],
|
||||
event: Event | None = None,
|
||||
)-> Generator[
|
||||
WebsocketBase_contractName,
|
||||
None,
|
||||
None
|
||||
]:
|
||||
|
||||
if not isinstance(event,Event):
|
||||
event = Event()
|
||||
event.set()
|
||||
|
||||
with connect(
|
||||
uri=(
|
||||
f"wss://core.hedgetech.ir/data-engine/ime/live/data/websocket/contract/name?"
|
||||
+ "&".join(f"contract_name={s}" for s in contract_names)
|
||||
),
|
||||
additional_headers=self.__AuthSyncClient.token
|
||||
) as ws:
|
||||
|
||||
while event.is_set():
|
||||
|
||||
try : yield loads(ws.recv(timeout=2))
|
||||
except TimeoutError : continue
|
||||
except Exception:
|
||||
ws.close()
|
||||
break
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
def websocket_by_id(
|
||||
self,
|
||||
contract_ids: List[str | int],
|
||||
event: Event | None = None,
|
||||
)-> Generator[
|
||||
WebsocketBase_contractId,
|
||||
None,
|
||||
None
|
||||
]:
|
||||
|
||||
if not isinstance(event,Event):
|
||||
event = Event()
|
||||
event.set()
|
||||
|
||||
with connect(
|
||||
uri=(
|
||||
f"wss://core.hedgetech.ir/data-engine/ime/live/data/websocket/contract/id?"
|
||||
+ "&".join(f"contract_id={s}" for s in contract_ids)
|
||||
),
|
||||
additional_headers=self.__AuthSyncClient.token
|
||||
) as ws:
|
||||
|
||||
while event.is_set():
|
||||
|
||||
try : yield loads(ws.recv(timeout=2))
|
||||
except TimeoutError : continue
|
||||
except Exception:
|
||||
ws.close()
|
||||
break
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
from .__AsyncClient import DataEngine_Ime_AsyncClient
|
||||
from .__SyncClient import DataEngine_Ime_SyncClient
|
||||
@@ -0,0 +1,12 @@
|
||||
from .__response import(
|
||||
WebsocketBase_contractName,
|
||||
WebsocketBase_contractId,
|
||||
|
||||
OverviewResponse,
|
||||
Contracts,
|
||||
|
||||
ContractInfoResponse,
|
||||
AllowedPriceRangeResponse,
|
||||
AggregateResponse,
|
||||
BestLimitResponse,
|
||||
)
|
||||
File diff suppressed because it is too large.
Load diff
@@ -2,3 +2,7 @@ from .__tse_ifb import (
|
||||
DataEngine_TseIfb_SyncClient,
|
||||
DataEngine_TseIfb_AsyncClient
|
||||
)
|
||||
from .__ime import (
|
||||
DataEngine_Ime_SyncClient,
|
||||
DataEngine_Ime_AsyncClient
|
||||
)
|
||||
@@ -2,7 +2,12 @@
|
||||
# Imports #
|
||||
# ========================================|======================================== #
|
||||
|
||||
from asyncio import Event
|
||||
from asyncio import (
|
||||
Event,
|
||||
wait_for,
|
||||
TimeoutError,
|
||||
sleep,
|
||||
)
|
||||
from websockets.asyncio.client import connect
|
||||
from json import loads
|
||||
from HedgeTech.Auth import AuthAsyncClient
|
||||
@@ -1461,7 +1466,7 @@ class DataEngine_TseIfb_AsyncClient:
|
||||
... print(update["data"])
|
||||
"""
|
||||
|
||||
if event is None :
|
||||
if not isinstance(event,Event):
|
||||
event = Event()
|
||||
event.set()
|
||||
|
||||
@@ -1476,9 +1481,13 @@ class DataEngine_TseIfb_AsyncClient:
|
||||
|
||||
while event.is_set():
|
||||
|
||||
try:
|
||||
yield loads(await ws.recv())
|
||||
except :
|
||||
try : yield loads(await wait_for(ws.recv(), timeout=2))
|
||||
|
||||
except TimeoutError:
|
||||
await sleep(0)
|
||||
continue
|
||||
|
||||
except Exception:
|
||||
await ws.close()
|
||||
break
|
||||
|
||||
@@ -1566,7 +1575,7 @@ class DataEngine_TseIfb_AsyncClient:
|
||||
... print(update["data"])
|
||||
"""
|
||||
|
||||
if event is None :
|
||||
if not isinstance(event,Event):
|
||||
event = Event()
|
||||
event.set()
|
||||
|
||||
@@ -1581,8 +1590,12 @@ class DataEngine_TseIfb_AsyncClient:
|
||||
|
||||
while event.is_set():
|
||||
|
||||
try:
|
||||
yield loads(await ws.recv())
|
||||
except :
|
||||
try: yield loads(await wait_for(ws.recv(), timeout=2))
|
||||
|
||||
except TimeoutError:
|
||||
await sleep(0)
|
||||
continue
|
||||
|
||||
except Exception:
|
||||
await ws.close()
|
||||
break
|
||||
@@ -1425,7 +1425,7 @@ class DataEngine_TseIfb_SyncClient:
|
||||
... print(update) # This will not run; method is not implemented
|
||||
"""
|
||||
|
||||
if event is None :
|
||||
if not isinstance(event,Event):
|
||||
event = Event()
|
||||
event.set()
|
||||
|
||||
@@ -1440,13 +1440,12 @@ class DataEngine_TseIfb_SyncClient:
|
||||
|
||||
while event.is_set():
|
||||
|
||||
try :
|
||||
yield loads(ws.recv())
|
||||
except :
|
||||
try : yield loads(ws.recv(timeout=2))
|
||||
except TimeoutError : continue
|
||||
except Exception:
|
||||
ws.close()
|
||||
break
|
||||
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def websocket_by_isin(
|
||||
@@ -1520,7 +1519,7 @@ class DataEngine_TseIfb_SyncClient:
|
||||
... print(update) # This will not run; method is not implemented
|
||||
"""
|
||||
|
||||
if event is None :
|
||||
if not isinstance(event,Event):
|
||||
event = Event()
|
||||
event.set()
|
||||
|
||||
@@ -1535,8 +1534,8 @@ class DataEngine_TseIfb_SyncClient:
|
||||
|
||||
while event.is_set():
|
||||
|
||||
try :
|
||||
yield loads(ws.recv())
|
||||
except :
|
||||
try : yield loads(ws.recv(timeout=2))
|
||||
except TimeoutError : continue
|
||||
except Exception:
|
||||
ws.close()
|
||||
break
|
||||
@@ -9,6 +9,7 @@ from typing import (
|
||||
Dict,
|
||||
Optional,
|
||||
TypedDict,
|
||||
Literal,
|
||||
)
|
||||
|
||||
# ========================================|======================================== #
|
||||
@@ -37,7 +38,15 @@ class WebsocketBase_symbolIsin(TypedDict):
|
||||
>>> message["symbolIsin"]
|
||||
'IR0001234567'
|
||||
"""
|
||||
channel: str
|
||||
channel: Literal[
|
||||
"best-limit",
|
||||
"order-book",
|
||||
"ohlcv-last-1m",
|
||||
"aggregate",
|
||||
"institutional-vs-individual",
|
||||
"contract-info",
|
||||
"fund-info",
|
||||
]
|
||||
symbolIsin: str
|
||||
timestamp: str
|
||||
|
||||
@@ -64,7 +73,15 @@ class WebsocketBase_symbolName(TypedDict):
|
||||
>>> message["symbolName"]
|
||||
'ETF001'
|
||||
"""
|
||||
channel: str
|
||||
channel: Literal[
|
||||
"best-limit",
|
||||
"order-book",
|
||||
"ohlcv-last-1m",
|
||||
"aggregate",
|
||||
"institutional-vs-individual",
|
||||
"contract-info",
|
||||
"fund-info",
|
||||
]
|
||||
symbolName: str
|
||||
timestamp: str
|
||||
|
||||
@@ -734,7 +751,6 @@ class Instruments(TypedDict):
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
class BestLimitItem(TypedDict):
|
||||
"""
|
||||
Represents the best limit order information at a given price level for a financial instrument.
|
||||
@@ -766,39 +782,6 @@ class BestLimitItem(TypedDict):
|
||||
sell_quantity: int
|
||||
sell_price: int
|
||||
|
||||
|
||||
class BestLimit(TypedDict):
|
||||
"""
|
||||
Represents the aggregated best limit orders for multiple instruments.
|
||||
|
||||
The structure is a nested dictionary where the first key is typically a symbol
|
||||
identifier (ISIN or symbolName) and the second key represents the order level or priority.
|
||||
|
||||
Attributes:
|
||||
items (Dict[str, Dict[str, BestLimitItem]]): Nested dictionary of BestLimitItem objects.
|
||||
- Outer key: Instrument identifier (e.g., ISIN or symbolName)
|
||||
- Inner key: Price level or order priority
|
||||
- Value: BestLimitItem for that level
|
||||
|
||||
Example:
|
||||
>>> best_limit: BestLimit = {
|
||||
... "ETF001": {
|
||||
... "1": {
|
||||
... "buy_order_count": 5,
|
||||
... "buy_quantity": 1000,
|
||||
... "buy_price": 12000,
|
||||
... "sell_order_count": 3,
|
||||
... "sell_quantity": 800,
|
||||
... "sell_price": 12100
|
||||
... }
|
||||
... }
|
||||
... }
|
||||
>>> best_limit["ETF001"]["1"]["sell_quantity"]
|
||||
800
|
||||
"""
|
||||
items: Dict[str, Dict[str, BestLimitItem]]
|
||||
|
||||
|
||||
class BestLimitResponse(TypedDict):
|
||||
"""
|
||||
Response structure for best limit orders from a REST API call.
|
||||
@@ -810,7 +793,18 @@ class BestLimitResponse(TypedDict):
|
||||
|
||||
Example:
|
||||
>>> response: BestLimitResponse = {
|
||||
... "Data": best_limit,
|
||||
... "Data": {
|
||||
... "ETF001": {
|
||||
... "1": {
|
||||
... "buy_order_count": 5,
|
||||
... "buy_quantity": 1000,
|
||||
... "buy_price": 12000,
|
||||
... "sell_order_count": 3,
|
||||
... "sell_quantity": 800,
|
||||
... "sell_price": 12100
|
||||
... },
|
||||
... },
|
||||
... },
|
||||
... "Status": {
|
||||
... "State": True,
|
||||
... "ServerTimeStamp": 1700350200.0,
|
||||
@@ -825,7 +819,13 @@ class BestLimitResponse(TypedDict):
|
||||
>>> response["Status"]["State"]
|
||||
True
|
||||
"""
|
||||
Data: BestLimit
|
||||
Data: Dict[
|
||||
str,
|
||||
Dict[
|
||||
Literal['1','2','3','4','5','6',],
|
||||
BestLimitItem
|
||||
]
|
||||
]
|
||||
Status: Status
|
||||
|
||||
|
||||
@@ -867,7 +867,10 @@ class BestLimit_WS_symbolIsin(WebsocketBase_symbolIsin):
|
||||
>>> ws_data["data"]["1"]["sell_price"]
|
||||
12100
|
||||
"""
|
||||
data: Dict[str, BestLimitItem]
|
||||
data: Dict[
|
||||
Literal['1','2','3','4','5','6',],
|
||||
BestLimitItem,
|
||||
]
|
||||
|
||||
|
||||
class BestLimit_WS_symbolName(WebsocketBase_symbolName):
|
||||
@@ -908,7 +911,10 @@ class BestLimit_WS_symbolName(WebsocketBase_symbolName):
|
||||
>>> ws_data["data"]["2"]["buy_price"]
|
||||
11950
|
||||
"""
|
||||
data: Dict[str, BestLimitItem]
|
||||
data: Dict[
|
||||
Literal['1','2','3','4','5','6',],
|
||||
BestLimitItem,
|
||||
]
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
@@ -1628,7 +1634,10 @@ class OverviewSecuritiesAndFunds(SecuritiesAndFunds):
|
||||
>>> overview["FundInfo"]["nav"]
|
||||
12500.0
|
||||
"""
|
||||
BestLimit: Dict[str, BestLimitItem]
|
||||
BestLimit: Dict[
|
||||
Literal['1','2','3','4','5','6',],
|
||||
BestLimitItem,
|
||||
]
|
||||
Aggregate: Aggregate
|
||||
institutional_vs_individual: institutional_vs_individual
|
||||
FundInfo: FundInfo
|
||||
@@ -1649,7 +1658,10 @@ class OverviewTreasuryBonds(TreasuryBonds):
|
||||
FundInfo (FundInfo)
|
||||
ContractInfo (ContractInfo)
|
||||
"""
|
||||
BestLimit: Dict[str, BestLimitItem]
|
||||
BestLimit: Dict[
|
||||
Literal['1','2','3','4','5','6',],
|
||||
BestLimitItem,
|
||||
]
|
||||
Aggregate: Aggregate
|
||||
institutional_vs_individual: institutional_vs_individual
|
||||
FundInfo: FundInfo
|
||||
@@ -1670,7 +1682,10 @@ class OverviewStockOptions(StockOptions):
|
||||
FundInfo (FundInfo)
|
||||
ContractInfo (ContractInfo)
|
||||
"""
|
||||
BestLimit: Dict[str, BestLimitItem]
|
||||
BestLimit: Dict[
|
||||
Literal['1','2','3','4','5','6',],
|
||||
BestLimitItem,
|
||||
]
|
||||
Aggregate: Aggregate
|
||||
institutional_vs_individual: institutional_vs_individual
|
||||
FundInfo: FundInfo
|
||||
@@ -1691,7 +1706,10 @@ class OverviewStockFuturess(StockFutures):
|
||||
FundInfo (FundInfo)
|
||||
ContractInfo (ContractInfo)
|
||||
"""
|
||||
BestLimit: Dict[str, BestLimitItem]
|
||||
BestLimit: Dict[
|
||||
Literal['1','2','3','4','5','6',],
|
||||
BestLimitItem,
|
||||
]
|
||||
Aggregate: Aggregate
|
||||
institutional_vs_individual: institutional_vs_individual
|
||||
FundInfo: FundInfo
|
||||
@@ -1728,7 +1746,8 @@ class OverviewResponse:
|
||||
True
|
||||
"""
|
||||
Data : Dict[
|
||||
str,Optional[
|
||||
str,
|
||||
Optional[
|
||||
Union[
|
||||
OverviewSecuritiesAndFunds,
|
||||
OverviewTreasuryBonds,
|
||||
|
||||
@@ -70,6 +70,8 @@ class Order:
|
||||
True if the order has been deleted.
|
||||
OrderId : HexUUID | None
|
||||
Unique identifier of the order after submission.
|
||||
OrderStatus : 'Unknown' | 'InQueue' | 'PartiallyFilled' | 'Cancelled' | 'Broken' | 'Settled'
|
||||
Current lifecycle status of the order. The value is 'Unknown' until a status is received from the server.
|
||||
|
||||
Methods
|
||||
-------
|
||||
@@ -93,6 +95,14 @@ class Order:
|
||||
self.Price : int = Price
|
||||
self.Volume : int = Volume
|
||||
self.is_deleted : bool = False
|
||||
self.OrderStatus : Literal[
|
||||
'Unknown',
|
||||
'InQueue',
|
||||
'PartiallyFilled',
|
||||
'Cancelled',
|
||||
'Broken',
|
||||
'Settled',
|
||||
] = 'Unknown'
|
||||
|
||||
self.OrderId : HexUUID | None = None
|
||||
|
||||
@@ -118,6 +128,8 @@ class Order:
|
||||
'953097ac6ced45ca8ef205b76ca6faf2'
|
||||
"""
|
||||
|
||||
try :
|
||||
|
||||
if self.OrderId is None :
|
||||
|
||||
SendOrder_Response = await self.__AuthASyncClient.httpx_Client.post(**self.__SendOrder_RequestInfo)
|
||||
@@ -133,6 +145,8 @@ class Order:
|
||||
|
||||
else : return None
|
||||
|
||||
except : return None
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
async def Edit(
|
||||
self,
|
||||
@@ -177,6 +191,8 @@ class Order:
|
||||
)
|
||||
"""
|
||||
|
||||
try :
|
||||
|
||||
if self.OrderId is not None:
|
||||
|
||||
Edit_response = await self.__AuthASyncClient.httpx_Client.patch(
|
||||
@@ -202,13 +218,39 @@ class Order:
|
||||
self.ValidityDate = ValidityDate
|
||||
self.Price = Edit_response['Data']['order_price']
|
||||
self.Volume = Edit_response['Data']['order_volume']
|
||||
return None
|
||||
|
||||
case _ :
|
||||
|
||||
status_respnse = await self.Status()
|
||||
|
||||
if status_respnse and (
|
||||
status_respnse['order_status'] in ('PartiallyFilled' , 'InQueue')
|
||||
and status_respnse['RemainedVolume'] + status_respnse['ExecutedVolume'] == Volume
|
||||
and status_respnse['Price'] == Price
|
||||
and status_respnse['ValidityDate'] == ValidityDate
|
||||
and status_respnse['ValidityType'] == Order_ValidityType
|
||||
):
|
||||
|
||||
self.ValidityType = status_respnse['ValidityType']
|
||||
self.ValidityDate = status_respnse['ValidityDate']
|
||||
self.Price = status_respnse['Price']
|
||||
self.Volume = status_respnse['RemainedVolume'] + status_respnse['ExecutedVolume']
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
return None
|
||||
|
||||
elif status_respnse and status_respnse['order_status'] not in ('PartiallyFilled' , 'InQueue'):
|
||||
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
|
||||
return None
|
||||
|
||||
case _ : return None
|
||||
else : return None
|
||||
|
||||
else : return None
|
||||
|
||||
except : return None
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def Status(self)-> OrderStatus | None:
|
||||
@@ -221,7 +263,7 @@ class Order:
|
||||
OrderStatus | None
|
||||
A dictionary containing the current order status with the following keys:
|
||||
- order_uuid: HexUUID, unique identifier of the order.
|
||||
- order_status: 'InQueue' | 'Cancelled' | 'Broken' | 'Settled'
|
||||
- order_status: 'InQueue' | 'PartiallyFilled' | 'Cancelled' | 'Broken' | 'Settled'
|
||||
- Price: int, the order price.
|
||||
- Volume: int, the original order volume.
|
||||
- RemainedVolume: int, volume remaining unexecuted.
|
||||
@@ -246,6 +288,7 @@ class Order:
|
||||
'ValidityDate': 0
|
||||
}
|
||||
"""
|
||||
try :
|
||||
|
||||
if self.OrderId is not None:
|
||||
|
||||
@@ -258,12 +301,17 @@ class Order:
|
||||
|
||||
case 200:
|
||||
|
||||
return status_respnse.json()['Data']
|
||||
status_respnse = status_respnse.json()['Data']
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
|
||||
return status_respnse
|
||||
|
||||
case _ : return None
|
||||
|
||||
else : return None
|
||||
|
||||
except : return None
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
async def Delete(self)-> None:
|
||||
@@ -284,6 +332,8 @@ class Order:
|
||||
True
|
||||
"""
|
||||
|
||||
try :
|
||||
|
||||
if self.OrderId is not None:
|
||||
|
||||
Delete_respnse = await self.__AuthASyncClient.httpx_Client.delete(
|
||||
@@ -297,12 +347,28 @@ class Order:
|
||||
case 200:
|
||||
|
||||
self.is_deleted = True
|
||||
self.OrderStatus = 'Cancelled'
|
||||
return None
|
||||
|
||||
case _ : return None
|
||||
case _ :
|
||||
|
||||
status_respnse = await self.Status()
|
||||
|
||||
if status_respnse and status_respnse['order_status'] == 'Cancelled':
|
||||
self.is_deleted = True
|
||||
self.OrderStatus = 'Cancelled'
|
||||
return None
|
||||
|
||||
elif status_respnse and status_respnse['order_status'] != 'Cancelled' :
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
return None
|
||||
|
||||
else : return None
|
||||
|
||||
else : return None
|
||||
|
||||
except : return None
|
||||
|
||||
# ================================================================================= #
|
||||
|
||||
class EmsEngine_TseIfb_AsyncClient:
|
||||
@@ -369,6 +435,7 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
OMS : Literal[
|
||||
'Omex | Parsian',
|
||||
'Sahra | Karamad',
|
||||
'Sahra | NIBB',
|
||||
]
|
||||
)-> ImageFile:
|
||||
|
||||
|
||||
@@ -74,6 +74,9 @@ class Order:
|
||||
Volume : int
|
||||
Order volume.
|
||||
|
||||
OrderStatus : 'Unknown' | 'InQueue' | 'PartiallyFilled' | 'Cancelled' | 'Broken' | 'Settled'
|
||||
Current lifecycle status of the order. The value is 'Unknown' until a status is received from the server.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> order = client.Buy_by_Name(
|
||||
@@ -92,10 +95,17 @@ class Order:
|
||||
self.Price : int = Price
|
||||
self.Volume : int = Volume
|
||||
self.is_deleted : bool = False
|
||||
self.OrderStatus : Literal[
|
||||
'Unknown',
|
||||
'InQueue',
|
||||
'Cancelled',
|
||||
'Broken',
|
||||
'Settled',
|
||||
'PartiallyFilled',
|
||||
] = 'Unknown'
|
||||
|
||||
self.OrderId : HexUUID | None = None
|
||||
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def send(self)-> None:
|
||||
@@ -122,6 +132,8 @@ class Order:
|
||||
'0xA23F...'
|
||||
"""
|
||||
|
||||
try :
|
||||
|
||||
if self.OrderId is None :
|
||||
|
||||
SendOrder_Response = self.__AuthSyncClient.httpx_Client.post(**self.__SendOrder_RequestInfo)
|
||||
@@ -137,6 +149,8 @@ class Order:
|
||||
|
||||
else : return None
|
||||
|
||||
except : return None
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def Edit(
|
||||
@@ -189,6 +203,8 @@ class Order:
|
||||
)
|
||||
"""
|
||||
|
||||
try :
|
||||
|
||||
if self.OrderId is not None:
|
||||
|
||||
Edit_response = self.__AuthSyncClient.httpx_Client.patch(
|
||||
@@ -214,13 +230,39 @@ class Order:
|
||||
self.ValidityDate = ValidityDate
|
||||
self.Price = Edit_response['Data']['order_price']
|
||||
self.Volume = Edit_response['Data']['order_volume']
|
||||
return None
|
||||
|
||||
case _ :
|
||||
|
||||
status_respnse = self.Status()
|
||||
|
||||
if status_respnse and (
|
||||
status_respnse['order_status'] in ('PartiallyFilled' , 'InQueue')
|
||||
and status_respnse['RemainedVolume'] + status_respnse['ExecutedVolume'] == Volume
|
||||
and status_respnse['Price'] == Price
|
||||
and status_respnse['ValidityDate'] == ValidityDate
|
||||
and status_respnse['ValidityType'] == Order_ValidityType
|
||||
):
|
||||
|
||||
self.ValidityType = status_respnse['ValidityType']
|
||||
self.ValidityDate = status_respnse['ValidityDate']
|
||||
self.Price = status_respnse['Price']
|
||||
self.Volume = status_respnse['RemainedVolume'] + status_respnse['ExecutedVolume']
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
return None
|
||||
|
||||
elif status_respnse and status_respnse['order_status'] not in ('PartiallyFilled' , 'InQueue'):
|
||||
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
|
||||
return None
|
||||
|
||||
case _ : return None
|
||||
else : return None
|
||||
|
||||
else : return None
|
||||
|
||||
except : return None
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def Status(self)-> OrderStatus | None:
|
||||
@@ -241,7 +283,7 @@ class Order:
|
||||
- order_uuid : HexUUID
|
||||
Unique identifier of the order.
|
||||
|
||||
- order_status : Literal['InQueue', 'Cancelled', 'Broken', 'Settled']
|
||||
- order_status : Literal['InQueue', 'PartiallyFilled, 'Cancelled', 'Broken', 'Settled']
|
||||
Current lifecycle state of the order.
|
||||
|
||||
* InQueue : Order is waiting for execution.
|
||||
@@ -310,6 +352,8 @@ class Order:
|
||||
}
|
||||
"""
|
||||
|
||||
try :
|
||||
|
||||
if self.OrderId is not None:
|
||||
|
||||
status_respnse = self.__AuthSyncClient.httpx_Client.get(
|
||||
@@ -321,12 +365,17 @@ class Order:
|
||||
|
||||
case 200:
|
||||
|
||||
return status_respnse.json()['Data']
|
||||
status_respnse = status_respnse.json()['Data']
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
|
||||
return status_respnse
|
||||
|
||||
case _ : return None
|
||||
|
||||
else : return None
|
||||
|
||||
except : return None
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
def Delete(self)-> None :
|
||||
@@ -351,6 +400,8 @@ class Order:
|
||||
True
|
||||
"""
|
||||
|
||||
try :
|
||||
|
||||
if self.OrderId is not None:
|
||||
|
||||
Delete_respnse = self.__AuthSyncClient.httpx_Client.delete(
|
||||
@@ -364,12 +415,28 @@ class Order:
|
||||
case 200:
|
||||
|
||||
self.is_deleted = True
|
||||
self.OrderStatus = 'Cancelled'
|
||||
return None
|
||||
|
||||
case _ : return None
|
||||
case _ :
|
||||
|
||||
status_respnse = self.Status()
|
||||
|
||||
if status_respnse and status_respnse['order_status'] == 'Cancelled':
|
||||
self.is_deleted = True
|
||||
self.OrderStatus = 'Cancelled'
|
||||
return None
|
||||
|
||||
elif status_respnse and status_respnse['order_status'] != 'Cancelled' :
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
return None
|
||||
|
||||
else : return None
|
||||
|
||||
else : return None
|
||||
|
||||
except : return None
|
||||
|
||||
# ================================================================================= #
|
||||
|
||||
class EmsEngine_TseIfb_SyncClient:
|
||||
@@ -401,6 +468,7 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
OMS : Literal[
|
||||
'Omex | Parsian',
|
||||
'Sahra | Karamad',
|
||||
'Sahra | NIBB',
|
||||
]
|
||||
)-> ImageFile:
|
||||
|
||||
|
||||
@@ -18,8 +18,58 @@ HexUUID = NewType("HexUUID", str)
|
||||
|
||||
class OrderStatus(TypedDict):
|
||||
|
||||
"""
|
||||
Represents the current status and execution details of an order.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
order_uuid : HexUUID
|
||||
order_status : Literal['InQueue','Cancelled','Broken','Settled']
|
||||
Unique identifier of the order.
|
||||
|
||||
order_status : Literal['InQueue', 'PartiallyFilled', 'Cancelled', 'Broken', 'Settled']
|
||||
Current lifecycle status of the order.
|
||||
|
||||
Possible values:
|
||||
- ``InQueue``: The order has been accepted and is waiting to be matched.
|
||||
- ``PartiallyFilled``: Part of the order has been executed, while the remaining volume is still active.
|
||||
- ``Cancelled``: The order has been cancelled and will no longer be executed.
|
||||
- ``Broken``: The order has been rejected or terminated due to an error or exchange-side condition.
|
||||
- ``Settled``: The order has been completely executed.
|
||||
|
||||
Price : int
|
||||
Order price.
|
||||
|
||||
Volume : int
|
||||
Total requested order volume.
|
||||
|
||||
RemainedVolume : int
|
||||
Remaining volume that has not yet been executed.
|
||||
|
||||
ExecutedVolume : int
|
||||
Total executed volume.
|
||||
|
||||
OrderSide : Literal['Buy', 'Sell']
|
||||
Side of the order.
|
||||
|
||||
Possible values:
|
||||
- ``Buy``: Buy order.
|
||||
- ``Sell``: Sell order.
|
||||
|
||||
ValidityType : Literal['DAY', 'GTC', 'GTD']
|
||||
Order validity policy.
|
||||
|
||||
Possible values:
|
||||
- ``DAY``: Valid only for the current trading session.
|
||||
- ``GTC`` (*Good Till Cancelled*): Remains active until cancelled.
|
||||
- ``GTD`` (*Good Till Date*): Remains active until the specified expiration date.
|
||||
|
||||
ValidityDate : int
|
||||
Expiration date of the order when ``ValidityType`` is ``GTD``.
|
||||
The format depends on the trading engine.
|
||||
"""
|
||||
|
||||
order_uuid : HexUUID
|
||||
order_status : Literal['InQueue','PartiallyFilled','Cancelled','Broken','Settled']
|
||||
Price : int
|
||||
Volume : int
|
||||
RemainedVolume : int
|
||||
|
||||
@@ -367,7 +367,7 @@ See LICENSE file.
|
||||
|
||||
## Support
|
||||
|
||||
GitHub Issues: https://github.com/HedgeTech-ir/HedgeTech/issues
|
||||
GitHub Issues: https://gitea.hedgetech.ir/HedgeTech/HedgeTech/issues
|
||||
|
||||
Email: info@hedgetech.ir
|
||||
|
||||
|
||||
+4
-4
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "HedgeTech"
|
||||
version = "0.2.3"
|
||||
version = "0.3.1b5"
|
||||
description = "A unified, high-performance API layer that powers all trading infrastructure across the HedgeTech ecosystem, providing modular, scalable, and real-time interfaces for market data, order management, and execution systems."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
@@ -33,7 +33,7 @@ classifiers = [
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Operating System :: OS Independent",
|
||||
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Development Status :: 4 - Beta",
|
||||
|
||||
"Intended Audience :: Developers",
|
||||
"Intended Audience :: Financial and Insurance Industry",
|
||||
@@ -59,5 +59,5 @@ dependencies = [
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://hedgetech.ir/landing/"
|
||||
Documentation = "https://github.com/HedgeTech-ir/HedgeTech/blob/main/README.md"
|
||||
Repository = "https://github.com/HedgeTech-ir/HedgeTech"
|
||||
Documentation = "https://gitea.hedgetech.ir/HedgeTech/HedgeTech/src/branch/main/README.md"
|
||||
Repository = "https://gitea.hedgetech.ir/HedgeTech/HedgeTech"
|
||||
Reference in new issue
Block a user