Skip to content

Commit 5aea372

Browse files
committed
Merge branch 'master' into feature_stock_screener
2 parents c429ff7 + b85d93b commit 5aea372

File tree

14 files changed

+330
-8
lines changed

14 files changed

+330
-8
lines changed

CHANGELOG.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
## 2.0.4 (2021-12-08)
2+
### New
3+
- 综合/模拟账户查询资产接口 TradeClient.get_prime_assets
4+
5+
## 2.0.3 (2021-12-01)
6+
### New
7+
- 期权链查询接口支持过滤 QuoteClient.get_option_chain
8+
- 新增延迟行情接口 QuoteClient.get_stock_delay_briefs
9+
10+
## 2.0.2 (2021-11-01)
11+
### Changed
12+
- 移除 client_config 中不常用的属性
13+
- 长链接订阅优化
14+
15+
## 2.0.1 (2021-09-18)
16+
### Breaking
17+
- 移除 python2 的兼容
18+
19+
## 1.4.0 (2021-06-28)
20+
### New
21+
- 新增深度行情查询及订阅
22+
- 新增行情权限抢占接口
23+
24+
## 1.2.0 (2020-04-02)
25+
### New
26+
- 新增行业接口
27+
28+
## 1.1.10 (2020-01-19)
29+
### New
30+
- 新增公司行动日历数据
31+
- 新增附加订单(仅环球账户)
32+
33+
## 1.1.9 (2019-10-28)
34+
### Fixed
35+
- 修复 1.1.8 的安装问题
36+
37+
## 1.1.8 (2019-10-27)
38+
### New
39+
- 持仓、订单相关接口中增加identifier,做为相关标的的唯一识别符。
40+
- 期权增增加 underlying asset 的历史波动率
41+
42+
## 1.1.7 (2019-08-02)
43+
### New
44+
- 期货行情的推送价格默认处理为小数
45+
- 订单与持仓推送中增加 symbol 字段(请注意标准账户与环球账户的差异)
46+
- 账户资产(asset)推送中新增 segment ,表示推送的账户类型。
47+
- 股票合约中增加保证金交易相关数据
48+
- example 中增加了一个示例策略
49+
- 新增一个生成 client_config 的方法
50+
51+
52+
## 1.1.6 (2019-07-12)
53+
### New
54+
- 支持按照 account 订阅持仓、订单、资产信息
55+
56+
## 1.1.5 (2019-06-27)
57+
### New
58+
- get_contracts 支持批量获取合约
59+
- PushClient 中的行情支持按照成交与报价分类订阅
60+
- PushClient 修复盘前成交推送的bug
61+
- PushClient 中的时间戳改为按需推送,不再需要单独订阅
62+
- 重新梳理了get_assets接口,股票与期货交易使用更加清晰
63+
### Documentation
64+
- SDK 中补全了文档,方便在IDE中快速查看
65+
66+
67+
## 1.1.4 (2019-06-06)
68+
### New
69+
- 创建订单不再需要联网请求合约数据和申请订单号, 减少为 place_order 一个请求
70+
- 获取订单列表,订单列表支持一次查询股票和期货订单
71+
- 行情订阅的 focus_key 订阅逻辑修复, 支持订阅指定字段的推送
72+
- get_order 支持按照 id 查询订单
73+
- get_trade_ticks 返回多只股票
74+
- 新增公司行动数据 API, 含分红以及拆合股数据
75+
- 添加基本面 API,含日级别的估值数据以及财报级别的三大报表及衍生因子
76+
- 增加已成交、待撤销和已撤销的订单列表
77+
- push_client 中新增加分钟分时的推送
78+
- push_client 中的订单状态改为 OrderStatus 对象
79+
- push_client 中增加心跳,减少链接断开的可能
80+
- 期货增加 3min、45min 等周期行情的查询, 修复期货 1min 周期的查询
81+
### Fixed
82+
- 修复 get_orders 的 sec_type 无效的问题

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.3'
7+
__VERSION__ = '2.0.4'

