Skip to content

Commit ebd9ab2

Browse files
committed
Merge branch 'feat_traderank' into 'master'
Feat traderank See merge request server/openapi/openapi-python-sdk!231
2 parents 762b412 + 5cbf152 commit ebd9ab2

File tree

9 files changed

+99
-4
lines changed

9 files changed

+99
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 3.3.3 (2025-03-04)
2+
### New
3+
- `QuoteClient.get_quote_overnight` 获取夜盘行情
4+
### Mod
5+
- Contract 添加属性 `support_overnight_trading`
6+
17
## 3.3.1 (2024-12-31)
28
### New
39
- `TradeClient.get_funding_history` 出入金历史查询

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.3.1'
7+
__VERSION__ = '3.3.3'

tigeropen/common/consts/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ class TradingSession(Enum):
3434
PreMarket = 'PreMarket' # 盘前
3535
Regular = 'Regular' # 盘中
3636
AfterHours = 'AfterHours' # 盘后
37-
OverNight = 'OverNight' # 夜盘
37+
OverNight = 'OverNight'
3838

3939

40+
@unique
41+
class TradingSessionType(Enum):
42+
PRE_RTH_POST = 'PRE_RTH_POST'
43+
OVERNIGHT ='OVERNIGHT' # 夜盘
44+
RTH = 'RTH' # 盘中
45+
FULL ='FULL' # 全时段
46+
4047

4148
@unique
4249
class SecurityType(Enum):

tigeropen/common/consts/service_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
WARRANT_REAL_TIME_QUOTE = "warrant_real_time_quote"
7373
KLINE_QUOTA = "kline_quota" # 历史k线额度
7474
STOCK_FUNDAMENTAL = "stock_fundamental"
75+
TRADE_RANK = "trade_rank"
76+
QUOTE_OVERNIGHT = "quote_overnight"
7577

7678
# 期权行情
7779
OPTION_EXPIRATION = "option_expiration"

tigeropen/quote/quote_client.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from tigeropen.common.consts import THREAD_LOCAL, SecurityType, CorporateActionType, IndustryLevel
1616
from tigeropen.common.consts.filter_fields import FieldBelongType
1717
from tigeropen.common.consts.service_types import GRAB_QUOTE_PERMISSION, QUOTE_DELAY, GET_QUOTE_PERMISSION, \
18-
HISTORY_TIMELINE, FUTURE_CONTRACT_BY_CONTRACT_CODE, STOCK_FUNDAMENTAL, TRADING_CALENDAR, FUTURE_CONTRACTS, MARKET_SCANNER, \
18+
HISTORY_TIMELINE, FUTURE_CONTRACT_BY_CONTRACT_CODE, STOCK_FUNDAMENTAL, TRADE_RANK, TRADING_CALENDAR, FUTURE_CONTRACTS, MARKET_SCANNER, \
1919
STOCK_BROKER, CAPITAL_FLOW, CAPITAL_DISTRIBUTION, WARRANT_REAL_TIME_QUOTE, WARRANT_FILTER, MARKET_SCANNER_TAGS, \
2020
KLINE_QUOTA, FUND_ALL_SYMBOLS, FUND_CONTRACTS, FUND_QUOTE, FUND_HISTORY_QUOTE, FINANCIAL_CURRENCY, \
2121
FINANCIAL_EXCHANGE_RATE, ALL_HK_OPTION_SYMBOLS, OPTION_DEPTH
@@ -24,7 +24,8 @@
2424
OPTION_KLINE, OPTION_TRADE_TICK, FUTURE_KLINE, FUTURE_TICK, FUTURE_CONTRACT_BY_EXCHANGE_CODE, \
2525
FUTURE_TRADING_DATE, QUOTE_SHORTABLE_STOCKS, FUTURE_REAL_TIME_QUOTE, \
2626
FUTURE_CURRENT_CONTRACT, QUOTE_REAL_TIME, QUOTE_STOCK_TRADE, FINANCIAL_DAILY, FINANCIAL_REPORT, CORPORATE_ACTION, \
27-
QUOTE_DEPTH, INDUSTRY_LIST, INDUSTRY_STOCKS, STOCK_INDUSTRY, STOCK_DETAIL, FUTURE_CONTINUOUS_CONTRACTS
27+
QUOTE_DEPTH, INDUSTRY_LIST, INDUSTRY_STOCKS, STOCK_INDUSTRY, STOCK_DETAIL, FUTURE_CONTINUOUS_CONTRACTS, \
28+
QUOTE_OVERNIGHT
2829
from tigeropen.common.exceptions import ApiException
2930
from tigeropen.common.request import OpenApiRequest
3031
from tigeropen.common.util.common_utils import eastern, get_enum_value, date_str_to_timestamp
@@ -79,9 +80,11 @@
7980
from tigeropen.quote.response.stock_trade_meta_response import TradeMetaResponse
8081
from tigeropen.quote.response.symbol_names_response import SymbolNamesResponse
8182
from tigeropen.quote.response.symbols_response import SymbolsResponse
83+
from tigeropen.quote.response.trade_rank_response import TradeRankResponse
8284
from tigeropen.quote.response.trading_calendar_response import TradingCalendarResponse
8385
from tigeropen.quote.response.warrant_briefs_response import WarrantBriefsResponse
8486
from tigeropen.quote.response.warrant_filter_response import WarrantFilterResponse
87+
from tigeropen.quote.response.quote_overnight_response import QuoteOvernightResponse
8588
from tigeropen.tiger_open_client import TigerOpenClient
8689
from tigeropen.tiger_open_config import LANGUAGE
8790

