Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0351324f9 | ||
|
|
3f936c17d7 | ||
|
|
71aeebfb44 | ||
|
|
0aa91d4e79 | ||
|
|
08244f17f2 | ||
|
|
4d775e9000 | ||
|
|
6c943a559c |
No files matched your search
@@ -14,6 +14,7 @@ from PIL.Image import open as image_open
|
||||
from PIL.ImageFile import ImageFile
|
||||
from io import BytesIO
|
||||
from asyncio import sleep
|
||||
from uuid import uuid4
|
||||
|
||||
# ========================================|======================================== #
|
||||
# Class Definitions #
|
||||
@@ -42,8 +43,6 @@ class Order:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
):
|
||||
@@ -70,6 +69,10 @@ class Order:
|
||||
True if the order has been deleted.
|
||||
OrderId : HexUUID | None
|
||||
Unique identifier of the order after submission.
|
||||
OrderOmsId : str | None
|
||||
Unique identifier of the order assigned by the OMS.
|
||||
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
|
||||
-------
|
||||
@@ -94,15 +97,16 @@ class Order:
|
||||
self.Volume : int = Volume
|
||||
self.is_deleted : bool = False
|
||||
self.OrderStatus : Literal[
|
||||
None,
|
||||
'Unknown',
|
||||
'InQueue',
|
||||
'PartiallyFilled',
|
||||
'Cancelled',
|
||||
'Broken',
|
||||
'Settled',
|
||||
]
|
||||
] = 'Unknown'
|
||||
|
||||
self.OrderId : HexUUID | None = None
|
||||
self.OrderId : HexUUID | None = None
|
||||
self.OrderOmsId : str | None = None
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
@@ -136,7 +140,9 @@ class Order:
|
||||
|
||||
case 200 :
|
||||
|
||||
self.OrderId = SendOrder_Response.json()['Data']['order_uuid']
|
||||
data = SendOrder_Response.json()
|
||||
self.OrderId = data['Data']['order_uuid']
|
||||
self.OrderOmsId = data['Data']['order_oms_id']
|
||||
return None
|
||||
|
||||
case _ : return None
|
||||
@@ -211,12 +217,10 @@ class Order:
|
||||
|
||||
Edit_response = Edit_response.json()
|
||||
|
||||
self.OrderId = Edit_response['Data']['order_uuid']
|
||||
self.ValidityType = Edit_response['Data']['order_validity_type']
|
||||
self.ValidityDate = ValidityDate
|
||||
self.Price = Edit_response['Data']['order_price']
|
||||
self.Volume = Edit_response['Data']['order_volume']
|
||||
self.OrderStatus = 'InQueue'
|
||||
self.Price = Edit_response['Data']['order_price']
|
||||
self.Volume = Edit_response['Data']['order_volume']
|
||||
return None
|
||||
|
||||
case _ :
|
||||
@@ -224,7 +228,7 @@ class Order:
|
||||
status_respnse = await self.Status()
|
||||
|
||||
if status_respnse and (
|
||||
status_respnse['order_status'] == 'InQueue'
|
||||
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
|
||||
@@ -235,10 +239,10 @@ class Order:
|
||||
self.ValidityDate = status_respnse['ValidityDate']
|
||||
self.Price = status_respnse['Price']
|
||||
self.Volume = status_respnse['RemainedVolume'] + status_respnse['ExecutedVolume']
|
||||
self.OrderStatus = 'InQueue'
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
return None
|
||||
|
||||
elif status_respnse and status_respnse['order_status'] != 'InQueue' :
|
||||
elif status_respnse and status_respnse['order_status'] not in ('PartiallyFilled' , 'InQueue'):
|
||||
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
|
||||
@@ -433,6 +437,7 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
self,
|
||||
OMS : Literal[
|
||||
'Omex | Parsian',
|
||||
'Omex | Khobregan',
|
||||
'Sahra | Karamad',
|
||||
'Sahra | NIBB',
|
||||
]
|
||||
@@ -556,8 +561,6 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
)-> Order | None:
|
||||
@@ -614,7 +617,8 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
'ValidityDate' : ValidityDate,
|
||||
'symbolName' : symbolName,
|
||||
'Price' : Price,
|
||||
'Volume' : Volume
|
||||
'Volume' : Volume,
|
||||
'InitialOrderId' : uuid4().hex,
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -634,8 +638,6 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
)-> Order | None:
|
||||
@@ -692,7 +694,8 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
'ValidityDate' : ValidityDate,
|
||||
'symbolName' : symbolName,
|
||||
'Price' : Price,
|
||||
'Volume' : Volume
|
||||
'Volume' : Volume,
|
||||
'InitialOrderId' : uuid4().hex,
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -711,8 +714,6 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
)-> Order | None:
|
||||
@@ -769,7 +770,8 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
'ValidityDate' : ValidityDate,
|
||||
'symbolIsin' : symbolIsin,
|
||||
'Price' : Price,
|
||||
'Volume' : Volume
|
||||
'Volume' : Volume,
|
||||
'InitialOrderId' : uuid4().hex,
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -788,8 +790,6 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
)-> Order | None:
|
||||
@@ -846,7 +846,8 @@ class EmsEngine_TseIfb_AsyncClient:
|
||||
'ValidityDate' : ValidityDate,
|
||||
'symbolIsin' : symbolIsin,
|
||||
'Price' : Price,
|
||||
'Volume' : Volume
|
||||
'Volume' : Volume,
|
||||
'InitialOrderId' : uuid4().hex,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ from HedgeTech.Auth import AuthSyncClient
|
||||
from PIL.Image import open as image_open
|
||||
from PIL.ImageFile import ImageFile
|
||||
from io import BytesIO
|
||||
from uuid import uuid4
|
||||
|
||||
# ========================================|======================================== #
|
||||
# Class Definitions #
|
||||
@@ -43,8 +44,6 @@ class Order:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
):
|
||||
|
||||
@@ -70,9 +69,14 @@ class Order:
|
||||
|
||||
Price : int
|
||||
Order price.
|
||||
|
||||
Volume : int
|
||||
Order volume.
|
||||
OrderId : HexUUID | None
|
||||
Unique identifier of the order after submission.
|
||||
OrderOmsId : str | None
|
||||
Unique identifier of the order assigned by the OMS.
|
||||
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
|
||||
--------
|
||||
@@ -93,16 +97,16 @@ class Order:
|
||||
self.Volume : int = Volume
|
||||
self.is_deleted : bool = False
|
||||
self.OrderStatus : Literal[
|
||||
None,
|
||||
'Unknown',
|
||||
'InQueue',
|
||||
'Cancelled',
|
||||
'Broken',
|
||||
'Settled',
|
||||
'PartiallyFilled',
|
||||
]
|
||||
|
||||
self.OrderId : HexUUID | None = None
|
||||
] = 'Unknown'
|
||||
|
||||
self.OrderId : HexUUID | None = None
|
||||
self.OrderOmsId : str | None = None
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
@@ -140,7 +144,9 @@ class Order:
|
||||
|
||||
case 200 :
|
||||
|
||||
self.OrderId = SendOrder_Response.json()['Data']['order_uuid']
|
||||
data = SendOrder_Response.json()
|
||||
self.OrderId = data['Data']['order_uuid']
|
||||
self.OrderOmsId = data['Data']['order_oms_id']
|
||||
return None
|
||||
|
||||
case _ : return None
|
||||
@@ -223,12 +229,10 @@ class Order:
|
||||
|
||||
Edit_response = Edit_response.json()
|
||||
|
||||
self.OrderId = Edit_response['Data']['order_uuid']
|
||||
self.ValidityType = Edit_response['Data']['order_validity_type']
|
||||
self.ValidityDate = ValidityDate
|
||||
self.Price = Edit_response['Data']['order_price']
|
||||
self.Volume = Edit_response['Data']['order_volume']
|
||||
self.OrderStatus = 'InQueue'
|
||||
self.Price = Edit_response['Data']['order_price']
|
||||
self.Volume = Edit_response['Data']['order_volume']
|
||||
return None
|
||||
|
||||
case _ :
|
||||
@@ -236,7 +240,7 @@ class Order:
|
||||
status_respnse = self.Status()
|
||||
|
||||
if status_respnse and (
|
||||
status_respnse['order_status'] == 'InQueue'
|
||||
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
|
||||
@@ -247,10 +251,10 @@ class Order:
|
||||
self.ValidityDate = status_respnse['ValidityDate']
|
||||
self.Price = status_respnse['Price']
|
||||
self.Volume = status_respnse['RemainedVolume'] + status_respnse['ExecutedVolume']
|
||||
self.OrderStatus = 'InQueue'
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
return None
|
||||
|
||||
elif status_respnse and status_respnse['order_status'] != 'InQueue' :
|
||||
elif status_respnse and status_respnse['order_status'] not in ('PartiallyFilled' , 'InQueue'):
|
||||
|
||||
self.OrderStatus = status_respnse['order_status']
|
||||
|
||||
@@ -466,6 +470,7 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
self,
|
||||
OMS : Literal[
|
||||
'Omex | Parsian',
|
||||
'Omex | Khobregan',
|
||||
'Sahra | Karamad',
|
||||
'Sahra | NIBB',
|
||||
]
|
||||
@@ -578,7 +583,6 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
def Buy_by_Name(
|
||||
self,
|
||||
*,
|
||||
@@ -589,8 +593,6 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
)-> Order | None:
|
||||
@@ -643,7 +645,8 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
'ValidityDate' : ValidityDate,
|
||||
'symbolName' : symbolName,
|
||||
'Price' : Price,
|
||||
'Volume' : Volume
|
||||
'Volume' : Volume,
|
||||
'InitialOrderId' : uuid4().hex,
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -664,8 +667,6 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
)-> Order | None:
|
||||
@@ -718,7 +719,8 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
'ValidityDate' : ValidityDate,
|
||||
'symbolName' : symbolName,
|
||||
'Price' : Price,
|
||||
'Volume' : Volume
|
||||
'Volume' : Volume,
|
||||
'InitialOrderId' : uuid4().hex,
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -737,8 +739,6 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
)-> Order | None:
|
||||
@@ -791,7 +791,8 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
'ValidityDate' : ValidityDate,
|
||||
'symbolIsin' : symbolIsin,
|
||||
'Price' : Price,
|
||||
'Volume' : Volume
|
||||
'Volume' : Volume,
|
||||
'InitialOrderId' : uuid4().hex,
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -810,8 +811,6 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
'DAY',
|
||||
'GTC', # Good Till Cancelled
|
||||
'GTD', # Good Till Date
|
||||
'FAK', # Fill And Kill
|
||||
'FOK', # Fill Or Kill
|
||||
] = 'DAY',
|
||||
ValidityDate : int = 0,
|
||||
)-> Order | None:
|
||||
@@ -864,7 +863,8 @@ class EmsEngine_TseIfb_SyncClient:
|
||||
'ValidityDate' : ValidityDate,
|
||||
'symbolIsin' : symbolIsin,
|
||||
'Price' : Price,
|
||||
'Volume' : Volume
|
||||
'Volume' : Volume,
|
||||
'InitialOrderId' : uuid4().hex,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -18,6 +18,56 @@ HexUUID = NewType("HexUUID", str)
|
||||
|
||||
class OrderStatus(TypedDict):
|
||||
|
||||
"""
|
||||
Represents the current status and execution details of an order.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
order_uuid : HexUUID
|
||||
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
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "HedgeTech"
|
||||
version = "0.3.1b3"
|
||||
version = "0.3.2b1"
|
||||
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"
|
||||
|
||||
Reference in new issue
Block a user