Futures

About 9 min

get_future_exchanges Get a List of Future Exchanges

QuoteClient::get_future_exchanges()

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

The DataFrame contains the following fields:

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

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_future_exchanges();
    cout << result << endl;

    return 0;
}

ResponseExample

[{"code":"CME","name":"CME","zoneId":"America/Chicago"},{"code":"NYMEX","name":"NYMEX","zoneId":"America/New_York"},{"code":"COMEX","name":"COMEX","zoneId":"America/New_York"},{"code":"SGX","name":"SGX","zoneId":"Singapore"},{"code":"HKEX","name":"HKEX","zoneId":"Asia/Hong_Kong"},{"code":"CBOT","name":"CBOT","zoneId":"America/Chicago"},{"code":"CBOE","name":"CBOE","zoneId":"America/Chicago"},{"code":"OSE","name":"OSE","zoneId":"Asia/Tokyo"},{"code":"CMEBTC","name":"CMEBTC","zoneId":"America/Chicago"},{"code":"TEST","name":"Test_Exchange","zoneId":"America/Chicago"},{"code":"TEST2","name":"Test_Exchange_2","zoneId":"America/Chicago"},{"code":"TEST3","name":"Test_Exchange_3","zoneId":"America/Chicago"},{"code":"CBOEXBT","name":"CBOEXBT","zoneId":"America/Chicago"},{"code":"EUREX","name":"EUREX","zoneId":"Europe/Berlin"},{"code":"ICEUS","name":"ICE FUTURES US","zoneId":"American/Chicago"},{"code":"ICEEU","name":"ICE FUTURES EUROPE","zoneId":"American/NewYork"}]

get_future_contracts Get Contracts Available for Trade


QuoteClient::get_future_contracts(exchange)

Description

Get Contracts Available for Trade Listed in Certain Exchange

How to deal with the first notice day and the last trading day: Whether it enters the first notice day or the final settlement day, the main trading month will be transferred to the next month contract, which will make the liquidity of the expiring month worse, so it is recommended whether it is Long order or short order, before the first notice day and before the last trading day approaches, transfer or trade the next month's contract.

Frequency Limit

Please see:Rate Limit for details

Arguments

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

Response

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_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 time
last_trading_datestrLast trading date
tradeboolIf the contract is still open for trading
continuousboolIf the contract is continuous
multiplierfloatMultiplier of the contract
min_tickfloatTick size

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_future_contracts("CL");
    cout << result << endl;

    return 0;
}

ResponseExample

[{"continuous":false,"contractCode":"CL2302","contractMonth":"202302","currency":"USD","displayMultiplier":1,"exchange":"NYMEX","exchangeCode":"NYMEX","firstNoticeDate":"20230124","ibCode":"CL","lastBiddingCloseTime":0,"lastTradingDate":"20230120","minTick":0.01,"multiplier":1000,"name":"WTI Crude Oil - Feb 2023","trade":true,"type":"CL"},{"continuous":false,"contractCode":"CL2303","contractMonth":"202303","currency":"USD","displayMultiplier":1,"exchange":"NYMEX","exchangeCode":"NYMEX","firstNoticeDate":"20230223","ibCode":"CL","lastBiddingCloseTime":0,"lastTradingDate":"20230221","minTick":0.01,"multiplier":1000,"name":"WTI Crude Oil - Mar 2023","trade":true,"type":"CL"},{"continuous":false,"contractCode":"CL2304","contractMonth":"202304","currency":"USD","displayMultiplier":1,"exchange":"NYMEX","exchangeCode":"NYMEX","firstNoticeDate":"20230323","ibCode":"CL","lastBiddingCloseTime":0,"lastTradingDate":"20230321","minTick":0.01,"multiplier":1000,"name":"WTI Crude Oil - Apr 2023","trade":true,"type":"CL"}]


get_future_contract_by_contract_code Get future contract by code

Description

Get future contract by code

Frequency Limit

Please see:Rate Limit for details

Arguments

ArgumentTypeRequiredDescription
contract_codestrYesfutrure contract code, e.g. CL2206

Response

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

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_future_contract_by_contract_code("CL2303");
    cout << result << endl;

    return 0;
}

ResponseExample

{"continuous":false,"contractCode":"CL2302","contractMonth":"202302","currency":"USD","displayMultiplier":1,"exchange":"NYMEX","exchangeCode":"NYMEX","firstNoticeDate":"20230124","ibCode":"CL","lastBiddingCloseTime":0,"lastTradingDate":"20230120","minTick":0.01,"multiplier":1000,"name":"WTI Crude Oil - Feb 2023","trade":true,"type":"CL"}


get_current_future_contract Identify Front Month Contract


QuoteClient::get_current_future_contract(future_type)

Description

Identify the Front month contract of a given futures product

Frequency Limit

Please see:Rate Limit for details

Arguments

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

Response

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

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_future_current_contract("CL");
    cout << result << endl;

    return 0;
}

ResponseExample

{"continuous":false,"contractCode":"CL2302","contractMonth":"202302","currency":"USD","displayMultiplier":1,"exchange":"NYMEX","exchangeCode":"NYMEX","firstNoticeDate":"20230124","ibCode":"CL","lastBiddingCloseTime":0,"lastTradingDate":"20230120","minTick":0.01,"multiplier":1000,"name":"WTI Crude Oil - Feb 2023","trade":true,"type":"CL"}


get_future_continuous_contracts Get Future Continuous Contracts


QuoteClient::get_future_continuous_contracts(future_type)

Description

Get Future Continuous Contracts

Frequency Limit

Please see:Rate Limit for details

Arguments

ColumnTypeDescription
future_typestrFull contract trading type, Example: CL

