Futures

About 10 min

get_future_exchanges Get a List of Future Exchanges

QuoteClient.get_future_exchanges(sec_type=SecurityType.FUT, lang=None)

Description

Get a List of Supported Future Exchanges

Frequency Limit

Please see:Rate Limit for details

Arguments

ArgumentTypeDescription
sec_typeSecurityTypeYou can use the enums defined in tigeropen.common.consts.SecurityType,the default value is SecurityType.FUT. FUT stands for futures,FOP stands for options.

Response

pandas.DataFrame

The DataFrame contains the following fields:

ColumnTypeDescription
codestrCode of the exchange
namestrName of the exchange
zonestrTime zone of the location of the exchange

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)

exchanges = quote_client.get_future_exchanges()

Response Example

    code   name              zone
0    CME    CME   America/Chicago
1  NYMEX  NYMEX  America/New_York
2  COMEX  COMEX  America/New_York
3    SGX    SGX         Singapore
4   HKEX   HKEX    Asia/Hong_Kong
5   CBOT   CBOT   America/Chicago
6    OSE    OSE        Asia/Tokyo
7   CBOE   CBOE   America/Chicago
8  EUREX  EUREX     Europe/Berlin

get_future_contracts Get Contracts Available for Trade

QuoteClient.get_future_contracts(exchange, lang=None)

Description

Get Contracts Available for Trade Listed in Certain Exchange

Frequency Limitation

Please see:Rate Limit for details

Arguments

ArgumentTypeDescription
exchangestrcode of an exchange,e.g. 'CBOE'

Response

pandas.DataFrame

The DataFrame contains the following fields:

ColumnTypeDescription
contract_codestrFull contract code. e.g. VIX2208
typestrContract code. Example: CL
symbolstrib symbol of the contract
namestrname of the contract
contract_monthstrMonth of delivery, in month code. Example: 202208 - 2022/08
currencystrCurrency of the contract
first_notice_datestrThe first notification day refers to the date when the physical delivery contract can be delivered physically, and the contract cannot open long positions after the first notification day. Existing long positions will be forced to close before the first notice day (usually the first three trading days). This field is empty for non-physical delivery contracts (such as index contracts)
last_bidding_close_timestrLast bidding time
last_trading_datestrRefers to the last trading date of the contract expiration month. Futures contracts that have not been cleared after the last trading day must be closed through the relevant "spot commodity" or "cash settlement". At present, the last trading day of most futures commodities is usually the settlement day. The first notification day of some commodities is the same day as the last trading day, such as the euro.For cash-settled futures, positions can be opened normally as long as the last trading time has not passed. Non-cash-settled futures are restricted from opening positions from the first three trading days according to the lesser of the last trading time and the first notice day.
tradeboolIf the contract is still open for trading
continuousboolIf the contract is continuous
multiplierfloatMultiplier of the contract
min_tickfloatThe minimum quotation unit for futures price changes. For example, if the current futures price is 2000 and minTick is 100, the correct quotation includes 2100, 2200, and 2005 does not meet the requirements

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)

contracts = quote_client.get_future_contracts('CME')

# Transfer contact as pandas DataFrame as index,and search
contract_nq2309 = contracts.set_index('contract_code').loc['NQ2309']
print(contract_nq2309.name)  # Contract name
print(contract_nq2309.multiplier)  # Multiplier
print(contract_nq2309.last_trading_date)  # Last trading date

Response Example

    contract_code symbol  type                        name contract_month  multiplier exchange  
0        MEUR2209    M6E  MEUR  E-Micro EUR/USD - Sep 2022         202209     12500.0      CME      USD           
1        MEUR2206    M6E  MEUR  E-Micro EUR/USD - Jun 2022         202206     12500.0      CME      USD              
2         CHF2209    CHF   CHF      Swiss Franc - Sep 2022         202209    125000.0      CME      USD          
3         CHF2212    CHF   CHF      Swiss Franc - Dec 2022         202212    125000.0      CME      USD           
4         CHF2303    CHF   CHF      Swiss Franc - Mar 2023         202303    125000.0      CME      USD           

  currency first_notice_date last_bidding_close_time last_trading_date  trade  \
