Options
get_option_expirations Get Options Expiration Date
QuoteClient.get_option_expirations(symbols, market=None)
Description
Get the Expiration date for option
Rate Limit
Refer to Rate Limit
Argument
Argument | Type | Description |
---|---|---|
symbols | list[str] | List of symbols of the underlying assets |
market | tigeropen.common.consts.Market | US/HK, required when request HK options |
Response
pandas.DataFrame
Column | Type | Description |
---|---|---|
symbol | str | symbol of the option |
date | str | Expiration time of the option. Date String formatted as "YYYY-MM-DD" |
timestamp | int | Expiration time of the option, Unix timestamp in millisecond |
period_tag | str | Option period label, "m" is the monthly option, "w" is the weekly option |
Response
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)
expiration = quote_client.get_option_expirations(symbols=['AAPL'])
Response Example
symbol date timestamp
0 AAPL 2019-01-11 1547182800000
1 AAPL 2019-01-18 1547787600000
2 AAPL 2019-01-25 1548392400000
3 AAPL 2019-02-01 1548997200000
4 AAPL 2019-02-08 1549602000000
get_option_briefs Get Option Briefs
QuoteClient.get_option_briefs(identifiers, market=None)
**Description
Gets the option realtime quote.
**Frequency of request
For frequency limits, see: interface request limits
Parameters
parameter name | type | required or not | description |
---|---|---|---|
identifiers | list[str] | Yes | option code list |
market | tigeropen.common.consts.Market | No | US/HK, required when request HK options |
Returns
| pandas.DataFrame
The meaning of each column is as follows:
fields | type | description |
---|---|---|
symbol | str | stock symbol |
strike | str | strike price |
bid_price | float | buy_price |
ask_price | float | bid_size |
ask_price | float | sell_price |
ask_size | int | sell_quantity |
latest_price | float | latest_price |
latest_price | float | latest_price |
volume | int | Volume |
high | float | highest_price |
pre_close | float | pre_close |
pre_close | float | previous_close |
pre_close | float | previous day's close |
pre_close | float | open_interest |
multiplier | int | Multiplier, default 100 for US options |
rates_bonds | float | One-year U.S. Treasury rate, updated daily, e.g., 0.0078 means the effective rate is 0.78% |
right | str | direction (PUT/CALL) |
volatility | str | Historical Volatility |
expiry | int | Time to expiration (milliseconds, 0:00 on the day) |
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)
briefs = quote_client.get_option_briefs(['AAPL 230317C000135000'])
Return example
identifier symbol expiry strike put_call multiplier \
0 AAPL 220128C00175000 AAPL 1643346000000 175.0 CALL 100
ask_price ask_size bid_price bid_size pre_close latest_price \
0 11.0 1 8.5 1 10.8 8.75
latest_time volume open_interest open high low rates_bonds \
0 None 304 328 11.7 12.5 8.72 0.0027
volatility expiry_date
0 28.52% 2022-01-28 00:00:00-05:00
get_option_chain Get Option Chain
QuoteClient.get_option_chain(self, symbol, expiry, option_filter=None, return_greek_value=None, market=None, **kwargs)
Description
Get option chain of a selected option
Rate Limit
Refer to:Rate Limit
Argument
Argument | Type | Description |
---|---|---|
symbol | str | Symbol of the underlying asset |
expiry | str/int | Expiry time of the option, Unix timestamp in millisecond (1705640400000), or a date string formatted as 'YYYY-MM-DD' ('2024-01-19') |
option_filter | tigeropen.quote.domain.filter.OptionFilter | Parameters for filtering the result. Optional |
return_greek_value | bool | Whether to return Greek values |
market | tigeropen.common.consts.Market | US/HK |
Filter by parameters:
For each parameters or criteria, besides 'in_the_money', use _min / _max suffix to define the upper and lower bounds of a filter criteria. Example: delta_min, theta_max. Please see below for a full example.
OptionFilter can use the following parameters to filter the result:
Parameters | Type | Required | Description |
---|---|---|---|
implied_volatility | float | No | Implied volatility |
in_the_money | bool | No | If the contract is in the money |
open_interest | int | No | Open interest. Total number of option contracts that has been traded but not yet been liquified |
delta | float | No | Delta, ranging from -1.0 ~ 1.0 |
gamma | float | No | Gamma |
theta | float | No | Theta |
vega | float | No | Vega |
rho | float | No | Rho |
Response
pandas.DataFrame
Argument | Type | Description |
---|---|---|
identifier | str | Option Identifier |
symbol | str | Symbol of the underlying asset |
expiry | int | Expiration time of the option, Unix timestamp in millisecond |
strike | float | Strike price |
put_call | str | Call/Put |
multiplier | float | Multiplier |
ask_price | float | Ask price |
ask_size | int | Ask size |
bid_price | float | Bid price |
bid_size | int | Bid size |
pre_close | float | Pre close price |
latest_price | float | Latest price |
volume | int | Volume |
open_interest | int | Open interest |
implied_vol | float | implied volatility |
delta | float | delta |
gamma | float | gamma |
theta | float | theta |
vega | float | vega |
rho | float | rho |
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='PEM key path, tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)
option_chain = quote_client.get_option_chain(symbol='AAPL', expiry='2019-01-18')
print(option_chain)
# Use OptionFilter to select options that meets your criteria
option_filter = OptionFilter(implied_volatility_min=0.5, implied_volatility_max=0.9, delta_min=0, delta_max=1,
open_interest_min=100, gamma_min=0.005, theta_max=-0.05, in_the_money=True)
option_chain = openapi_client.get_option_chain('AAPL', '2023-01-20', option_filter=option_filter)
print(option_chain)
# or filiter by indicators
option_chain = openapi_client.get_option_chain('AAPL', '2023-01-20', implied_volatility_min=0.5, open_interest_min=200, vega_min=0.1, rho_max=0.9)
# format expiry time
option_chain['expiry_date'] = pd.to_datetime(option_chain['expiry'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
Response Example
symbol expiry identifier strike put_call volume latest_price pre_close open_interest multiplier implied_vol delta gamma theta vega rho expiry_date
0 AAPL 1689912000000 AAPL 230721C00095000 95.0 CALL 0 80.47 80.47 117 100 0.989442 0.957255 0.001332 -0.061754 0.059986 0.133840 2023-07-21 00:00:00-04:00
1 AAPL 1689912000000 AAPL 230721C00100000 100.0 CALL 0 73.50 76.85 206 100 0.903816 0.955884 0.001497 -0.058678 0.060930 0.141341 2023-07-21 00:00:00-04:00
2 AAPL 1689912000000 AAPL 230721C00105000 105.0 CALL 0 70.01 70.01 84 100 0.852019 0.949875 0.001762 -0.063437 0.070260 0.147292 2023-07-21 00:00:00-04:00
3 AAPL 1689912000000 AAPL 230721C00110000 110.0 CALL 0 61.83 61.83 521 100 0.773813 0.948045 0.001997 -0.059834 0.071063 0.154672 2023-07-21 00:00:00-04:00
4 AAPL 1689912000000 AAPL 230721C00115000 115.0 CALL 0 58.95 58.95 336 100 0.731485 0.939517 0.002387 -0.064365 0.081470 0.159871 2023-07-21 00:00:00-04:00
5 AAPL 1689912000000 AAPL 230721C00120000 120.0 CALL 0 53.60 53.60 566 100 0.662279 0.936079 0.002755 -0.060497 0.082236 0.166783 2023-07-21 00:00:00-04:00
6 AAPL 1689912000000 AAPL 230721C00125000 125.0 CALL 0 48.56 48.56 1360 100 0.612029 0.927733 0.003281 -0.063228 0.093132 0.172146 2023-07-21 00:00:00-04:00
7 AAPL 1689912000000 AAPL 230721C00130000 130.0 CALL 0 42.48 42.48 1675 100 0.583578 0.911524 0.004017 -0.067753 0.105918 0.175052 2023-07-21 00:00:00-04:00```
get_option_bars Get Option Bars
QuoteClient.get_option_bars(identifiers, begin_time=-1, end_time=4070880000000, market=None)
Description
Get daily aggregate bars for an option over a given date range.
Rate Limit
Please refer to Rate Limit
Argument
Argument | Type | Required | Description |
---|---|---|---|
identifiers | list[str] | Yes | A list of option identifiers. Maximum number of contracts per request is 30. Example: ['AAPL 220128C000175000'] |
begin_time | str/int | Yes | The start time of the time window. UNIX timestamp in millisecond, or a date string. Example: 1643346000000 / '2019-01-01' |
end_time | str/int | Yes | The end time of the time window. UNIX timestamp in millisecond, or a date string. Example: 1643346000000 / '2019-01-01' |
period | tigeropen.common.consts.BarPeriod | Yes | kLineType, range of values (DAY:1day, ONE_MINUTE:1min, FIVE_MINUTES:5min, HALF_HOUR. 30 minutes, ONE_HOUR:60 minutes) |
sort_dir | tigeropen.common.consts.SortDirection | No | Sort direction. ASC/DESC ,default ASC |
market | tigeropen.common.consts.Market | No | US/HK, required when request HK options |
Response
pandas.DataFrame
Structured as follows:
Argument | Type | Description |
---|---|---|
identifier | str | Option Identifier |
symbol | str | Symbol of the underlying asset |
expiry | int | Option expiration date, format: YYYY-MM-DD |
put_call | str | Put or call |
strike | float | Strike price |
time | int | Timestamp of the open/start time of each bar, UNIX timestamp in millisecond |
open | float | Opening price |
high | float | High |
low | float | Low |
close | float | Close |
volume | int | Volume |
open_interest | int | Open interest. Total number of option contracts that has been traded but not yet been liquified |
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)
bars = quote_client.get_option_bars(['AAPL 190104P00134000'])
print(bars)
# Format time
bars['expiry_date'] = pd.to_datetime(bars['expiry'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
bars['time_date'] = pd.to_datetime(bars['time'], unit='ms').dt.tz_localize('UTC').dt.tz_convert('US/Eastern')
Response Example
identifier symbol expiry put_call strike time open high low close volume open_interest expiry_date time_date
0 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1639026000000 8.92 9.80 8.00 8.20 364 0 2022-01-28 00:00:00-05:00 2021-12-09 00:00:00-05:00
1 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1639112400000 9.05 10.80 7.80 10.80 277 177 2022-01-28 00:00:00-05:00 2021-12-10 00:00:00-05:00
2 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1639371600000 11.70 12.50 8.72 8.75 304 328 2022-01-28 00:00:00-05:00 2021-12-13 00:00:00-05:00
3 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1639458000000 8.60 9.82 7.00 7.80 1139 427 2022-01-28 00:00:00-05:00 2021-12-14 00:00:00-05:00
4 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1639544400000 8.30 10.70 7.05 10.57 927 1207 2022-01-28 00:00:00-05:00 2021-12-15 00:00:00-05:00
5 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1639630800000 10.50 11.60 6.60 7.14 1118 1447 2022-01-28 00:00:00-05:00 2021-12-16 00:00:00-05:00
6 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1639717200000 6.75 7.25 5.80 6.25 674 2057 2022-01-28 00:00:00-05:00 2021-12-17 00:00:00-05:00
7 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1639976400000 5.00 5.85 4.75 5.40 1034 2363 2022-01-28 00:00:00-05:00 2021-12-20 00:00:00-05:00
8 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640062800000 6.20 6.30 4.85 6.20 756 2549 2022-01-28 00:00:00-05:00 2021-12-21 00:00:00-05:00
9 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640149200000 6.24 7.40 5.90 7.40 2211 3002 2022-01-28 00:00:00-05:00 2021-12-22 00:00:00-05:00
10 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640235600000 7.35 7.65 7.09 7.40 909 3031 2022-01-28 00:00:00-05:00 2021-12-23 00:00:00-05:00
11 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640581200000 7.75 9.70 7.60 9.50 1165 3324 2022-01-28 00:00:00-05:00 2021-12-27 00:00:00-05:00
12 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640667600000 9.38 10.05 8.52 8.85 1110 2816 2022-01-28 00:00:00-05:00 2021-12-28 00:00:00-05:00
get_option_trade_ticks Get Option Tick Data
QuoteClient.get_option_trade_ticks(identifiers, market=None)
Description
Get the most recent tick data for a given option
Rate Limit
Refer to Rate Limit
Argument
Argument | Type | Description |
---|---|---|
identifiers | str | A list of option identifiers. Example: ['AAPL 220128C000175000'] |
market | tigeropen.common.consts.Market | US/HK, required when request HK options |
Response
pandas.DataFrame
Structured as follows:
Argument | Type | Description |
---|---|---|
symbol | str | Option identifier |
expiry | str | Option expiration date, format: YYYY-MM-DD |
put_call | str | Put or call |
strike | float | Strike price |
time | int | Time of the |
price | float | Price |
volume | int | Volume |
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)
option_trade_ticks = quote_client.get_option_trade_ticks(['AAPL 190111P00134000'])
Response Example
identifier symbol expiry put_call strike time price volume
0 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640701803177 9.38 9
1 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640701803177 9.38 1
2 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640701803846 9.46 7
3 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640701806266 9.55 1
4 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640701918302 9.08 1
.. ... ... ... ... ... ... ... ...
111 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640722112754 8.91 25
112 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640723067491 9.00 4
113 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640723585351 8.85 4
114 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640724302670 9.13 2
115 AAPL 220128C00175000 AAPL 1643346000000 CALL 175.0 1640724600973 8.85 1
get_option_depth Get Option Depth Quote
QuoteClient.get_option_depth(identifiers: list[str], market)
Description
Get the depth of an option's ticker data
Request Limit
Refer to Rate Limit
Parameters
parameter name | type | required or not | description |
---|---|---|---|
identifiers | list[str] | Yes | List of option codes, e.g. ['AAPL 220128C000175000']. [Format description](/en/python/operation/trade/getContract.md#Contract introduction) |
market | tigeropen.common.consts.Market | No | US/HK, required when request HK options |
Returns
The structure is as follows:
parameter name | type | description |
---|---|---|
identifier | str | option symbol |
asks | list[tuple] | asks information |
bids | list[tuple] | bids information |
Each item in asks
and bids
is a tuple whose elements are (price, volume, timestamp, code)
.
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
from tigeropen.common.util.contract_utils import get_option_identifier
client_config = get_client_config(private key path', tiger_id='your tiger id', account='your account')
# or client_config = get_client_config(props_path='directory path to tiger_openapi_config.properties file')
quote_client = QuoteClient(client_config)
identifier = 'AAPL 190104P00134000' # or generated by four elements
# or generated by four elements
# identifier = get_option_identifier('AAPL', '20190104', 'PUT', 134)
result = quote_client.get_option_depth([identifier])
print(result)
Return example When requesting a single subject
{'identifier': 'ADBE 240816C00560000',
'request': 3, 10, 1719852973090, 'CBOE'), (18.3, 7, 1719852973090, 'gem'), (18.3, 7, 1719852969591, 'mcry'), (18.3, 7, 1719852969585, 'bzx'), (18.3, 7. 1719852969591, 'BZX'). 3, 6, 1719852969647, 'NSDQ'), (18.3, 4, 1719852973525, 'ARCA'), (18.3, 3, 1719852972512, 'MEMX'), (18.3, 3, 1719852969818, 'C2'), (18.3, 2. 1719852973422, 'BX')],
Bid [(17.9, 8, 1719852972512, 'BOX'), (17.9, 7, 1719852973487, 'AMEX'), (17.9, 6, 1719852973090, 'EMLD'), (17.9, 6, 1719852972660, 'MPRL'), (17.9, 6. 1719852969837, 'ISE'), (17.9, 5, 1719852973422, 'BX'), (1
When requesting multiple subjects
{'ADBE 240816C00560000':
{'identifier': 'ADBE 240816C00560000',
'asks': [(18.3, 36, 1719852973090, 'PHLX'), (18.3, 19, 1719852973090, 'EDGX'), (18.3, 14, 1719852972660, 'MPRL'), (18.3, 14, 1719852972512, 'BOX'), (18.3, 13, 1719852973090, 'EMLD'), (18.3, 12, 1719852973090, 'MIAX'), (18.3, 11, 1719852969837, 'ISE'), (18.3, 10, 1719852973487, 'AMEX'), (18.3, 10, 1719852973090, 'CBOE'), (18.3, 7, 1719852973090, 'GEM'), (18.3, 7, 1719852969591, 'MCRY'), (18.3, 7, 1719852969585, 'BZX'), (18.3, 6, 1719852969647, 'NSDQ'), (18.3, 4, 1719852973525, 'ARCA'), (18.3, 3, 1719852972512, 'MEMX'), (18.3, 3, 1719852969818, 'C2'), (18.3, 2, 1719852973422, 'BX')],
'bids': [(17.9, 8, 1719852972512, 'BOX'), (17.9, 7, 1719852973487, 'AMEX'), (17.9, 6, 1719852973090, 'EMLD'), (17.9, 6, 1719852972660, 'MPRL'), (17.9, 6, 1719852969837, 'ISE'), (17.9, 5, 1719852973422, 'BX'), (17.9, 5, 1719852973090, 'PHLX'), (17.9, 5, 1719852969647, 'NSDQ'), (17.9, 5, 1719852969591, 'MCRY'), (17.9, 4, 1719852973090, 'EDGX'), (17.9, 4, 1719852973090, 'MIAX'), (17.9, 3, 1719852973525, 'ARCA'), (17.9, 2, 1719852973090, 'CBOE'), (17.9, 2, 1719852973090, 'GEM'), (17.9, 2, 1719852969818, 'C2'), (17.9, 1, 1719852969585, 'BZX'), (17.85, 6, 1719852972512, 'MEMX')]},
'ADBE 240816P00560000':
{'identifier': 'ADBE 240816P00560000',
'asks': [(17.45, 6, 1719863999000, 'BOX'), (17.45, 5, 1719863999000, 'EMLD'), (17.45, 5, 1719863999000, 'PHLX'), (17.45, 1, 1719863999000, 'CBOE'), (17.45, 1, 1719863999000, 'ISE'), (17.45, 1, 1719863999000, 'ARCA'), (17.45, 1, 1719863999000, 'MPRL'), (17.45, 1, 1719863999000, 'NSDQ'), (17.45, 1, 1719863999000, 'BX'), (17.45, 1, 1719863999000, 'C2'), (17.45, 1, 1719863999000, 'BZX'), (21.65, 4, 1719863999000, 'EDGX'), (22.0, 2, 1719863999000, 'AMEX'), (27.3, 1, 1719863999000, 'GEM'), (27.5, 1, 1719863999000, 'MIAX'), (28.0, 1, 1719863999000, 'MCRY'), (0.0, 0, 1719864000000, 'MEMX')],
'bids': [(17.05, 6, 1719863999000, 'ISE'), (17.05, 5, 1719863999000, 'BOX'), (17.05, 5, 1719863999000, 'PHLX'), (17.05, 3, 1719863999000, 'MCRY'), (17.05, 2, 1719863999000, 'ARCA'), (17.05, 2, 1719863999000, 'MPRL'), (17.05, 2, 1719863999000, 'NSDQ'), (17.05, 2, 1719863999000, 'BX'), (17.05, 2, 1719863999000, 'BZX'), (17.05, 1, 1719863999000, 'AMEX'), (17.05, 1, 1719863999000, 'CBOE'), (17.05, 1, 1719863999000, 'GEM'), (17.05, 1, 1719863999000, 'C2'), (15.6, 1, 1719863999000, 'EDGX'), (15.5, 1, 1719863999000, 'MIAX'), (11.95, 1, 1719863999000, 'EMLD'), (0.0, 0, 1719864000000, 'MEMX')]}
}
get_option_symbols Get HK options symbols
QuoteClient.get_option_symbols(lang: Language = Language.en_US)
Description
Get the symbols of Hong Kong stock options, e.g. the symbol of 00700 is TCH.
Request Frequency
Refer to Rate Limit
Parameters
parameter name | type | required or not | description |
---|---|---|---|
lang | Language | No | Language of the returned message, not required, defaults to English |
Returns
pandas.DataFrame
.
The structure is as follows:
parameter name | type | description |
---|---|---|
symbol | str | option code, e.g. TCH.HK |
name | str | name |
underlying_symbol | str | HK stock code e.g. 00700 |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
from tigeropen.common.util.contract_utils import get_option_identifier
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_option_symbols()
print(result)
Return example
symbol name underlying_symbol
0 ALC.HK ALC 02600
1 CRG.HK CRG 00390
2 PAI.HK PAI 02318
3 XCC.HK XCC 00939
4 XTW.HK XTW 00788
5 SHL.HK SHL 00968
6 GHL.HK GHL 00868
7 HEX.HK HEX 00388
8 ACC.HK ACC 00914
9 STC.HK STC 02888