Stocks
get_market_status Get Market Status
QuoteClient.get_market_status(market=Market.ALL, lang=None)
Description
Get the market status of a queried market(pre-market,post-market), and get the most recent open time of this market
Rate Limit
Please refer to Rate Limit
Parameter | Type | Required | Description |
---|---|---|---|
market | Market | No | Market being queried, use enums defined in tigeropen.common.consts.Market , such as Market.US, see enums for details |
lang | Language | No | Language, use enums defined in tigeropen.common.consts.Language , such as Language.zh_CN,default: client_config.language |
Return
list
Each element is a MarketStatus object,MarketStatus is structured as follows:
Parameter | Type | Description |
---|---|---|
market | str | name of the Market being queried |
trading_status | str | status of the market. Possible status are: NOT_YET_OPEN, PRE_HOUR_TRADING, TRADING, MIDDLE_CLOSE, POST_HOUR_TRADING, CLOSING, EARLY_CLOSED, MARKET_CLOSED; |
status | str | a description of the current market status |
open_time | datetime | closest market open time in the future, a datetime object with tzinfo |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key file path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
market_status_list = quote_client.get_market_status(Market.US)
[MarketStatus({'market': 'US', 'status': 'PreMarket', 'open_time': datetime.datetime(2019, 1, 7, 9, 30, tzinfo=<DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>), 'trading_status': 'PRE_HOUR_TRADING'})]
get_trading_calendar
get trading calendar of market
QuoteClient.get_trading_calendar(market, begin_date=None, end_date=None)
Description
The trading day is obtained by excluding weekends and holidays from the natural day and does not exclude temporary market closures.
Provides a calendar from 2015 onwards to the end of this year. If it is out of range, the start and end times will be processed to be within the range of the provided data.
Rate limit
Please refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
market | Market | Yes | filter by market, you can use the enums defined in tigeropen.common.consts.Market , such as Market.US |
begin_date | str | No | begin date of calendar,include this day. format yyyy-MM-dd, like '2022-06-01' |
end_date | str | No | end date of calendar,exclude this day. format yyyy-MM-dd |
begin_date and end_date parameters description:
begin_date provided | end_date provided | Date Range Result |
---|---|---|
yes | yes | (begin_date, end_date) |
yes | no | (begin_date, begin_date+365) |
no | yes | (end_date-365,end_date) |
no | no | (Today, Today + 30) |
Return
list
Each item is a dict, which key's meaning as follows:
Parameter | Type | Description |
---|---|---|
date | str | trade day date |
type | str | trade day type. TRADING: whole day trading; EARLY_CLOSE: close market early |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
calendar = quote_client.get_trading_calendar(Market.US, begin_date='2022-11-01', end_date='2022-12-01')
print(calendar)
Return example
[{'date': '2022-11-01', 'type': 'TRADING'}, {'date': '2022-11-02', 'type': 'TRADING'}, {'date': '2022-11-03', 'type': 'TRADING'},
{'date': '2022-11-04', 'type': 'TRADING'}, {'date': '2022-11-07', 'type': 'TRADING'}, {'date': '2022-11-08', 'type': 'TRADING'},
{'date': '2022-11-09', 'type': 'TRADING'}, {'date': '2022-11-10', 'type': 'TRADING'}, {'date': '2022-11-11', 'type': 'TRADING'},
{'date': '2022-11-14', 'type': 'TRADING'}, {'date': '2022-11-15', 'type': 'TRADING'}, {'date': '2022-11-16', 'type': 'TRADING'},
{'date': '2022-11-17', 'type': 'TRADING'}, {'date': '2022-11-18', 'type': 'TRADING'}, {'date': '2022-11-21', 'type': 'TRADING'},
{'date': '2022-11-22', 'type': 'TRADING'}, {'date': '2022-11-23', 'type': 'TRADING'}, {'date': '2022-11-25', 'type': 'EARLY_CLOSE'},
{'date': '2022-11-28', 'type': 'TRADING'}, {'date': '2022-11-29', 'type': 'TRADING'}, {'date': '2022-11-30', 'type': 'TRADING'}]
get_symbols Get Stock Symbols
QuoteClient.get_symbols(market=Market.ALL, include_otc=False)
Description
Get ticker symbols of all securities of the selected market, including delisted stocks or stocks that are not available for trade
Rate Limit
Please refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
market | Market | No | filter by market, you can use the enums defined in tigeropen.common.consts.Market , such as Market.US, default: Market.ALL |
include_otc | bool | No | if include OTC stocks, default: False. |
Return
list
The elements are ticker symbols for all securities in the market, including symbols for delisted and untradable securities. Symbols begins with '. ' means indexes, such as '.dji' stands for Dow Jones Index.
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key file path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
symbols = quote_client.get_symbols(Market.US)
print(symbols)
Return Example
['.DJI', '.IXIC', '.SPX', 'A', 'AA', 'AAA', 'AAAU', 'AAC', 'AAC.U', 'AAC.WS', 'AACG', 'AACI', 'AACIU', 'AACIW', 'AACQW', 'AADI', 'AADR', 'AAIC', 'AAIN', 'AAL', 'AAMC', 'AAME', 'AAN', 'AAOI', 'AAON', 'AAP', 'AAPL',....,'ZYME', 'ZYNE', 'ZYXI']
get_symbol_names Get Symbols and Names
QuoteClient.get_symbol_names(market=Market.ALL, lang=None, include_otc=False)
Description
Get the ticker symbols and names of all securities in the selected market
Rate Limit
Refer to rate limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
market | Market | No | filter by market, you can use the enums defined in tigeropen.common.consts.Market , such as Market.US,default: Market.ALL |
lang | Language | No | use enums defined in tigeropen.common.consts.Language (Language.en_US),default: client_config.language |
include_otc | bool | No | if True include OTC stocks, default: False |
Response
list
Structured as follows:
Each object in the list is a tuple. The first element of the tuple is the symbol and the second element is the name
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
symbol_names = quote_client.get_symbol_names(market=Market.ALL)
print(symbol_names)
Response Example
[('AAAP', 'Advanced Accelerator Applications SA'), ('AAAU', 'Perth Mint Physical Gold ETF'), ('AABA', 'Altaba'), ('AAC', 'AAC Holdings Inc')]
get_timeline Get timeline
QuoteClient.get_timeline(symbols, include_hour_trading=False, begin_time=-1, lang=None, trade_session=None)
Description
Get the latest timeline data, which contains one-minute price data of the stock. This method will only return data from last trading day, use get_bars
method to inqury
Rate Limit
Refer to:Rate limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | Symbols of stocks, with a maximum of 50 per request. Example: ['AAPL', 'MSFT'] |
include_hour_trading | bool | No | Whether data after regular trading hours is included. default: False |
begin_time | str | No | The beginning time of the first data point, Use timestamp or a time string. Format: 1639386000000 or '2019-06-07 23:00:00' or '2019-06-07' |
lang | Language | No | Language supported, use enums defined in tigeropen.common.consts.Language ,default: client_config.language |
trade_session | TradingSession | No | Trade Session, PreMarket/Regular/AfterHours/OverNight, default: None/Regular |
Response
pandas.DataFrame
Structured as follows:
COLUMN | Type | Description |
---|---|---|
symbol | str | Ticker symbol of asset. such as AAPL |
time | int | Timestamp. Example: 1639386000000 |
price | float | close price of current one-minute bar |
avg_price | float | volume weighted average price |
pre_close | float | close price of last trading day |
volume | int | volume of current one-minute bar |
trading_session | str | Possible values are: "pre_market", "regular" and "after_hours" |
Example
import pandas as pd
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
timeline = quote_client.get_timeline(['01810'], include_hour_trading=False)
# format time into human readable time
timeline['cn_date'] = pd.to_datetime(timeline['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('Asia/Shanghai')
timeline['us_date'] = pd.to_datetime(timeline['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
Response Example
symbol time price avg_price pre_close volume trading_session
0 01810 1547217000000 23.4700 23.211563 23.4 233000 regular
1 01810 1547217060000 23.6700 23.408620 23.4 339296 regular
2 01810 1547217120000 23.5900 23.423038 23.4 46337 regular
3 01810 1547217180000 23.5000 23.428830 23.4 66697 regular
4 01810 1547217240000 23.5108 23.433360 23.4 46762 regular
get_timeline_history Get history timeline
QuoteClient.get_timeline_history(symbols, date, right=QuoteRight.BR)
Description
Get the historical time-share data for a certain date
Rate Limit
Refer to:Rate limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | security code list, Up to 50 passes at a time, e.g. ['AAPL', 'TSLA'] |
date | str | Yes | timeline date. e.g. '2022-04-14' |
right | QuoteRight | No | quote right, refer to: tigeropen.common.consts.QuoteRight enum .default: Quote.Right.BR, |
Response
pandas.DataFrame
Parameter | Type | Description |
---|---|---|
symbol | str | security code, e.g. AAPL |
time | int | millisecond timestamp, e.g. 1639386000000 |
price | float | current minute closing price |
avg_price | float | volume-weighted average price to the current time |
Example
import pandas as pd
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
timeline = quote_client.get_timeline_history(['AAPL', 'BABA'], '2021-04-11')
# Converts time to the datetime of the corresponding timezone
timeline['cn_date'] = pd.to_datetime(timeline['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('Asia/Shanghai')
timeline['us_date'] = pd.to_datetime(timeline['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
# Use symbol as filter
df = timeline.loc[timeline['symbol'] == 'AAPL']
Response Example
symbol time volume price avg_price cn_date us_date
0 AAPL 1649683800000 1569372 168.5000 168.749760 2022-04-11 21:30:00+08:00 2022-04-11 09:30:00-04:00
1 AAPL 1649683860000 323022 168.5800 168.739030 2022-04-11 21:31:00+08:00 2022-04-11 09:31:00-04:00
2 AAPL 1649683920000 362722 168.3230 168.713610 2022-04-11 21:32:00+08:00 2022-04-11 09:32:00-04:00
3 AAPL 1649683980000 511613 167.8300 168.637360 2022-04-11 21:33:00+08:00 2022-04-11 09:33:00-04:00
4 AAPL 1649684040000 332041 167.7700 168.587750 2022-04-11 21:34:00+08:00 2022-04-11 09:34:00-04:00
.. ... ... ... ... ... ... ...
385 BABA 1649706900000 98750 101.5600 102.089710 2022-04-12 03:55:00+08:00 2022-04-11 15:55:00-04:00
386 BABA 1649706960000 74946 101.5984 102.088660 2022-04-12 03:56:00+08:00 2022-04-11 15:56:00-04:00
387 BABA 1649707020000 88570 101.5900 102.087290 2022-04-12 03:57:00+08:00 2022-04-11 15:57:00-04:00
388 BABA 1649707080000 113611 101.5207 102.085380 2022-04-12 03:58:00+08:00 2022-04-11 15:58:00-04:00
389 BABA 1649707140000 430195 101.5500 102.076324 2022-04-12 03:59:00+08:00 2022-04-11 15:59:00-04:00
get_trade_ticks Get Trade Ticks
QuoteClient.get_trade_ticks(symbols, trade_session=None, begin_index=None, end_index=None, limit=None, lang=None)
Description
To obtain transaction data by transaction, this interface can support the query of the full transaction record of the current trading day after the market closes, and can also support the query of the latest real-time transaction record in the market.
Rate Limit
Please refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | Ticker symbol of a list of stocks |
trade_session | tigeropen.common.consts.TradingSession | No | Trade session,PreMarket/Regular/AfterHours. |
begin_index | int | No | Start index |
end_index | int | No | End index |
limit | int | No | Upper limit of the number of data points |
lang | Language | No | Language supported, Use enums defined under tigeropen.common .consts.Language`,default: client_config.language |
begin_index, end_index parameters description
query type | begin_index | end_index | description |
---|---|---|---|
query latest data | -1 | -1 | limit default value: 200 |
query by section | index number | index number | for example:begin_index=10, end_index=100 ,Returns 90 rows containing 10 to 99. If limit is set to 20, 20 records from 10 to 29 will be returned. |
Response
pandas.DataFrame
Structured as below:
Parameter | Type | Description |
---|---|---|
index | int | index |
time | int | timestamp in millisecond |
price | float | price |
volume | int | volume |
direction | str | direction of the price change, "+" stands for "active buy", "-" stands for "active sell", "*" stands for "neutral transaction" |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
# query latest tick data
ticks = quote_client.get_trade_ticks(['AAPL'], begin_index=-1, end_index=-1)
ticks = quote_client.get_trade_ticks(['00700'])
# request pre trading hours data
ticks = quote_client.get_trade_ticks(['AAPL'], trade_session=TradingSession.PreMarket)
Response Example
symbol time volume price direction index
0 AAPL 1712347199527 291 169.53 - 521645
1 AAPL 1712347199564 200 169.53 - 521646
2 AAPL 1712347199564 400 169.53 - 521647
3 AAPL 1712347199564 500 169.53 - 521648
4 AAPL 1712347199566 900 169.53 - 521649
.. ... ... ... ... ... ...
395 AMD 1712347200234 40 170.40 * 556800
396 AMD 1712347200273 55 170.39 * 556801
397 AMD 1712347200274 5 170.39 * 556802
398 AMD 1712347200488 1577655 170.42 * 556803
399 AMD 1712347200489 33 170.42 * 556804
get_stock_briefs Get Stock Briefs
QuoteClient.get_stock_briefs(symbols, include_hour_trading=False, lang=None)
Description
Get real-time data for a stock/stocks. An active market quote permission is required.
Rate Limit
Refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | Symbols of stocks, with a maximum of 50 per request. Example: ['AAPL', 'MSFT'] |
include_hour_trading | bool | No | Whether to include U.S. stocks before and after the market data, default: False |
lang | Language | No | Language supported, use enums defined in tigeropen.common.consts.Language ,default: client_config.language |
Response
pandas.DataFrame
Structured as follows:
COLUMN | Type | Description |
---|---|---|
symbol | str | Ticker symbol of a specific stock |
ask_price | float | Ask price |
ask_size | int | Ask size |
bid_price | float | Bid price |
bid_size | int | Bid size |
pre_close | float | Close price of the last trading day |
latest_price | float | Latest price |
latest_time | int | Time when last trade is made. Unix timestamp, example: 1547516984730 |
volume | int | Volume |
open | float | Opening price |
high | float | High price |
low | float | Low price |
status | str | Trading status |
adj_pre_close | str | 复权调整后的昨收价格 |
Possible trading status:
- "UNKNOWN"
- "NORMAL"
- "HALTED"
- "DELIST"
- "NEW"
- "ALTER"
Example
import pandas as pd
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
briefs = quote_client.get_stock_briefs(['MSFT','MARA'])
# format time into human readable time
briefs['cn_date'] = pd.to_datetime(briefs['latest_time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('Asia/Shanghai')
briefs['us_date'] = pd.to_datetime(briefs['latest_time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
print(briefs.to_string())
Return Example
symbol open high low close pre_close latest_price latest_time ask_price ask_size bid_price bid_size volume status adj_pre_close cn_date us_date
0 MSFT 398.82 398.82 386.155 388.49 396.99 388.49 1741035600000 385.30 100 384.95 200 23007726 NORMAL 388.49 2025-03-04 05:00:00+08:00 2025-03-03 16:00:00-05:00
1 MARA 15.32 15.59 13.520 13.79 13.92 13.79 1741035600000 13.47 150 13.44 536 70463879 NORMAL 13.79 2025-03-04 05:00:00+08:00 2025-03-03 16:00:00-05:00
get_stock_delay_briefs Get Delayed Data (Free)
QuoteClient.get_stock_delay_briefs(symbols, lang=None)
Description
Get delayed market data for U.S. stocks. An active market data permission subscription is not required. This data is only available for U.S stocks. The data is delayed by 15 minutes
Rate Limit
Please refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | A list of ticker symbols, only U.S market is supported. Example: ['MSFT', 'MARA'] |
lang | Language | No | Supported languages, Use enums defined by tigeropen.common.consts.Language . Example: Language.en_US,default: client_config.language |
Response
pandas.DataFrame
Structured as below:
Parameter | Type | Description |
---|---|---|
symbol | str | Ticker symbol of the stock |
pre_close | float | close price of last trading day |
time | int | Last update time, format: UNIX timestamp. Example: 1639429200000 |
volume | int | Volume |
open | float | Opening price |
high | float | High Price |
low | float | Low price |
close | float | Close price |
halted | float | Status of the stock (0: Normal 3: Halt 4: Delisted 7: New 8: Alter) |
Example
import pandas as pd
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
briefs = quote_client.get_stock_briefs(['AAPL'])
# format time into
briefs['cn_date'] = pd.to_datetime(briefs['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('Asia/Shanghai')
briefs['us_date'] = pd.to_datetime(briefs['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
Response Example
symbol pre_close halted time open high low close \
0 AAPL 174.33 0.0 1639602000000 175.11 179.5 172.3108 179.3
volume cn_date us_date
0 131063257 2021-12-16 05:00:00+08:00 2021-12-15 16:00:00-05:00
get_bars Get Bars of a Stock
QuoteClient.get_bars(symbols, period=BarPeriod.DAY, begin_time=-1, end_time=-1, right=QuoteRight.BR, limit=251, lang=None, page_token=None, trade_session=None)
Description
Get the K-line data of a specified stock, and different time granularities can be specified. Currently, this interface supports obtaining K-line data in units of day, week, month, year, minute, 5 minutes, 15 minutes, 30 minutes, and 60 minutes. Considering the performance and stability of the interface, the maximum number of requests for this interface is 1200. For users who need more historical data for analysis or backtesting, it can be requested through the get_bars_by_page method. You can also implement the loop yourself to obtain historical data with a longer time range through multiple requests.
Rate Limit
Please refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | A list of symbols. Maximum 50 per request, example: ['AAPL', 'GOOG'] |
period | BarPeriod | No | K line period. Use enums defined in tigeropen.common.consts.BarPeriod . Example: BarPeriod.DAY。 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min',default: BarPeriod.DAY |
begin_time | int/str | No | Begin time. Unix time stamp in millisecond or a date string. Example: 1639371600000 / '2019-06-07 23:00:00' / '2019-06-07' |
end_time | int/str | No | End time. Unix time stamp in millisecond or a date string. Example: 1639371600000 / '2019-06-07 23:00:00' / '2019-06-07' |
right | QuoteRight | No | Adjustment type. Use enums defined in tigeropen.common.consts.QuoteRight . Example: QuoteRight.BR-forward adjust. QuoteRight.NR-No adjustment,default: QuoteRight.BR |
limit | int | No | The maximum number of bars returned. default: 251 |
lang | Language | No | Supported language. Use enums defined in tigeropen.common.consts.Language . Example: Language.zh_CNdefault: client_config.language |
page_token | str | No | The token of next page. only supported when exactly one symbol |
trade_session | TradingSession | No | Trade Session, PreMarket/Regular/AfterHours/OverNight, default: None |
Response
pandas.DataFrame
Structured as below:
Parameter | Type | Description |
---|---|---|
time | int | Timestamp. Example: 1639371600000 |
open | float | Opening price of a bar |
close | float | Closing price of a bar |
high | float | High pricce of a bar |
low | float | low price of a bar |
volume | float | Volume of a bar |
amount | float | amount of a bar |
next_page_token | str | token of next page |
Example
import pandas as pd
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
bars = quote_client.get_bars(['AAPL'])
print(bars.head().to_string())
# Format time
bars['cn_date'] = pd.to_datetime(bars['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('Asia/Shanghai')
bars['us_date'] = pd.to_datetime(bars['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
Response Example
symbol time open high low close volume amount next_page_token
0 AAPL 1709269200000 179.55 180.53 177.38 179.66 73563082 1.316966e+10 None
1 AAPL 1709528400000 176.15 176.90 173.79 175.10 81510101 1.428321e+10 None
2 AAPL 1709614800000 170.76 172.04 169.62 170.12 95132355 1.625481e+10 None
3 AAPL 1709701200000 171.06 171.24 168.68 169.12 68587707 1.162877e+10 None
4 AAPL 1709787600000 169.15 170.73 168.49 169.00 71765061 1.215380e+10 None
get_bars_by_page Get bars by page
QuoteClient.get_bars_by_page(symbol, period=BarPeriod.DAY, begin_time=-1, end_time=-1, total=10000, page_size=1000, right=QuoteRight.BR, time_interval=2, lang=None, trade_session=None)
Description
Get the bar data of the specified stock in a pagination.
Rate Limit
Refer to [Rate Limit](
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbol | str | Yes | security code |
period | BarPeriod | No | Bar period type. refer to: tigeropen.common.consts.BarPeriod enum. e.g. BarPeriod.DAY. all available values: 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min',default: BarPeriod.DAY |
begin_time | int or str | No | begin time. supports millisecond-level timestamps or date strings, e.g. 1639371600000 or '2019-06-07 23:00:00' or '2019-06-07' |
end_time | int or str | No | end time.supports millisecond-level timestamps or date strings, e.g. 1639371600000 or '2019-06-07 23:00:00' or '2019-06-07' |
total | int | No | total request bar count. default: 10000 |
page_size | int | No | bar page size. default: 1000 |
right | QuoteRight | No | Quote Right. refer to tigeropen.common.consts.QuoteRight enum, e.g. QuoteRight.BR, QuoteRight.NR |
time_interval | int | No | time interval seconds, default: 2 seconds |
lang | Language | No | support language, refer to tigeropen.common.consts.Language enum, e.g. Language.zh_CNdefault: client_config.language |
trade_session | TradingSession | No | PreMarket/Regular/AfterHours/OverNight, default: None |
Response |
pandas.DataFrame
Parameter | Type | Description |
---|---|---|
time | int | millsecond timestamp,e.g. 1639371600000 |
open | float | Bar open price |
close | float | Bar close price |
high | float | Bar highest price |
low | float | Bar lowest price |
volume | float | Bar volume |
next_page_token | str | next page token |
Example
import pandas as pd
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
bars = quote_client.get_bars_by_page(
['AAPL'],
period=BarPeriod.DAY,
begin_time='2024-06-25 21:30:00',
end_time='2025-02-02 23:31:00',
total=1000,
page_size=10,
time_interval=0.01,
)
print(bars.head().to_string())
Response Example
symbol time open high low close volume amount next_page_token
0 AAPL 1719374400000 211.50 214.8600 210.64 213.25 66213186 1.411181e+10 a2xpbmUyLjB8QUFQTHxkYXl8MTcxOTMyMjIwMDAwMHwxNzIwNTg0MDMwMDAw
1 AAPL 1719460800000 214.69 215.7395 212.35 214.10 49772707 1.064720e+10 a2xpbmUyLjB8QUFQTHxkYXl8MTcxOTMyMjIwMDAwMHwxNzIwNTg0MDMwMDAw
2 AAPL 1719547200000 215.77 216.0700 210.30 210.62 82542718 1.784669e+10 a2xpbmUyLjB8QUFQTHxkYXl8MTcxOTMyMjIwMDAwMHwxNzIwNTg0MDMwMDAw
3 AAPL 1719806400000 212.09 217.5100 211.92 216.75 60402929 1.306020e+10 a2xpbmUyLjB8QUFQTHxkYXl8MTcxOTMyMjIwMDAwMHwxNzIwNTg0MDMwMDAw
4 AAPL 1719892800000 216.15 220.3800 215.10 220.27 58046178 1.281286e+10 a2xpbmUyLjB8QUFQTHxkYXl8MTcxOTMyMjIwMDAwMHwxNzIwNTg0MDMwMDAw
get_depth_quote Get Depth Quote
QuoteClient.get_depth_quote(symbols, market)
Description
Get market depth quote, including price, quantity and number of orders, Request limit is 50 symbols per request
CAUTION
The closing auction time of Hong Kong stocks is 16:00-16:10 (the market closes randomly between 16:08 and 16:10), and the last ask-bid data is generally delayed to update one or two minutes after 16:10 US stock market depth data includes pre-market and after-hours information. No parameters are required, and real-time data can be retrieved instantly upon request
Rate Limit
Refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | A list of stock ticker symbols, maximum number is 50 |
market | Market | Yes | Market being quoted, use enums defined by tigeropen.common.consts.Market |
Response
dict
Example:
#for a single symbol:
{'symbol': '02833',
'asks': [(27.4, 300, 2), (27.45, 500, 1), (27.5, 4400, 1), (27.55, 0, 0), (27.6, 5700, 3), (27.65, 0, 0),
(27.7, 500, 1), (27.75, 0, 0), (27.8, 0, 0), (27.85, 0, 0)],
'bids': [(27, 4000, 3), (26.95, 200, 1), (26.9, 0, 0), (26.85, 400, 1), (26.8, 0, 0), (26.75, 0, 0),
(26.7, 0, 0), (26.65, 0, 0), (26.6, 0, 0), (26.55, 0, 0)]
}
#for a list of symbols:
{'02833':
{'symbol': '02833',
'asks': [(27.35, 200, 1), (27.4, 2100, 2), (27.45, 500, 1), (27.5, 4400, 1), (27.55, 0, 0),
(27.6, 5700, 3), (27.65, 0, 0), (27.7, 500, 1), (27.75, 0, 0), (27.8, 0, 0)],
'bids': [(27.05, 100, 1), (27, 5000, 4), (26.95, 200, 1), (26.9, 0, 0), (26.85, 400, 1), (26.8, 0, 0),
(26.75, 0, 0), (26.7, 0, 0), (26.65, 0, 0), (26.6, 0, 0)]
},
'02828':
{'symbol': '02828',
'asks': [(106.6, 6800, 7), (106.7, 110200, 10), (106.8, 64400, 8), (106.9, 80600, 8), (107, 9440, 16),
(107.1, 31800, 5), (107.2, 11800, 4), (107.3, 9800, 2), (107.4, 9400, 1), (107.5, 21000, 9)],
'bids': [(106.5, 62800, 17), (106.4, 68200, 9), (106.3, 78400, 6), (106.2, 52400, 4), (106.1, 3060, 4),
(106, 33400, 4), (105.9, 29600, 3), (105.8, 9600, 2), (105.7, 15200, 2), (105.6, 0, 0)]}
}
Data is organized as (price,quantity,order count) :
[(ask_price1, ask_volume1, order_count), (ask_price2, ask_volume2, order_count), ...]
[(bid_price1, bid_volume2, order_count), (bid_price2, bid_volume2, order_count), ...]
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
depth_quote = quote_client.get_depth_quote(['02833'], Market.HK)
Return
{'symbol': '02833',
'asks': [(27.4, 300, 2), (27.45, 500, 1), (27.5, 4400, 1), (27.55, 0, 0), (27.6, 5700, 3), (27.65, 0, 0),
(27.7, 500, 1), (27.75, 0, 0), (27.8, 0, 0), (27.85, 0, 0)],
'bids': [(27, 4000, 3), (26.95, 200, 1), (26.9, 0, 0), (26.85, 400, 1), (26.8, 0, 0), (26.75, 0, 0),
(26.7, 0, 0), (26.65, 0, 0), (26.6, 0, 0), (26.55, 0, 0)]
}
get_short_interest Get Short Interest) [Useless]
QuoteClient.get_short_interest(symbols, lang=None)
Description
Get short interest of a stock/stocks
Rate Limit
Refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | A list of symbols, maximum number of symbols supported is 100 |
lang | Language | No | Supported languages, Use enums defined by tigeropen.common.consts.Language . Example: Language.en_US,default: client_config.language |
Response
pandas.DataFrame
COLUMN | Type | Description |
---|---|---|
symbol | str | Ticker symbol of a selected stock |
settlement_date | str | Settlement date |
short_interest | int | Short interest of the stock |
avg_daily_volume | int | Daily average volume of the last trading day |
days_to_cover | float | days to cover, which equals short interest/average daily volume. |
percent_of_float | float | Percent of float |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
short_interest = quote_client.get_short_interest(['GOOG', 'AAPL', '00700'])
Response Example
symbol settlement_date short_interest avg_daily_volume days_to_cover percent_of_float
0 GOOG 2018-12-14 2193320 1894404 1.000000 0.7000
1 GOOG 2018-11-30 2580444 1846248 1.000000 0.8000
2 GOOG 2018-11-15 2300074 1677483 1.000000 0.8000
3 GOOG 2018-10-31 2206410 2371360 1.000000 0.7000
4 GOOG 2018-10-15 2103149 1821532 1.000000 0.7000
get_trade_metas Get Trade Requirement Information
QuoteClient.get_trade_metas(symbols)
Description
Get the required information for trading, such as lot size, for a tradable asset.
Rate Limit
Please refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbols | list[str] | Yes | A list of stock symbols, maximum limit being returned is 50 |
Response
pandas.DataFrame
Structured as follows:
COLUMN | Type | Description |
---|---|---|
symbol | str | Ticker symbol of stocks |
lot_size | int | lot size |
min_tick | float | tick size |
spread_scale | float | spread_scale |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
trade_metas = quote_client.get_trade_metas(symbols=['00700', '00336'])
Response Example
symbol lot_size min_tick spread_scale
0 00700 100 0.20 0
1 00336 1000 0.01 0
get_capital_flow
QuoteClient.get_capital_flow(symbol, market, period, begin_time=-1, end_time=-1, limit=200, lang=None))
Description
Get capital net inflow Data, including different time periods, such as daily, weekly, monthly, etc.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbol | string | Yes | symbol |
market | string | Yes | US-U.S. Stocks, HK-Hongkong Stocks, CN-A-Shares |
period | string | Yes | period, possible values are: intraday, day, week, month, year, quarter, 6month |
begin_time | long | No | Begin time. Unix time stamp in millisecond or a date string. Example: 1639371600000, default: -1, which means unbounded. |
end_time | long | No | End time. Unix time stamp in millisecond or a date string. Example: 1639371600000, default: -1, which means unbounded. |
limit | integer | No | The maximum number of points returned. default: 200, Maximum is 1200 |
lang | string | No | Supported languages, Use enums defined by tigeropen.common.consts.Language . Example: Language.en_US,default: client_config.language |
Return
pandas.DataFrame
Parameter | Type | Description |
---|---|---|
symbol | string | stock symbol |
period | string | period type |
time | string | time string,real-time format is "11-25 12:48:00 EST",non real-time format is "2022-11-22" |
timestamp | int | timestamp in millisecond |
net_inflow | float | net inflow, negative means outflow |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
result = quote_client.get_capital_flow('AAPL', market=Market.US, period=CapitalPeriod.INTRADAY)
print(result[:5])
#get first lane net_inflow only
#print(result.iloc[0]['net_inflow'])
# or result['net_inflow'].iloc[0]
Return example
time timestamp net_inflow symbol period
0 03-04 09:30:00 EST 1741098600000 -2.109543e+08 AAPL intraday
1 03-04 09:31:00 EST 1741098660000 -2.147305e+08 AAPL intraday
2 03-04 09:32:00 EST 1741098720000 -2.179206e+08 AAPL intraday
3 03-04 09:33:00 EST 1741098780000 -2.224500e+08 AAPL intraday
4 03-04 09:34:00 EST 1741098840000 -2.222383e+08 AAPL intraday
get_capital_distribution
QuoteClient.get_capital_distribution(symbol, market, lang=None)
Description
Get capital distribution.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbol | string | Yes | symbol |
market | string | Yes | US-U.S. Stocks, HK-Hongkong Stocks, CN-A-Shares |
lang | string | No | Supported languages, Use enums defined by tigeropen.common.consts.Language . Example: Language.en_US,default: client_config.language |
Return
tigeropen.quote.domain.capital_distribution.CapitalDistribution
Name | Type | Description |
---|---|---|
symbol | string | symbol |
net_inflow | double | net inflow(inAll - outAll) |
in_all | double | all inflow(inBig + inMid + inSmall) |
in_big | double | big orders's inflow |
in_mid | double | median orders's inflow |
in_small | double | small orders's inflow |
out_all | double | all outflow(outBig + outMid + outSmall) |
out_big | double | big orders's outflow |
out_mid | double | median orders's outflow |
out_small | double | small orders's outflow |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
result = quote_client.get_capital_distribution('JD', market=Market.US)
print(result)
Return example
CapitalDistribution({'symbol': 'JD', 'net_inflow': -14178801.76, 'in_all': 157357147.5,
'in_big': 25577130.842900004, 'in_mid': 13664116.789999994, 'in_small': 118115899.86410056,
'out_all': 171535949.25, 'out_big': 22642951.677099995, 'out_mid': 12733553.691200001,
'out_small': 136159443.88620025})
get_stock_broker
QuoteClient.get_stock_broker(symbol, limit=40, lang=None))
Get stock broker infomation.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbol | string | Yes | symbol |
limit | integer | No | The maximum number of points returned. Default value is 40. Maximum is 60 |
lang | string | No | Supported languages, Use enums defined by tigeropen.common.consts.Language . Example: Language.en_US,default: client_config.language |
Response
tigeropen.quote.domain.stock_broker.StockBroker
Name | Type | Description |
---|---|---|
symbol | str | stock symbol |
bid_broker | tigeropen.quote.domain.stock_broker.LevelBroker | LevelBroker |
ask_broker | tigeropen.quote.domain.stock_broker.LevelBroker | LevelBroker |
LevelBroker:
Name | Type | Description |
---|---|---|
level | integer | price level |
price | double | price |
broker_count | integer | the count of borkers |
broker | list[igeropen.quote.domain.stock_broker.Broker] | list of Broker |
Broker:
Name | Type | Description |
---|---|---|
id | str | broker id |
name | str | broker name |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
result = quote_client.get_stock_broker('01810', limit=5)
print(result)
Response Example
StockBroker({'symbol': '01810',
'bid_broker': [
LevelBroker({'level': 1, 'price': 11.46, 'broker_count': 5,
'broker': [Broker({'id': '5999', 'name': ''}), Broker({'id': '4374', 'name': ''}),
Broker({'id': '1438', 'name': 'Susquehanna'}), Broker({'id': '4821', 'name': ''}),
Broker({'id': '6998', 'name': ''})]})],
'ask_broker': [
LevelBroker({'level': 1, 'price': 11.48, 'broker_count': 5,
'broker': [Broker({'id': '4374', 'name': ''}), Broker({'id': '9056', 'name': ''}),
Broker({'id': '2027', 'name': ''}), Broker({'id': '4821', 'name': ''}),
Broker({'id': '4374', 'name': ''})]})]})
get_trade_rank
QuoteClient.get_trade_rank(market, lang=Language.en_US)
Description
Get market trading rankings data
Rate Limit
Please refer to Rate Limit
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
market | Market | Yes | Market to query, use enums defined in tigeropen.common.consts.Market , available values are Market.US, Market.HK, Market.SG |
lang | Language | No | Supported languages, Use enums defined by tigeropen.common.consts.Language . Example: Language.en_US,default: Language.en_US |
Response
US stocks return 30 rows, HK and Singapore stocks return 10 rows.
pandas.DataFrame
Structured as follows:
Field | Type | Description |
---|---|---|
symbol | str | Stock symbol |
market | str | Market |
name | str | Name |
sec_type | str | Security type |
change_rate | float | Change rate. If the current time is not in the trading time, it is the change rate of the previous trading day. |
sell_order_rate | float | Sell order ratio. The cumulative buy and sell ratio of the day, for example, in the trading session, it is the cumulative buy and sell ratio of the day, in the after-hours session, it is the cumulative buy and sell ratio of the day, including the pre-market and post-market. |
buy_order_rate | float | Buy order ratio. The calculation method is the same as the above. |
hour_trading_trading_status | int | Pre/Post market trading status (US stocks only) |
hour_trading_trade_session | str | Pre/Post market trading session (US stocks only) |
hour_trading_change_rate | float | The latest change rate of the pre-market and post-market. (Only for US) |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
from tigeropen.common.consts import Market, RankField, RankPeriod
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
rank_data = quote_client.get_trade_rank(
market=Market.US,
lang=Language.en_US
)
print(rank_data)
Response Example
symbol market name sec_type change_rate sell_order_rate buy_order_rate hour_trading_trading_status hour_trading_trade_session hour_trading_change_rate
0 TSLA US Tesla Motors STK -0.021522 0.363025 0.636975 3 AfterHours -0.010952
1 NVDA US NVIDIA STK -0.030871 0.380049 0.619951 3 AfterHours 0.005139
2 BABA US Alibaba STK -0.102330 0.365064 0.634936 3 AfterHours -0.005812
3 PLTR US Palantir Technologies Inc. STK -0.105279 0.401607 0.598393 3 AfterHours -0.032422
4 TIGR US Tiger Brokers STK -0.135366 0.521724 0.478276 3 AfterHours -0.004231
5 TEM US Tempus AI STK 0.021736 0.426186 0.573814 3 AfterHours -0.141871
6 PDD US PDD Holdings Inc STK -0.088092 0.280690 0.719310 3 AfterHours -0.006429
7 AAPL US Apple STK 0.006312 0.493617 0.506383 3 AfterHours 0.004006
8 SMCI US SUPER MICRO COMPUTER INC STK -0.079543 0.514141 0.485859 3 AfterHours -0.019570
9 MSFT US Microsoft STK -0.010313 0.249634 0.750366 3 AfterHours 0.000000
10 TSLL US Direxion Daily TSLA Bull 2X Shares STK -0.043070 0.417538 0.582462 3 AfterHours -0.021927