0      USD              None                    None          20191216   True   
1      USD              None                    None          20190916   True   
2      USD              None                    None          20190916   True   
3      USD              None                    None          20190920   True   
4      USD              None                    None          20200320   True   

   continuous   min_tick
0       False     0.0001
1       False     0.0001
2       False     0.0001
3       False     0.0001
4       False     0.0001



get_future_contract Get future contract by code

Description

Get future contract by contract code.

Frequency Limit

Refer to Rate Limitopen in new window

Argument

ArgumentTypeRequiredDescription
contract_codestrYesfuture contract code, e.g. CL2206

Response

`pandas.DataFrame

ArgumentTypeDescription
contract_codecontract code, e.g. CL2112
typestrfuture contract type, e.g. CL
namestrfuture contract name
contract_monthstrcontract month, e.g. 202112, indicates delivery in December 2021
currencystrtrading currency
first_notice_datestrThe first notice day is the date on which physical delivery of the contract can take place, and the contract cannot be opened for long positions after the first notice day. Existing long positions will be forced to close before the first notification date (usually the first three trading days). Non-physical delivery contracts (e.g. index contracts) this field is empty
last_bidding_close_timestrlast bidding close time
last_trading_datestrRefers to the last trading date of the contract expiration month. Futures contracts that have not been cleared after the last trading day must be closed through the relevant spot commodity or cash settlement, and currently the last trading day for most futures commodities is usually the settlement day. Some commodities have the same day as the first notice day and the last trading day, such as the euro For cash delivery futures, as long as the last trading time has not passed, you can open positions normally, Non-cash delivery futures are restricted from opening positions in the first three trading days according to the smaller of the last trading time and the first notice day
tradeboolis tradable
continuousboolis continuous
multiplierfloatcontract multiplier, The real value of a contract is determined by multiplying the futures price by the contract multiplier. The reasonable price of futures can be estimated by dividing the contract multiplier by the physical price.
min_tickfloatThe minimum quote unit for futures price movement, for example, if the current futures price is 2000 and minTick is 100, then the correct quote includes 2100, 2200, and 2005 does not satisfy the requirement

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)

contract = quote_client.get_future_contract('VIX2206')
print(contract)

Response Example

   contract_code symbol type        name contract_month  multiplier exchange currency first_notice_date last_bidding_close_time last_trading_date  trade  continuous  min_tick
0       VIX2206    VIX  VIX        2206         202206      1000.0     CBOE      USD              None                    None          20220615   True       False      0.05


get_current_future_contract Identify Front Month Contract

QuoteClient.get_current_future_contract(future_type, lang=None)

Description

Identify the Front month contract of a given futures product

Frequency Limit

Refer to Rate Limitopen in new window

Arguments

ArgumentTypeDescription
future_typeThe contract code of the future contract, excluding month code. Example: CL, ES

Response

pandas.DataFrame

Structured as follows:

ColumnTypeDescription
contract_codeFull contract trading code, Example: CL2112
typestrcontract code of the product, excluding month code. Example: CL
namestrFull name of the contract
contract_monthstrDelivery month of the contract. Example: 202112, means the delivery month is December of 2021
currencystrCurrency of the contract
first_notice_datestrFirst notice date, the contract cannot be longed after the FND. Existing long positions will be closed out before the FND
last_bidding_close_timestrLast bidding day
last_trading_datestrLast trading day
tradeboolIf the contract is currently available for trade
continuousboolIf the contract is continuous
multiplierfloatmultiplier
min_tickfloatticksize of the contact

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)

contracts = quote_client.get_current_future_contract('ES')

Response Example

contract_code 	symbol type                       name 		contract_month  multiplier exchange  currency \

0        ES2209     ES   ES  		E-mini S&P 500 - Sep 2022         202209        50.0      CME      USD              


 first_notice_date last_bidding_close_time last_trading_date  trade  continuous  min_tick
0            None   									None          20220916   True       False      0.25

get_all_future_contracts

QuoteClient.get_all_future_contracts(future_type, lang=None)

Description

Get all contracts of a given future type, like 'CL'

Frequency Limit

Refer to Rate Limitopen in new window

Arguments

ArgumentTypeDescription
future_typestrThe contract code of the future contract, excluding month code. Example: CL, ES

Response

pandas.DataFrame

Structured as follows:

ColumnTypeDescription
contract_codeFull contract trading code, Example: CL2112
typestrcontract code of the product, excluding month code. Example: CL
namestrFull name of the contract
contract_monthstrDelivery month of the contract. Example: 202112, means the delivery month is December of 2021
currencystrCurrency of the contract
first_notice_datestrFirst notice date, the contract cannot be longed after the FND. Existing long positions will be closed out before the FND
last_bidding_close_timestrLast bidding day
last_trading_datestrLast trading day
tradeboolIf the contract is currently available for trade
continuousboolIf the contract is continuous
multiplierfloatmultiplier
min_tickfloatticksize of the contact

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)

contracts = quote_client.get_current_future_contract('CL')

Response Example

0         CL2209     CL   CL  Light  Crude Oil - Sep 2022         202209      1000.0    NYMEX      USD          20220824                    None          20220822   True       False      0.01
1         CL2210     CL   CL  Light  Crude Oil - Oct 2022         202210      1000.0    NYMEX      USD          20220922                    None          20220920   True       False      0.01
2         CL2211     CL   CL  Light  Crude Oil - Nov 2022         202211      1000.0    NYMEX      USD          20221024                    None          20221020   True       False      0.01
3         CL2212     CL   CL  Light  Crude Oil - Dec 2022         202212      1000.0    NYMEX      USD          20221123                    None          20221121   True       False      0.01
  

get_future_trading_times Get Trading Times of a Future Contract

get_future_trading_times(contract_code, trading_date=None)

Description

Get Trading Times of a selected future contract

Rate Limit

Refer to Rate Limitopen in new window

Arguments

ArgumentTypeDescription
contract_codestrContract code. Example CL1901
trading_dateintTrading date. Example 1643346000000

Response

pandas.DataFrame

Structured as follows:

ColumnTypeDescription
startintTime when trading starts
endintTime when trading ends
tradingboolIf it's a continuous trading session
biddingboolIf it's a bidding session
zonestrTime zone

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 file path', tiger_id='your tiger id', account='your account')
quote_client = QuoteClient(client_config)

times = quote_client.get_future_trading_times('CN1901', trading_date=1545049282852)
# Format start、end 
times['zone_start'] = pd.to_datetime(times['start'], unit='ms').dt.tz_localize('UTC').dt.tz_convert(times['zone'][0])
times['zone_end'] = pd.to_datetime(times['end'], unit='ms').dt.tz_localize('UTC').dt.tz_convert(times['zone'][0])

Response Example

           start            end  trading  bidding       zone  
0  1545036600000  1545037200000    False     True  Singapore   
1  1545093900000  1545094800000    False     True  Singapore   
2  1545121800000  1545122100000    False     True  Singapore   
3  1545037200000  1545079500000     True    False  Singapore   
4  1545094800000  1545121800000     True    False  Singapore   

get_future_bars Get Futures Bars

QuoteClient.get_future_bars(symbol, 
                            period=BarPeriod.DAY, 
                            begin_time=-1, 
                            end_time=-1, 
                            limit=1000)

Description

It provides daily K-line data of popular contracts in the past 10 years, as well as minute-level data of all contracts from August 2017 to the present.

The returned result is a collection of data in reverse chronological order starting from endTime.

For the 1-minute K-line, if there is no transaction within this 1 minute, the K-line data of this minute will be blank; the interface can only pull the K-line data of this 1 minute after there is a transaction within the latest minute. The first transaction is generated at 50 seconds, and the latest data cannot be pulled before 50 seconds.

Frequency Limit

Refer to Rate Limitopen in new window

Argument

nametyperequiredescription
identifierslistYesFuture symbol list
begin_timeintNoStart time, timestamp in milliseconds, the query result contains this time point, the default is: -1, begin_time and end_time both pass -1 by default, and will return according to the number of items set by limit
end_timeintNoEnd time, timestamp in milliseconds, the query result does not include this time point, the default is: -1
periodBarPeriodNoThe obtained K-line period. The default is BarPeriod.DAY, you can use the enumeration constant provided under tigeropen.common.consts.BarPeriod, such as BarPeriod.DAY. 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min'
limitintNoLimit on the number of requests, default 1000, maximum limit: 1000
page_tokenstrNoPaging token, which records the location of the paging. The next_page_token returned by the last request can be passed in as the start flag of the next request. When using pageToken to pull data by paging, other query conditions cannot be changed

Response

pandas.DataFrame, column explain:

columntypedescription
identifierstrFuture symbol
timeintThe timestamp corresponding to the Bar, that is, the end time of the Bar. The cutting method of the bar is consistent with that of the exchange. Taking CN1901 as an example, the data from 17:00 on T day to 16:30 on T+1 day will be synthesized into a daily bar.
latest_timeintBar Last time
openfloatOpen price
highfloatHigh price
lowfloatLow price
closefloatClose price
settlementfloatsettle price,returns 0 when no settlement price is generated
volumeintTrade volume
open_interestintOpen Interest Quantity
next_page_tokenstrpage token

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 = openapi_client.get_future_bars(['CN1901', 'MXP1903'], 
                                          begin_time=-1, 
                                          end_time=1545105097358)
print(bars.head())

Response

  identifier           time    latest_time     open     high     low    close  \
0     CN1901  1545035400000  1545035700002  11022.5  11097.5  109350  10940.0   
1     CN1901  1544776200000  1544776168000  11182.5  11197.5  110025  11030.0   
2     CN1901  1544689800000  1544689765000  11012.5  11252.5  110125  11212.5   
3     CN1901  1544603400000  1544603321185  10940.0  11070.0  109400  11035.0   
4     CN1901  1544517000000  1544516945000  10895.0  10962.5  108150  10942.5   

   settlement  volume  open_interest  
0     10935.0    3872          15148  
1     11042.5    1379          14895  
2     11202.5    4586          12870  
3     11032.5    3514          12237  
4     10927.5    2378          10575  


get_future_bar_by_page Get future bars by page

QuoteClient.get_future_bars_by_page(identifier, period=BarPeriod.DAY, begin_time=-1, end_time=-1, total=10000, page_size=1000, time_interval=2)

Description Get Futures Bars

Frequency Limit

Refer to Rate Limitopen in new window

Argument

ArgumentTypeRequiredDescription
identifierstrYesfuture contract code
periodBarPeriodNobar period. Default: BarPeriod.DAY,refer to: tigeropen.common.consts.BarPeriod enum, e.g. BarPeriod.DAY。 all available value: 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min'
begin_timeintNobegin time, in millsecond timestamp,The query results contain this time point, default:-1,when begin_time and end_time both equals -1, will return the number of items set by the limit
end_timeintNoend time,in millsecond timestamp, The query results not contain this time point, default:-1
totalintNorequest bar total count, default: 10000
page_sizeintNoBar per page size, default: 1000
time_intervalintNotime interval secondes, default: 2 seconds

Response `pandas.DataFrame

ArgumentTypeDescription
identifierstrfuture contract code
timeintBar timestamp is bar finish time. The Bar is cut in the same way as the exchange, using CN1901 as an example, the data from 17:00 on day T to 16:30 on day T+1 will be synthesized into a daily Bar.
latest_timeintBar latest time
openfloatopen price
highfloathighest price
lowfloatlowest price
closefloatclose price
settlementfloatsettlement price
volumeintvolume
open_interestintopen interest
next_page_tokenstrnext page token

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_future_bars_by_page('CLmain',
                                            end_time=1648526400000,
                                            total=10,
                                            page_size=4)
print(bars.head())

Response

  identifier           time    latest_time    open    high     low   close  settlement  volume  open_interest                                    next_page_token
0     CLmain  1647378000000  1647377999000  102.28  102.58   93.53   95.18       96.44  297127         141240  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
1     CLmain  1647464400000  1647464399000   95.23   99.22   94.07   95.36       95.04  220577         119614  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
2     CLmain  1647550800000  1647550797000   95.34  104.24   94.85  103.62      102.98  129667          97283  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
3     CLmain  1647637200000  1647637192000  103.62  106.28  102.30  105.10      104.70   32312         280113  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
4     CLmain  1647896400000  1647896399000  103.62  111.08  102.47  110.93      109.97  187356         280043  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
5     CLmain  1647982800000  1647982795000  110.91  113.35  107.10  108.75      109.27  253043         293664  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
6     CLmain  1648069200000  1648069197000  108.85  115.40  108.38  114.35      114.93  224802         294597  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
7     CLmain  1648155600000  1648155599000  114.47  116.64  110.61  111.27      112.34  240864         292211  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
8     CLmain  1648242000000  1648241998000  111.75  114.12  108.68  112.60      113.90  253610         282247  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...
9     CLmain  1648501200000  1648501199000  112.92  112.93  102.83  103.49      105.96  298655         282016  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMD...