@@ -1887,4 +1890,32 @@ def get_stock_fundamental(self, symbols, market):
18871890
else:
18881891
raise ApiException(response.code, response.message)
18891892

1893+
def get_trade_rank(self, market, lang=Language.en_US):
1894+
params = MarketParams()
1895+
params.market = get_enum_value(market)
1896+
params.lang = get_enum_value(lang)
1897+
request = OpenApiRequest(TRADE_RANK, biz_model=params)
1898+
response_content = self.__fetch_data(request)
1899+
if response_content:
1900+
response = TradeRankResponse()
1901+
response.parse_response_content(response_content)
1902+
if response.is_success():
1903+
return response.result
1904+
else:
1905+
raise ApiException(response.code, response.message)
1906+
1907+
def get_quote_overnight(self, symbols, lang=Language.en_US):
1908+
params = MultipleQuoteParams()
1909+
params.symbols = symbols if isinstance(symbols, list) else [symbols]
1910+
params.lang = get_enum_value(lang)
1911+
request = OpenApiRequest(QUOTE_OVERNIGHT, biz_model=params)
1912+
response_content = self.__fetch_data(request)
1913+
if response_content:
1914+
response = QuoteOvernightResponse()
1915+
response.parse_response_content(response_content)
1916+
if response.is_success():
1917+
return response.result
1918+
else:
1919+
raise ApiException(response.code, response.message)
1920+
18901921

tigeropen/quote/request/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,3 +1479,4 @@ def to_openapi_dict(self):
14791479
if self.with_details is not None:
14801480
params['with_details'] = self.with_details
14811481
return params
1482+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import pandas as pd
4+
5+
from tigeropen.common.response import TigerResponse
6+
from tigeropen.common.util.string_utils import camel_to_underline_obj
7+
8+
9+
class QuoteOvernightResponse(TigerResponse):
10+
def __init__(self):
11+
super(QuoteOvernightResponse, self).__init__()
12+
self.result = None
13+
14+
def parse_response_content(self, response_content):
15+
response = super(QuoteOvernightResponse, self).parse_response_content(response_content)
16+
if 'data' in response:
17+
data = camel_to_underline_obj(response['data'])
18+
self.result = pd.DataFrame(data)
19+
return response
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from tigeropen.common.response import TigerResponse
2+
import pandas as pd
3+
from tigeropen.common.util.string_utils import camel_to_underline_obj
4+
5+
class TradeRankResponse(TigerResponse):
6+
def __init__(self):
7+
super(TradeRankResponse, self).__init__()
8+
self.result = pd.DataFrame()
9+
self._is_success = None
10+
11+
def parse_response_content(self, response_content):
12+
response = super(TradeRankResponse, self).parse_response_content(response_content)
13+
if 'is_success' in response:
14+
self._is_success = response['is_success']
15+
16+
if self.data:
17+
df_data = []
18+
for item in self.data:
19+
formated_item = camel_to_underline_obj(item)
20+
hour_trading = formated_item.pop('hour_trading', None)
21+
if hour_trading:
22+
for key, value in hour_trading.items():
23+
formated_item['hour_trading_' + key] = value
24+
df_data.append(formated_item)
25+
26+
self.result = pd.DataFrame(df_data)
27+
28+

tigeropen/trade/domain/contract.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def __init__(self, symbol=None, currency=None, contract_id=None, sec_type=None,
9090
self.discounted_end_at = kwargs.get('discounted_end_at')
9191
self.categories = kwargs.get('categories')
9292
self.lot_size = kwargs.get('lot_size')
93+
self.support_overnight_trading = kwargs.get('support_overnight_trading')
9394

9495
@property
9596
def right(self):

0 commit comments

Comments
 (0)