Futures
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
Argument | Type | Description |
---|---|---|
sec_type | SecurityType | You 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:
Column | Type | Description |
---|---|---|
code | str | Code of the exchange |
name | str | Name of the exchange |
zone | str | Time 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
Argument | Type | Description |
---|---|---|
exchange | str | code of an exchange,e.g. 'CBOE' |
Response
The DataFrame contains the following fields:
Column | Type | Description |
---|---|---|
contract_code | str | Full contract code. e.g. VIX2208 |
type | str | Contract code. Example: CL |
symbol | str | ib symbol of the contract |
name | str | name of the contract |
contract_month | str | Month of delivery, in month code. Example: 202208 - 2022/08 |
currency | str | Currency of the contract |
first_notice_date | str | First notice date, the contract cannot be longed after the FND. Existing long positions will be closed out before the FND |
last_bidding_close_time | str | Last bidding time |
last_trading_date | str | Last trading date |
trade | bool | If the contract is still open for trading |
continuous | bool | If the contract is continuous |
multiplier | float | Multiplier of the contract |
min_tick | float | Tick 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
Argument | Type | Required | Description |
---|---|---|---|
contract_code | str | Yes | futrure contract code, e.g. CL2206 |
Response
Argument | Type | Description |
---|---|---|
contract_code | contract code, e.g. CL2112 | |
type | str | future contract type, e.g. CL |
name | str | future contract name |
contract_month | str | contract month, e.g. 202112, indicates delivery in December 2021 |
currency | str | trading currency |
first_notice_date | str | The 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_time | str | last bidding close time |
last_trading_date | str | Refers 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 |
trade | bool | is tradable |
continuous | bool | is continuous |
multiplier | float | contract 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_tick | float | The 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
Argument | Type | Description |
---|---|---|
future_type | The contract code of the future contract, excluding month code. Example: CL, ES |
Response
Structured as follows:
Column | Type | Description |
---|---|---|
contract_code | Full contract trading code, Example: CL2112 | |
type | str | contract code of the product, excluding month code. Example: CL |
name | str | Full name of the contract |
contract_month | str | Delivery month of the contract. Example: 202112, means the delivery month is December of 2021 |
currency | str | Currency of the contract |
first_notice_date | str | First notice date, the contract cannot be longed after the FND. Existing long positions will be closed out before the FND |
last_bidding_close_time | str | Last bidding day |
last_trading_date | str | Last trading day |
trade | bool | If the contract is currently available for trade |
continuous | bool | If the contract is continuous |
multiplier | float | multiplier |
min_tick | float | ticksize 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
Column | Type | Description |
---|---|---|
future_type | str | Full contract trading type, Example: CL |
Response
The DataFrame contains the following fields:
Column | Type | Description |
---|---|---|
contract_code | str | Full contract code. e.g. VIX2208 |
type | str | Contract code. Example: CL |
symbol | str | ib symbol of the contract |
name | str | name of the contract |
contract_month | str | Month of delivery, in month code. Example: 202208 - 2022/08 |
currency | str | Currency of the contract |
first_notice_date | str | First notice date, the contract cannot be longed after the FND. Existing long positions will be closed out before the FND |
last_bidding_close_time | str | Last bidding time |
last_trading_date | str | Last trading date |
trade | bool | If the contract is still open for trading |
continuous | bool | If the contract is continuous |
multiplier | float | Multiplier of the contract |
min_tick | float | Tick 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
Argument | Type | Description |
---|---|---|
contract_code | str | Contract code. Example CL1901 |
trading_date | int | Trading date. Example 1643346000000 |
Response
Structured as follows:
Column | Type | Description |
---|---|---|
start | int | Time when trading starts |
end | int | Time when trading ends |
trading | bool | If it's a continuous trading session |
bidding | bool | If it's a bidding session |
zone | str | Time 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
Arguments | Type | Required | Description |
---|---|---|---|
identifiers | list | Yes | futures code name list |
begin_time | int | No | Start 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_time | int | No | End time, timestamp in milliseconds, the query result does not include this time point,default:-1 |
period | BarPeriod | No | The 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' |
limit | int | No | Request number limit, default: 1000,max:1000 |
page_token | str | No | Paging 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
column | type | description |
---|---|---|
identifier | str | futures code name list |
time | int | The 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_time | int | Bar was last updated |
open | float | open price |
high | float | high price |
low | float | low price |
close | float | close price |
settlement | float | Settlement price at the last update time of Bar, Response 0 when no settlement price is generated |
volume | int | volume |
open_interest | int | open interest |
next_page_token | str | next 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
Arguments | Type | Required | Description |
---|---|---|---|
identifier | str | Yes | future code name |
begin_index | int | Yes | start index |
end_index | int | Yes | end index |
limit | int | No | Response 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
Arguments | Type | Required | Description |
---|---|---|---|
identifiers | Yes | future code,such as ['CL2201'] |
Response
column | type | description |
---|---|---|
identifier | str | futures code name |
ask_price | float | ask price |
ask_size | int | ask size |
bid_price | float | bid price |
bid_size | int | bid size |
pre_close | float | pre close price |
latest_price | float | latest price |
latest_size | int | latest size |
latest_time | int | latest time |
volume | int | accumlate volume |
open_interest | int | open interest |
open | float | open |
high | float | high |
low | float | low |
limit_up | float | limit up price |
limit_down | float | limit 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