get_future_trade_ticks Get Futures Trade Ticks

QuoteClient.get_future_trade_ticks(identifier, 
                                  begin_index=0, 
                                  end_index=30, 
                                  limit=1000)

Description Get Futures Trade ticks

Frequency Limit

Refer to Rate Limitopen in new window

Arguments

nametyperequiredescription
identifierstrYesFuture symbol
begin_indexintYesbegin index
end_indexintYesend index
limitintNoreturn limit,max 1000 trade ticks

Response

pandas.DataFrame, each column meaning:

nametypedescription
indexintindex
timeintTransaction time, timestamp accurate to milliseconds
pricefloattrade price
volumeinttrade 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)

ticks = quote_client.get_future_trade_ticks('CN1901')
print(ticks)

   identifier  index           time        price  volume
0      CN1901      0  1547456400000  10607.50000       5
1      CN1901      1  1547456402000  10605.00000       6
2      CN1901      2  1547456407000  10602.50000       4
3      CN1901      3  1547456407000  10605.00000       2
4      CN1901      4  1547456424000  10602.50000       5

get_future_brief Get The Latest Futures Quotes

QuoteClient.get_future_brief(identifiers)

Description Get the latest futures quotes, Including ask-bid data, latest transaction data, etc.

Frequency Limit

Refer to Rate Limitopen in new window

Arguments

  • identifiers: futures code name list,such as ['CL2201']

Response

pandas.DataFrame, column explain:

columntypedescription
identifierstrfuture symbol
ask_pricefloatask price
ask_sizeintask quantity
bid_pricefloatbid price
bid_sizeintbid quantity
pre_closefloatPre closing price
latest_pricefloatlast price
latest_sizeintlast quantity
latest_timeintlast time
volumeintintraday cumulative volume
open_interestintopen Interest Quantity
openfloatopen price
highfloathigh price
lowfloatlow price
limit_upfloatlimit up
limit_downfloatlimit down

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_future_brief(['CN1901', 'MXP1903'])
print(briefs)


Response

  identifier    ask_price  ask_size    bid_price  bid_size pre_close  \
0     CN1901  10677.50000        13  10675.00000       145      None   
1    MXP1903      0.05219         9      0.05218         3      None   

   latest_price  latest_size    latest_time  volume  open_interest  \
0   10677.50000            2  1547519736000  111642         863308   
1       0.05219            4  1547519636000    1706         190126   

          open         high          low    limit_up  limit_down  
0  10607.50000  10707.50000  10572.50000  11670.0000   9550.0000  
1      0.05223      0.05223      0.05216      0.0562      0.0482  

Last update: