Skip to content

Commit b1b1cb0

Browse files
committed
Merge branch 'feat_broker_hold' into 'master'
Feat broker hold See merge request server/openapi/openapi-python-sdk!235
2 parents 4570c4e + 5b63800 commit b1b1cb0

File tree

6 files changed

+111
-5
lines changed

6 files changed

+111
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.3.5 (2025-04-11)
2+
### New
3+
- `QuoteClient.get_broker_hold` 经纪商市值
4+
15
## 3.3.4 (2025-04-09)
26
### New
37
- `TradeClient.get_aggregate_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__ = '3.3.4'
7+
__VERSION__ = '3.3.5'

tigeropen/common/consts/service_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
GET_QUOTE_PERMISSION = "get_quote_permission"
6868
TRADING_CALENDAR = "trading_calendar"
6969
STOCK_BROKER = "stock_broker" # 港股股票实时经纪队列
70+
BROKER_HOLD = "broker_hold"
7071
CAPITAL_DISTRIBUTION = "capital_distribution" # 股票当日资金分布
7172
CAPITAL_FLOW = "capital_flow" # 股票资金流向
7273
WARRANT_FILTER = "warrant_filter"

tigeropen/quote/quote_client.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
import pandas as pd
1212

1313
from tigeropen.common.consts import Market, QuoteRight, BarPeriod, OPEN_API_SERVICE_VERSION_V3, \
14-
OPEN_API_SERVICE_VERSION_V1, Language
14+
OPEN_API_SERVICE_VERSION_V1, Language, SortDirection
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, TRADE_RANK, TRADING_CALENDAR, FUTURE_CONTRACTS, MARKET_SCANNER, \
18+
HISTORY_TIMELINE, FUTURE_CONTRACT_BY_CONTRACT_CODE, STOCK_FUNDAMENTAL, TRADE_RANK, TRADING_CALENDAR, \
19+
FUTURE_CONTRACTS, MARKET_SCANNER, \
1920
STOCK_BROKER, CAPITAL_FLOW, CAPITAL_DISTRIBUTION, WARRANT_REAL_TIME_QUOTE, WARRANT_FILTER, MARKET_SCANNER_TAGS, \
2021
KLINE_QUOTA, FUND_ALL_SYMBOLS, FUND_CONTRACTS, FUND_QUOTE, FUND_HISTORY_QUOTE, FINANCIAL_CURRENCY, \
21-
FINANCIAL_EXCHANGE_RATE, ALL_HK_OPTION_SYMBOLS, OPTION_DEPTH
22+
FINANCIAL_EXCHANGE_RATE, ALL_HK_OPTION_SYMBOLS, OPTION_DEPTH, BROKER_HOLD
2223
from tigeropen.common.consts.service_types import MARKET_STATE, ALL_SYMBOLS, ALL_SYMBOL_NAMES, BRIEF, \
2324
TIMELINE, KLINE, TRADE_TICK, OPTION_EXPIRATION, OPTION_CHAIN, FUTURE_EXCHANGE, OPTION_BRIEF, \
2425
OPTION_KLINE, OPTION_TRADE_TICK, FUTURE_KLINE, FUTURE_TICK, FUTURE_CONTRACT_BY_EXCHANGE_CODE, \
@@ -45,7 +46,9 @@
4546
from tigeropen.quote.request.model import MarketParams, MultipleQuoteParams, MultipleContractParams, \
4647
FutureQuoteParams, FutureExchangeParams, FutureContractParams, FutureTradingTimeParams, SingleContractParams, \
4748
SingleOptionQuoteParams, DepthQuoteParams, OptionChainParams, TradingCalendarParams, MarketScannerParams, \
48-
StockBrokerParams, CapitalParams, WarrantFilterParams, KlineQuotaParams, SymbolsParams, OptionContractsParams
49+
StockBrokerParams, CapitalParams, WarrantFilterParams, KlineQuotaParams, SymbolsParams, OptionContractsParams, \
50+
BrokerHoldParams
51+
from tigeropen.quote.response.broker_hold_response import BrokerHoldResponse
4952
from tigeropen.quote.response.capital_distribution_response import CapitalDistributionResponse
5053
from tigeropen.quote.response.capital_flow_response import CapitalFlowResponse
5154
from tigeropen.quote.response.fund_contracts_response import FundContractsResponse
@@ -1689,6 +1692,27 @@ def get_stock_broker(self, symbol, limit=40, lang=None):
16891692
else:
16901693
raise ApiException(response.code, response.message)
16911694

1695+
def get_broker_hold(self, market=Market.HK, order_by='marketValue', direction=SortDirection.ASC, limit=50,
1696+
page=0, lang=None):
1697+
"""获取港股实时经纪队列数据"""
1698+
params = BrokerHoldParams()
1699+
params.market = get_enum_value(market)
1700+
params.order_by = order_by
1701+
params.direction = get_enum_value(direction.name)
1702+
params.limit = limit
1703+
params.page = page
1704+
params.lang = get_enum_value(lang) if lang else get_enum_value(self._lang)
1705+
request = OpenApiRequest(BROKER_HOLD, biz_model=params)
1706+
response_content = self.__fetch_data(request)
1707+
if response_content:
1708+
response = BrokerHoldResponse()
1709+
response.parse_response_content(response_content)
1710+
if response.is_success():
1711+
return response.result
1712+
else:
1713+
raise ApiException(response.code, response.message)
1714+
1715+
16921716
def get_capital_flow(self, symbol, market, period, begin_time=-1, end_time=-1, limit=200, lang=None):
16931717
"""Get capital net inflow Data, including different time periods, such as daily, weekly, monthly, etc.
16941718
:param symbol: 股票代号

tigeropen/quote/request/model.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,60 @@ def to_openapi_dict(self):
10991099
params['limit'] = self.limit
11001100
return params
11011101

1102+
class BrokerHoldParams(BaseParams):
1103+
def __init__(self):
1104+
super().__init__()
1105+
self._market = None
1106+
self._page = None
1107+
self._limit = None
1108+
self._order_by = None
1109+
self._direction = None
1110+
1111+
@property
1112+
def market(self):
1113+
return self._market
1114+
@market.setter
1115+
def market(self, value):
1116+
self._market = value
1117+
@property
1118+
def page(self):
1119+
return self._page
1120+
@page.setter
1121+
def page(self, value):
1122+
self._page = value
1123+
@property
1124+
def limit(self):
1125+
return self._limit
1126+
@limit.setter
1127+
def limit(self, value):
1128+
self._limit = value
1129+
@property
1130+
def order_by(self):
1131+
return self._order_by
1132+
@order_by.setter
1133+
def order_by(self, value):
1134+
self._order_by = value
1135+
@property
1136+
def direction(self):
1137+
return self._direction
1138+
@direction.setter
1139+
def direction(self, value):
1140+
self._direction = value
1141+
def to_openapi_dict(self):
1142+
params = super().to_openapi_dict()
1143+
if self.market:
1144+
params['market'] = self.market
1145+
if self.page is not None and self.page >= 0:
1146+
params['page'] = self.page
1147+
if self.limit:
1148+
params['limit'] = self.limit
1149+
if self.order_by:
1150+
params['order_by'] = self.order_by
1151+
if self.direction:
1152+
params['direction'] = self.direction
1153+
return params
1154+
1155+
11021156

11031157
class CapitalParams(BaseParams):
11041158
def __init__(self):
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pandas as pd
2+
from tigeropen.common.response import TigerResponse
3+
from tigeropen.common.util import string_utils
4+
5+
class BrokerHoldResponse(TigerResponse):
6+
def __init__(self):
7+
super().__init__()
8+
self.result = None
9+
self._is_success = None
10+
11+
def parse_response_content(self, response_content):
12+
response = super().parse_response_content(response_content)
13+
if 'is_success' in response:
14+
self._is_success = response['is_success']
15+
if self.data:
16+
formated_data = string_utils.camel_to_underline_obj(self.data)
17+
items = formated_data.get('items')
18+
result = pd.DataFrame(data=items)
19+
result['page'] = formated_data.get('page')
20+
result['total_page'] = formated_data.get('total_page')
21+
result['total_count'] = formated_data.get('total_count')
22+
self.result = result
23+

0 commit comments

Comments
 (0)