Skip to content

Commit 4218e92

Browse files
committed
Merge branch 'feat_future_fields' into 'master'
future add fields See merge request server/openapi/openapi-python-sdk!247
2 parents 96247f7 + 3b6eaf0 commit 4218e92

File tree

4 files changed

+25
-31
lines changed

4 files changed

+25
-31
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 3.4.2 (2025-07-18)
2+
### New
3+
订单工具函数支持 time_in_force 参数
4+
QuoteClient 期货合约接口增加字段 合约规模 product_worth,交割方式 delivery_mode,合约类型 product_type
5+
QuoteClient 期货实时行情接口增加字段 `open_interest_change`
6+
7+
### Breaking
8+
订单/成交记录支持 page token;
9+
110
## 3.4.1 (2025-06-26)
211
### New
312
- `QuoteClient.get_option_timeline` 期权分时接口

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__ = '3.4.1'
7+
__VERSION__ = '3.4.2'

tigeropen/quote/quote_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ def get_future_brief(self, identifiers):
12951295
response = FutureBriefsResponse()
12961296
response.parse_response_content(response_content)
12971297
if response.is_success():
1298-
return response.briefs
1298+
return response.result
12991299
else:
13001300
raise ApiException(response.code, response.message)
13011301

tigeropen/quote/response/future_briefs_response.py

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,30 @@
77
import pandas as pd
88

99
from tigeropen.common.response import TigerResponse
10+
from tigeropen.common.util.string_utils import camel_to_underline
1011

11-
COLUMNS = ['identifier', 'ask_price', 'ask_size', 'bid_price', 'bid_size', 'pre_close', 'latest_price', 'latest_size',
12-
'latest_time', 'volume', 'open_interest', 'open', 'high', 'low', 'limit_up', 'limit_down', 'settlement',
13-
'settle_date']
14-
BRIEF_FIELD_MAPPINGS = {'askPrice': 'ask_price', 'askSize': 'ask_size', 'bidPrice': 'bid_price', 'bidSize': 'bid_size',
15-
'latestPrice': 'latest_price', 'openInterest': 'open_interest', 'preClose': 'pre_close',
16-
'right': 'put_call', 'latestTime': 'latest_time', 'latestSize': 'latest_size',
17-
'limitUp': 'limit_up', 'limitDown': 'limit_down', 'contractCode': 'identifier',
18-
'settleDate': 'settle_date'}
12+
BRIEF_FIELD_MAPPINGS = {'right': 'put_call', 'contractCode': 'identifier'}
1913

2014

2115
class FutureBriefsResponse(TigerResponse):
2216
def __init__(self):
2317
super(FutureBriefsResponse, self).__init__()
24-
self.briefs = None
18+
self.result = None
2519
self._is_success = None
2620

2721
def parse_response_content(self, response_content):
2822
response = super(FutureBriefsResponse, self).parse_response_content(response_content)
2923
if 'is_success' in response:
3024
self._is_success = response['is_success']
3125

32-
brief_data = []
33-
if self.data and isinstance(self.data, list):
34-
for item in self.data:
35-
item_values = {}
36-
for key, value in item.items():
37-
if value is None:
38-
continue
39-
tag = BRIEF_FIELD_MAPPINGS[key] if key in BRIEF_FIELD_MAPPINGS else key
40-
item_values[tag] = value
41-
brief_data.append([item_values.get(tag) for tag in COLUMNS])
42-
elif isinstance(self.data, dict):
43-
item_values = {}
44-
for key, value in self.data.items():
45-
if value is None:
46-
continue
47-
tag = BRIEF_FIELD_MAPPINGS[key] if key in BRIEF_FIELD_MAPPINGS else key
48-
item_values[tag] = value
49-
brief_data.append([item_values.get(tag) for tag in COLUMNS])
50-
51-
self.briefs = pd.DataFrame(brief_data, columns=COLUMNS)
26+
if self.data:
27+
if isinstance(self.data, list):
28+
fields_map = {origin: camel_to_underline(origin) for origin in self.data[0].keys()}
29+
df = pd.DataFrame(self.data)
30+
else:
31+
fields_map = {origin: camel_to_underline(origin) for origin in self.data.keys()}
32+
df = pd.DataFrame([self.data])
33+
fields_map.update(BRIEF_FIELD_MAPPINGS)
34+
self.result = df.rename(columns=fields_map)
35+
else:
36+
self.result = pd.DataFrame()

0 commit comments

Comments
 (0)