中文

Futures

get_future_exchanges Get List of Futures Exchanges

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

Description

Get the list of futures exchanges

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

ParameterTypeDescription
sec_typeSecurityTypeUse enums from tigeropen.common.consts.SecurityType, default is SecurityType.FUT, FUT represents futures, FOP represents future options
langLanguagezh_CN, zh_TW, en_US

Returns

pandas.DataFrame

Structure:

COLUMNTypeDescription
codestrExchange code
namestrExchange name
zonestrExchange time zone

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

exchanges = quote_client.get_future_exchanges()
# Print the code, name, and time zone of the first exchange
exchange1 = exchanges.iloc[0]
print(f'code: {exchange1.code}, name: {exchange1.name}, zone: {exchange1.zone}')

Return Example

      code           name                        zone 
0      SGX    Singapore Exchange               Singapore
1     HKEX     Hong Kong Exchange           Asia/Hong_Kong
2  CBOEXBT  Chicago Board Options Exchange  America/Chicago
3      OSE     Osaka Exchange                  Asia/Tokyo
4     CBOE  Chicago Board Options Exchange   America/Chicago

get_future_contracts Get Tradable Contracts Under Exchange

QuoteClient.get_future_contracts(exchange, lang=None)

Description

Get tradable contracts under an exchange

How to handle First Notice Day and Last Trading Day: Whether entering the First Notice Day or after the Last Settlement Day, the main trading month will shift to the next month contract, making the liquidity of the expiring month worse. Therefore, it is recommended that whether it is long or short positions, roll over or trade the next month contract before the First Notice Day and close to the Last Trading Day.

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

ParameterTypeRequiredDescription
exchangestrYesExchange code, e.g. 'CBOE'
langLanguageNozh_CN, zh_TW, en_US

Returns

pandas.DataFrame

Structure:

COLUMNTypeDescription
contract_codestrContract code, e.g. VIX2208
typestrTrading variety corresponding to the futures contract, e.g. CL
symbolstrCorresponding symbol
namestrName of the futures contract
contract_monthstrContract delivery month, e.g. 202208, representing August 2022
currencystrTrading currency type
exchangestrExchange code
first_notice_datestrFirst Notice Date, the date when physical delivery contracts can proceed with physical delivery. Contracts cannot open long positions after the First Notice Date. Existing long positions will be force-closed before the First Notice Date (usually three trading days prior). This field is empty for non-physical delivery contracts (such as index contracts)
last_bidding_close_timestrBidding close time
last_trading_datestrThe last trading date in the contract expiry month. Futures contracts not yet settled after the last trading date must be closed through related 'spot commodities' or 'cash settlement'. Currently, for most futures commodities, the last trading date is usually the settlement date. For some commodities, the First Notice Date and Last Trading Date are the same day, such as Euro
For cash-settled futures, positions can be opened normally as long as the last trading time has not passed. For non-cash-settled futures, based on the smaller of the last trading time and first notice date, opening positions will be restricted starting three trading days prior
tradeboolWhether tradable
continuousboolWhether it's a continuous contract
multiplierfloatContract multiplier. The futures price multiplied by the contract multiplier gives the contract's face value. You can estimate the reasonable futures price by dividing the physical price by the contract multiplier
min_tickfloatMinimum price change unit for futures prices. For example, if the current futures price is 2000 and minTick is 100, then correct quotes include 2100, 2200, while 2005 does not meet requirements
product_worthstrContract size
delivery_modestrDelivery method
product_typestrContract type

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

contracts = quote_client.get_future_contracts('CME')

# Set contract code as pandas DataFrame index and query fields
contract_nq2309 = contracts.set_index('contract_code').loc['NQ2309']
print(contract_nq2309.name)  # Contract name
print(contract_nq2309.multiplier)  # Contract multiplier
print(contract_nq2309.last_trading_date)  # Last trading date

Return Example

  contract_code symbol  type         name contract_month  multiplier exchange  \
