Compare commits
2 Commits
8a5f3142ef
...
ecc1070f1c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecc1070f1c | ||
|
|
126eab66f7 |
@ -1107,4 +1107,205 @@ class OverviewResponse(TypedDict):
|
||||
]
|
||||
]
|
||||
]
|
||||
Status: Status
|
||||
Status: Status
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
|
||||
class Websocket_data(TypedDict):
|
||||
|
||||
"""
|
||||
Live market data payload for IME WebSocket streams.
|
||||
|
||||
This TypedDict represents the complete real-time market data for a single contract,
|
||||
including order book, trading statistics, price limits, and contract information.
|
||||
|
||||
Attributes:
|
||||
BestLimit (Dict[Literal['1','2','3'], BestLimitItem]):
|
||||
Best limit order book with 3 levels. Keys "1" (best), "2", "3" (worst).
|
||||
Each level contains buy/sell quantities and prices.
|
||||
|
||||
Aggregate (Aggregate):
|
||||
Aggregate trading statistics including OHLC, volume, trade count,
|
||||
and timestamps.
|
||||
|
||||
AllowedPriceRange (AllowedPriceRange):
|
||||
Daily price limits (minimum and maximum allowed prices).
|
||||
|
||||
ContractInfo (ContractInfo):
|
||||
Contract information including open interest and its changes.
|
||||
|
||||
Example:
|
||||
>>> ws_data: Websocket_data = {
|
||||
... "BestLimit": {
|
||||
... "1": {
|
||||
... "buy_quantity": 1500,
|
||||
... "buy_price": 35200,
|
||||
... "sell_quantity": 800,
|
||||
... "sell_price": 35300
|
||||
... },
|
||||
... "2": {
|
||||
... "buy_quantity": 1200,
|
||||
... "buy_price": 35100,
|
||||
... "sell_quantity": 600,
|
||||
... "sell_price": 35400
|
||||
... },
|
||||
... "3": {
|
||||
... "buy_quantity": 900,
|
||||
... "buy_price": 35000,
|
||||
... "sell_quantity": 400,
|
||||
... "sell_price": 35500
|
||||
... }
|
||||
... },
|
||||
... "Aggregate": {
|
||||
... "date": "2025-01-15",
|
||||
... "time": "14:30:00",
|
||||
... "trade_count": 1250,
|
||||
... "total_volume": 50000,
|
||||
... "total_value": 1765000000,
|
||||
... "closing_price": 35250.0,
|
||||
... "last_price": 35250.0,
|
||||
... "low_price": 34900.0,
|
||||
... "high_price": 35500.0,
|
||||
... "open_price": 35100.0,
|
||||
... "previous_close": 35000.0
|
||||
... },
|
||||
... "AllowedPriceRange": {
|
||||
... "minAllowedPrice": 33250.0,
|
||||
... "maxAllowedPrice": 36750.0
|
||||
... },
|
||||
... "ContractInfo": {
|
||||
... "open_interest": 125000,
|
||||
... "open_interest_changes": 2500
|
||||
... }
|
||||
... }
|
||||
>>> print(f"Best bid: {ws_data['BestLimit']['1']['buy_price']}")
|
||||
Best bid: 35200
|
||||
>>> print(f"Last price: {ws_data['Aggregate']['last_price']}")
|
||||
Last price: 35250.0
|
||||
>>> print(f"Price range: {ws_data['AllowedPriceRange']['minAllowedPrice']} - {ws_data['AllowedPriceRange']['maxAllowedPrice']}")
|
||||
Price range: 33250.0 - 36750.0
|
||||
"""
|
||||
|
||||
BestLimit: Dict[
|
||||
Literal['1','2','3',],
|
||||
BestLimitItem
|
||||
]
|
||||
Aggregate: Aggregate
|
||||
AllowedPriceRange: AllowedPriceRange
|
||||
ContractInfo: ContractInfo
|
||||
|
||||
class WebsocketBase_contractId(TypedDict):
|
||||
"""
|
||||
Base WebSocket message structure for IME live data (identified by Contract ID).
|
||||
|
||||
This TypedDict defines the standard format of all real-time messages received
|
||||
when subscribing to the `/contract/id` WebSocket endpoint.
|
||||
|
||||
Attributes:
|
||||
channel (Literal["IME Stream"]):
|
||||
Fixed channel name for IME live market data streams.
|
||||
|
||||
contractId (str):
|
||||
Unique identifier of the IME contract (e.g., "IME001", "IME002").
|
||||
|
||||
timestamp (str):
|
||||
ISO-formatted timestamp when the message was generated
|
||||
(e.g., "2025-01-15T14:30:00.123456").
|
||||
|
||||
data (Websocket_data):
|
||||
Live market data payload containing BestLimit, Aggregate,
|
||||
AllowedPriceRange, and ContractInfo.
|
||||
|
||||
Example:
|
||||
>>> message: WebsocketBase_contractId = {
|
||||
... "channel": "IME Stream",
|
||||
... "contractId": "012345",
|
||||
... "timestamp": "2025-01-15T14:30:00.123456",
|
||||
... "data": {
|
||||
... "BestLimit": {
|
||||
... "1": {"buy_quantity": 1500, "buy_price": 35200, "sell_quantity": 800, "sell_price": 35300}
|
||||
... },
|
||||
... "Aggregate": {
|
||||
... "date": "2025-01-15", "time": "14:30:00", "trade_count": 1250,
|
||||
... "total_volume": 50000, "total_value": 1765000000, "closing_price": 35250.0,
|
||||
... "last_price": 35250.0, "low_price": 34900.0, "high_price": 35500.0,
|
||||
... "open_price": 35100.0, "previous_close": 35000.0
|
||||
... },
|
||||
... "AllowedPriceRange": {"minAllowedPrice": 33250.0, "maxAllowedPrice": 36750.0},
|
||||
... "ContractInfo": {"open_interest": 125000, "open_interest_changes": 2500}
|
||||
... }
|
||||
... }
|
||||
>>> print(f"Channel: {message['channel']}")
|
||||
Channel: IME Stream
|
||||
>>> print(f"Contract ID: {message['contractId']}")
|
||||
Contract ID: IME0012345
|
||||
>>> print(f"Timestamp: {message['timestamp']}")
|
||||
Timestamp: 2025-01-15T14:30:00.123456
|
||||
>>> print(f"Last price: {message['data']['Aggregate']['last_price']}")
|
||||
Last price: 35250.0
|
||||
"""
|
||||
|
||||
channel : Literal["IME Stream",]
|
||||
contractId : str
|
||||
timestamp : str
|
||||
data : Websocket_data
|
||||
|
||||
class WebsocketBase_contractName(TypedDict):
|
||||
"""
|
||||
Base WebSocket message structure for IME live data (identified by Contract Name).
|
||||
|
||||
This TypedDict defines the standard format of all real-time messages received
|
||||
when subscribing to the `/contract/name` WebSocket endpoint.
|
||||
|
||||
Attributes:
|
||||
channel (Literal["IME Stream"]):
|
||||
Fixed channel name for IME live market data streams.
|
||||
|
||||
contractName (str):
|
||||
Name of the IME contract (e.g., "GOLD_FUT_M1", "GOLD1g").
|
||||
|
||||
timestamp (str):
|
||||
ISO-formatted timestamp when the message was generated
|
||||
(e.g., "2025-01-15T14:30:00.123456").
|
||||
|
||||
data (Websocket_data):
|
||||
Live market data payload containing BestLimit, Aggregate,
|
||||
AllowedPriceRange, and ContractInfo.
|
||||
|
||||
Example:
|
||||
>>> message: WebsocketBase_contractName = {
|
||||
... "channel": "IME Stream",
|
||||
... "contractName": "GOLD_FUT_M1",
|
||||
... "timestamp": "2025-01-15T14:30:00.123456",
|
||||
... "data": {
|
||||
... "BestLimit": {
|
||||
... "1": {"buy_quantity": 1500, "buy_price": 35200, "sell_quantity": 800, "sell_price": 35300},
|
||||
... "2": {"buy_quantity": 1200, "buy_price": 35100, "sell_quantity": 600, "sell_price": 35400},
|
||||
... "3": {"buy_quantity": 900, "buy_price": 35000, "sell_quantity": 400, "sell_price": 35500}
|
||||
... },
|
||||
... "Aggregate": {
|
||||
... "date": "2025-01-15", "time": "14:30:00", "trade_count": 1250,
|
||||
... "total_volume": 50000, "total_value": 1765000000, "closing_price": 35250.0,
|
||||
... "last_price": 35250.0, "low_price": 34900.0, "high_price": 35500.0,
|
||||
... "open_price": 35100.0, "previous_close": 35000.0
|
||||
... },
|
||||
... "AllowedPriceRange": {"minAllowedPrice": 33250.0, "maxAllowedPrice": 36750.0},
|
||||
... "ContractInfo": {"open_interest": 125000, "open_interest_changes": 2500}
|
||||
... }
|
||||
... }
|
||||
>>> print(f"Channel: {message['channel']}")
|
||||
Channel: IME Stream
|
||||
>>> print(f"Contract Name: {message['contractName']}")
|
||||
Contract Name: GOLD_FUT_M1
|
||||
>>> print(f"Timestamp: {message['timestamp']}")
|
||||
Timestamp: 2025-01-15T14:30:00.123456
|
||||
>>> best_bid = message['data']['BestLimit']['1']['buy_price']
|
||||
>>> print(f"Best bid: {best_bid}")
|
||||
Best bid: 35200
|
||||
"""
|
||||
|
||||
channel : Literal["IME Stream",]
|
||||
contractName : str
|
||||
timestamp : str
|
||||
data : Websocket_data
|
||||
@ -38,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
|
||||
|
||||
@ -65,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
|
||||
|
||||
@ -851,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):
|
||||
@ -892,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,
|
||||
]
|
||||
|
||||
# +--------------------------------------------------------------------------------------+ #
|
||||
|
||||
@ -1612,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
|
||||
@ -1633,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
|
||||
@ -1654,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
|
||||
@ -1675,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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user