實時成交明細推送
已訂閱的標的的實時逐筆成交明細推送。
SDK Links
Info
業務指令:104
數據格式
Properties
| Name | Type | Description |
|---|---|---|
| symbol | string | 標的代碼,例如:AAPL.US |
| sequence | int64 | 序列號 |
| trades | object[] | 逐筆明細數據 |
| ∟ price | string | 價格 |
| ∟ volume | int64 | 成交量 |
| ∟ timestamp | int64 | 成交時間 |
| ∟ trade_type | string | 交易類型說明 |
| ∟ direction | int32 | 交易方向 可选值: 0 - neutral1 - down2 - up |
| ∟ trade_session | int32 | 交易時段,詳見 TradeSession |
交易類型
港股
*- 場外交易D- 碎股交易M- 非自動對盤P- 開市前成交盤U- 競價交易X- 同一券商非自動對盤Y- 同一券商自動對盤- 自動對盤
美股
- 自動對盤A- 收購B- 批量交易D- 分配F- 跨市掃盤單G- 批量賣出H- 離價交易I- 碎股交易K- 第 155 條交易(紐交所規則)M- 交易所收盤價P- 前參考價Q- 交易所開盤價S- 拆單交易V- 附屬交易W- 平均價成交X- 跨市場交易1- 停售股票(常規交易)
Protobuf
protobuf
message PushTrade {
string symbol = 1;
int64 sequence = 2;
repeated Trade trade = 3;
}
message Trade {
string price = 1;
int64 volume = 2;
int64 timestamp = 3;
string trade_type = 4;
int32 direction = 5;
TradeSession trade_session = 6;
}Example
python
from time import sleep
from longbridge.openapi import QuoteContext, Config, SubType, PushTrades, OAuthBuilder
def on_trades(symbol: str, event: PushTrades):
print(symbol, event)
oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = QuoteContext(config)
ctx.set_on_trades(on_trades)
ctx.subscribe(["700.HK", "AAPL.US"], [SubType.Trade])
sleep(30)JSON Example
json
{
"symbol": "700.HK",
"sequence": 160808750000000,
"trades": [
{
"price": "158.760",
"volume": 1,
"timestamp": 1651103979,
"trade_type": "I",
"direction": 0,
"trade_session": 2
},
{
"price": "158.745",
"volume": 1,
"timestamp": 1651103985,
"trade_type": "I",
"direction": 0,
"trade_session": 2
},
{
"price": "158.800",
"volume": 1,
"timestamp": 1651103995,
"trade_type": "I",
"direction": 0,
"trade_session": 2
}
]
}