0       MXP1912    MXP   MXP       Peso 1912         201912    500000.0   GLOBEX   
1       MXP1909    MXP   MXP       Peso 1909         201909    500000.0   GLOBEX   
2      MEUR1909    M6E  MEUR      Micro Euro 1909         201909     12500.0   GLOBEX   
3        ES1909     ES    ES  S&P500 Index 1909         201909        50.0   GLOBEX   
4        ES2003     ES    ES  S&P500 Index 2003         202003        50.0   GLOBEX   

  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  
0       False  
1       False  
2       False  
3       False  
4       False  


get_future_contract Get Futures Contract by Code

QuoteClient.get_future_contract(contract_code, lang=None)

Description

Get futures contract by code

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

ParameterTypeRequiredDescription
contract_codestrYesFutures contract code, e.g. CL2206
langLanguageNozh_CN, zh_TW, en_US

Returns

pandas.DataFrame

Structure:

COLUMNTypeDescription
contract_codeContract code, e.g. CL2112
typestrTrading variety corresponding to the futures contract, e.g. CL
namestrName of the futures contract
contract_monthstrContract delivery month, e.g. 202112, representing December 2021 delivery
currencystrTrading currency
first_notice_datestrFirst Notice Date, the date when physical delivery contracts can proceed with physical delivery. Contracts cannot open long positions after the First Notice Date. Existing long positions will be force-closed before the First Notice Date (usually three trading days prior). This field is empty for non-physical delivery contracts (such as index contracts)
last_bidding_close_timestrBidding close time
last_trading_datestrThe last trading date in the contract expiry month. Futures contracts not yet settled after the last trading date must be closed through related 'spot commodities' or 'cash settlement'. Currently, for most futures commodities, the last trading date is usually the settlement date. For some commodities, the First Notice Date and Last Trading Date are the same day, such as Euro
For cash-settled futures, positions can be opened normally as long as the last trading time has not passed. For non-cash-settled futures, based on the smaller of the last trading time and first notice date, opening positions will be restricted starting three trading days prior
tradeboolWhether tradable
continuousboolWhether it's a continuous contract
multiplierfloatContract multiplier. The futures price multiplied by the contract multiplier gives the contract's face value. You can estimate the reasonable futures price by dividing the physical price by the contract multiplier
min_tickfloatMinimum price change unit for futures prices. For example, if the current futures price is 2000 and minTick is 100, then correct quotes include 2100, 2200, while 2005 does not meet requirements
exchangestrExchange code
symbolstrContract symbol

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import get_client_config
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

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

Return Example

  contract_code  continuous contract_month currency  display_multiplier exchange exchange_code first_notice_date  last_bidding_close_time last_trading_date  min_tick  multiplier    name symbol  trade type
0       CHF2512       False         202512      USD                   1      CME        GLOBEX                                          0          20251215   0.00005    125000.0  Swiss Franc 2512    CHF   True  CHF

get_current_future_contract Query Current Contract for Specified Variety

QuoteClient.get_current_future_contract(future_type, lang=None)

Description

Query the current contract for a specified variety, i.e., the main continuous contract

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

ParameterTypeRequiredDescription
future_typestrYesTrading variety corresponding to futures contract, e.g. CL
langLanguageNozh_CN, zh_TW, en_US

Returns

pandas.DataFrame

Structure:

COLUMNTypeDescription
contract_codeContract code, e.g. CL2112
typestrTrading variety corresponding to the futures contract, e.g. CL
namestrName of the futures contract
contract_monthstrContract delivery month, e.g. 202112, representing December 2021 delivery
currencystrTrading currency
first_notice_datestrFirst Notice Date, the date when physical delivery contracts can proceed with physical delivery. Contracts cannot open long positions after the First Notice Date. Existing long positions will be force-closed before the First Notice Date (usually three trading days prior). This field is empty for non-physical delivery contracts (such as index contracts)
last_bidding_close_timestrBidding close time
last_trading_datestrThe last trading date in the contract expiry month. Futures contracts not yet settled after the last trading date must be closed through related 'spot commodities' or 'cash settlement'. Currently, for most futures commodities, the last trading date is usually the settlement date. For some commodities, the First Notice Date and Last Trading Date are the same day, such as Euro
For cash-settled futures, positions can be opened normally as long as the last trading time has not passed. For non-cash-settled futures, based on the smaller of the last trading time and first notice date, opening positions will be restricted starting three trading days prior
tradeboolWhether tradable
continuousboolWhether it's a continuous contract
multiplierfloatContract multiplier. The futures price multiplied by the contract multiplier gives the contract's face value. You can estimate the reasonable futures price by dividing the physical price by the contract multiplier
min_tickfloatMinimum price change unit for futures prices. For example, if the current futures price is 2000 and minTick is 100, then correct quotes include 2100, 2200, while 2005 does not meet requirements
exchangestrExchange code
symbolstrContract symbol
product_worthstrContract size
delivery_modestrDelivery method
product_typestrContract type

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

contracts = quote_client.get_current_future_contract('ES')

Return Example

  contract_code type         name contract_month currency first_notice_date  \
0        ES1903   ES  S&P500 Index 1903         201903      USD          20190315   

   last_bidding_close_time last_trading_date  trade  continuous  
0                        0          20190315   True       False  

get_all_future_contracts Query All Contracts of Specified Variety

QuoteClient.get_all_future_contracts(future_type, lang=None)

Description

Query all contracts of a specified variety

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

Parameter NameTypeRequiredDescription
future_typestrYesTrading variety of futures contract, e.g., CL
langLanguageNozh_CN, zh_TW, en_US

Returns

pandas.DataFrame

Structure as follows:

COLUMNTypeDescription
contract_codeContract code, e.g., CL2112
typestrTrading variety of futures contract, e.g., CL
namestrName of futures contract
contract_monthstrContract delivery month, e.g., 202112, indicating December 2021 delivery
currencystrTrading currency
first_notice_datestrFirst notice date, indicating the date when physical delivery contracts can be physically delivered. Contracts cannot open long positions after the first notice date. Existing long positions will be forcibly closed before the first notice date (usually three trading days before). This field is empty for non-physical delivery contracts (e.g., index contracts)
last_bidding_close_timestrBidding close time
last_trading_datestrThe last trading date of the contract's expiration month. Futures contracts not yet cleared after the last trading date must be closed through relevant 'spot commodities' or 'cash settlement' methods. Currently, for most futures commodities, the last trading date is usually the settlement date. For some commodities, the first notice date and last trading date are the same day, such as the Euro
For cash-settled futures, positions can be opened normally as long as the last trading time has not passed. For non-cash settled futures, position opening is restricted starting three trading days before the smaller of the last trading time and first notice date
tradeboolWhether tradable
continuousboolWhether it is a continuous contract
multiplierfloatContract multiplier. The futures price multiplied by the contract multiplier gives the contract face value. The reasonable futures price can be estimated by dividing the physical price by the contract multiplier
min_tickfloatMinimum price movement unit for futures prices. For example, if the current futures price is 2000 and minTick is 100, then correct quotes include 2100, 2200, while 2005 does not meet requirements
exchangestrExchange code
symbolstrContract code
product_worthstrContract size
delivery_modestrDelivery method
product_typestrContract type

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

contracts = quote_client.get_all_future_contracts('CL')

Return Example

   contract_code symbol type       name contract_month  multiplier exchange exchange_code currency first_notice_date last_bidding_close_time last_trading_date  trade  continuous  min_tick
0         CL2304     CL   CL  WTI Crude 2304         202304      1000.0    NYMEX         NYMEX      USD          20230323                    None          20230321   True       False      0.01
1         CL2305     CL   CL  WTI Crude 2305         202305      1000.0    NYMEX         NYMEX      USD          20230424                    None          20230420   True       False      0.01
2         CL2306     CL   CL  WTI Crude 2306         202306      1000.0    NYMEX         NYMEX      USD          20230524                    None          20230522   True       False      0.01
3         CL2307     CL   CL  WTI Crude 2307         202307      1000.0    NYMEX         NYMEX      USD          20230622                    None          20230620   True       False      0.01
4         CL2308     CL   CL  WTI Crude 2308         202308      1000.0    NYMEX         NYMEX      USD          20230724                    None          20230720   True       False      0.01
5         CL2309     CL   CL  WTI Crude 2309         202309      1000.0    NYMEX         NYMEX      USD          20230824                    None          20230822   True       False      0.01
6         CL2310     CL   CL  WTI Crude 2310         202310      1000.0    NYMEX         NYMEX      USD          20230922  ```

get_future_continuous_contracts Query Continuous Contracts of Specified Variety

QuoteClient.get_future_continuous_contracts(future_type, lang=None)

Description

Query continuous contracts of a specified variety

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

Parameter NameTypeRequiredDescription
future_typestrYesTrading variety of futures contract, e.g., CL
langLanguageNozh_CN, zh_TW, en_US

Returns

pandas.DataFrame

Structure as follows:

COLUMNTypeDescription
contract_codestrContract code, e.g., CLmain
continuousboolWhether it is a continuous contract
contract_monthstrContract delivery month, e.g., 202112, indicating December 2021 delivery
currencystrTrading currency
display_multiplierfloatContract multiplier. The futures price multiplied by the contract multiplier gives the contract face value. The reasonable futures price can be estimated by dividing the physical price by the contract multiplier
exchangestrExchange
exchange_codestrExchange code
first_notice_datestrFirst notice date, indicating the date when physical delivery contracts can be physically delivered. Contracts cannot open long positions after the first notice date. Existing long positions will be forcibly closed before the first notice date (usually three trading days before). This field is empty for non-physical delivery contracts (e.g., index contracts)
last_bidding_close_timestrBidding close time
last_trading_datestrThe last trading date of the contract's expiration month. Futures contracts not yet cleared after the last trading date must be closed through relevant 'spot commodities' or 'cash settlement' methods. Currently, for most futures commodities, the last trading date is usually the settlement date. For some commodities, the first notice date and last trading date are the same day, such as the Euro
For cash-settled futures, positions can be opened normally as long as the last trading time has not passed. For non-cash settled futures, position opening is restricted starting three trading days before the smaller of the last trading time and first notice date
min_tickfloatMinimum price movement unit for futures prices. For example, if the current futures price is 2000 and minTick is 100, then correct quotes include 2100, 2200, while 2005 does not meet requirements
multiplierfloatContract multiplier. The futures price multiplied by the contract multiplier gives the contract face value. The reasonable futures price can be estimated by dividing the physical price by the contract multiplier
namestrName of futures contract
symbolstrAbbreviation of futures contract
tradeboolWhether tradable
typestrTrading variety of futures contract, e.g., CL
product_worthstrContract size
delivery_modestrDelivery method
product_typestrContract type

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

contracts = quote_client.get_future_continuous_contracts('CL')

Return Example

 contract_code  continuous contract_month currency  display_multiplier exchange exchange_code first_notice_date  last_bidding_close_time last_trading_date  min_tick  multiplier          name symbol  trade type
0        CLmain       False                     USD                   1    NYMEX         NYMEX                                          0                        0.01      1000.0  WTI Crude Main     CL   True   CL

get_future_trading_times Query Trading Hours of Specified Contract

get_future_trading_times(identifier, trading_date=None)

Description

Query trading hours of a specified contract

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

Parameter NameTypeRequiredDescription
identifierstrYesContract code, e.g., CL1901
trading_dateintYesMillisecond timestamp for specified trading date, e.g., 1643346000000

Returns

pandas.DataFrame

Structure as follows:

COLUMNTypeDescription
startintTrading start time
endintTrading end time
tradingboolWhether continuous trading
biddingboolWhether auction trading
zonestrTime zone

Example

import pandas as pd
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

times = quote_client.get_future_trading_times('CN1901', trading_date=1545049282852)
# Convert start and end format
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])
print(times.to_string())

Return 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_brief Get Latest Futures Quotes

QuoteClient.get_future_brief(identifiers)

Description

Get latest futures quotes, including order book data, latest trade data, etc.

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

Parameter NameTypeRequiredDescription
identifierslistYesList of futures codes, e.g., ['CL2201']

Returns

pandas.DataFrame

Column meanings as follows:

COLUMNTypeDescription
identifierstrFutures code
ask_pricefloatAsk price
ask_sizeintAsk size
bid_pricefloatBid price
bid_sizeintBid size
pre_closefloatPrevious close price
latest_pricefloatLatest price
latest_sizeintLatest trade size
latest_timeintLatest price trade time
volumeintDaily accumulated trade volume
open_interestintOpen interest quantity
open_interest_changeintOpen interest change
openfloatOpen price
highfloatHigh price
lowfloatLow price
limit_upfloatUpper limit price
limit_downfloatLower limit price

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

briefs = quote_client.get_future_brief(['CN1901', 'MXP1903'])
print(briefs.to_string())

Return Example

  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  


get_future_depth Get Futures Depth Market Data

QuoteClient.get_future_depth(identifiers)

Description

Get futures depth market data. Requires SDK version 3.4.6 and above.

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

ParameterTypeRequiredDescription
identifierslist[str]YesList of futures codes, e.g. ['CL2201']

Returns

dict

Structure as follows:

FieldTypeDescription
identifierstrFutures code
asklist[tuple]Ask information
bidslist[tuple]Bid information

Each item in asks and bids is a tuple with elements (price, volume)

For a single symbol, the dict structure is as described above; for multiple symbols, the dict is nested two levels with futures symbols as keys. See return examples.

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

result = self.client.get_future_depth(identifiers=['ES2509'])

Return Example

Single symbol

  {
  "identifier": "CL2509",
  "asks": [
      {"price": 63.07, "size": 10},
      {"price": 63.08, "size": 5},
      ...
  ],
  "bids": [
      {"price": 63.06, "size": 7},
      {"price": 63.05, "size": 12},
      ...
  ]
}

Multiple symbols

  {
    "CL2509": {
        "asks": [
            {"price": 63.07, "size": 10},
            {"price": 63.08, "size": 5},
            ...
        ],
        "bids": [
            {"price": 63.06, "size": 7},
            {"price": 63.05, "size": 12},
            ...
        ]
    },
    "ES2509": {
        "asks": [
            {"price": 6469.5, "size": 11},
            {"price": 6469.75, "size": 14},
            ...
        ],
        "bids": [
            {"price": 6469.25, "size": 8},
            {"price": 6469.0, "size": 10},
            ...
        ]
    }
}

get_future_trade_ticks Get Futures Tick-by-Tick Trades

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

Description

The index resets to 0 at 6:00 AM Beijing time each day. Previous day's tick data is cleared one minute before the earliest trading session (auction or trading) begins. New tick data is recorded after the new trading session starts. This reset occurs only once per day, meaning multiple trading sessions within the same trading day will not trigger additional resets.

⚠️

Caution

Once the previous day's tick data is cleared, the API will no longer be able to access that data.

For example: GC2504 tick data is accessible until 5:59 AM, but will reset to index 0 at 6:00 AM.

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

ParameterTypeRequiredDescription
identifierstrYesFutures code
begin_indexintNoStarting index
end_indexintNoEnding index
limitintNoReturn limit, maximum 1000 tick records supported

Returns

pandas.DataFrame

Column meanings:

ParameterTypeDescription
indexintIndex value
timeintTrade time, timestamp in milliseconds
pricefloatTrade price
volumeintTrade volume

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

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

Return Example

   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_bars Get Futures K-Line Data

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

Description

Provides daily-level K-line data for popular contracts over the past 10 years, and minute-level data for all contracts from August 2017 to present.

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

For 1-minute K-line data, if there are no trades within that minute, the 1-minute K-line data will be missing; the API can only retrieve the 1-minute K-line data after trades occur in the most recent minute. If the first trade occurs at the 50th second, data for the latest point cannot be retrieved before the 50th second.

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

ParameterTypeRequiredDescription
identifierslistYesList of futures codes
begin_timeintNoStart time, millisecond timestamp, query results include this time point, default: -1, when both begin_time and end_time default to -1, returns data based on limit setting
end_timeintNoEnd time, millisecond timestamp, query results exclude this time point, default: -1
periodBarPeriodNoK-line period to retrieve. Default BarPeriod.DAY, can use enum constants from tigeropen.common.consts.BarPeriod, such as BarPeriod.DAY. 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min'
limitintNoRequest count limit, default 1000, maximum limit: 1000
page_tokenstrNoPagination token, records pagination position, next_page_token from previous request can be passed as starting marker for next request, other query conditions cannot change when using pageToken pagination

Returns pandas.DataFrame

Column meanings:

COLUMNTypeDescription
identifierstrFutures contract code
timeintTimestamp corresponding to the bar, i.e., the end time of the bar. Bar segmentation is consistent with the exchange. For CN1901 example, data from 17:00 on day T to 16:30 on day T+1 will be combined into one daily bar.
latest_timeintLast update time of the bar
openfloatOpen price
highfloatHigh price
lowfloatLow price
closefloatClose price
settlementfloatSettlement price, returns 0 when settlement price is not yet generated
volumeintVolume
open_interestintOpen interest
next_page_tokenstrPage token for next page

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

quote_client = QuoteClient(client_config)

bars = quote_client.get_future_bars(['CN1901', 'MXP1903'], 
                                          begin_time=-1, 
                                          end_time=1545105097358)
print(bars.head().to_string())

Return Example

  identifier           time    latest_time     open     high      low    close  settlement  volume  open_interest next_page_token
0     CN1901  1545035400000  1545035700002  11022.5  11097.5  10935.0  10940.0     10935.0    3872          15148            None
1     CN1901  1544776200000  1544776168000  11182.5  11197.5  11002.5  11030.0     11042.5    1379          14895            None
2     CN1901  1544689800000  1544689765000  11012.5  11252.5  11012.5  11212.5     11202.5    4586          12870            None
3     CN1901  1544603400000  1544603321185  10940.0  11070.0  10940.0  11035.0     11032.5    3514          12237            None
4     CN1901  1544517000000  1544516945000  10895.0  10962.5  10815.0  10942.5     10927.5    2378          10575            None

get_future_bar_by_page Get Futures K-Line Data 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 K-line data

Request Frequency

For frequency limits, please refer to: API Request Limits

Parameters

ParameterTypeRequiredDescription
identifierstrYesFutures code, can only query single symbol at a time
periodBarPeriodNoK-line period to retrieve. Default BarPeriod.DAY, can use enum constants from tigeropen.common.consts.BarPeriod, such as BarPeriod.DAY. 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min'
begin_timeintNoStart time, millisecond timestamp, query results include this time point, default: -1, when both begin_time and end_time default to -1, returns data based on limit setting
end_timeintNoEnd time, millisecond timestamp, query results exclude this time point, default: -1
totalintNoTotal number of bars requested, default: 10000
page_sizeintNoNumber of bars per page, default: 1000
time_intervalintNoTime interval between requests, in seconds, default: 2 seconds

Returns pandas.DataFrame

Column meanings:

COLUMNTypeDescription
identifierstrFutures contract code
timeintTimestamp corresponding to the bar, i.e., the end time of the bar. Bar segmentation is consistent with the exchange. For CN1901 example, data from 17:00 on day T to 16:30 on day T+1 will be combined into one daily bar.
latest_timeintLast update time of the bar
openfloatOpen price
highfloatHigh price
lowfloatLow price
closefloatClose price
settlementfloatSettlement price, returns 0 when settlement price is not yet generated
volumeintVolume
open_interestintOpen interest
next_page_tokenstrPage token for next page

Example

from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')

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().to_string())

Return Example

  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  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMDAwMHwxNjQ3Mzc3OTcwMDAw
1     CLmain  1647464400000  1647464399000   95.23   99.22   94.07   95.36       95.04  220577         119614  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMDAwMHwxNjQ3Mzc3OTcwMDAw
2     CLmain  1647550800000  1647550797000   95.34  104.24   94.85  103.62      102.98  129667          97283  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMDAwMHwxNjQ3NTUwNzcwMDAw
3     CLmain  1647637200000  1647637192000  103.62  106.28  102.30  105.10      104.70   32312         280113  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMDAwMHwxNjQ3NTUwNzcwMDAw
4     CLmain  1647896400000  1647896399000  103.62  111.08  102.47  110.93      109.97  187356         280043  ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMDAwMHwxNjQ3NTUwNzcwMDAw