Stocks
get_market_status Get Market Status
QuoteClient.get_market_status(market=Market.ALL, lang=None)
Description
Get the maket 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
Argument | Type | Description |
---|---|---|
market | Market | Market being queried, use enums defined in tigeropen.common.consts.Market, such as Market.US, see enums for details |
lang | Language | Language, use enums defined in tigeropen.common.consts.Language, such as Language.zh_CN |
Return
list
Each element is a MarketStatus object,MarketStatus is structured as follows:
Argument | 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
Arguments
Argument | Type | Description |
---|---|---|
market | Market | filter by market, you can use the enums defined in tigeropen.common.consts.Market, such as Market.US |
begin_date | str | begin date of calendar,include this day. format yyyy-MM-dd, like '2022-06-01' |
end_date | str | end date of calendar,exclude this day. format yyyy-MM-dd |
begin_time and end_time arguments' description:
begin_time is passed | end_time is passed | description |
---|---|---|
yes | yes | begin_time, end_time are the values passed |
yes | no | end_time is 365 days after begin_time |
no | yes | begin_time is 365 days before end_time |
no | no | begin_time is the current date, end_time is 30 days after begin_time |
Return
list
Each item is a dict, which key's meaning as follows:
Argument | 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 = openapi_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 symobls 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
Arguments
Argument | Type | Description |
---|---|---|
market | Market | filter by market, you can use the enums defined in tigeropen.common.consts.Market, such as Market.US |
include_otc | bool | if include OTC stocks, default is False. |
Retrun
list
The element 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, include_otc=False)
Description
Get the ticker symbols and names of all securities in the selected market
Rate Limit
Refer to rate limit
Arguments
Argument | Type | Description |
---|---|---|
market | Market | filter by market, you can use the enums defined in tigeropen.common.consts.Market, such as Market.US |
include_otc | bool | if include OTC stocks, default is 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)
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
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | Symbols of stocks, with a maximum of 50 per request. Example: ['AAPL', 'MSFT'] |
include_hour_trading | bool | Whether data after regular trading hours is included. Optional. Use True or False |
begin_time | str | 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 | Language supported, use enums defined in tigeropen.common.consts.Language |
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)
Description
Get the historical time-share data for a certain date
Rate Limit
Refer to:Rate limit
Argument
Argument | 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. |
Response
pandas.DataFrame
Argument | 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=0, end_index=30, limit=30, 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
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | Ticker symbol of a list of stocks |
trade_session | tigeropen.common.consts.TradingSession | Trade session,PreMarket/Regular/AfterHours. Optional,default TradingSession.Regular |
begin_index | int | Start index |
end_index | int | End index |
limit | int | Upper limit of the number of data points |
lang | Language | Language supported, Use enums defined under tigeropen.common.consts.Language |
begin_index, end_index arguments 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:
Argument | 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, lang=None)
Description
Get real-time data for a stock/stocks. An active market quote permission is required.
Rate Limit
Refer to Rate Limit
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | Symbols of stocks, with a maximum of 50 per request. Example: ['AAPL', 'MSFT'] |
lang | Language | Language supported, use enums defined in tigeropen.common.consts.Language |
include_hour_trading | bool | Whether to include U.S. stocks before and after the market data, default: false |
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 | 复权调整后的昨收价格 |
hour_trading_tag | str | pre-market("Pre-Mkt")、post-market("Post-Mkt") tag |
hour_trading_latest_price | float | latest price |
hour_trading_latest_time | str | latest trade time |
hour_trading_volume | int | trading volume |
hour_trading_timestamp | int | latest trade time in timestamp(ms) |
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(['00700'])
# format latest_time to 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')
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 hour_trading_tag hour_trading_latest_price hour_trading_pre_close hour_trading_latest_time hour_trading_volume hour_trading_timestamp cn_date us_date
0 MARA 15.28 16.74 15.24 15.67 15.32 15.67 1688760000000 15.79 200 15.75 300 60526218 NORMAL 15.67 Pre-Mkt 15.79 15.67 05:43 EDT 58654 1688982215635 2023-07-08 04:00:00+08:00 2023-07-07 16:00:00-04:00
1 MSFT 339.32 341.79 337.00 337.22 341.27 337.22 1688760000000 334.60 600 334.25 800 21214824 NORMAL 337.22 Pre-Mkt 334.27 337.22 05:43 EDT 58514 1688982207634 2023-07-08 04:00:00+08:00 2023-07-07 16:00:00-04: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
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | A list of ticker symbols, only U.Ss makret is supported. Example: ['AAPL', 'MSFT'] |
lang | Language | Supported languages, Use enums defined by tigeropen.common.consts.Language. Example: Language.en_US |
Response
pandas.DataFrame
Structured as below:
Argument | 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)
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
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | A list of symbols. Maximum 50 per request, example: ['AAPL', 'GOOG'] |
period | BarPeriod | K line period. Default is BarPeriod.DAY. Use enums defined in tigeropen.common.consts.BarPeriod. Example: BarPeriod.DAY。 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min' |
begin_time | int/str | 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 | End time. Unix time stamp in millisecond or a date string. Example: 1639371600000 / '2019-06-07 23:00:00' / '2019-06-07' |
right | QuoteRight | Adjuestment type. Default value is forward adjustment. Use enums defined in tigeropen.common.consts.QuoteRight. Example: QuoteRight.BR-forward adjust. QuoteRight.NR-No adjustment |
limit | int | The maximum number of bars returned. Default value is 251 |
lang | Language | Supported language. Use enums defined in tigeropen.common.consts.Language. Example: Language.zh_CN |
Resoponse
pandas.DataFrame
Strutured as below:
Argument | 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 |
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())
# 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
0 00700 1515474000000 174.5500 175.0600 173.4100 174.33 21583997
1 00700 1515560400000 173.1600 174.3000 173.0000 174.29 23959895
2 00700 1515646800000 174.5900 175.4886 174.4900 175.28 18667729
3 00700 1515733200000 176.1800 177.3600 175.6500 177.09 25418080
4 00700 1516078800000 177.9000 179.3900 176.1400 176.19 29565947
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)
Description
Get the bar data of the specified stock in a pagination.
Rate Limit
Refer to [Rate Limit](
Argument
Argument | Type | Required | Description |
---|---|---|---|
symbol | str | Yes | security code |
period | BarPeriod | No | Bar period type.Default is BarPeriod.DAY, refer to: tigeropen.common.consts.BarPeriod enum. e.g. BarPeriod.DAY. all available values: 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min' |
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 |
time_interval | int | No | time interval seconds, default: 2 seconds |
right | QuoteRight | No | Quote Right. refer to tigeropen.common.consts.QuoteRight enum, e.g. QuoteRight.BR, QuoteRight.NR |
limit | int | No | limitation count. default: 251 |
lang | Language | No | support language, refer to tigeropen.common.consts.Language enum, e.g. Language.zh_CN |
Response
pandas.DataFrame
Argument | 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')
print(bars.head())
Response Example
symbol time open high low close volume next_page_token
0 AAPL 1650254400000 163.92 166.5984 163.57 165.07 69023941 a2xpbmUyLjB8QUFQTHxkYXl8MTY1MTMzNDQwMDAwMHwxNj...
1 AAPL 1650340800000 165.02 167.8200 163.91 167.40 67723833 a2xpbmUyLjB8QUFQTHxkYXl8MTY1MTMzNDQwMDAwMHwxNj...
2 AAPL 1650427200000 168.76 168.8800 166.10 167.23 67929814 a2xpbmUyLjB8QUFQTHxkYXl8MTY1MTMzNDQwMDAwMHwxNj...
3 AAPL 1650513600000 168.91 171.5300 165.91 166.42 87227768 a2xpbmUyLjB8QUFQTHxkYXl8MTY1MTMzNDQwMDAwMHwxNj...
4 AAPL 1650600000000 166.46 167.8699 161.50 161.79 84882424 a2xpbmUyLjB8QUFQTHxkYXl8MTY1MTMzNDQwMDAwMHwxNj...
5 AAPL 1650859200000 161.12 163.1700 158.46 162.88 96046376 a2xpbmUyLjB8QUFQTHxkYXl8MTY1MTMzNDQwMDAwMHwxNj...
6 AAPL 1650945600000 162.25 162.3400 156.72 156.80 95623240 a2xpbmUyLjB8QUFQTHxkYXl8MTY1MTMzNDQwMDAwMHwxNj...
7 AAPL 1651032000000 155.91 159.7900 155.38 156.57 88063191 a2xpbmUyLjB8QUFQTHxkYXl8MTY1MTMzNDQwMDAwMHwxNj...
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
Rate Limit
Refer to Rate Limit
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | A list of stock ticker symbols, maximum number is 50 |
market | Market | 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
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | A list of symbols, maximum number of symbols supported is 100 |
lang | Language | Language supported, Use the enums under tigeropen.common.consts.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
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | 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
Description
Get capital net inflow Data, including different time periods, such as daily, weekly, monthly, etc.
Argument
Argument | Type | Required | Description |
---|---|---|---|
symbol | string | Yes | symbol |
period | string | Yes | period, possible values are: intraday, day, week, month, year, quarter, 6month |
market | string | Yes | US-U.S. Stocks, HK-Hongkong Stocks, CN-A-Shares |
begin_time | long | No | Begin time. Unix time stamp in millisecond or a date string. Example: 1639371600000, default value is -1, which means unbounded. |
end_time | long | No | End time. Unix time stamp in millisecond or a date string. Example: 1639371600000, default value is -1, which means unbounded. |
limit | integer | No | The maximum number of points returned. Default value is 200. Maximum is 1200 |
lang | string | No | Language: zh_CN,zh_TW,en_US. en_US by default |
Return
pandas.DataFrame
Argument | 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)
#get fist lane net_inflow
result.iloc[0]['net_inflow']
# or result['net_inflow'].iloc[0]
Return example
time timestamp net_inflow symbol period
0 2022-02-24 1645678800000 -5.889058e+08 AAPL day
1 2022-02-25 1645765200000 -1.229127e+08 AAPL day
2 2022-02-28 1646024400000 1.763644e+08 AAPL day
get_capital_distribution
QuoteClient.get_capital_distribution
Description
Get capital distribution.
Argument
Argument | Type | Required | Description |
---|---|---|---|
symbol | string | Yes | symbol |
market | string | Yes | US-U.S. Stocks, HK-Hongkong Stocks, CN-A-Shares |
lang | string | No | Language: zh_CN,zh_TW,en_US. en_US by default |
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
Get stock broker infomation.
Argument
Argument | 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 | Language: zh_CN,zh_TW,en_US. en_US by default |
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': ''})]})]})