tigeropen/common/consts/service_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""
1717
ACCOUNTS = "accounts"
1818
ASSETS = "assets"
19+
PRIME_ASSETS = "prime_assets"
1920
POSITIONS = "positions"
2021
ORDERS = "orders"
2122
ACTIVE_ORDERS = "active_orders" # 待成交订单
@@ -40,6 +41,7 @@
4041
KLINE = "kline"
4142
TRADE_TICK = "trade_tick"
4243
QUOTE_REAL_TIME = "quote_real_time"
44+
QUOTE_DELAY = "quote_delay"
4345
QUOTE_SHORTABLE_STOCKS = "quote_shortable_stocks"
4446
QUOTE_STOCK_TRADE = "quote_stock_trade"
4547
QUOTE_DEPTH = "quote_depth" # level2 深度行情

tigeropen/common/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ def version(self, value):
2020

2121
class Field(Enum):
2222
pass
23+

tigeropen/common/util/string_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ def add_start_end(key, start_marker, end_marker):
1919

2020
def camel_to_underline(hunp_str):
2121
return re.sub(CAMEL_PATTERN, r'\1_\2', hunp_str).lower()
22+
23+
24+
def camel_to_underline_obj(d):
25+
if isinstance(d, list):
26+
return [camel_to_underline_obj(i) if isinstance(i, (dict, list)) else i for i in d]
27+
return {camel_to_underline(k): camel_to_underline_obj(v) if isinstance(v, (dict, list)) else v
28+
for k, v in d.items()}

tigeropen/examples/quote_client_demo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def get_quote():
5151
stock_details = openapi_client.get_stock_details(['AAPL', '03690'])
5252
print(stock_details)
5353

54+
# 获取延迟行情
55+
delay_brief = openapi_client.get_stock_delay_briefs(['AAPL', 'GOOG'])
56+
print(delay_brief)
57+
5458

5559
def get_option_quote():
5660
symbol = 'AAPL'

tigeropen/examples/trade_client_demo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def get_account_apis():
6464
openapi_client.get_positions()
6565
# 获取资产
6666
openapi_client.get_assets()
67+
# 综合/模拟账户获取资产
68+
openapi_client.get_prime_assets()
6769

6870

6971
def trade_apis():

tigeropen/fundamental/request/model.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# -*- coding: utf-8 -*-
2+
from tigeropen.common.model import BaseParams
23

34

4-
class FinancialDailyParams:
5+
class FinancialDailyParams(BaseParams):
56
def __init__(self):
7+
super(FinancialDailyParams, self).__init__()
68
self._symbols = None
79
self._market = None
810
self._period_type = None
@@ -82,8 +84,9 @@ def to_openapi_dict(self):
8284
return params
8385

8486

85-
class FinancialReportParams:
87+
class FinancialReportParams(BaseParams):
8688
def __init__(self):
89+
super(FinancialReportParams, self).__init__()
8790
self._symbols = None
8891
self._market = None
8992
self._fields = None
@@ -139,8 +142,9 @@ def to_openapi_dict(self):
139142
return params
140143

141144

142-
class CorporateActionParams:
145+
class CorporateActionParams(BaseParams):
143146
def __init__(self):
147+
super(CorporateActionParams, self).__init__()
144148
self._symbols = None
145149
self._market = None
146150
self._action_type = None
@@ -208,8 +212,9 @@ def to_openapi_dict(self):
208212
return params
209213

210214

211-
class IndustryParams:
215+
class IndustryParams(BaseParams):
212216
def __init__(self):
217+
super(IndustryParams, self).__init__()
213218
self._industry_level = None
214219
self._industry_id = None
215220
self._market = None

