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
| Parameter | Type | Description |
|---|---|---|
| sec_type | SecurityType | Use enums from tigeropen.common.consts.SecurityType, default is SecurityType.FUT, FUT represents futures, FOP represents future options |
| lang | Language | zh_CN, zh_TW, en_US |
Returns
pandas.DataFrame
Structure:
| COLUMN | Type | Description |
|---|---|---|
| code | str | Exchange code |
| name | str | Exchange name |
| zone | str | Exchange 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| exchange | str | Yes | Exchange code, e.g. 'CBOE' |
| lang | Language | No | zh_CN, zh_TW, en_US |
Returns
pandas.DataFrame
Structure:
| COLUMN | Type | Description |
|---|---|---|
| contract_code | str | Contract code, e.g. VIX2208 |
| type | str | Trading variety corresponding to the futures contract, e.g. CL |
| symbol | str | Corresponding symbol |
| name | str | Name of the futures contract |
| contract_month | str | Contract delivery month, e.g. 202208, representing August 2022 |
| currency | str | Trading currency type |
| exchange | str | Exchange code |
| first_notice_date | str | First 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_time | str | Bidding close time |
| last_trading_date | str | The 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 |
| trade | bool | Whether tradable |
| continuous | bool | Whether it's a continuous contract |
| multiplier | float | Contract 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_tick | float | Minimum 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_worth | str | Contract size |
| delivery_mode | str | Delivery method |
| product_type | str | Contract 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| contract_code | str | Yes | Futures contract code, e.g. CL2206 |
| lang | Language | No | zh_CN, zh_TW, en_US |
Returns
pandas.DataFrame
Structure:
| COLUMN | Type | Description |
|---|---|---|
| contract_code | Contract code, e.g. CL2112 | |
| type | str | Trading variety corresponding to the futures contract, e.g. CL |
| name | str | Name of the futures contract |
| contract_month | str | Contract delivery month, e.g. 202112, representing December 2021 delivery |
| currency | str | Trading currency |
| first_notice_date | str | First 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_time | str | Bidding close time |
| last_trading_date | str | The 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 |
| trade | bool | Whether tradable |
| continuous | bool | Whether it's a continuous contract |
| multiplier | float | Contract 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_tick | float | Minimum 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 |
| exchange | str | Exchange code |
| symbol | str | Contract 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| future_type | str | Yes | Trading variety corresponding to futures contract, e.g. CL |
| lang | Language | No | zh_CN, zh_TW, en_US |
Returns
pandas.DataFrame
Structure:
| COLUMN | Type | Description |
|---|---|---|
| contract_code | Contract code, e.g. CL2112 | |
| type | str | Trading variety corresponding to the futures contract, e.g. CL |
| name | str | Name of the futures contract |
| contract_month | str | Contract delivery month, e.g. 202112, representing December 2021 delivery |
| currency | str | Trading currency |
| first_notice_date | str | First 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_time | str | Bidding close time |
| last_trading_date | str | The 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 |
| trade | bool | Whether tradable |
| continuous | bool | Whether it's a continuous contract |
| multiplier | float | Contract 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_tick | float | Minimum 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 |
| exchange | str | Exchange code |
| symbol | str | Contract symbol |
| product_worth | str | Contract size |
| delivery_mode | str | Delivery method |
| product_type | str | Contract 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 Name | Type | Required | Description |
|---|---|---|---|
| future_type | str | Yes | Trading variety of futures contract, e.g., CL |
| lang | Language | No | zh_CN, zh_TW, en_US |
Returns
pandas.DataFrame
Structure as follows:
| COLUMN | Type | Description |
|---|---|---|
| contract_code | Contract code, e.g., CL2112 | |
| type | str | Trading variety of futures contract, e.g., CL |
| name | str | Name of futures contract |
| contract_month | str | Contract delivery month, e.g., 202112, indicating December 2021 delivery |
| currency | str | Trading currency |
| first_notice_date | str | First 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_time | str | Bidding close time |
| last_trading_date | str | The 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 |
| trade | bool | Whether tradable |
| continuous | bool | Whether it is a continuous contract |
| multiplier | float | Contract 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_tick | float | Minimum 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 |
| exchange | str | Exchange code |
| symbol | str | Contract code |
| product_worth | str | Contract size |
| delivery_mode | str | Delivery method |
| product_type | str | Contract 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 Name | Type | Required | Description |
|---|---|---|---|
| future_type | str | Yes | Trading variety of futures contract, e.g., CL |
| lang | Language | No | zh_CN, zh_TW, en_US |
Returns
pandas.DataFrame
Structure as follows:
| COLUMN | Type | Description |
|---|---|---|
| contract_code | str | Contract code, e.g., CLmain |
| continuous | bool | Whether it is a continuous contract |
| contract_month | str | Contract delivery month, e.g., 202112, indicating December 2021 delivery |
| currency | str | Trading currency |
| display_multiplier | float | Contract 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 |
| exchange | str | Exchange |
| exchange_code | str | Exchange code |
| first_notice_date | str | First 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_time | str | Bidding close time |
| last_trading_date | str | The 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_tick | float | Minimum 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 |
| multiplier | float | Contract 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 |
| name | str | Name of futures contract |
| symbol | str | Abbreviation of futures contract |
| trade | bool | Whether tradable |
| type | str | Trading variety of futures contract, e.g., CL |
| product_worth | str | Contract size |
| delivery_mode | str | Delivery method |
| product_type | str | Contract 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 Name | Type | Required | Description |
|---|---|---|---|
| identifier | str | Yes | Contract code, e.g., CL1901 |
| trading_date | int | Yes | Millisecond timestamp for specified trading date, e.g., 1643346000000 |
Returns
pandas.DataFrame
Structure as follows:
| COLUMN | Type | Description |
|---|---|---|
| start | int | Trading start time |
| end | int | Trading end time |
| trading | bool | Whether continuous trading |
| bidding | bool | Whether auction trading |
| zone | str | Time 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 Name | Type | Required | Description |
|---|---|---|---|
| identifiers | list | Yes | List of futures codes, e.g., ['CL2201'] |
Returns
pandas.DataFrame
Column meanings as follows:
| COLUMN | Type | Description |
|---|---|---|
| identifier | str | Futures code |
| ask_price | float | Ask price |
| ask_size | int | Ask size |
| bid_price | float | Bid price |
| bid_size | int | Bid size |
| pre_close | float | Previous close price |
| latest_price | float | Latest price |
| latest_size | int | Latest trade size |
| latest_time | int | Latest price trade time |
| volume | int | Daily accumulated trade volume |
| open_interest | int | Open interest quantity |
| open_interest_change | int | Open interest change |
| open | float | Open price |
| high | float | High price |
| low | float | Low price |
| limit_up | float | Upper limit price |
| limit_down | float | Lower 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| identifiers | list[str] | Yes | List of futures codes, e.g. ['CL2201'] |
Returns
dict
Structure as follows:
| Field | Type | Description |
|---|---|---|
| identifier | str | Futures code |
| ask | list[tuple] | Ask information |
| bids | list[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
| Parameter | Type | Required | Description |
|---|---|---|---|
| identifier | str | Yes | Futures code |
| begin_index | int | No | Starting index |
| end_index | int | No | Ending index |
| limit | int | No | Return limit, maximum 1000 tick records supported |
Returns
pandas.DataFrame
Column meanings:
| Parameter | Type | Description |
|---|---|---|
| index | int | Index value |
| time | int | Trade time, timestamp in milliseconds |
| price | float | Trade price |
| volume | int | Trade 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| identifiers | list | Yes | List of futures codes |
| begin_time | int | No | Start 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_time | int | No | End time, millisecond timestamp, query results exclude this time point, default: -1 |
| period | BarPeriod | No | K-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' |
| limit | int | No | Request count limit, default 1000, maximum limit: 1000 |
| page_token | str | No | Pagination 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:
| COLUMN | Type | Description |
|---|---|---|
| identifier | str | Futures contract code |
| time | int | Timestamp 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_time | int | Last update time of the bar |
| open | float | Open price |
| high | float | High price |
| low | float | Low price |
| close | float | Close price |
| settlement | float | Settlement price, returns 0 when settlement price is not yet generated |
| volume | int | Volume |
| open_interest | int | Open interest |
| next_page_token | str | Page 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| identifier | str | Yes | Futures code, can only query single symbol at a time |
| period | BarPeriod | No | K-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_time | int | No | Start 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_time | int | No | End time, millisecond timestamp, query results exclude this time point, default: -1 |
| total | int | No | Total number of bars requested, default: 10000 |
| page_size | int | No | Number of bars per page, default: 1000 |
| time_interval | int | No | Time interval between requests, in seconds, default: 2 seconds |
Returns
pandas.DataFrame
Column meanings:
| COLUMN | Type | Description |
|---|---|---|
| identifier | str | Futures contract code |
| time | int | Timestamp 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_time | int | Last update time of the bar |
| open | float | Open price |
| high | float | High price |
| low | float | Low price |
| close | float | Close price |
| settlement | float | Settlement price, returns 0 when settlement price is not yet generated |
| volume | int | Volume |
| open_interest | int | Open interest |
| next_page_token | str | Page 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 ZnV0dXJlX2tsaW5lfENMbWFpbnxkYXl8MTY0ODUyNjQwMDAwMHwxNjQ3NTUwNzcwMDAwUpdated 1 day ago
