Skip to content

Commit 80bd18d

Browse files
committed
remove place order response check of order.order_id
remove fixed pandas version change version
1 parent 9803ec4 commit 80bd18d

File tree

8 files changed

+37
-13
lines changed

8 files changed

+37
-13
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## 2.0.5 (2022-01-07)
2+
### New
3+
- 查询行情权限接口 QuoteClient.get_quote_permission
4+
- 订单综合账户成交记录接口 TradeClient.get_transactions
5+
- 增加一个完整的策略示例
6+
7+
### Changed
8+
- 方法枚举参数优化,使用枚举参数的方法也可以直接使用该枚举对应值
9+
- TradeClient.place_order 去除返回数据中 Order.order_id 属性的校验
10+
- 将 SDK 内部的日志级别由 INFO 调整为 DEBUG, 防止默认情况下输出 SDK 的日志
11+
- 去除 pandas 固定版本号, 方便安装时灵活指定版本
12+
13+
### Breaking
14+
- 行情权限抢占接口 QuoteClient.grab_quote_permission 返回的数据项中,'expireAt' 字段格式转换为 'expire_at'
15+
116
## 2.0.4 (2021-12-08)
217
### New
318
- 综合/模拟账户查询资产接口 TradeClient.get_prime_assets

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.0.4'
7+
__VERSION__ = '2.0.5'

tigeropen/common/consts/service_types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
PLACE_ORDER = "place_order"
1111
CANCEL_ORDER = "cancel_order"
1212
MODIFY_ORDER = "modify_order"
13-
BATCH_PLACE_ORDER = "batch_place_order"
1413

1514
"""
1615
账户/资产

tigeropen/trade/domain/account.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class CommoditySegment:
122122
- initial_margin_requirement: 初始保证金
123123
- maintenance_margin_requirement: 维持保证金
124124
- net_liquidation: 总资产(净清算价值)。计算方法:现金价值 + 盯市盈亏
125+
- gross_position_value: 持仓总价值
125126
- timestamp: 更新时间
126127
"""
127128
def __init__(self):
@@ -134,6 +135,7 @@ def __init__(self):
134135
self.initial_margin_requirement = float('inf')
135136
self.maintenance_margin_requirement = float('inf')
136137
self.net_liquidation = float('inf')
138+
self.gross_position_value = float('inf')
137139
self.timestamp = None
138140

139141
def __repr__(self):

tigeropen/trade/domain/order.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ class Order:
1515
__slots__ = ["account", "id", "order_id", "parent_id", "order_time", "reason", "trade_time", "contract", "action",
1616
"quantity", "filled", "_remaining", "avg_fill_price", "commission", "realized_pnl", "_status",
1717
"trail_stop_price", "limit_price", "aux_price", "trailing_percent", "percent_offset", "action",
18-
"order_type", "time_in_force", "outside_rth", "order_legs", "algo_params", "secret_key"]
18+
"order_type", "time_in_force", "outside_rth", "order_legs", "algo_params", "secret_key", "liquidation",
19+
"algo_strategy", "discount"]
1920

2021
def __init__(self, account, contract, action, order_type, quantity, limit_price=None, aux_price=None,
2122
trail_stop_price=None, trailing_percent=None, percent_offset=None, time_in_force=None,
2223
outside_rth=None, filled=0, avg_fill_price=0, commission=None, realized_pnl=None,
2324
id=None, order_id=None, parent_id=None, order_time=None, trade_time=None, order_legs=None,
24-
algo_params=None, secret_key=None):
25+
algo_params=None, secret_key=None, **kwargs):
2526
"""
2627
- account: 订单所属的账户
2728
- id: 全局订单 id
@@ -50,6 +51,9 @@ def __init__(self, account, contract, action, order_type, quantity, limit_price=
5051
- order_legs: 附加订单列表
5152
- algo_params: 算法订单参数
5253
- secret_key: 机构交易员专有密钥
54+
- liquidation
55+
- algo_strategy
56+
- discount
5357
"""
5458