tigeropen/quote/quote_client.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from tigeropen.common.consts import Market, Language, QuoteRight, BarPeriod, OPEN_API_SERVICE_VERSION_V3
1414
from tigeropen.common.consts import THREAD_LOCAL, SecurityType, CorporateActionType, IndustryLevel
15-
from tigeropen.common.consts.service_types import GRAB_QUOTE_PERMISSION, STOCK_SCREENER
15+
from tigeropen.common.consts.service_types import GRAB_QUOTE_PERMISSION, QUOTE_DELAY, STOCK_SCREENER
1616
from tigeropen.common.consts.service_types import MARKET_STATE, ALL_SYMBOLS, ALL_SYMBOL_NAMES, BRIEF, \
1717
TIMELINE, KLINE, TRADE_TICK, OPTION_EXPIRATION, OPTION_CHAIN, FUTURE_EXCHANGE, OPTION_BRIEF, \
1818
OPTION_KLINE, OPTION_TRADE_TICK, FUTURE_KLINE, FUTURE_TICK, FUTURE_CONTRACT_BY_EXCHANGE_CODE, \
@@ -50,6 +50,7 @@
5050
from tigeropen.quote.response.option_quote_ticks_response import OptionTradeTickResponse
5151
from tigeropen.quote.response.quote_bar_response import QuoteBarResponse
5252
from tigeropen.quote.response.quote_brief_response import QuoteBriefResponse
53+
from tigeropen.quote.response.quote_delay_briefs_response import DelayBriefsResponse
5354
from tigeropen.quote.response.quote_depth_response import DepthQuoteResponse
5455
from tigeropen.quote.response.quote_grab_permission_response import QuoteGrabPermissionResponse
5556
from tigeropen.quote.response.quote_ticks_response import TradeTickResponse
@@ -248,6 +249,38 @@ def get_stock_briefs(self, symbols, lang=None):
248249

249250
return None
250251

252+
def get_stock_delay_briefs(self, symbols, lang=None):
253+
"""
254+
query delay quote
255+
:param symbols: stock symbol list, like ['AAPL', 'GOOG']
256+
:param lang: language: tigeropen.common.consts.Language: zh_CN,zh_TW,en_US
257+
:return: pandas.DataFrame. the columns are as follows:
258+
symbol:
259+
pre_close:
260+
time: last quote change time
261+
volume:
262+
open:
263+
high:
264+
low:
265+
close:
266+
halted: stock status(0: normal 3: suspended 4: delist 7: ipo 8: changed)
267+
"""
268+
params = MultipleQuoteParams()
269+
params.symbols = symbols
270+
params.lang = lang.value if lang else self._lang.value
271+
272+
request = OpenApiRequest(QUOTE_DELAY, biz_model=params)
273+
response_content = self.__fetch_data(request)
274+
if response_content:
275+
response = DelayBriefsResponse()
276+
response.parse_response_content(response_content)
277+
if response.is_success():
278+
return response.briefs
279+
else:
280+
raise ApiException(response.code, response.message)
281+
282+
return None
283+
251284
def get_stock_details(self, symbols, lang=None):
252285
"""
253286
获取股票详情
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on 2021/11/11
4+
5+
@author: sukai
6+
"""
7+
8+
import pandas as pd
9+
10+
from tigeropen.common.response import TigerResponse
11+
12+
from tigeropen.common.util import string_utils
13+
14+
15+
class DelayBriefsResponse(TigerResponse):
16+
def __init__(self):
17+
super(DelayBriefsResponse, self).__init__()
18+
self.briefs = None
19+
self._is_success = None
20+
21+
def parse_response_content(self, response_content):
22+
response = super(DelayBriefsResponse, self).parse_response_content(response_content)
23+
if 'is_success' in response:
24+
self._is_success = response['is_success']
25+
if self.data and isinstance(self.data, list):
26+
df = pd.DataFrame(self.data)
27+
field_mapping = {item: string_utils.camel_to_underline(item) for item in df.columns}
28+
self.briefs = df.rename(columns=field_mapping)

0 commit comments

Comments
 (0)