Futures
Get the list of futures exchanges
Request: FutureExchangeRequest
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
secType | String | Yes | Contract type. "FUT": futures, "FOP": futures options (the market for futures options is not yet available) |
lang | Language | No | Language parameter, which affects the "name" field in the return value, and the value range is: "zh_CN", "en_US" |
Response
List of FutureExchangeItem
objects
The specific fields of the FutureExchangeItem
object are described as follows:
Name | Type | Description |
---|---|---|
code | String | exchange code |
name | String | exchange name |
zoneId | String | Transaction time zone |
Example
FutureExchangeResponse response = client.execute(FutureExchangeRequest.newRequest(SecType.FUT.name()));
System.out.println(response.getFutureExchangeItems());
Response example
[FutureExchangeItem{code='CME', name='CME', zoneId='America/Chicago'}, FutureExchangeItem{code='NYMEX', name='NYMEX', zoneId='America/New_York'}, FutureExchangeItem{code ='COMEX', name='COMEX', zoneId='America/New_York'}, FutureExchangeItem{code='SGX', name='SGX', zoneId='Singapore'}, FutureExchangeItem{code='HKEX', name ='HKEX', zoneId='Asia/Hong_Kong'}, FutureExchangeItem{code='CBOT', name='CBOT', zoneId='America/Chicago'}, FutureExchangeItem{code='CBOE', name='CBOE' , zoneId='America/Chicago'}]
Query the futures contract according to the contract code
Request: FutureContractByConCodeRequest
How to deal with the first notice day and the last trading day: Whether it is 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 not to Whether it is a long order or a short order, before the first notice day and the last trading day is approaching, transfer or trade the next month's contract.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
contractCode | String | Yes | symbol of the contract, such as CN1901 |
lang | Language | No | Language parameter, which affects the "name" field in the return value, and the value range is: "zh_CN", "en_US" |
Response
FutureContractItem
object
The specific fields of the FutureContractItem
object are described as follows:
Name | Type | Description |
---|---|---|
type | String | The trading variety corresponding to the futures contract, such as CL |
name | String | The name of the contract, there are simplified and English names, returned according to the parameter lang |
ibCode | String | Transaction contract code, used when placing an order. Such as: CL |
contractCode | String | Contract code, for example, CL1901 |
contractMonth | String | Contract delivery month |
exchangeCode | String | Exchange code |
exchange | String | Exchange symbol |
multiplier | BigDecimal | Contract multiplier, the futures price multiplied by the contract multiplier is the face value of the contract, and the reasonable price of the futures can be estimated by dividing the physical price by the contract multiplier |
minTick | BigDecimal | The minimum quotation unit for futures price changes. For example, if the current futures price is 2000 and minTick is 100, the correct quotation includes 2100, 2200, and 2005 does not meet the requirements |
lastTradingDate | String | 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". At present, the last trading day of most futures commodities is usually settlement day. For some commodities, the first notification day is the same day as the last trading day, such as the euro For cash-settled futures, as long as the last trading time has not passed, positions can be opened normally. Non-cash-settled futures are based on The lesser of the last trading time and the first notice day, limit the opening of positions in the first three trading days |
firstNoticeDate | String | The first notice date refers to the date when the physical delivery contract can be delivered. The contract cannot open long positions after the first notice date. Existing long positions will be forced to close before the first notice day (usually the first three trading days). This field is empty for non-physical delivery contracts (such as index contracts) |
lastBiddingCloseTime | long | Bidding closing time |
currency | String | The currency of the transaction |
continuous | boolean | Whether the contract is continuous |
trade | boolean | Whether it can be traded |
Example
FutureContractResponse response = client.execute(FutureContractByConCodeRequest.newRequest("CN2203"));
System.out.println(response.getFutureContractItem());
Response Example
FutureContractItem{type='CL', name='Light Crude Oil - Mar 2022', ibCode='CL', contractCode='CL2203', contractMonth='202203', exchangeCode='NYMEX', multiplier=1000, minTick=0.01 , lastTradingDate='20220222', firstNoticeDate='20220224', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true}
Get the tradable contracts under the exchange
Request: FutureContractByExchCodeRequest
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
exchangeCode | String | Yes | exchange code |
lang | Language | no | Language parameter, which affects the "name" field in the return value, and the value range is: "zh_CN", "en_US" |
Response
List of FutureContractItem
objects
The specific fields of the FutureContractItem
object are described as follows:
name | type | description |
---|---|---|
type | String | The trading variety corresponding to the futures contract, such as CL |
name | String | The name of the contract, there are simplified and English names, returned according to the parameter lang |
ibCode | String | Transaction contract code, used when placing an order. Such as: CL |
contractCode | String | Contract code, for example, CL1901 |
contractMonth | String | Contract delivery month |
exchangeCode | String | Exchange code |
exchange | String | Exchange symbol |
multiplier | BigDecimal | Contract multiplier, the futures price multiplied by the contract multiplier is the face value of the contract, and the reasonable price of the futures can be estimated by dividing the physical price by the contract multiplier |
minTick | BigDecimal | The minimum quotation unit for futures price changes. For example, if the current futures price is 2000 and minTick is 100, the correct quotation includes 2100, 2200, and 2005 does not meet the requirements |
lastTradingDate | String | 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". At present, the last trading day of most futures commodities is usually settlement day. For some commodities, the first notification day is the same day as the last trading day, such as the euro For cash-settled futures, as long as the last trading time has not passed, positions can be opened normally. Non-cash-settled futures are based on The lesser of the last trading time and the first notice day, limit the opening of positions in the first three trading days |
firstNoticeDate | String | The first notice date refers to the date when the physical delivery contract can be delivered. The contract cannot open long positions after the first notice date. Existing long positions will be forced to close before the first notice day (usually the first three trading days). This field is empty for non-physical delivery contracts (such as index contracts) |
lastBiddingCloseTime | long | Bidding closing time |
currency | String | The currency of the transaction |
continuous | boolean | Whether the contract is continuous |
trade | boolean | Whether it can be traded |
Example
FutureBatchContractResponse response = client.execute(FutureContractByExchCodeRequest.newRequest("CME"));
System.out.println(response.getFutureContractItems());
Response example
[FutureContractItem{type='MEUR', name='E-Micro EUR/USD - main', ibCode='M6E', contractCode='MEURmain', contractMonth='', exchangeCode='GLOBEX', multiplier=12500, minTick =0.0001, lastTradingDate='', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='MEUR', name='E-Micro EUR/USD - Jun 2022', ibCode='M6E', contractCode='MEUR2206', contractMonth='202206', exchangeCode='GLOBEX', multiplier=12500, minTick=0.0001, lastTradingDate='20220613', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='MEUR', name='E-Micro EUR/USD - Mar 2022', ibCode='M6E', contractCode='MEUR2203', contractMonth='202203', exchangeCode='GLOBEX', multiplier=12500, minTick=0.0001, lastTradingDate='20220314', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='CHF', name='Swiss Franc - Jun 2022', ibCode='CHF', contractCode='CHF2206', contractMonth='202206', exchangeCode='GLOBEX', multiplier=125000, minTick=0.0001, lastTradingDate='20220613', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='CHF', name='Swiss Franc - main', ibCode='CHF', contractCode='CHFmain', contractMonth='', exchangeCode='GLOBEX', multiplier=125000, minTick=0.0001, lastTradingDate= '', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='CHF', name='Swiss Franc - Dec 2022', ibCode='CHF', contractCode='CHF2212', contractMonth='202212', exchangeCode='GLOBEX', multiplier=125000, minTick=0.0001, lastTradingDate='20221219', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true}
]
Query all contracts of the specified symbol
Request: FutureContractsRequest
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
type | String | yes | The trading variety corresponding to the futures contract, such as CL |
lang | Language | yes | Language parameter, which affects the "name" field in the return value, and the value range is: "zh_CN", "en_US" |
Response
List of FutureContractItem
objects
The specific fields of the FutureContractItem
object are described as follows:
Name | Type | Description |
---|---|---|
type | String | The trading variety corresponding to the futures contract, such as CL |
name | String | The name of the contract, there are simplified and English names, returned according to the parameter lang |
ibCode | String | Transaction contract code, used when placing an order. Such as: CL |
contractCode | String | Contract code, for example, CL1901 |
contractMonth | String | Contract delivery month |
exchangeCode | String | Exchange code |
exchange | String | Exchange symbol |
multiplier | BigDecimal | Contract multiplier, the futures price multiplied by the contract multiplier is the face value of the contract, and the reasonable price of the futures can be estimated by dividing the physical price by the contract multiplier |
minTick | BigDecimal | The minimum quotation unit for futures price changes. For example, if the current futures price is 2000 and minTick is 100, the correct quotation includes 2100, 2200, and 2005 does not meet the requirements |
lastTradingDate | String | 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". At present, the last trading day of most futures commodities is usually settlement day. For some commodities, the first notification day is the same day as the last trading day, such as the euro For cash-settled futures, as long as the last trading time has not passed, positions can be opened normally. Non-cash-settled futures are based on The lesser of the last trading time and the first notice day, limit the opening of positions in the first three trading days |
firstNoticeDate | String | The first notice date refers to the date when the physical delivery contract can be delivered. The contract cannot open long positions after the first notice date. Existing long positions will be forced to close before the first notice day (usually the first three trading days). This field is empty for non-physical delivery contracts (such as index contracts) |
lastBiddingCloseTime | long | Bidding closing time |
currency | String | The currency of the transaction |
continuous | boolean | Whether the contract is continuous |
trade | boolean | Whether it can be traded |
Example
FutureContractsResponse contractResponse = client.execute(FutureContractsRequest.newRequest("CN"));
System.out.println(contractResponse.getFutureContractItems());
Response example
[FutureContractItem{type='CN', name='China A50 Index - Aug 2022', ibCode='XINA50', contractCode='CN2208', contractMonth='202208', exchangeCode='SGX', multiplier=1, minTick= 1, lastTradingDate='20220830', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='CN', name='China A50 Index - Sep 2022', ibCode='XINA50', contractCode='CN2209', contractMonth='202209', exchangeCode='SGX', multiplier=1, minTick=1 , lastTradingDate='20220929', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='CN', name='China A50 Index - Oct 2022', ibCode='XINA50', contractCode='CN2210', contractMonth='202210', exchangeCode='SGX', multiplier=1, minTick=1 , lastTradingDate='20221028', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='CN', name='China A50 Index - Dec 2022', ibCode='XINA50', contractCode='CN2212', contractMonth='202212', exchangeCode='SGX', multiplier=1, minTick=1 , lastTradingDate='20221229', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true},
FutureContractItem{type='CN', name='China A50 Index - Mar 2023', ibCode='XINA50', contractCode='CN2303', contractMonth='202303', exchangeCode='SGX', multiplier=1, minTick=1 , lastTradingDate='20230330', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true}]
Query the continuous contract of the specified symbol
Request: FutureContinuousContractRequest
Parameter
Parameter | Type | Required | Description |
---|---|---|---|
type | String | yes | the trading variety corresponding to the futures contract, such as CL |
lang | Language | yes | Language parameter, which affects the "name" field in the return value, and the value range is: "zh_CN", "en_US" |
Response
FutureContractItem
object
The specific fields of the FutureContractItem
object are described as follows:
Name | Type | Description |
---|---|---|
type | String | The trading variety corresponding to the futures contract, such as CL |
name | String | The name of the contract, there are simplified and English names, returned according to the parameter lang |
ibCode | String | Transaction contract code, used when placing an order. Such as: CL |
contractCode | String | Contract code, for example, CL1901 |
contractMonth | String | Contract delivery month |
exchangeCode | String | Exchange code |
exchange | String | Exchange symbol |
multiplier | BigDecimal | Contract multiplier, the futures price multiplied by the contract multiplier is the face value of the contract, and the reasonable price of the futures can be estimated by dividing the physical price by the contract multiplier |
minTick | BigDecimal | The minimum quotation unit for futures price changes. For example, if the current futures price is 2000 and minTick is 100, the correct quotation includes 2100, 2200, and 2005 does not meet the requirements |
lastTradingDate | String | 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". At present, the last trading day of most futures commodities is usually settlement day. For some commodities, the first notification day is the same day as the last trading day, such as the euro For cash-settled futures, as long as the last trading time has not passed, positions can be opened normally. Non-cash-settled futures are based on The lesser of the last trading time and the first notice day, limit the opening of positions in the first three trading days |
firstNoticeDate | String | The first notice date refers to the date when the physical delivery contract can be delivered. The contract cannot open long positions after the first notice date. Existing long positions will be forced to close before the first notice day (usually the first three trading days). This field is empty for non-physical delivery contracts (such as index contracts) |
lastBiddingCloseTime | long | Bidding closing time |
currency | String | The currency of the transaction |
continuous | boolean | Whether the contract is continuous |
trade | boolean | Whether it can be traded |
Example
FutureContractResponse cl = client.execute(FutureContinuousContractRequest.newRequest("CL"));
System.out.println(cl.getFutureContractItem());
Example Response
FutureContractItem{type='ES', name='E-mini S&P 500 - main', ibCode='ES', contractCode='ESmain', contractMonth='', exchangeCode='GLOBEX', multiplier=50, minTick=0.25 , lastTradingDate='', firstNoticeDate='', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true}
Query the current contract of the specified symbol
Request: FutureCurrentContractRequest
Description
Query the current contract of the specified product, that is, the main chain of the contract
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
type | String | Yes | the trading variety corresponding to the futures contract, such as CL |
lang | Language | No | Language parameter, which affects the "name" field in the return value, and the value range is: "zh_CN", "en_US" |
Response
FutureContractItem
object
The specific fields of the FutureContractItem
object are described as follows:
Name | Type | Description |
---|---|---|
type | String | The trading variety corresponding to the futures contract, such as CL |
name | String | The name of the contract, there are simplified and English names, returned according to the parameter lang |
ibCode | String | Transaction contract code, used when placing an order. Such as: CL |
contractCode | String | Contract code, for example, CL1901 |
contractMonth | String | Contract delivery month |
exchangeCode | String | Exchange code |
exchange | String | Exchange symbol |
multiplier | BigDecimal | Contract multiplier, the futures price multiplied by the contract multiplier is the face value of the contract, and the reasonable price of the futures can be estimated by dividing the physical price by the contract multiplier |
minTick | BigDecimal | The minimum quotation unit for futures price changes. For example, if the current futures price is 2000 and minTick is 100, the correct quotation includes 2100, 2200, and 2005 does not meet the requirements |
lastTradingDate | String | 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". At present, the last trading day of most futures commodities is usually settlement day. For some commodities, the first notification day is the same day as the last trading day, such as the euro For cash-settled futures, as long as the last trading time has not passed, positions can be opened normally. Non-cash-settled futures are based on The lesser of the last trading time and the first notice day, limit the opening of positions in the first three trading days |
firstNoticeDate | String | The first notice date refers to the date when the physical delivery contract can be delivered. The contract cannot open long positions after the first notice date. Existing long positions will be forced to close before the first notice day (usually the first three trading days). This field is empty for non-physical delivery contracts (such as index contracts) |
lastBiddingCloseTime | long | Bidding closing time |
currency | String | The currency of the transaction |
continuous | boolean | Whether the contract is continuous |
trade | boolean | Whether it can be traded |
Example
FutureContractResponse response = client.execute(FutureCurrentContractRequest.newRequest("CL"));
System.out.println(response.getFutureContractItem());
Response example
FutureContractItem{type='CL', name='Light Crude Oil - Mar 2022', ibCode='CL', contractCode='CL2203', contractMonth='202203', exchangeCode='NYMEX', multiplier=1000, minTick=0.01 , lastTradingDate='20220222', firstNoticeDate='20220224', lastBiddingCloseTime=0, currency='USD', continuous=false, trade=true}
Query the trading time of the specified futures contract
Request: FutureTradingDateRequest
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
contractCode | String | Yes | Futures contract code, such as CL1901 |
tradingDate | Long/String | Yes | Timestamp of trading day |
Response
FutureTradingDateItem
object
The specific fields of FutureTradingDateItem
are described as follows:
Name | Type | Description |
---|---|---|
tradingTimes | List<TimeSection> | Trading times |
biddingTimes | List<TimeSection> | Bidding times |
timeSection | String | The transaction time zone |
The fields of TimeSection
are described as follows:
Name | Type | Description |
---|---|---|
start | long | Start time |
end | long | End time |
Example
FutureTradingDateResponse response = client.execute(FutureTradingDateRequest.newRequest("ES2203", System.currentTimeMillis()));
System.out.println(response.getFutureTradingDateItem());
Response example
FutureTradingDateItem{biddingTimes=[TimeSection{start=1644873300000, end=1644874200000}], tradingTimes=[TimeSection{start=1644793200000, end=1644873300000}, TimeSection{start=1644874200000 , end=1644876000000}], timeSection='America/Chicago' }
Get futures K-line data
Corresponding request class: FutureKlineRequest
Description
It provides daily K-line data of popular contracts in the past 10 years, as well as minute-level data of all contracts from August 2017 to the present.
The returned result is a collection of data in reverse chronological order starting from endTime.
For the 1-minute K-line, if there is no transaction within this 1 minute, the K-line data of this minute will be blank; the interface can only pull the K-line data of this 1 minute after there is a transaction within the latest minute. The first transaction is generated at 50 seconds, and the latest data cannot be pulled before 50 seconds.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
contractCodes | List<String> | Yes | Contract code list, support to query the main contract, such as CL1901/CLmain |
kType | FutureKType | No | K line period, value range: "min", "3min", "5min", "10min", "15min", "30min", "45min", "60min", "2hour", "3hour", "4hour", "6hour", "day", "week", "month" |
beginTime | String | No | Start time (inclusive) |
endTime | String | No | End time (exclusive) |
zoneId | TimeZoneId | No | Description of the timezone used |
limit | Integer | No | Request limit, default: 200, maximum: 1000 |
Additional Methods
public void withPageToken(String pageToken) {
if (apiModel != null && apiModel instanceof FutureKlineModel) {
FutureKlineModel model = (FutureKlineModel)this.getApiModel();
model.setPageToken(pageToken);
}
}
Response
List of FutureKlineBatchItem
objects
The specific fields of FutureKlineBatchItem
are described as follows:
Name | Type | Description |
---|---|---|
contractCode | String | contract code |
nextPageToken | String | Query the token of the next page (only supports a single contract code, it is valid only when endTime is not null and -1), and returns null if there is no more data |
items | List<FutureKlineItem> | K-line array, please refer to the description below for the fields |
The attributes of FutureKlineItem
are as follows:
Name | Type | Description |
---|---|---|
time | long | Time |
lastTime | long | The transaction time of the latest price |
open | BigDecimal | Opening price |
close | BigDecimal | Closing price |
high | BigDecimal | Highest price |
low | BigDecimal | Lowest price |
volume | long | Volume |
openInterest | long | Amount of open interest |
settlement | BigDecimal | Settlement price, returns 0 if no settlement price is generated |
Example
List<String> contractCodes = new ArrayList<>();
contractCodes.add("CL1901");
FutureKlineResponse response = client. execute(
FutureKlineRequest.newRequest(contractCodes, FutureKType.min15, 1535634249489L,
1538807049489L, 200));
System.out.println(response.getFutureKlineItems());
Response example
{
"code": 0,
"timestamp": 1545105097358,
"message": "success",
"data": [{
"contractCode": "CL1901",
"items": [{
"lastTime": 1545083998000,
"volume": 124206,
"high": 51.87,
"openInterest": 90329,
"low": 4901,
"time": 1545084000000,
"close": 49.16,
"open": 51.25,
"settlement": 49.88
},
{
"lastTime": 1544824796000,
"volume": 434074,
"high": 52.95,
"openInterest": 131753,
"low": 5084,
"time": 1544824800000,
"close": 51.23,
"open": 52.83,
"settlement": 51.2
},
{
"lastTime": 1544738399000,
"volume": 593178,
"high": 53.27,
"openInterest": 186783,
"low": 5035,
"time": 1544738400000,
"close": 52.85,
"open": 51.2,
"settlement": 52.58
}
]
}]
}
PageToken Example
List<String> contractCodes = new ArrayList<>();
contractCodes.add("NGmain");
// pagetoken only for single symbol and specified endTime
FutureKlineRequest request = FutureKlineRequest.newRequest(contractCodes, FutureKType.day,
1650920400000L, 1651870900000L, 3);
int count = 1;
while (true) {
FutureKlineResponse response = client. execute(request);
System.out.println("search time:" + count + ", success:" + response.isSuccess() + ", msg:" + response.getMessage());
if (!response. isSuccess()) {
break;
}
System.out.println(response.getFutureKlineItems());
if (response. getFutureKlineItems(). size() == 0) {
break;
}
String nextPageToken = response.getFutureKlineItems().get(0).getNextPageToken();
if (nextPageToken == null) {
break;
}
count++;
// 10 times per minute
try {
TimeUnit. SECONDS. sleep(6);
} catch (InterruptedException e) {
e.printStackTrace();
}
// set nextPageToken and search next page data
request.withPageToken(nextPageToken);
}
Futures real-time market
Request: FutureRealTimeQuoteRequest
Description
Get real-time futures quotes
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
contractCodes | List<String> | Yes | Contract code list, support to query the main contract, such as CL1901/CLmain |
Response
List of FutureRealTimeItem
objects
The specific fields of FutureRealTimeItem
are described as follows:
Name | Type | Description |
---|---|---|
contractCode | String | contract code |
latestPrice | BigDecimal | latest transaction price |
latestSize | Long | the volume of the latest price |
latestTime | Long | The transaction time of the latest price |
bidPrice | BigDecimal | bid price (first file) |
askPrice | BigDecimal | ask price (one file) |
bidSize | Long | Bid size (one level) |
askSize | Long | Amount of sell orders (one file) |
openInterest | Long | amount of open interest |
volume | Long | Cumulative number of lots traded on the day |
open | BigDecimal | opening price |
high | BigDecimal | highest price |
low | BigDecimal | lowest price |
settlement | BigDecimal | settlement price, returns 0 if no settlement price is generated |
limitUp | BigDecimal | limit up price |
limitDown | BigDecimal | limit down price |
Example
List<String> contractCodes = new ArrayList<>();
contractCodes.add("CL1902");
FutureRealTimeQuoteResponse response = client.execute(FutureRealTimeQuoteRequest.newRequest(contractCodes));
System.out.println(response.getFutureRealTimeItems());
Response example
{
"code": 0,
"timestamp": 1545102059229,
"message": "success",
"data": [{
"contractCode": "CN1901",
"askPrice": 49.4,
"askSize": 2,
"bidPrice": 49.39,
"bidSize": 4,
"latestSize": 1,
"latestPrice": 49.39,
"volume": -18140,
"openInterest": 72189,
"settlement": 49.88,
"high": 49.59,
"low": 49.14,
"latestTime": 1545102035000,
"open": 49.16,
"limitUp": 55.88,
"limitDown": 43.88
}]
}
Get futures tick-by-tick data
Request: FutureTickRequest
Description
Obtain futures transaction data by ticks. The index resets to 0 every day at 6:00 AM China Standard Time. The previous day's tick data is cleared one minute before the earliest session (auction or trading). New tick data is registered after the new trading session starts. This reset only occurs once per trading day, i.e. multiple trading sessions within the same trading day do not trigger additional resets.
Note: Once the previous day's tick data is cleared, it is no longer accessible via the API.
For example: The GC2504 tick data will be accessible up until 5:59 AM but will be reset to index 0 at 6:00 AM.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
contractCode | String | Yes | Futures contract code, such as: CL1901 |
beginIndex | long | No | Starting index, beginIndex and endIndex can be set to -1 when the first request is made, the first request will return the latest item-by-item data, subsequent upload the latest index value +1 returned last time |
endIndex | long | No | End index, If the difference between the end index and the start index is greater than 1000, it will return a maximum of 1000. When either the end index or the start index is set to -1, the query will be started from the end other than -1, and limit items of item-by-item data will be returned. |
limit | int | No | The default is 200, the maximum limit is 1000 |
begin_index and end_index parameter usage instructions
Query method | beginIndex | endIndex | Description |
---|---|---|---|
Check records one by one from front to back | Specific value | -1 | For example: beginIndex=10, endIndex=-1, limit=20, return 20 records from 10 to 29. |
Query record by record from back to front | -1 | Specific value | For example: beginIndex=-1, endIndex=29, limit=20, return 20 records from 10 to 29. |
Query the latest record by record | -1 | -1 | Return the latest record by limit. |
Query interval index | specific value | specific value | For example: beginIndex=10, endIndex=100, 91 records including 10 to 100 will be returned. If limit is set to 20, 20 records from 10 to 29 will be returned. |
Response
FutureTickBatchItem
object
The specific fields of FutureTickBatchItem
are described as follows:
Name | Type | Description |
---|---|---|
contractCode | String | Contract code |
items | List<FutureTickItem> | Future ticks |
The specific fields of FutureTickItem
are described as follows:
Name | Type | Description |
---|---|---|
index | long | index |
price | BigDecimal | Transaction price |
volume | long | Volume |
time | long | Time |
Example
List<String> contractCodes = new ArrayList<>();
contractCodes.add("CL1902");
FutureTickResponse response = client.execute(FutureTickRequest.newRequest("CL2209", 10L, 100L,20));
System.out.println(response.getFutureTickItems());
Response example
{
"code": 0,
"data": {
"contractCode": "CL2209",
"items": [{
"index": 10,
"price": 87.91,
"time": 1660600802000,
"volume": 6
}, {
"index": 11,
"price": 87.90,
"time": 1660600802000,
"volume": 1
}, {
"index": 12,
"price": 87.93,
"time": 1660600802000,
"volume": 1
}, {
"index": 13,
"price": 87.91,
"time": 1660600803000,
"volume": 4
}, {
"index": 14,
"price": 87.89,
"time": 1660600804000,
"volume": 1
}, {
"index": 15,
"price": 87.90,
"time": 1660600804000,
"volume": 1
}, {
"index": 16,
"price": 87.92,
"time": 1660600804000,
"volume": 2
}, {
"index": 17,
"price": 87.91,
"time": 1660600804000,
"volume": 1
}, {
"index": 18,
"price": 87.93,
"time": 1660600805000,
"volume": 8
}, {
"index": 19,
"price": 87.93,
"time": 1660600805000,
"volume": 10
}, {
"index": 20,
"price": 87.93,
"time": 1660600805000,
"volume": 7
}, {
"index": 21,
"price": 87.93,
"time": 1660600805000,
"volume": 8
}, {
"index": 22,
"price": 87.93,
"time": 1660600805000,
"volume": 7
}, {
"index": 23,
"price": 87.95,
"time": 1660600806000,
"volume": 1
}, {
"index": 24,
"price": 87.94,
"time": 1660600806000,
"volume": 1
}, {
"index": 25,
"price": 87.95,
"time": 1660600807000,
"volume": 1
}, {
"index": 26,
"price": 87.98,
"time": 1660600807000,
"volume": 1
}, {
"index": 27,
"price": 87.99,
"time": 1660600807000,
"volume": 1
}, {
"index": 28,
"price": 88.00,
"time": 1660600807000,
"volume": 1
}, {
"index": 29,
"price": 87.97,
"time": 1660600807000,
"volume": 2
}]
},
"message": "success",
"sign": "llqaLoA5mQZN+nx1pGq5/mp1Ds5Z77uCvD+wM4TM7jtyvW",
"success": true,
"timestamp": 1660620843648
}
Get futures main's historical contract codes
Request: FutureHistoryMainContractRequest
Description
Get futures main's historical contract codes
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
contractCodes | List<String> | Yes | futures code list |
beginTime | Long/String | Yes | Begin time(exclude), millisecond timestamp |
endTime | Long/String | Yes | End time(include), millisecond timestamp |
zoneId | TimeZoneId | No | Description of the timezone used |
ResponseFutureHistoryMainContractItem
object list
Structured as below:
Name | Type | Description |
---|---|---|
contractCode | String | Futures main contract code |
mainReferItems | List<FutureHistoryContractItem> | List of historical futures contract code |
FutureHistoryContractItem object has the following attributes:
Name | Type | Description |
---|---|---|
time | long | timestamp |
referContractCode | String | Futures main's historical contract code |
Example
List<String> contractCodes = new ArrayList<>();
contractCodes.add("ESmain");
FutureHistoryMainContractRequest request = FutureHistoryMainContractRequest.newRequest(contractCodes,
"2023-06-01", "2023-10-05", TimeZoneId.NewYork);
FutureHistoryMainContractResponse response = client.execute(request);
if (response.isSuccess()) {
System.out.println(JSONObject.toJSONString(response));
} else {
System.out.println(response.getMessage());
}
Response Example
{
"code":0,
"data":[
{
"contractCode":"ESmain",
"mainReferItems":[
{
"referContractCode":"ES2312",
"time":1696453200000
},
{
"referContractCode":"ES2312",
"time":1696366800000
},
{
"referContractCode":"ES2312",
"time":1696280400000
},
{
"referContractCode":"ES2312",
"time":1696021200000
},
{
"referContractCode":"ES2312",
"time":1695934800000
},
{
"referContractCode":"ES2312",
"time":1695848400000
},
{
"referContractCode":"ES2312",
"time":1695762000000
},
{
"referContractCode":"ES2312",
"time":1695675600000
},
{
"referContractCode":"ES2312",
"time":1695416400000
},
{
"referContractCode":"ES2312",
"time":1695330000000
},
{
"referContractCode":"ES2312",
"time":1695243600000
},
{
"referContractCode":"ES2312",
"time":1695157200000
},
{
"referContractCode":"ES2312",
"time":1695070800000
},
{
"referContractCode":"ES2312",
"time":1694811600000
},
{
"referContractCode":"ES2312",
"time":1694725200000
},
{
"referContractCode":"ES2312",
"time":1694638800000
},
{
"referContractCode":"ES2312",
"time":1694552400000
},
{
"referContractCode":"ES2312",
"time":1694466000000
},
{
"referContractCode":"ES2309",
"time":1694206800000
},
{
"referContractCode":"ES2309",
"time":1694120400000
},
{
"referContractCode":"ES2309",
"time":1694034000000
},
{
"referContractCode":"ES2309",
"time":1693947600000
},
{
"referContractCode":"ES2309",
"time":1693602000000
},
{
"referContractCode":"ES2309",
"time":1693515600000
},
{
"referContractCode":"ES2309",
"time":1693429200000
},
{
"referContractCode":"ES2309",
"time":1693342800000
},
{
"referContractCode":"ES2309",
"time":1693256400000
},
{
"referContractCode":"ES2309",
"time":1692997200000
},
{
"referContractCode":"ES2309",
"time":1692910800000
},
{
"referContractCode":"ES2309",
"time":1692824400000
},
{
"referContractCode":"ES2309",
"time":1692738000000
},
{
"referContractCode":"ES2309",
"time":1692651600000
},
{
"referContractCode":"ES2309",
"time":1692392400000
},
{
"referContractCode":"ES2309",
"time":1692306000000
},
{
"referContractCode":"ES2309",
"time":1692219600000
},
{
"referContractCode":"ES2309",
"time":1692133200000
},
{
"referContractCode":"ES2309",
"time":1692046800000
},
{
"referContractCode":"ES2309",
"time":1691787600000
},
{
"referContractCode":"ES2309",
"time":1691701200000
},
{
"referContractCode":"ES2309",
"time":1691614800000
},
{
"referContractCode":"ES2309",
"time":1691528400000
},
{
"referContractCode":"ES2309",
"time":1691442000000
},
{
"referContractCode":"ES2309",
"time":1691182800000
},
{
"referContractCode":"ES2309",
"time":1691096400000
},
{
"referContractCode":"ES2309",
"time":1691010000000
},
{
"referContractCode":"ES2309",
"time":1690923600000
},
{
"referContractCode":"ES2309",
"time":1690837200000
},
{
"referContractCode":"ES2309",
"time":1690578000000
},
{
"referContractCode":"ES2309",
"time":1690491600000
},
{
"referContractCode":"ES2309",
"time":1690405200000
},
{
"referContractCode":"ES2309",
"time":1690318800000
},
{
"referContractCode":"ES2309",
"time":1690232400000
},
{
"referContractCode":"ES2309",
"time":1689973200000
},
{
"referContractCode":"ES2309",
"time":1689886800000
},
{
"referContractCode":"ES2309",
"time":1689800400000
},
{
"referContractCode":"ES2309",
"time":1689714000000
},
{
"referContractCode":"ES2309",
"time":1689627600000
},
{
"referContractCode":"ES2309",
"time":1689368400000
},
{
"referContractCode":"ES2309",
"time":1689282000000
},
{
"referContractCode":"ES2309",
"time":1689195600000
},
{
"referContractCode":"ES2309",
"time":1689109200000
},
{
"referContractCode":"ES2309",
"time":1689022800000
},
{
"referContractCode":"ES2309",
"time":1688763600000
},
{
"referContractCode":"ES2309",
"time":1688677200000
},
{
"referContractCode":"ES2309",
"time":1688590800000
},
{
"referContractCode":"ES2309",
"time":1688404500000
},
{
"referContractCode":"ES2309",
"time":1688158800000
},
{
"referContractCode":"ES2309",
"time":1688072400000
},
{
"referContractCode":"ES2309",
"time":1687986000000
},
{
"referContractCode":"ES2309",
"time":1687899600000
},
{
"referContractCode":"ES2309",
"time":1687813200000
},
{
"referContractCode":"ES2309",
"time":1687554000000
},
{
"referContractCode":"ES2309",
"time":1687467600000
},
{
"referContractCode":"ES2309",
"time":1687381200000
},
{
"referContractCode":"ES2309",
"time":1687294800000
},
{
"referContractCode":"ES2309",
"time":1686949200000
},
{
"referContractCode":"ES2309",
"time":1686862800000
},
{
"referContractCode":"ES2309",
"time":1686776400000
},
{
"referContractCode":"ES2309",
"time":1686690000000
},
{
"referContractCode":"ES2309",
"time":1686603600000
},
{
"referContractCode":"ES2306",
"time":1686344400000
},
{
"referContractCode":"ES2306",
"time":1686258000000
},
{
"referContractCode":"ES2306",
"time":1686171600000
},
{
"referContractCode":"ES2306",
"time":1686085200000
},
{
"referContractCode":"ES2306",
"time":1685998800000
},
{
"referContractCode":"ES2306",
"time":1685739600000
},
{
"referContractCode":"ES2306",
"time":1685653200000
}
]
}
],
"message":"success",
"sign":"H/m3GVmsGstQNJxnQrF4nNwkJ3EBJEIBTHMdxzvRKVdM5XtB+PhxlVJBSYclHSRkFn13ckgEr13pzGTrGYjM7cT5zXTTNn0wS0WtVsJoycaUoWqr8KT8P6B6cHq0Sj5LVA5nZlNpno33dplWMWNX3urDf6OiGtQ6J9/ZJcZnvxM=",
"success":true,
"timestamp":1696499214141
}