5559
self.id = id
@@ -79,6 +83,9 @@ def __init__(self, account, contract, action, order_type, quantity, limit_price=
7983
self.order_legs = order_legs
8084
self.algo_params = algo_params
8185
self.secret_key = secret_key
86+
self.liquidation = kwargs.get('liquidation')
87+
self.algo_strategy = kwargs.get('algo_strategy')
88+
self.discount = kwargs.get('discount')
8289

8390
def to_dict(self):
8491
dct = {name: getattr(self, name) for name in self.__slots__ if name not in ORDER_FIELDS_TO_IGNORE}

tigeropen/trade/response/assets_response.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ def _parse_segment(segment, sub_value):
8080
sub_tag = ACCOUNT_FIELD_MAPPINGS[segment_key]
8181
else:
8282
sub_tag = camel_to_underline(segment_key)
83-
if hasattr(segment, sub_tag):
84-
setattr(segment, sub_tag, segment_value)
83+
setattr(segment, sub_tag, segment_value)
8584

8685
@staticmethod
8786
def _parse_market_value(market_value, sub_value):

tigeropen/trade/response/orders_response.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'remark': 'reason',
2020
'localSymbol': 'local_symbol', 'originSymbol': 'origin_symbol', 'outsideRth': 'outside_rth',
2121
'timeInForce': 'time_in_force', 'openTime': 'order_time', 'latestTime': 'trade_time',
22-
'contractId': 'contract_id',
22+
'contractId': 'contract_id', 'algoStrategy': 'algo_strategy',
2323
'trailStopPrice': 'trail_stop_price', 'trailingPercent': 'trailing_percent',
2424
'percentOffset': 'percent_offset', 'identifier': 'identifier', 'algoParameters': 'algo_params'}
2525

@@ -90,17 +90,21 @@ def parse_order(item, secret_key=None):
9090
avg_fill_price = order_fields.get('avg_fill_price')
9191
commission = order_fields.get('commission')
9292
realized_pnl = order_fields.get('realized_pnl')
93-
id = order_fields.get('id')
93+
id_ = order_fields.get('id')
9494
order_id = order_fields.get('order_id')
9595
parent_id = order_fields.get('parent_id')
9696
status = get_order_status(order_fields.get('status'))
9797
algo_params = AlgoParams.from_tags(order_fields.get('algo_params'))
98+
liquidation = order_fields.get('liquidation')
99+
algo_strategy = order_fields.get('algo_strategy')
100+
discount = order_fields.get('discount')
98101

99102
order = Order(account, contract, action, order_type, quantity, limit_price=limit_price, aux_price=aux_price,
100103
trail_stop_price=trail_stop_price, trailing_percent=trailing_percent,
101104
percent_offset=percent_offset, time_in_force=time_in_force, outside_rth=outside_rth,
102105
filled=filled, avg_fill_price=avg_fill_price, commission=commission,
103-
realized_pnl=realized_pnl, id=id, order_id=order_id, parent_id=parent_id, algo_params=algo_params)
106+
realized_pnl=realized_pnl, id=id_, order_id=order_id, parent_id=parent_id,
107+
algo_params=algo_params, liquidation=liquidation, algo_strategy=algo_strategy, discount=discount)
104108
if 'order_time' in order_fields:
105109
order.order_time = order_fields.get('order_time')
106110
if 'trade_time' in order_fields:

tigeropen/trade/trade_client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,9 @@ def place_order(self, order):
513513
response.parse_response_content(response_content)
514514
if response.is_success():
515515
order.id = response.id
516-
if order.order_id:
517-
return response.order_id == order.order_id
518-
else:
516+
if order.order_id is None and response.order_id:
519517
order.order_id = response.order_id
520-
return True
518+
return True
521519
else:
522520
raise ApiException(response.code, response.message)
523521

0 commit comments

Comments
 (0)