Skip to content

Commit a7aa812

Browse files
committed
Merge branch 'feature_push_usermark' into 'dev'
modify protobuf tradetick;order usermark See merge request server/openapi/openapi-python-sdk!176
2 parents cc8f70c + 6a8442b commit a7aa812

9 files changed

Lines changed: 165 additions & 51 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.3.9 (2023-06-01)
2+
### Fix
3+
- 修复protobuf推送tick数据未解压的问题
4+
### Modify
5+
- 修改订单状态推送proto定义,增加 userMark
6+
17
## 2.3.8 (2023-05-09)
28
### New
39
- 合约接口新增字段保证金优惠信息

tigeropen/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
55
@author: gaoan
66
"""
7-
__VERSION__ = '2.3.8'
7+
__VERSION__ = '2.3.9'

tigeropen/examples/push_client_demo.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from tigeropen.push.pb.QuoteBasicData_pb2 import QuoteBasicData
1717
from tigeropen.push.pb.QuoteDepthData_pb2 import QuoteDepthData
1818
from tigeropen.push.pb.TradeTickData_pb2 import TradeTickData
19+
from tigeropen.push.pb.trade_tick import TradeTick
1920
from tigeropen.push.push_client import PushClient
2021
from tigeropen.examples.client_config import get_client_config
2122

@@ -152,24 +153,11 @@ def on_quote_depth_changed(frame: QuoteDepthData):
152153
print(f'quote depth changed: {frame}')
153154

154155

155-
def on_tick_changed(frame: TradeTickData):
156+
def on_tick_changed(frame: TradeTick):
156157
"""逐笔成交回调
157158
example:
158-
symbol: "00700"
159-
type: "-+"
160-
sn: 37998
161-
priceBase: 3636
162-
priceOffset: 1
163-
time: 1677742815311
164-
time: 69
165-
price: 0
166-
price: 2
167-
volume: 500
168-
volume: 100
169-
quoteLevel: "hkStockQuoteLv2"
170-
timestamp: 1677742815776
171-
secType: "STK"
172-
159+
TradeTick<{'symbol': '00700', 'sec_type': 'STK', 'quote_level': 'hkStockQuoteLv2', 'timestamp': 1685602618145, 'ticks': [TradeTickItem<{'tick_type': '+', 'price': 316.6, 'volume': 100, 'part_code': None, 'part_code_name': None, 'cond': None, 'time': 1685602617046, 'sn': 42055}>, TradeTickItem<{'tick_type': '-', 'price': 316.4, 'volume': 600, 'part_code': None, 'part_code_name': None, 'cond': None, 'time': 1685602617639, 'sn': 42056}>, TradeTickItem<{'tick_type': '-', 'price': 316.4, 'volume': 200, 'part_code': None, 'part_code_name': None, 'cond': None, 'time': 1685602617639, 'sn': 42057}>]}>
160+
TradeTick<{'symbol': 'CLmain', 'sec_type': 'FUT', 'quote_level': '', 'timestamp': 1685602618153, 'ticks': [TradeTickItem<{'tick_type': None, 'price': 68.7, 'volume': 1, 'part_code': None, 'part_code_name': None, 'cond': None, 'time': 1685602616000, 'sn': 109150}>, TradeTickItem<{'tick_type': None, 'price': 68.7, 'volume': 1, 'part_code': None, 'part_code_name': None, 'cond': None, 'time': 1685602616000, 'sn': 109151}>]}>
173161
"""
174162
print(frame)
175163

tigeropen/push/network/listener.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ def __heartbeat_loop(self):
222222
self.transport.set_connected(False)
223223
self.transport.disconnect_socket()
224224
self.transport.stop()
225-
for listener in self.transport.listeners.values():
226-
listener.on_heartbeat_timeout()
227225
self.heartbeat_thread = None
228226
self.heartbeat_terminate_event.clear()
229227
if self.heartbeats != (0, 0):

tigeropen/push/pb/OrderStatusData.proto

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,45 @@ syntax = "proto3";
22

33
package tigeropen.push.pb;
44

5-
65
message OrderStatusData {
76
sint64 id = 1; // unique order id
87
string account = 2; // user account
98
string symbol = 3;
10-
string identifier = 4;
11-
uint32 multiplier = 5; // multiplier for futures, options, warrants and CBBC
12-
string action = 6; // BUY or SELL
13-
string market = 7; // market. US, HK, etc.
14-
string currency = 8; // currency. USD, HKD, etc.
15-
string segType = 9; // Securities Category C: (Commodities Futures), S: (Securities Stocks)
16-
string secType = 10; // STK Stocks, OPT Options, WAR Warrants, IOPT CBBC, CASH FOREX, FUT Futures, FOP Future Options
9+
string expiry = 4; // for options, formate:yyyyMMdd
10+
string strike = 5; // for options
11+
string right = 6; // for options
12+
string identifier = 7;
13+
uint32 multiplier = 8; // multiplier for futures, options, warrants and CBBC
14+
string action = 9; // BUY or SELL
15+
string market = 10; // market. US, HK, etc.
16+
string currency = 11; // currency. USD, HKD, etc.
17+
string segType = 12; // Securities Category C: (Commodities Futures), S: (Securities Stocks)
18+
string secType = 13; // STK Stocks, OPT Options, WAR Warrants, IOPT CBBC, CASH FOREX, FUT Futures, FOP Future Options
1719

18-
string orderType = 11; // order type
19-
bool isLong = 12;
20-
sint64 totalQuantity = 13; // total quantity
21-
sint32 totalQuantityScale = 14; // total quantity scale
22-
sint64 filledQuantity = 15; // filled quantity
23-
sint32 filledQuantityScale = 16; // filled quantity scale
24-
double avgFillPrice = 17; // average price at which the orders got filled
25-
double limitPrice = 18; // limit price(required when orderType is 'LMT')
26-
double realizedPnl = 19; // realized profit and loss
27-
string status = 20; // order status
20+
string orderType = 14; // order type
21+
bool isLong = 15;
22+
sint64 totalQuantity = 16; // total quantity
23+
sint32 totalQuantityScale = 17; // total quantity scale
24+
sint64 filledQuantity = 18; // filled quantity
25+
sint32 filledQuantityScale = 19; // filled quantity scale
26+
double avgFillPrice = 20; // average price at which the orders got filled
27+
double limitPrice = 21; // limit price(required when orderType is 'LMT')
28+
double stopPrice = 22; // stop price(required when orderType is 'STP')
29+
double realizedPnl = 23; // realized profit and loss
30+
string status = 24; // order status
31+
string replaceStatus = 25; // order replace status
32+
string cancelStatus = 26; // order cancel status
2833

29-
bool outsideRth = 21; // if trade outside regular trading hours (only applicable to U.S. market)
30-
bool canModify = 22;
31-
bool canCancel = 23;
32-
string name = 24; // symbol name
33-
string source = 25; // order source(from 'OpenApi', or not)
34-
string errorMsg = 26; // error message
35-
float commissionAndFee = 27; // commission and fee
36-
uint64 openTime = 28; // timestamp when the order is placed
37-
uint64 timestamp = 29;
34+
bool outsideRth = 27; // if trade outside regular trading hours (only applicable to U.S. market)
35+
bool canModify = 28;
36+
bool canCancel = 29;
37+
bool liquidation = 30;
38+
string name = 31; // symbol name
39+
string source = 32; // order source(from 'OpenApi', or not)
40+
string errorMsg = 33; // error message
41+
string attrDesc = 34; // order description
42+
float commissionAndFee = 35; // commission and fee
43+
uint64 openTime = 36; // timestamp when the order is placed
44+
uint64 timestamp = 37;
45+
string userMark = 38;
3846
}

tigeropen/push/pb/OrderStatusData_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tigeropen/push/pb/OrderStatusData_pb2.pyi

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,81 @@ from typing import ClassVar as _ClassVar, Optional as _Optional
55
DESCRIPTOR: _descriptor.FileDescriptor
66

77
class OrderStatusData(_message.Message):
8-
__slots__ = ["account", "action", "avgFillPrice", "canCancel", "canModify", "commissionAndFee", "currency", "errorMsg", "filledQuantity", "filledQuantityScale", "id", "identifier", "isLong", "limitPrice", "market", "multiplier", "name", "openTime", "orderType", "outsideRth", "realizedPnl", "secType", "segType", "source", "status", "symbol", "timestamp", "totalQuantity", "totalQuantityScale"]
8+
__slots__ = ["account", "action", "attrDesc", "avgFillPrice", "canCancel", "canModify", "cancelStatus", "commissionAndFee", "currency", "errorMsg", "expiry", "filledQuantity", "filledQuantityScale", "id", "identifier", "isLong", "limitPrice", "liquidation", "market", "multiplier", "name", "openTime", "orderType", "outsideRth", "realizedPnl", "replaceStatus", "right", "secType", "segType", "source", "status", "stopPrice", "strike", "symbol", "timestamp", "totalQuantity", "totalQuantityScale", "userMark"]
99
ACCOUNT_FIELD_NUMBER: _ClassVar[int]
1010
ACTION_FIELD_NUMBER: _ClassVar[int]
11+
ATTRDESC_FIELD_NUMBER: _ClassVar[int]
1112
AVGFILLPRICE_FIELD_NUMBER: _ClassVar[int]
1213
CANCANCEL_FIELD_NUMBER: _ClassVar[int]
14+
CANCELSTATUS_FIELD_NUMBER: _ClassVar[int]
1315
CANMODIFY_FIELD_NUMBER: _ClassVar[int]
1416
COMMISSIONANDFEE_FIELD_NUMBER: _ClassVar[int]
1517
CURRENCY_FIELD_NUMBER: _ClassVar[int]
1618
ERRORMSG_FIELD_NUMBER: _ClassVar[int]
19+
EXPIRY_FIELD_NUMBER: _ClassVar[int]
1720
FILLEDQUANTITYSCALE_FIELD_NUMBER: _ClassVar[int]
1821
FILLEDQUANTITY_FIELD_NUMBER: _ClassVar[int]
1922
IDENTIFIER_FIELD_NUMBER: _ClassVar[int]
2023
ID_FIELD_NUMBER: _ClassVar[int]
2124
ISLONG_FIELD_NUMBER: _ClassVar[int]
2225
LIMITPRICE_FIELD_NUMBER: _ClassVar[int]
26+
LIQUIDATION_FIELD_NUMBER: _ClassVar[int]
2327
MARKET_FIELD_NUMBER: _ClassVar[int]
2428
MULTIPLIER_FIELD_NUMBER: _ClassVar[int]
2529
NAME_FIELD_NUMBER: _ClassVar[int]
2630
OPENTIME_FIELD_NUMBER: _ClassVar[int]
2731
ORDERTYPE_FIELD_NUMBER: _ClassVar[int]
2832
OUTSIDERTH_FIELD_NUMBER: _ClassVar[int]
2933
REALIZEDPNL_FIELD_NUMBER: _ClassVar[int]
34+
REPLACESTATUS_FIELD_NUMBER: _ClassVar[int]
35+
RIGHT_FIELD_NUMBER: _ClassVar[int]
3036
SECTYPE_FIELD_NUMBER: _ClassVar[int]
3137
SEGTYPE_FIELD_NUMBER: _ClassVar[int]
3238
SOURCE_FIELD_NUMBER: _ClassVar[int]
3339
STATUS_FIELD_NUMBER: _ClassVar[int]
40+
STOPPRICE_FIELD_NUMBER: _ClassVar[int]
41+
STRIKE_FIELD_NUMBER: _ClassVar[int]
3442
SYMBOL_FIELD_NUMBER: _ClassVar[int]
3543
TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
3644
TOTALQUANTITYSCALE_FIELD_NUMBER: _ClassVar[int]
3745
TOTALQUANTITY_FIELD_NUMBER: _ClassVar[int]
46+
USERMARK_FIELD_NUMBER: _ClassVar[int]
3847
account: str
3948
action: str
49+
attrDesc: str
4050
avgFillPrice: float
4151
canCancel: bool
4252
canModify: bool
53+
cancelStatus: str
4354
commissionAndFee: float
4455
currency: str
4556
errorMsg: str
57+
expiry: str
4658
filledQuantity: int
4759
filledQuantityScale: int
4860
id: int
4961
identifier: str
5062
isLong: bool
5163
limitPrice: float
64+
liquidation: bool
5265
market: str
5366
multiplier: int
5467
name: str
5568
openTime: int
5669
orderType: str
5770
outsideRth: bool
5871
realizedPnl: float
72+
replaceStatus: str
73+
right: str
5974
secType: str
6075
segType: str
6176
source: str
6277
status: str
78+
stopPrice: float
79+
strike: str
6380
symbol: str
6481
timestamp: int
6582
totalQuantity: int
6683
totalQuantityScale: int
67-
def __init__(self, id: _Optional[int] = ..., account: _Optional[str] = ..., symbol: _Optional[str] = ..., identifier: _Optional[str] = ..., multiplier: _Optional[int] = ..., action: _Optional[str] = ..., market: _Optional[str] = ..., currency: _Optional[str] = ..., segType: _Optional[str] = ..., secType: _Optional[str] = ..., orderType: _Optional[str] = ..., isLong: bool = ..., totalQuantity: _Optional[int] = ..., totalQuantityScale: _Optional[int] = ..., filledQuantity: _Optional[int] = ..., filledQuantityScale: _Optional[int] = ..., avgFillPrice: _Optional[float] = ..., limitPrice: _Optional[float] = ..., realizedPnl: _Optional[float] = ..., status: _Optional[str] = ..., outsideRth: bool = ..., canModify: bool = ..., canCancel: bool = ..., name: _Optional[str] = ..., source: _Optional[str] = ..., errorMsg: _Optional[str] = ..., commissionAndFee: _Optional[float] = ..., openTime: _Optional[int] = ..., timestamp: _Optional[int] = ...) -> None: ...
84+
userMark: str
85+
def __init__(self, id: _Optional[int] = ..., account: _Optional[str] = ..., symbol: _Optional[str] = ..., expiry: _Optional[str] = ..., strike: _Optional[str] = ..., right: _Optional[str] = ..., identifier: _Optional[str] = ..., multiplier: _Optional[int] = ..., action: _Optional[str] = ..., market: _Optional[str] = ..., currency: _Optional[str] = ..., segType: _Optional[str] = ..., secType: _Optional[str] = ..., orderType: _Optional[str] = ..., isLong: bool = ..., totalQuantity: _Optional[int] = ..., totalQuantityScale: _Optional[int] = ..., filledQuantity: _Optional[int] = ..., filledQuantityScale: _Optional[int] = ..., avgFillPrice: _Optional[float] = ..., limitPrice: _Optional[float] = ..., stopPrice: _Optional[float] = ..., realizedPnl: _Optional[float] = ..., status: _Optional[str] = ..., replaceStatus: _Optional[str] = ..., cancelStatus: _Optional[str] = ..., outsideRth: bool = ..., canModify: bool = ..., canCancel: bool = ..., liquidation: bool = ..., name: _Optional[str] = ..., source: _Optional[str] = ..., errorMsg: _Optional[str] = ..., attrDesc: _Optional[str] = ..., commissionAndFee: _Optional[float] = ..., openTime: _Optional[int] = ..., timestamp: _Optional[int] = ..., userMark: _Optional[str] = ...) -> None: ...

tigeropen/push/pb/trade_tick.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# @Date : 2023/6/1
4+
# @Author : sukai
5+
class TradeTickItem:
6+
def __int__(self):
7+
self.tick_type = None
8+
self.price = None
9+
self.volume = None
10+
self.part_code = None
11+
self.part_code_name = None
12+
self.cond = None
13+
self.time = None
14+
self.sn = None
15+
16+
def __repr__(self):
17+
return f'TradeTickItem<{self.__dict__}>'
18+
19+
class TradeTick:
20+
def __int__(self):
21+
self.symbol = None
22+
self.sec_type = None
23+
self.quote_level = None
24+
self.timestamp = None
25+
self.ticks = None
26+
27+
def __repr__(self):
28+
return f'TradeTick<{self.__dict__}>'

0 commit comments

Comments
 (0)