Response

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_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 time
last_trading_datestrLast trading date
tradeboolIf the contract is still open for trading
continuousboolIf the contract is continuous
multiplierfloatMultiplier of the contract
min_tickfloatTick size

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_future_current_contract("CL");
    cout << result << endl;

    return 0;
}

ResponseExample

{"continuous":false,"contractCode":"CL2302","contractMonth":"202302","currency":"USD","displayMultiplier":1,"exchange":"NYMEX","exchangeCode":"NYMEX","firstNoticeDate":"20230124","ibCode":"CL","lastBiddingCloseTime":0,"lastTradingDate":"20230120","minTick":0.01,"multiplier":1000,"name":"WTI Crude Oil - Feb 2023","trade":true,"type":"CL"}


get_future_trading_date Get Trading Times of a Future Contract


get_future_trading_times(contract_code, trading_date=None)

Description

Get Trading Times of a Future Contract

Frequency Limit

Please see:Rate Limit for details

Arguments

ArgumentTypeDescription
contract_codestrContract code. Example CL1901
trading_dateintTrading date. Example 1643346000000

Response

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

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_future_trading_date("CL2303", "2023-01-12");
    cout << result << endl;

    return 0;
}

ResponseExample

  {"biddingTimes":[],"timeSection":"America/New_York","tradingTimes":[{"end":1673474400000,"start":1673391600000}]}

get_future_kline Get Futures Bars


value get_future_kline(value contract_codes, BarPeriod period=BarPeriod::DAY, long begin_time=-1, long end_time=-1,  
                       int limit=251, string page_token="")

Description

Get Futures Bars

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 Response 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

Please see:Rate Limit for details

Arguments

ArgumentsTypeRequiredDescription
identifierslistYesfutures code name list
begin_timeintNoStart time, timestamp in milliseconds, query results include this time point,default:-1,when begin_time and end_time both equals -1,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,default:-1
periodBarPeriodNoThe obtained K-line period. default: BarPeriod.DAY,You can use the enumeration constants provided under tigerapi/enums.h BarPeriod,such as BarPeriod.DAY。 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min'
limitintNoRequest number limit, default: 1000,max:1000
page_tokenstrNoPaging token, which records the location of the paging. The next_page_token of the last request for Response 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

columntypedescription
identifierstrfutures code name list
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 was last updated
openfloatopen price
highfloathigh price
lowfloatlow price
closefloatclose price
settlementfloatSettlement price at the last update time of Bar, Response 0 when no settlement price is generated
volumeintvolume
open_interestintopen interest
next_page_tokenstrnext page token

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();  
	symbols[0] = value::string("CL2303");  
	cout << "symbols " << symbols << endl;  
	value result = quote_client->get_future_kline(symbols);
    cout << result << endl;

    return 0;
}

** ResponseExample **

 [
		{
			"contractCode":"CL2303",
			"items":[
				{
					"close":74.959999999999994,
					"high":76.159999999999997,
					"lastTime":1673387996000,
					"low":74.159999999999997,
					"open":75.159999999999997,
					"openInterest":222544,
					"settlement":75.370000000000005,
					"time":1673388000000,
					"volume":30663
				},
				{
					"close":75.159999999999997,
					"high":76.969999999999999,
					"lastTime":1673301592000,
					"low":73.790000000000006,
					"open":73.870000000000005,
					"openInterest":209157,
					"settlement":74.920000000000002,
					"time":1673301600000,
					"volume":42603
				}
		]
	}
}

get_future_tick Get Futures Trade Ticks


QuoteClient::get_future_tick(identifier, 
                                  begin_index=0, 
                                  end_index=30, 
                                  limit=1000)

Description

Get Futures Trade ticks

Frequency Limit

Please see:Rate Limit for details

Arguments

ArgumentsTypeRequiredDescription
identifierstrYesfuture code name
begin_indexintYesstart index
end_indexintYesend index
limitintNoResponse limit count,max support is : 1000

Response

Arguments|Type|Description ---|---|---|--- index|int| tick index time|int| timestamp tick time price|float| tick price volume|int| tick volume

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config); 
	value result = quote_client->get_future_tick("CL2312");
    cout << result << endl;

    return 0;
}

** ResponseExample **

{"contractCode":"CL2312","items":[{"index":0,"price":76.22,"volume":1,"time":1673478173000},{"index":1,"price":76.20,"volume":1,"time":1673478436000},{"index":2,"price":76.25,"volume":1,"time":1673481448000},{"index":3,"price":76.26,"volume":1,"time":1673481479000},{"index":4,"price":76.25,"volume":1,"time":1673481565000},{"index":5,"price":76.25,"volume":2,"time":1673481570000},{"index":6,"price":76.25,"volume":2,"time":1673481601000},{"index":7,"price":76.25,"volume":1,"time":1673481616000},{"index":8,"price":76.16,"volume":2,"time":1673481678000}]
}

get_future_real_time_quote Get The Latest Futures Quotes


QuoteClient::get_future_real_time_quote(identifiers)

Description

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

Frequency Limit

Please see:Rate Limit for details

Arguments

ArgumentsTypeRequiredDescription
identifiersYesfuture code,such as ['CL2201']

Response

columntypedescription
identifierstrfutures code name
ask_pricefloatask price
ask_sizeintask size
bid_pricefloatbid price
bid_sizeintbid size
pre_closefloatpre close price
latest_pricefloatlatest price
latest_sizeintlatest size
latest_timeintlatest time
volumeintaccumlate volume
open_interestintopen interest
openfloatopen
highfloathigh
lowfloatlow
limit_upfloatlimit up price
limit_downfloatlimit down price

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config); 
	value result = quote_client->get_future_tick("CL2312");
    cout << result << endl;

    return 0;
}

Response



Last update: