Skip to content

Latest commit

History

History
2114 lines (1656 loc) · 78.2 KB

File metadata and controls

2114 lines (1656 loc) · 78.2 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
listOptionsUnderlyingsGET /options/underlyingsList all underlying assets
listOptionsExpirationsGET /options/expirationsList all expiration dates
listOptionsContractsGET /options/contractsList all contracts for specified underlying and expiration date
getOptionsContractGET /options/contracts/{contract}Query specified contract details
listOptionsSettlementsGET /options/settlementsList settlement history
getOptionsSettlementGET /options/settlements/{contract}Get specified contract settlement information
listMyOptionsSettlementsGET /options/my_settlementsQuery personal settlement records
listOptionsOrderBookGET /options/order_bookQuery options contract order book
listOptionsTickersGET /options/tickersQuery options market ticker information
listOptionsUnderlyingTickersGET /options/underlying/tickers/{underlying}Query underlying ticker information
listOptionsCandlesticksGET /options/candlesticksOptions contract market candlestick chart
listOptionsUnderlyingCandlesticksGET /options/underlying/candlesticksUnderlying index price candlestick chart
listOptionsTradesGET /options/tradesMarket trade records
listOptionsAccountGET /options/accountsQuery account information
listOptionsAccountBookGET /options/account_bookQuery account change history
listOptionsPositionsGET /options/positionsList user's positions of specified underlying
getOptionsPositionGET /options/positions/{contract}Get specified contract position
listOptionsPositionCloseGET /options/position_closeList user's liquidation history of specified underlying
listOptionsOrdersGET /options/ordersList options orders
createOptionsOrderPOST /options/ordersCreate an options order
cancelOptionsOrdersDELETE /options/ordersCancel all orders with 'open' status
getOptionsOrderGET /options/orders/{order_id}Query single order details
amendOptionsOrderPUT /options/orders/{order_id}Option Order Modification
cancelOptionsOrderDELETE /options/orders/{order_id}Cancel single order
countdownCancelAllOptionsPOST /options/countdown_cancel_allCountdown cancel orders
listMyOptionsTradesGET /options/my_tradesQuery personal trading records
getOptionsMMPGET /options/mmpMMP Query.
setOptionsMMPPOST /options/mmpMMP Settings
resetOptionsMMPPOST /options/mmp/resetMMP Reset

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlying assets

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyings");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

List<OptionsUnderlying>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration dates

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<Long> result = apiInstance.listOptionsExpirations(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<Long>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List expiration dates for specified underlying-

listOptionsContracts

List<OptionsContract> listOptionsContracts(underlying).expiration(expiration).execute();

List all contracts for specified underlying and expiration date

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longexpiration = 1636588800L; // Long | Unix timestamp of expiration datetry {
List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
.expiration(expiration)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
expirationLongUnix timestamp of expiration date[optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsContractresult = apiInstance.getOptionsContract(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsContract");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsSettlements

List<OptionsSettlement> listOptionsSettlements(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List settlement history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract settlement information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longat = 56L; // Long | try {
OptionsSettlementresult = apiInstance.getOptionsSettlement(contract, underlying, at);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsSettlement");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString
underlyingStringUnderlying (Obtained by listing underlying endpoint)
atLong

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listMyOptionsSettlements

List<OptionsMySettlements> listMyOptionsSettlements(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal settlement records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrderBook

OptionsOrderBook listOptionsOrderBook(contract).interval(interval).limit(limit).withId(withId).execute();

Query options contract order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringinterval = "0"; // String | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0Integerlimit = 10; // Integer | Number of depth levelsBooleanwithId = false; // Boolean | Whether to return depth update ID. This ID increments by 1 each time the depth changestry {
OptionsOrderBookresult = apiInstance.listOptionsOrderBook(contract)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
intervalStringPrice precision for merged depth. 0 means no merging. If not specified, defaults to 0[optional] [default to 0] [enum: 0, 0.1, 0.01]
limitIntegerNumber of depth levels[optional] [default to 10]
withIdBooleanWhether to return depth update ID. This ID increments by 1 each time the depth changes[optional] [default to false]

Return type

OptionsOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Depth query successful-

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

Query options market ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<OptionsTicker> result = apiInstance.listOptionsTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<OptionsTicker>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Query underlying ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
OptionsUnderlyingTickerresult = apiInstance.listOptionsUnderlyingTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsCandlesticks

List<OptionsCandlestick> listOptionsCandlesticks(contract).limit(limit).from(from).to(to).interval(interval).execute();

Options contract market candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingCandlesticks

List<OptionsCandlestick> listOptionsUnderlyingCandlesticks(underlying).limit(limit).from(from).to(to).interval(interval).execute();

Underlying index price candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsTrades

List<OptionsTrade> listOptionsTrades().contract(contract).type(type).limit(limit).offset(offset).from(from).to(to).execute();

Market trade records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringtype = "1546935600"; // String | `C` for call, `P` for putIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsTrade> result = apiInstance.listOptionsTrades()
.contract(contract)
.type(type)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
typeString`C` for call, `P` for put[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsTrade>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsAccount

OptionsAccount listOptionsAccount()

Query account information

Query account information for classic option account and unified account

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
OptionsAccountresult = apiInstance.listOptionsAccount();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsAccountBook

List<OptionsAccountBook> listOptionsAccountBook().limit(limit).offset(offset).from(from).to(to).type(type).execute();

Query account change history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringtype = "dnw"; // String | Change types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&Ltry {
List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
typeStringChange types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&L[optional] [enum: dnw, prem, fee, refr, set]

Return type

List<OptionsAccountBook>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsPositions

List<OptionsPosition> listOptionsPositions().underlying(underlying).execute();

List user's positions of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsPosition> result = apiInstance.listOptionsPositions()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsPositionresult = apiInstance.getOptionsPosition(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsPositionClose

List<OptionsPositionClose> listOptionsPositionClose(underlying).contract(contract).execute();

List user's liquidation history of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nametry {
List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
.contract(contract)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositionClose");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrders

List<OptionsOrder> listOptionsOrders(status).contract(contract).underlying(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List options orders

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringstatus = "open"; // String | Query order list based on statusStringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
.contract(contract)
.underlying(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
statusStringQuery order list based on status[enum: open, finished]
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsOrderoptionsOrder = newOptionsOrder(); // OptionsOrder | try {
OptionsOrderresult = apiInstance.createOptionsOrder(optionsOrder);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#createOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsOrderOptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Order detail-

cancelOptionsOrders

List<OptionsOrder> cancelOptionsOrders(contract, underlying, side)

Cancel all orders with 'open' status

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingStringside = "ask"; // String | Specify all bids or all asks, both included if not specifiedtry {
List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
sideStringSpecify all bids or all asks, both included if not specified[optional] [enum: ask, bid]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Batch cancellation successful-

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Query single order details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.getOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

amendOptionsOrder

OptionsOrder amendOptionsOrder(orderId, amendOptionsOrderRequest)

Option Order Modification

Modify the order price and/or quantity of a specified order; only orders with status 'open' are supported

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdAmendOptionsOrderRequestamendOptionsOrderRequest = newAmendOptionsOrderRequest(); // AmendOptionsOrderRequest | try {
OptionsOrderresult = apiInstance.amendOptionsOrder(orderId, amendOptionsOrderRequest);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#amendOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created
amendOptionsOrderRequestAmendOptionsOrderRequest

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel single order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.cancelOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

countdownCancelAllOptions

TriggerTime countdownCancelAllOptions(countdownCancelAllOptionsTask)

Countdown cancel orders

Option order heartbeat detection, when the `timeout` time set by the user is reached, if the existing countdown is not canceled or a new countdown is set, the related `option pending order` will be automatically canceled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at intervals of 30 seconds, with each countdown `timeout` set to 30 (seconds). If this interface is not called again within 30 seconds, all pending orders on the `underlying` `contract` you specified will be automatically cancelled. If `underlying` `contract` is not specified, user will be automatically cancelled If `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the automatic order cancellation function will be cancelled.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
CountdownCancelAllOptionsTaskcountdownCancelAllOptionsTask = newCountdownCancelAllOptionsTask(); // CountdownCancelAllOptionsTask | try {
TriggerTimeresult = apiInstance.countdownCancelAllOptions(countdownCancelAllOptionsTask);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#countdownCancelAllOptions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
countdownCancelAllOptionsTaskCountdownCancelAllOptionsTask

Return type

TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Countdown set successfully-

listMyOptionsTrades

List<OptionsMyTrade> listMyOptionsTrades(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal trading records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsMMP

List<OptionsMMP> getOptionsMMP().underlying(underlying).execute();

MMP Query.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsMMP> result = apiInstance.getOptionsMMP()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsMMP>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

setOptionsMMP

OptionsMMP setOptionsMMP(optionsMMP)

MMP Settings

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPoptionsMMP = newOptionsMMP(); // OptionsMMP | try {
OptionsMMPresult = apiInstance.setOptionsMMP(optionsMMP);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#setOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPOptionsMMP

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-

resetOptionsMMP

OptionsMMP resetOptionsMMP(optionsMMPReset)

MMP Reset

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPResetoptionsMMPReset = newOptionsMMPReset(); // OptionsMMPReset | try {
OptionsMMPresult = apiInstance.resetOptionsMMP(optionsMMPReset);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#resetOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPResetOptionsMMPReset

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
gateapi-java/docs/OptionsApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
2114 lines (1656 loc) · 78.2 KB

File metadata and controls

2114 lines (1656 loc) · 78.2 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
listOptionsUnderlyingsGET /options/underlyingsList all underlying assets
listOptionsExpirationsGET /options/expirationsList all expiration dates
listOptionsContractsGET /options/contractsList all contracts for specified underlying and expiration date
getOptionsContractGET /options/contracts/{contract}Query specified contract details
listOptionsSettlementsGET /options/settlementsList settlement history
getOptionsSettlementGET /options/settlements/{contract}Get specified contract settlement information
listMyOptionsSettlementsGET /options/my_settlementsQuery personal settlement records
listOptionsOrderBookGET /options/order_bookQuery options contract order book
listOptionsTickersGET /options/tickersQuery options market ticker information
listOptionsUnderlyingTickersGET /options/underlying/tickers/{underlying}Query underlying ticker information
listOptionsCandlesticksGET /options/candlesticksOptions contract market candlestick chart
listOptionsUnderlyingCandlesticksGET /options/underlying/candlesticksUnderlying index price candlestick chart
listOptionsTradesGET /options/tradesMarket trade records
listOptionsAccountGET /options/accountsQuery account information
listOptionsAccountBookGET /options/account_bookQuery account change history
listOptionsPositionsGET /options/positionsList user's positions of specified underlying
getOptionsPositionGET /options/positions/{contract}Get specified contract position
listOptionsPositionCloseGET /options/position_closeList user's liquidation history of specified underlying
listOptionsOrdersGET /options/ordersList options orders
createOptionsOrderPOST /options/ordersCreate an options order
cancelOptionsOrdersDELETE /options/ordersCancel all orders with 'open' status
getOptionsOrderGET /options/orders/{order_id}Query single order details
amendOptionsOrderPUT /options/orders/{order_id}Option Order Modification
cancelOptionsOrderDELETE /options/orders/{order_id}Cancel single order
countdownCancelAllOptionsPOST /options/countdown_cancel_allCountdown cancel orders
listMyOptionsTradesGET /options/my_tradesQuery personal trading records
getOptionsMMPGET /options/mmpMMP Query.
setOptionsMMPPOST /options/mmpMMP Settings
resetOptionsMMPPOST /options/mmp/resetMMP Reset

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlying assets

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyings");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

List<OptionsUnderlying>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration dates

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<Long> result = apiInstance.listOptionsExpirations(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<Long>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List expiration dates for specified underlying-

listOptionsContracts

List<OptionsContract> listOptionsContracts(underlying).expiration(expiration).execute();

List all contracts for specified underlying and expiration date

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longexpiration = 1636588800L; // Long | Unix timestamp of expiration datetry {
List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
.expiration(expiration)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
expirationLongUnix timestamp of expiration date[optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsContractresult = apiInstance.getOptionsContract(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsContract");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsSettlements

List<OptionsSettlement> listOptionsSettlements(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List settlement history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract settlement information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longat = 56L; // Long | try {
OptionsSettlementresult = apiInstance.getOptionsSettlement(contract, underlying, at);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsSettlement");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString
underlyingStringUnderlying (Obtained by listing underlying endpoint)
atLong

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listMyOptionsSettlements

List<OptionsMySettlements> listMyOptionsSettlements(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal settlement records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrderBook

OptionsOrderBook listOptionsOrderBook(contract).interval(interval).limit(limit).withId(withId).execute();

Query options contract order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringinterval = "0"; // String | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0Integerlimit = 10; // Integer | Number of depth levelsBooleanwithId = false; // Boolean | Whether to return depth update ID. This ID increments by 1 each time the depth changestry {
OptionsOrderBookresult = apiInstance.listOptionsOrderBook(contract)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
intervalStringPrice precision for merged depth. 0 means no merging. If not specified, defaults to 0[optional] [default to 0] [enum: 0, 0.1, 0.01]
limitIntegerNumber of depth levels[optional] [default to 10]
withIdBooleanWhether to return depth update ID. This ID increments by 1 each time the depth changes[optional] [default to false]

Return type

OptionsOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Depth query successful-

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

Query options market ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<OptionsTicker> result = apiInstance.listOptionsTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<OptionsTicker>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Query underlying ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
OptionsUnderlyingTickerresult = apiInstance.listOptionsUnderlyingTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsCandlesticks

List<OptionsCandlestick> listOptionsCandlesticks(contract).limit(limit).from(from).to(to).interval(interval).execute();

Options contract market candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingCandlesticks

List<OptionsCandlestick> listOptionsUnderlyingCandlesticks(underlying).limit(limit).from(from).to(to).interval(interval).execute();

Underlying index price candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsTrades

List<OptionsTrade> listOptionsTrades().contract(contract).type(type).limit(limit).offset(offset).from(from).to(to).execute();

Market trade records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringtype = "1546935600"; // String | `C` for call, `P` for putIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsTrade> result = apiInstance.listOptionsTrades()
.contract(contract)
.type(type)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
typeString`C` for call, `P` for put[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsTrade>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsAccount

OptionsAccount listOptionsAccount()

Query account information

Query account information for classic option account and unified account

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
OptionsAccountresult = apiInstance.listOptionsAccount();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsAccountBook

List<OptionsAccountBook> listOptionsAccountBook().limit(limit).offset(offset).from(from).to(to).type(type).execute();

Query account change history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringtype = "dnw"; // String | Change types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&Ltry {
List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
typeStringChange types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&L[optional] [enum: dnw, prem, fee, refr, set]

Return type

List<OptionsAccountBook>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsPositions

List<OptionsPosition> listOptionsPositions().underlying(underlying).execute();

List user's positions of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsPosition> result = apiInstance.listOptionsPositions()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsPositionresult = apiInstance.getOptionsPosition(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsPositionClose

List<OptionsPositionClose> listOptionsPositionClose(underlying).contract(contract).execute();

List user's liquidation history of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nametry {
List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
.contract(contract)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositionClose");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrders

List<OptionsOrder> listOptionsOrders(status).contract(contract).underlying(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List options orders

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringstatus = "open"; // String | Query order list based on statusStringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
.contract(contract)
.underlying(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
statusStringQuery order list based on status[enum: open, finished]
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsOrderoptionsOrder = newOptionsOrder(); // OptionsOrder | try {
OptionsOrderresult = apiInstance.createOptionsOrder(optionsOrder);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#createOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsOrderOptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Order detail-

cancelOptionsOrders

List<OptionsOrder> cancelOptionsOrders(contract, underlying, side)

Cancel all orders with 'open' status

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingStringside = "ask"; // String | Specify all bids or all asks, both included if not specifiedtry {
List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
sideStringSpecify all bids or all asks, both included if not specified[optional] [enum: ask, bid]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Batch cancellation successful-

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Query single order details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.getOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

amendOptionsOrder

OptionsOrder amendOptionsOrder(orderId, amendOptionsOrderRequest)

Option Order Modification

Modify the order price and/or quantity of a specified order; only orders with status 'open' are supported

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdAmendOptionsOrderRequestamendOptionsOrderRequest = newAmendOptionsOrderRequest(); // AmendOptionsOrderRequest | try {
OptionsOrderresult = apiInstance.amendOptionsOrder(orderId, amendOptionsOrderRequest);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#amendOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created
amendOptionsOrderRequestAmendOptionsOrderRequest

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel single order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.cancelOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

countdownCancelAllOptions

TriggerTime countdownCancelAllOptions(countdownCancelAllOptionsTask)

Countdown cancel orders

Option order heartbeat detection, when the `timeout` time set by the user is reached, if the existing countdown is not canceled or a new countdown is set, the related `option pending order` will be automatically canceled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at intervals of 30 seconds, with each countdown `timeout` set to 30 (seconds). If this interface is not called again within 30 seconds, all pending orders on the `underlying` `contract` you specified will be automatically cancelled. If `underlying` `contract` is not specified, user will be automatically cancelled If `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the automatic order cancellation function will be cancelled.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
CountdownCancelAllOptionsTaskcountdownCancelAllOptionsTask = newCountdownCancelAllOptionsTask(); // CountdownCancelAllOptionsTask | try {
TriggerTimeresult = apiInstance.countdownCancelAllOptions(countdownCancelAllOptionsTask);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#countdownCancelAllOptions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
countdownCancelAllOptionsTaskCountdownCancelAllOptionsTask

Return type

TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Countdown set successfully-

listMyOptionsTrades

List<OptionsMyTrade> listMyOptionsTrades(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal trading records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsMMP

List<OptionsMMP> getOptionsMMP().underlying(underlying).execute();

MMP Query.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsMMP> result = apiInstance.getOptionsMMP()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsMMP>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

setOptionsMMP

OptionsMMP setOptionsMMP(optionsMMP)

MMP Settings

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPoptionsMMP = newOptionsMMP(); // OptionsMMP | try {
OptionsMMPresult = apiInstance.setOptionsMMP(optionsMMP);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#setOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPOptionsMMP

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-

resetOptionsMMP

OptionsMMP resetOptionsMMP(optionsMMPReset)

MMP Reset

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPResetoptionsMMPReset = newOptionsMMPReset(); // OptionsMMPReset | try {
OptionsMMPresult = apiInstance.resetOptionsMMP(optionsMMPReset);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#resetOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPResetOptionsMMPReset

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' gateapi-java/docs/OptionsApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
2114 lines (1656 loc) · 78.2 KB

File metadata and controls

2114 lines (1656 loc) · 78.2 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
listOptionsUnderlyingsGET /options/underlyingsList all underlying assets
listOptionsExpirationsGET /options/expirationsList all expiration dates
listOptionsContractsGET /options/contractsList all contracts for specified underlying and expiration date
getOptionsContractGET /options/contracts/{contract}Query specified contract details
listOptionsSettlementsGET /options/settlementsList settlement history
getOptionsSettlementGET /options/settlements/{contract}Get specified contract settlement information
listMyOptionsSettlementsGET /options/my_settlementsQuery personal settlement records
listOptionsOrderBookGET /options/order_bookQuery options contract order book
listOptionsTickersGET /options/tickersQuery options market ticker information
listOptionsUnderlyingTickersGET /options/underlying/tickers/{underlying}Query underlying ticker information
listOptionsCandlesticksGET /options/candlesticksOptions contract market candlestick chart
listOptionsUnderlyingCandlesticksGET /options/underlying/candlesticksUnderlying index price candlestick chart
listOptionsTradesGET /options/tradesMarket trade records
listOptionsAccountGET /options/accountsQuery account information
listOptionsAccountBookGET /options/account_bookQuery account change history
listOptionsPositionsGET /options/positionsList user's positions of specified underlying
getOptionsPositionGET /options/positions/{contract}Get specified contract position
listOptionsPositionCloseGET /options/position_closeList user's liquidation history of specified underlying
listOptionsOrdersGET /options/ordersList options orders
createOptionsOrderPOST /options/ordersCreate an options order
cancelOptionsOrdersDELETE /options/ordersCancel all orders with 'open' status
getOptionsOrderGET /options/orders/{order_id}Query single order details
amendOptionsOrderPUT /options/orders/{order_id}Option Order Modification
cancelOptionsOrderDELETE /options/orders/{order_id}Cancel single order
countdownCancelAllOptionsPOST /options/countdown_cancel_allCountdown cancel orders
listMyOptionsTradesGET /options/my_tradesQuery personal trading records
getOptionsMMPGET /options/mmpMMP Query.
setOptionsMMPPOST /options/mmpMMP Settings
resetOptionsMMPPOST /options/mmp/resetMMP Reset

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlying assets

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyings");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

List<OptionsUnderlying>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration dates

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<Long> result = apiInstance.listOptionsExpirations(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<Long>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List expiration dates for specified underlying-

listOptionsContracts

List<OptionsContract> listOptionsContracts(underlying).expiration(expiration).execute();

List all contracts for specified underlying and expiration date

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longexpiration = 1636588800L; // Long | Unix timestamp of expiration datetry {
List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
.expiration(expiration)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
expirationLongUnix timestamp of expiration date[optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsContractresult = apiInstance.getOptionsContract(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsContract");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsSettlements

List<OptionsSettlement> listOptionsSettlements(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List settlement history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract settlement information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longat = 56L; // Long | try {
OptionsSettlementresult = apiInstance.getOptionsSettlement(contract, underlying, at);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsSettlement");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString
underlyingStringUnderlying (Obtained by listing underlying endpoint)
atLong

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listMyOptionsSettlements

List<OptionsMySettlements> listMyOptionsSettlements(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal settlement records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrderBook

OptionsOrderBook listOptionsOrderBook(contract).interval(interval).limit(limit).withId(withId).execute();

Query options contract order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringinterval = "0"; // String | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0Integerlimit = 10; // Integer | Number of depth levelsBooleanwithId = false; // Boolean | Whether to return depth update ID. This ID increments by 1 each time the depth changestry {
OptionsOrderBookresult = apiInstance.listOptionsOrderBook(contract)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
intervalStringPrice precision for merged depth. 0 means no merging. If not specified, defaults to 0[optional] [default to 0] [enum: 0, 0.1, 0.01]
limitIntegerNumber of depth levels[optional] [default to 10]
withIdBooleanWhether to return depth update ID. This ID increments by 1 each time the depth changes[optional] [default to false]

Return type

OptionsOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Depth query successful-

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

Query options market ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<OptionsTicker> result = apiInstance.listOptionsTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<OptionsTicker>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Query underlying ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
OptionsUnderlyingTickerresult = apiInstance.listOptionsUnderlyingTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsCandlesticks

List<OptionsCandlestick> listOptionsCandlesticks(contract).limit(limit).from(from).to(to).interval(interval).execute();

Options contract market candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingCandlesticks

List<OptionsCandlestick> listOptionsUnderlyingCandlesticks(underlying).limit(limit).from(from).to(to).interval(interval).execute();

Underlying index price candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsTrades

List<OptionsTrade> listOptionsTrades().contract(contract).type(type).limit(limit).offset(offset).from(from).to(to).execute();

Market trade records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringtype = "1546935600"; // String | `C` for call, `P` for putIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsTrade> result = apiInstance.listOptionsTrades()
.contract(contract)
.type(type)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
typeString`C` for call, `P` for put[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsTrade>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsAccount

OptionsAccount listOptionsAccount()

Query account information

Query account information for classic option account and unified account

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
OptionsAccountresult = apiInstance.listOptionsAccount();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsAccountBook

List<OptionsAccountBook> listOptionsAccountBook().limit(limit).offset(offset).from(from).to(to).type(type).execute();

Query account change history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringtype = "dnw"; // String | Change types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&Ltry {
List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
typeStringChange types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&L[optional] [enum: dnw, prem, fee, refr, set]

Return type

List<OptionsAccountBook>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsPositions

List<OptionsPosition> listOptionsPositions().underlying(underlying).execute();

List user's positions of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsPosition> result = apiInstance.listOptionsPositions()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsPositionresult = apiInstance.getOptionsPosition(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsPositionClose

List<OptionsPositionClose> listOptionsPositionClose(underlying).contract(contract).execute();

List user's liquidation history of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nametry {
List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
.contract(contract)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositionClose");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrders

List<OptionsOrder> listOptionsOrders(status).contract(contract).underlying(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List options orders

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringstatus = "open"; // String | Query order list based on statusStringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
.contract(contract)
.underlying(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
statusStringQuery order list based on status[enum: open, finished]
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsOrderoptionsOrder = newOptionsOrder(); // OptionsOrder | try {
OptionsOrderresult = apiInstance.createOptionsOrder(optionsOrder);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#createOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsOrderOptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Order detail-

cancelOptionsOrders

List<OptionsOrder> cancelOptionsOrders(contract, underlying, side)

Cancel all orders with 'open' status

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingStringside = "ask"; // String | Specify all bids or all asks, both included if not specifiedtry {
List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
sideStringSpecify all bids or all asks, both included if not specified[optional] [enum: ask, bid]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Batch cancellation successful-

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Query single order details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.getOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

amendOptionsOrder

OptionsOrder amendOptionsOrder(orderId, amendOptionsOrderRequest)

Option Order Modification

Modify the order price and/or quantity of a specified order; only orders with status 'open' are supported

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdAmendOptionsOrderRequestamendOptionsOrderRequest = newAmendOptionsOrderRequest(); // AmendOptionsOrderRequest | try {
OptionsOrderresult = apiInstance.amendOptionsOrder(orderId, amendOptionsOrderRequest);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#amendOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created
amendOptionsOrderRequestAmendOptionsOrderRequest

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel single order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.cancelOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

countdownCancelAllOptions

TriggerTime countdownCancelAllOptions(countdownCancelAllOptionsTask)

Countdown cancel orders

Option order heartbeat detection, when the `timeout` time set by the user is reached, if the existing countdown is not canceled or a new countdown is set, the related `option pending order` will be automatically canceled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at intervals of 30 seconds, with each countdown `timeout` set to 30 (seconds). If this interface is not called again within 30 seconds, all pending orders on the `underlying` `contract` you specified will be automatically cancelled. If `underlying` `contract` is not specified, user will be automatically cancelled If `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the automatic order cancellation function will be cancelled.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
CountdownCancelAllOptionsTaskcountdownCancelAllOptionsTask = newCountdownCancelAllOptionsTask(); // CountdownCancelAllOptionsTask | try {
TriggerTimeresult = apiInstance.countdownCancelAllOptions(countdownCancelAllOptionsTask);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#countdownCancelAllOptions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
countdownCancelAllOptionsTaskCountdownCancelAllOptionsTask

Return type

TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Countdown set successfully-

listMyOptionsTrades

List<OptionsMyTrade> listMyOptionsTrades(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal trading records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsMMP

List<OptionsMMP> getOptionsMMP().underlying(underlying).execute();

MMP Query.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsMMP> result = apiInstance.getOptionsMMP()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsMMP>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

setOptionsMMP

OptionsMMP setOptionsMMP(optionsMMP)

MMP Settings

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPoptionsMMP = newOptionsMMP(); // OptionsMMP | try {
OptionsMMPresult = apiInstance.setOptionsMMP(optionsMMP);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#setOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPOptionsMMP

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-

resetOptionsMMP

OptionsMMP resetOptionsMMP(optionsMMPReset)

MMP Reset

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPResetoptionsMMPReset = newOptionsMMPReset(); // OptionsMMPReset | try {
OptionsMMPresult = apiInstance.resetOptionsMMP(optionsMMPReset);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#resetOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPResetOptionsMMPReset

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' gateapi-java/docs/OptionsApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
2114 lines (1656 loc) · 78.2 KB

File metadata and controls

2114 lines (1656 loc) · 78.2 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
listOptionsUnderlyingsGET /options/underlyingsList all underlying assets
listOptionsExpirationsGET /options/expirationsList all expiration dates
listOptionsContractsGET /options/contractsList all contracts for specified underlying and expiration date
getOptionsContractGET /options/contracts/{contract}Query specified contract details
listOptionsSettlementsGET /options/settlementsList settlement history
getOptionsSettlementGET /options/settlements/{contract}Get specified contract settlement information
listMyOptionsSettlementsGET /options/my_settlementsQuery personal settlement records
listOptionsOrderBookGET /options/order_bookQuery options contract order book
listOptionsTickersGET /options/tickersQuery options market ticker information
listOptionsUnderlyingTickersGET /options/underlying/tickers/{underlying}Query underlying ticker information
listOptionsCandlesticksGET /options/candlesticksOptions contract market candlestick chart
listOptionsUnderlyingCandlesticksGET /options/underlying/candlesticksUnderlying index price candlestick chart
listOptionsTradesGET /options/tradesMarket trade records
listOptionsAccountGET /options/accountsQuery account information
listOptionsAccountBookGET /options/account_bookQuery account change history
listOptionsPositionsGET /options/positionsList user's positions of specified underlying
getOptionsPositionGET /options/positions/{contract}Get specified contract position
listOptionsPositionCloseGET /options/position_closeList user's liquidation history of specified underlying
listOptionsOrdersGET /options/ordersList options orders
createOptionsOrderPOST /options/ordersCreate an options order
cancelOptionsOrdersDELETE /options/ordersCancel all orders with 'open' status
getOptionsOrderGET /options/orders/{order_id}Query single order details
amendOptionsOrderPUT /options/orders/{order_id}Option Order Modification
cancelOptionsOrderDELETE /options/orders/{order_id}Cancel single order
countdownCancelAllOptionsPOST /options/countdown_cancel_allCountdown cancel orders
listMyOptionsTradesGET /options/my_tradesQuery personal trading records
getOptionsMMPGET /options/mmpMMP Query.
setOptionsMMPPOST /options/mmpMMP Settings
resetOptionsMMPPOST /options/mmp/resetMMP Reset

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlying assets

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyings");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

List<OptionsUnderlying>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration dates

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<Long> result = apiInstance.listOptionsExpirations(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<Long>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List expiration dates for specified underlying-

listOptionsContracts

List<OptionsContract> listOptionsContracts(underlying).expiration(expiration).execute();

List all contracts for specified underlying and expiration date

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longexpiration = 1636588800L; // Long | Unix timestamp of expiration datetry {
List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
.expiration(expiration)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
expirationLongUnix timestamp of expiration date[optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsContractresult = apiInstance.getOptionsContract(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsContract");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsSettlements

List<OptionsSettlement> listOptionsSettlements(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List settlement history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract settlement information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longat = 56L; // Long | try {
OptionsSettlementresult = apiInstance.getOptionsSettlement(contract, underlying, at);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsSettlement");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString
underlyingStringUnderlying (Obtained by listing underlying endpoint)
atLong

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listMyOptionsSettlements

List<OptionsMySettlements> listMyOptionsSettlements(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal settlement records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrderBook

OptionsOrderBook listOptionsOrderBook(contract).interval(interval).limit(limit).withId(withId).execute();

Query options contract order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringinterval = "0"; // String | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0Integerlimit = 10; // Integer | Number of depth levelsBooleanwithId = false; // Boolean | Whether to return depth update ID. This ID increments by 1 each time the depth changestry {
OptionsOrderBookresult = apiInstance.listOptionsOrderBook(contract)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
intervalStringPrice precision for merged depth. 0 means no merging. If not specified, defaults to 0[optional] [default to 0] [enum: 0, 0.1, 0.01]
limitIntegerNumber of depth levels[optional] [default to 10]
withIdBooleanWhether to return depth update ID. This ID increments by 1 each time the depth changes[optional] [default to false]

Return type

OptionsOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Depth query successful-

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

Query options market ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<OptionsTicker> result = apiInstance.listOptionsTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<OptionsTicker>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Query underlying ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
OptionsUnderlyingTickerresult = apiInstance.listOptionsUnderlyingTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsCandlesticks

List<OptionsCandlestick> listOptionsCandlesticks(contract).limit(limit).from(from).to(to).interval(interval).execute();

Options contract market candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingCandlesticks

List<OptionsCandlestick> listOptionsUnderlyingCandlesticks(underlying).limit(limit).from(from).to(to).interval(interval).execute();

Underlying index price candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsTrades

List<OptionsTrade> listOptionsTrades().contract(contract).type(type).limit(limit).offset(offset).from(from).to(to).execute();

Market trade records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringtype = "1546935600"; // String | `C` for call, `P` for putIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsTrade> result = apiInstance.listOptionsTrades()
.contract(contract)
.type(type)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
typeString`C` for call, `P` for put[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsTrade>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsAccount

OptionsAccount listOptionsAccount()

Query account information

Query account information for classic option account and unified account

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
OptionsAccountresult = apiInstance.listOptionsAccount();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsAccountBook

List<OptionsAccountBook> listOptionsAccountBook().limit(limit).offset(offset).from(from).to(to).type(type).execute();

Query account change history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringtype = "dnw"; // String | Change types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&Ltry {
List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
typeStringChange types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&L[optional] [enum: dnw, prem, fee, refr, set]

Return type

List<OptionsAccountBook>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsPositions

List<OptionsPosition> listOptionsPositions().underlying(underlying).execute();

List user's positions of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsPosition> result = apiInstance.listOptionsPositions()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsPositionresult = apiInstance.getOptionsPosition(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsPositionClose

List<OptionsPositionClose> listOptionsPositionClose(underlying).contract(contract).execute();

List user's liquidation history of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nametry {
List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
.contract(contract)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositionClose");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrders

List<OptionsOrder> listOptionsOrders(status).contract(contract).underlying(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List options orders

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringstatus = "open"; // String | Query order list based on statusStringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
.contract(contract)
.underlying(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
statusStringQuery order list based on status[enum: open, finished]
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsOrderoptionsOrder = newOptionsOrder(); // OptionsOrder | try {
OptionsOrderresult = apiInstance.createOptionsOrder(optionsOrder);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#createOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsOrderOptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Order detail-

cancelOptionsOrders

List<OptionsOrder> cancelOptionsOrders(contract, underlying, side)

Cancel all orders with 'open' status

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingStringside = "ask"; // String | Specify all bids or all asks, both included if not specifiedtry {
List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
sideStringSpecify all bids or all asks, both included if not specified[optional] [enum: ask, bid]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Batch cancellation successful-

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Query single order details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.getOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

amendOptionsOrder

OptionsOrder amendOptionsOrder(orderId, amendOptionsOrderRequest)

Option Order Modification

Modify the order price and/or quantity of a specified order; only orders with status 'open' are supported

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdAmendOptionsOrderRequestamendOptionsOrderRequest = newAmendOptionsOrderRequest(); // AmendOptionsOrderRequest | try {
OptionsOrderresult = apiInstance.amendOptionsOrder(orderId, amendOptionsOrderRequest);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#amendOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created
amendOptionsOrderRequestAmendOptionsOrderRequest

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel single order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.cancelOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

countdownCancelAllOptions

TriggerTime countdownCancelAllOptions(countdownCancelAllOptionsTask)

Countdown cancel orders

Option order heartbeat detection, when the `timeout` time set by the user is reached, if the existing countdown is not canceled or a new countdown is set, the related `option pending order` will be automatically canceled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at intervals of 30 seconds, with each countdown `timeout` set to 30 (seconds). If this interface is not called again within 30 seconds, all pending orders on the `underlying` `contract` you specified will be automatically cancelled. If `underlying` `contract` is not specified, user will be automatically cancelled If `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the automatic order cancellation function will be cancelled.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
CountdownCancelAllOptionsTaskcountdownCancelAllOptionsTask = newCountdownCancelAllOptionsTask(); // CountdownCancelAllOptionsTask | try {
TriggerTimeresult = apiInstance.countdownCancelAllOptions(countdownCancelAllOptionsTask);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#countdownCancelAllOptions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
countdownCancelAllOptionsTaskCountdownCancelAllOptionsTask

Return type

TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Countdown set successfully-

listMyOptionsTrades

List<OptionsMyTrade> listMyOptionsTrades(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal trading records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsMMP

List<OptionsMMP> getOptionsMMP().underlying(underlying).execute();

MMP Query.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsMMP> result = apiInstance.getOptionsMMP()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsMMP>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

setOptionsMMP

OptionsMMP setOptionsMMP(optionsMMP)

MMP Settings

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPoptionsMMP = newOptionsMMP(); // OptionsMMP | try {
OptionsMMPresult = apiInstance.setOptionsMMP(optionsMMP);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#setOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPOptionsMMP

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-

resetOptionsMMP

OptionsMMP resetOptionsMMP(optionsMMPReset)

MMP Reset

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPResetoptionsMMPReset = newOptionsMMPReset(); // OptionsMMPReset | try {
OptionsMMPresult = apiInstance.resetOptionsMMP(optionsMMPReset);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#resetOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPResetOptionsMMPReset

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' gateapi-java/docs/OptionsApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
2114 lines (1656 loc) · 78.2 KB

File metadata and controls

2114 lines (1656 loc) · 78.2 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
listOptionsUnderlyingsGET /options/underlyingsList all underlying assets
listOptionsExpirationsGET /options/expirationsList all expiration dates
listOptionsContractsGET /options/contractsList all contracts for specified underlying and expiration date
getOptionsContractGET /options/contracts/{contract}Query specified contract details
listOptionsSettlementsGET /options/settlementsList settlement history
getOptionsSettlementGET /options/settlements/{contract}Get specified contract settlement information
listMyOptionsSettlementsGET /options/my_settlementsQuery personal settlement records
listOptionsOrderBookGET /options/order_bookQuery options contract order book
listOptionsTickersGET /options/tickersQuery options market ticker information
listOptionsUnderlyingTickersGET /options/underlying/tickers/{underlying}Query underlying ticker information
listOptionsCandlesticksGET /options/candlesticksOptions contract market candlestick chart
listOptionsUnderlyingCandlesticksGET /options/underlying/candlesticksUnderlying index price candlestick chart
listOptionsTradesGET /options/tradesMarket trade records
listOptionsAccountGET /options/accountsQuery account information
listOptionsAccountBookGET /options/account_bookQuery account change history
listOptionsPositionsGET /options/positionsList user's positions of specified underlying
getOptionsPositionGET /options/positions/{contract}Get specified contract position
listOptionsPositionCloseGET /options/position_closeList user's liquidation history of specified underlying
listOptionsOrdersGET /options/ordersList options orders
createOptionsOrderPOST /options/ordersCreate an options order
cancelOptionsOrdersDELETE /options/ordersCancel all orders with 'open' status
getOptionsOrderGET /options/orders/{order_id}Query single order details
amendOptionsOrderPUT /options/orders/{order_id}Option Order Modification
cancelOptionsOrderDELETE /options/orders/{order_id}Cancel single order
countdownCancelAllOptionsPOST /options/countdown_cancel_allCountdown cancel orders
listMyOptionsTradesGET /options/my_tradesQuery personal trading records
getOptionsMMPGET /options/mmpMMP Query.
setOptionsMMPPOST /options/mmpMMP Settings
resetOptionsMMPPOST /options/mmp/resetMMP Reset

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlying assets

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyings");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

List<OptionsUnderlying>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration dates

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<Long> result = apiInstance.listOptionsExpirations(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<Long>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List expiration dates for specified underlying-

listOptionsContracts

List<OptionsContract> listOptionsContracts(underlying).expiration(expiration).execute();

List all contracts for specified underlying and expiration date

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longexpiration = 1636588800L; // Long | Unix timestamp of expiration datetry {
List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
.expiration(expiration)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
expirationLongUnix timestamp of expiration date[optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsContractresult = apiInstance.getOptionsContract(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsContract");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsSettlements

List<OptionsSettlement> listOptionsSettlements(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List settlement history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract settlement information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longat = 56L; // Long | try {
OptionsSettlementresult = apiInstance.getOptionsSettlement(contract, underlying, at);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsSettlement");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString
underlyingStringUnderlying (Obtained by listing underlying endpoint)
atLong

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listMyOptionsSettlements

List<OptionsMySettlements> listMyOptionsSettlements(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal settlement records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrderBook

OptionsOrderBook listOptionsOrderBook(contract).interval(interval).limit(limit).withId(withId).execute();

Query options contract order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringinterval = "0"; // String | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0Integerlimit = 10; // Integer | Number of depth levelsBooleanwithId = false; // Boolean | Whether to return depth update ID. This ID increments by 1 each time the depth changestry {
OptionsOrderBookresult = apiInstance.listOptionsOrderBook(contract)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
intervalStringPrice precision for merged depth. 0 means no merging. If not specified, defaults to 0[optional] [default to 0] [enum: 0, 0.1, 0.01]
limitIntegerNumber of depth levels[optional] [default to 10]
withIdBooleanWhether to return depth update ID. This ID increments by 1 each time the depth changes[optional] [default to false]

Return type

OptionsOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Depth query successful-

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

Query options market ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<OptionsTicker> result = apiInstance.listOptionsTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<OptionsTicker>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Query underlying ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
OptionsUnderlyingTickerresult = apiInstance.listOptionsUnderlyingTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsCandlesticks

List<OptionsCandlestick> listOptionsCandlesticks(contract).limit(limit).from(from).to(to).interval(interval).execute();

Options contract market candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingCandlesticks

List<OptionsCandlestick> listOptionsUnderlyingCandlesticks(underlying).limit(limit).from(from).to(to).interval(interval).execute();

Underlying index price candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsTrades

List<OptionsTrade> listOptionsTrades().contract(contract).type(type).limit(limit).offset(offset).from(from).to(to).execute();

Market trade records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringtype = "1546935600"; // String | `C` for call, `P` for putIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsTrade> result = apiInstance.listOptionsTrades()
.contract(contract)
.type(type)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
typeString`C` for call, `P` for put[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsTrade>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsAccount

OptionsAccount listOptionsAccount()

Query account information

Query account information for classic option account and unified account

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
OptionsAccountresult = apiInstance.listOptionsAccount();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsAccountBook

List<OptionsAccountBook> listOptionsAccountBook().limit(limit).offset(offset).from(from).to(to).type(type).execute();

Query account change history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringtype = "dnw"; // String | Change types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&Ltry {
List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
typeStringChange types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&L[optional] [enum: dnw, prem, fee, refr, set]

Return type

List<OptionsAccountBook>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsPositions

List<OptionsPosition> listOptionsPositions().underlying(underlying).execute();

List user's positions of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsPosition> result = apiInstance.listOptionsPositions()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsPositionresult = apiInstance.getOptionsPosition(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsPositionClose

List<OptionsPositionClose> listOptionsPositionClose(underlying).contract(contract).execute();

List user's liquidation history of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nametry {
List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
.contract(contract)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositionClose");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrders

List<OptionsOrder> listOptionsOrders(status).contract(contract).underlying(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List options orders

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringstatus = "open"; // String | Query order list based on statusStringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
.contract(contract)
.underlying(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
statusStringQuery order list based on status[enum: open, finished]
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsOrderoptionsOrder = newOptionsOrder(); // OptionsOrder | try {
OptionsOrderresult = apiInstance.createOptionsOrder(optionsOrder);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#createOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsOrderOptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Order detail-

cancelOptionsOrders

List<OptionsOrder> cancelOptionsOrders(contract, underlying, side)

Cancel all orders with 'open' status

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingStringside = "ask"; // String | Specify all bids or all asks, both included if not specifiedtry {
List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
sideStringSpecify all bids or all asks, both included if not specified[optional] [enum: ask, bid]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Batch cancellation successful-

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Query single order details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.getOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

amendOptionsOrder

OptionsOrder amendOptionsOrder(orderId, amendOptionsOrderRequest)

Option Order Modification

Modify the order price and/or quantity of a specified order; only orders with status 'open' are supported

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdAmendOptionsOrderRequestamendOptionsOrderRequest = newAmendOptionsOrderRequest(); // AmendOptionsOrderRequest | try {
OptionsOrderresult = apiInstance.amendOptionsOrder(orderId, amendOptionsOrderRequest);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#amendOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created
amendOptionsOrderRequestAmendOptionsOrderRequest

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel single order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.cancelOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

countdownCancelAllOptions

TriggerTime countdownCancelAllOptions(countdownCancelAllOptionsTask)

Countdown cancel orders

Option order heartbeat detection, when the `timeout` time set by the user is reached, if the existing countdown is not canceled or a new countdown is set, the related `option pending order` will be automatically canceled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at intervals of 30 seconds, with each countdown `timeout` set to 30 (seconds). If this interface is not called again within 30 seconds, all pending orders on the `underlying` `contract` you specified will be automatically cancelled. If `underlying` `contract` is not specified, user will be automatically cancelled If `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the automatic order cancellation function will be cancelled.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
CountdownCancelAllOptionsTaskcountdownCancelAllOptionsTask = newCountdownCancelAllOptionsTask(); // CountdownCancelAllOptionsTask | try {
TriggerTimeresult = apiInstance.countdownCancelAllOptions(countdownCancelAllOptionsTask);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#countdownCancelAllOptions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
countdownCancelAllOptionsTaskCountdownCancelAllOptionsTask

Return type

TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Countdown set successfully-

listMyOptionsTrades

List<OptionsMyTrade> listMyOptionsTrades(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal trading records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsMMP

List<OptionsMMP> getOptionsMMP().underlying(underlying).execute();

MMP Query.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsMMP> result = apiInstance.getOptionsMMP()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsMMP>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

setOptionsMMP

OptionsMMP setOptionsMMP(optionsMMP)

MMP Settings

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPoptionsMMP = newOptionsMMP(); // OptionsMMP | try {
OptionsMMPresult = apiInstance.setOptionsMMP(optionsMMP);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#setOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPOptionsMMP

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-

resetOptionsMMP

OptionsMMP resetOptionsMMP(optionsMMPReset)

MMP Reset

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPResetoptionsMMPReset = newOptionsMMPReset(); // OptionsMMPReset | try {
OptionsMMPresult = apiInstance.resetOptionsMMP(optionsMMPReset);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#resetOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPResetOptionsMMPReset

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' gateapi-java/docs/OptionsApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
2114 lines (1656 loc) · 78.2 KB

File metadata and controls

2114 lines (1656 loc) · 78.2 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
listOptionsUnderlyingsGET /options/underlyingsList all underlying assets
listOptionsExpirationsGET /options/expirationsList all expiration dates
listOptionsContractsGET /options/contractsList all contracts for specified underlying and expiration date
getOptionsContractGET /options/contracts/{contract}Query specified contract details
listOptionsSettlementsGET /options/settlementsList settlement history
getOptionsSettlementGET /options/settlements/{contract}Get specified contract settlement information
listMyOptionsSettlementsGET /options/my_settlementsQuery personal settlement records
listOptionsOrderBookGET /options/order_bookQuery options contract order book
listOptionsTickersGET /options/tickersQuery options market ticker information
listOptionsUnderlyingTickersGET /options/underlying/tickers/{underlying}Query underlying ticker information
listOptionsCandlesticksGET /options/candlesticksOptions contract market candlestick chart
listOptionsUnderlyingCandlesticksGET /options/underlying/candlesticksUnderlying index price candlestick chart
listOptionsTradesGET /options/tradesMarket trade records
listOptionsAccountGET /options/accountsQuery account information
listOptionsAccountBookGET /options/account_bookQuery account change history
listOptionsPositionsGET /options/positionsList user's positions of specified underlying
getOptionsPositionGET /options/positions/{contract}Get specified contract position
listOptionsPositionCloseGET /options/position_closeList user's liquidation history of specified underlying
listOptionsOrdersGET /options/ordersList options orders
createOptionsOrderPOST /options/ordersCreate an options order
cancelOptionsOrdersDELETE /options/ordersCancel all orders with 'open' status
getOptionsOrderGET /options/orders/{order_id}Query single order details
amendOptionsOrderPUT /options/orders/{order_id}Option Order Modification
cancelOptionsOrderDELETE /options/orders/{order_id}Cancel single order
countdownCancelAllOptionsPOST /options/countdown_cancel_allCountdown cancel orders
listMyOptionsTradesGET /options/my_tradesQuery personal trading records
getOptionsMMPGET /options/mmpMMP Query.
setOptionsMMPPOST /options/mmpMMP Settings
resetOptionsMMPPOST /options/mmp/resetMMP Reset

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlying assets

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyings");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

List<OptionsUnderlying>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration dates

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<Long> result = apiInstance.listOptionsExpirations(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<Long>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List expiration dates for specified underlying-

listOptionsContracts

List<OptionsContract> listOptionsContracts(underlying).expiration(expiration).execute();

List all contracts for specified underlying and expiration date

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longexpiration = 1636588800L; // Long | Unix timestamp of expiration datetry {
List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
.expiration(expiration)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
expirationLongUnix timestamp of expiration date[optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsContractresult = apiInstance.getOptionsContract(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsContract");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsSettlements

List<OptionsSettlement> listOptionsSettlements(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List settlement history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract settlement information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longat = 56L; // Long | try {
OptionsSettlementresult = apiInstance.getOptionsSettlement(contract, underlying, at);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsSettlement");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString
underlyingStringUnderlying (Obtained by listing underlying endpoint)
atLong

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listMyOptionsSettlements

List<OptionsMySettlements> listMyOptionsSettlements(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal settlement records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrderBook

OptionsOrderBook listOptionsOrderBook(contract).interval(interval).limit(limit).withId(withId).execute();

Query options contract order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringinterval = "0"; // String | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0Integerlimit = 10; // Integer | Number of depth levelsBooleanwithId = false; // Boolean | Whether to return depth update ID. This ID increments by 1 each time the depth changestry {
OptionsOrderBookresult = apiInstance.listOptionsOrderBook(contract)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
intervalStringPrice precision for merged depth. 0 means no merging. If not specified, defaults to 0[optional] [default to 0] [enum: 0, 0.1, 0.01]
limitIntegerNumber of depth levels[optional] [default to 10]
withIdBooleanWhether to return depth update ID. This ID increments by 1 each time the depth changes[optional] [default to false]

Return type

OptionsOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Depth query successful-

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

Query options market ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<OptionsTicker> result = apiInstance.listOptionsTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<OptionsTicker>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Query underlying ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
OptionsUnderlyingTickerresult = apiInstance.listOptionsUnderlyingTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsCandlesticks

List<OptionsCandlestick> listOptionsCandlesticks(contract).limit(limit).from(from).to(to).interval(interval).execute();

Options contract market candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingCandlesticks

List<OptionsCandlestick> listOptionsUnderlyingCandlesticks(underlying).limit(limit).from(from).to(to).interval(interval).execute();

Underlying index price candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsTrades

List<OptionsTrade> listOptionsTrades().contract(contract).type(type).limit(limit).offset(offset).from(from).to(to).execute();

Market trade records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringtype = "1546935600"; // String | `C` for call, `P` for putIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsTrade> result = apiInstance.listOptionsTrades()
.contract(contract)
.type(type)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
typeString`C` for call, `P` for put[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsTrade>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsAccount

OptionsAccount listOptionsAccount()

Query account information

Query account information for classic option account and unified account

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
OptionsAccountresult = apiInstance.listOptionsAccount();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsAccountBook

List<OptionsAccountBook> listOptionsAccountBook().limit(limit).offset(offset).from(from).to(to).type(type).execute();

Query account change history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringtype = "dnw"; // String | Change types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&Ltry {
List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
typeStringChange types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&L[optional] [enum: dnw, prem, fee, refr, set]

Return type

List<OptionsAccountBook>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsPositions

List<OptionsPosition> listOptionsPositions().underlying(underlying).execute();

List user's positions of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsPosition> result = apiInstance.listOptionsPositions()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsPositionresult = apiInstance.getOptionsPosition(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsPositionClose

List<OptionsPositionClose> listOptionsPositionClose(underlying).contract(contract).execute();

List user's liquidation history of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nametry {
List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
.contract(contract)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositionClose");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrders

List<OptionsOrder> listOptionsOrders(status).contract(contract).underlying(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List options orders

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringstatus = "open"; // String | Query order list based on statusStringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
.contract(contract)
.underlying(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
statusStringQuery order list based on status[enum: open, finished]
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsOrderoptionsOrder = newOptionsOrder(); // OptionsOrder | try {
OptionsOrderresult = apiInstance.createOptionsOrder(optionsOrder);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#createOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsOrderOptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Order detail-

cancelOptionsOrders

List<OptionsOrder> cancelOptionsOrders(contract, underlying, side)

Cancel all orders with 'open' status

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingStringside = "ask"; // String | Specify all bids or all asks, both included if not specifiedtry {
List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
sideStringSpecify all bids or all asks, both included if not specified[optional] [enum: ask, bid]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Batch cancellation successful-

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Query single order details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.getOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

amendOptionsOrder

OptionsOrder amendOptionsOrder(orderId, amendOptionsOrderRequest)

Option Order Modification

Modify the order price and/or quantity of a specified order; only orders with status 'open' are supported

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdAmendOptionsOrderRequestamendOptionsOrderRequest = newAmendOptionsOrderRequest(); // AmendOptionsOrderRequest | try {
OptionsOrderresult = apiInstance.amendOptionsOrder(orderId, amendOptionsOrderRequest);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#amendOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created
amendOptionsOrderRequestAmendOptionsOrderRequest

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel single order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.cancelOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

countdownCancelAllOptions

TriggerTime countdownCancelAllOptions(countdownCancelAllOptionsTask)

Countdown cancel orders

Option order heartbeat detection, when the `timeout` time set by the user is reached, if the existing countdown is not canceled or a new countdown is set, the related `option pending order` will be automatically canceled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at intervals of 30 seconds, with each countdown `timeout` set to 30 (seconds). If this interface is not called again within 30 seconds, all pending orders on the `underlying` `contract` you specified will be automatically cancelled. If `underlying` `contract` is not specified, user will be automatically cancelled If `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the automatic order cancellation function will be cancelled.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
CountdownCancelAllOptionsTaskcountdownCancelAllOptionsTask = newCountdownCancelAllOptionsTask(); // CountdownCancelAllOptionsTask | try {
TriggerTimeresult = apiInstance.countdownCancelAllOptions(countdownCancelAllOptionsTask);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#countdownCancelAllOptions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
countdownCancelAllOptionsTaskCountdownCancelAllOptionsTask

Return type

TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Countdown set successfully-

listMyOptionsTrades

List<OptionsMyTrade> listMyOptionsTrades(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal trading records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsMMP

List<OptionsMMP> getOptionsMMP().underlying(underlying).execute();

MMP Query.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsMMP> result = apiInstance.getOptionsMMP()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsMMP>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

setOptionsMMP

OptionsMMP setOptionsMMP(optionsMMP)

MMP Settings

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPoptionsMMP = newOptionsMMP(); // OptionsMMP | try {
OptionsMMPresult = apiInstance.setOptionsMMP(optionsMMP);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#setOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPOptionsMMP

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-

resetOptionsMMP

OptionsMMP resetOptionsMMP(optionsMMPReset)

MMP Reset

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPResetoptionsMMPReset = newOptionsMMPReset(); // OptionsMMPReset | try {
OptionsMMPresult = apiInstance.resetOptionsMMP(optionsMMPReset);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#resetOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPResetOptionsMMPReset

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' gateapi-java/docs/OptionsApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
2114 lines (1656 loc) · 78.2 KB

File metadata and controls

2114 lines (1656 loc) · 78.2 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
listOptionsUnderlyingsGET /options/underlyingsList all underlying assets
listOptionsExpirationsGET /options/expirationsList all expiration dates
listOptionsContractsGET /options/contractsList all contracts for specified underlying and expiration date
getOptionsContractGET /options/contracts/{contract}Query specified contract details
listOptionsSettlementsGET /options/settlementsList settlement history
getOptionsSettlementGET /options/settlements/{contract}Get specified contract settlement information
listMyOptionsSettlementsGET /options/my_settlementsQuery personal settlement records
listOptionsOrderBookGET /options/order_bookQuery options contract order book
listOptionsTickersGET /options/tickersQuery options market ticker information
listOptionsUnderlyingTickersGET /options/underlying/tickers/{underlying}Query underlying ticker information
listOptionsCandlesticksGET /options/candlesticksOptions contract market candlestick chart
listOptionsUnderlyingCandlesticksGET /options/underlying/candlesticksUnderlying index price candlestick chart
listOptionsTradesGET /options/tradesMarket trade records
listOptionsAccountGET /options/accountsQuery account information
listOptionsAccountBookGET /options/account_bookQuery account change history
listOptionsPositionsGET /options/positionsList user's positions of specified underlying
getOptionsPositionGET /options/positions/{contract}Get specified contract position
listOptionsPositionCloseGET /options/position_closeList user's liquidation history of specified underlying
listOptionsOrdersGET /options/ordersList options orders
createOptionsOrderPOST /options/ordersCreate an options order
cancelOptionsOrdersDELETE /options/ordersCancel all orders with 'open' status
getOptionsOrderGET /options/orders/{order_id}Query single order details
amendOptionsOrderPUT /options/orders/{order_id}Option Order Modification
cancelOptionsOrderDELETE /options/orders/{order_id}Cancel single order
countdownCancelAllOptionsPOST /options/countdown_cancel_allCountdown cancel orders
listMyOptionsTradesGET /options/my_tradesQuery personal trading records
getOptionsMMPGET /options/mmpMMP Query.
setOptionsMMPPOST /options/mmpMMP Settings
resetOptionsMMPPOST /options/mmp/resetMMP Reset

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlying assets

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyings");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

List<OptionsUnderlying>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration dates

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<Long> result = apiInstance.listOptionsExpirations(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<Long>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List expiration dates for specified underlying-

listOptionsContracts

List<OptionsContract> listOptionsContracts(underlying).expiration(expiration).execute();

List all contracts for specified underlying and expiration date

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longexpiration = 1636588800L; // Long | Unix timestamp of expiration datetry {
List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
.expiration(expiration)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
expirationLongUnix timestamp of expiration date[optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsContractresult = apiInstance.getOptionsContract(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsContract");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsSettlements

List<OptionsSettlement> listOptionsSettlements(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List settlement history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract settlement information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longat = 56L; // Long | try {
OptionsSettlementresult = apiInstance.getOptionsSettlement(contract, underlying, at);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsSettlement");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString
underlyingStringUnderlying (Obtained by listing underlying endpoint)
atLong

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listMyOptionsSettlements

List<OptionsMySettlements> listMyOptionsSettlements(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal settlement records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrderBook

OptionsOrderBook listOptionsOrderBook(contract).interval(interval).limit(limit).withId(withId).execute();

Query options contract order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringinterval = "0"; // String | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0Integerlimit = 10; // Integer | Number of depth levelsBooleanwithId = false; // Boolean | Whether to return depth update ID. This ID increments by 1 each time the depth changestry {
OptionsOrderBookresult = apiInstance.listOptionsOrderBook(contract)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
intervalStringPrice precision for merged depth. 0 means no merging. If not specified, defaults to 0[optional] [default to 0] [enum: 0, 0.1, 0.01]
limitIntegerNumber of depth levels[optional] [default to 10]
withIdBooleanWhether to return depth update ID. This ID increments by 1 each time the depth changes[optional] [default to false]

Return type

OptionsOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Depth query successful-

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

Query options market ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<OptionsTicker> result = apiInstance.listOptionsTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<OptionsTicker>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Query underlying ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
OptionsUnderlyingTickerresult = apiInstance.listOptionsUnderlyingTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsCandlesticks

List<OptionsCandlestick> listOptionsCandlesticks(contract).limit(limit).from(from).to(to).interval(interval).execute();

Options contract market candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingCandlesticks

List<OptionsCandlestick> listOptionsUnderlyingCandlesticks(underlying).limit(limit).from(from).to(to).interval(interval).execute();

Underlying index price candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsTrades

List<OptionsTrade> listOptionsTrades().contract(contract).type(type).limit(limit).offset(offset).from(from).to(to).execute();

Market trade records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringtype = "1546935600"; // String | `C` for call, `P` for putIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsTrade> result = apiInstance.listOptionsTrades()
.contract(contract)
.type(type)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
typeString`C` for call, `P` for put[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsTrade>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsAccount

OptionsAccount listOptionsAccount()

Query account information

Query account information for classic option account and unified account

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
OptionsAccountresult = apiInstance.listOptionsAccount();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsAccountBook

List<OptionsAccountBook> listOptionsAccountBook().limit(limit).offset(offset).from(from).to(to).type(type).execute();

Query account change history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringtype = "dnw"; // String | Change types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&Ltry {
List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
typeStringChange types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&L[optional] [enum: dnw, prem, fee, refr, set]

Return type

List<OptionsAccountBook>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsPositions

List<OptionsPosition> listOptionsPositions().underlying(underlying).execute();

List user's positions of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsPosition> result = apiInstance.listOptionsPositions()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsPositionresult = apiInstance.getOptionsPosition(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsPositionClose

List<OptionsPositionClose> listOptionsPositionClose(underlying).contract(contract).execute();

List user's liquidation history of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nametry {
List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
.contract(contract)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositionClose");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrders

List<OptionsOrder> listOptionsOrders(status).contract(contract).underlying(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List options orders

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringstatus = "open"; // String | Query order list based on statusStringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
.contract(contract)
.underlying(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
statusStringQuery order list based on status[enum: open, finished]
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsOrderoptionsOrder = newOptionsOrder(); // OptionsOrder | try {
OptionsOrderresult = apiInstance.createOptionsOrder(optionsOrder);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#createOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsOrderOptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Order detail-

cancelOptionsOrders

List<OptionsOrder> cancelOptionsOrders(contract, underlying, side)

Cancel all orders with 'open' status

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingStringside = "ask"; // String | Specify all bids or all asks, both included if not specifiedtry {
List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
sideStringSpecify all bids or all asks, both included if not specified[optional] [enum: ask, bid]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Batch cancellation successful-

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Query single order details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.getOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

amendOptionsOrder

OptionsOrder amendOptionsOrder(orderId, amendOptionsOrderRequest)

Option Order Modification

Modify the order price and/or quantity of a specified order; only orders with status 'open' are supported

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdAmendOptionsOrderRequestamendOptionsOrderRequest = newAmendOptionsOrderRequest(); // AmendOptionsOrderRequest | try {
OptionsOrderresult = apiInstance.amendOptionsOrder(orderId, amendOptionsOrderRequest);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#amendOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created
amendOptionsOrderRequestAmendOptionsOrderRequest

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel single order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.cancelOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

countdownCancelAllOptions

TriggerTime countdownCancelAllOptions(countdownCancelAllOptionsTask)

Countdown cancel orders

Option order heartbeat detection, when the `timeout` time set by the user is reached, if the existing countdown is not canceled or a new countdown is set, the related `option pending order` will be automatically canceled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at intervals of 30 seconds, with each countdown `timeout` set to 30 (seconds). If this interface is not called again within 30 seconds, all pending orders on the `underlying` `contract` you specified will be automatically cancelled. If `underlying` `contract` is not specified, user will be automatically cancelled If `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the automatic order cancellation function will be cancelled.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
CountdownCancelAllOptionsTaskcountdownCancelAllOptionsTask = newCountdownCancelAllOptionsTask(); // CountdownCancelAllOptionsTask | try {
TriggerTimeresult = apiInstance.countdownCancelAllOptions(countdownCancelAllOptionsTask);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#countdownCancelAllOptions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
countdownCancelAllOptionsTaskCountdownCancelAllOptionsTask

Return type

TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Countdown set successfully-

listMyOptionsTrades

List<OptionsMyTrade> listMyOptionsTrades(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal trading records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsMMP

List<OptionsMMP> getOptionsMMP().underlying(underlying).execute();

MMP Query.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsMMP> result = apiInstance.getOptionsMMP()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsMMP>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

setOptionsMMP

OptionsMMP setOptionsMMP(optionsMMP)

MMP Settings

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPoptionsMMP = newOptionsMMP(); // OptionsMMP | try {
OptionsMMPresult = apiInstance.setOptionsMMP(optionsMMP);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#setOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPOptionsMMP

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-

resetOptionsMMP

OptionsMMP resetOptionsMMP(optionsMMPReset)

MMP Reset

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPResetoptionsMMPReset = newOptionsMMPReset(); // OptionsMMPReset | try {
OptionsMMPresult = apiInstance.resetOptionsMMP(optionsMMPReset);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#resetOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPResetOptionsMMPReset

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); gateapi-java/docs/OptionsApi.md at master · gate/gateapi-java · GitHub
Skip to content

Latest commit

History

History
2114 lines (1656 loc) · 78.2 KB

File metadata and controls

2114 lines (1656 loc) · 78.2 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

MethodHTTP requestDescription
listOptionsUnderlyingsGET /options/underlyingsList all underlying assets
listOptionsExpirationsGET /options/expirationsList all expiration dates
listOptionsContractsGET /options/contractsList all contracts for specified underlying and expiration date
getOptionsContractGET /options/contracts/{contract}Query specified contract details
listOptionsSettlementsGET /options/settlementsList settlement history
getOptionsSettlementGET /options/settlements/{contract}Get specified contract settlement information
listMyOptionsSettlementsGET /options/my_settlementsQuery personal settlement records
listOptionsOrderBookGET /options/order_bookQuery options contract order book
listOptionsTickersGET /options/tickersQuery options market ticker information
listOptionsUnderlyingTickersGET /options/underlying/tickers/{underlying}Query underlying ticker information
listOptionsCandlesticksGET /options/candlesticksOptions contract market candlestick chart
listOptionsUnderlyingCandlesticksGET /options/underlying/candlesticksUnderlying index price candlestick chart
listOptionsTradesGET /options/tradesMarket trade records
listOptionsAccountGET /options/accountsQuery account information
listOptionsAccountBookGET /options/account_bookQuery account change history
listOptionsPositionsGET /options/positionsList user's positions of specified underlying
getOptionsPositionGET /options/positions/{contract}Get specified contract position
listOptionsPositionCloseGET /options/position_closeList user's liquidation history of specified underlying
listOptionsOrdersGET /options/ordersList options orders
createOptionsOrderPOST /options/ordersCreate an options order
cancelOptionsOrdersDELETE /options/ordersCancel all orders with 'open' status
getOptionsOrderGET /options/orders/{order_id}Query single order details
amendOptionsOrderPUT /options/orders/{order_id}Option Order Modification
cancelOptionsOrderDELETE /options/orders/{order_id}Cancel single order
countdownCancelAllOptionsPOST /options/countdown_cancel_allCountdown cancel orders
listMyOptionsTradesGET /options/my_tradesQuery personal trading records
getOptionsMMPGET /options/mmpMMP Query.
setOptionsMMPPOST /options/mmpMMP Settings
resetOptionsMMPPOST /options/mmp/resetMMP Reset

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlying assets

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyings");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

List<OptionsUnderlying>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration dates

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<Long> result = apiInstance.listOptionsExpirations(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<Long>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List expiration dates for specified underlying-

listOptionsContracts

List<OptionsContract> listOptionsContracts(underlying).expiration(expiration).execute();

List all contracts for specified underlying and expiration date

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longexpiration = 1636588800L; // Long | Unix timestamp of expiration datetry {
List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
.expiration(expiration)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
expirationLongUnix timestamp of expiration date[optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsContractresult = apiInstance.getOptionsContract(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsContract");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsSettlements

List<OptionsSettlement> listOptionsSettlements(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List settlement history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract settlement information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Longat = 56L; // Long | try {
OptionsSettlementresult = apiInstance.getOptionsSettlement(contract, underlying, at);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsSettlement");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString
underlyingStringUnderlying (Obtained by listing underlying endpoint)
atLong

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listMyOptionsSettlements

List<OptionsMySettlements> listMyOptionsSettlements(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal settlement records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsSettlements");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrderBook

OptionsOrderBook listOptionsOrderBook(contract).interval(interval).limit(limit).withId(withId).execute();

Query options contract order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringinterval = "0"; // String | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0Integerlimit = 10; // Integer | Number of depth levelsBooleanwithId = false; // Boolean | Whether to return depth update ID. This ID increments by 1 each time the depth changestry {
OptionsOrderBookresult = apiInstance.listOptionsOrderBook(contract)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
intervalStringPrice precision for merged depth. 0 means no merging. If not specified, defaults to 0[optional] [default to 0] [enum: 0, 0.1, 0.01]
limitIntegerNumber of depth levels[optional] [default to 10]
withIdBooleanWhether to return depth update ID. This ID increments by 1 each time the depth changes[optional] [default to false]

Return type

OptionsOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Depth query successful-

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

Query options market ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)try {
List<OptionsTicker> result = apiInstance.listOptionsTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)

Return type

List<OptionsTicker>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Query underlying ticker information

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
OptionsUnderlyingTickerresult = apiInstance.listOptionsUnderlyingTickers(underlying);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsCandlesticks

List<OptionsCandlestick> listOptionsCandlesticks(contract).limit(limit).from(from).to(to).interval(interval).execute();

Options contract market candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsUnderlyingCandlesticks

List<OptionsCandlestick> listOptionsUnderlyingCandlesticks(underlying).limit(limit).from(from).to(to).interval(interval).execute();

Underlying index price candlestick chart

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Integerlimit = 100; // Integer | Maximum number of records returned in a single listLongfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringinterval = "5m"; // String | Time interval between data pointstry {
List<OptionsCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsUnderlyingCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
intervalStringTime interval between data points[optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<OptionsCandlestick>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsTrades

List<OptionsTrade> listOptionsTrades().contract(contract).type(type).limit(limit).offset(offset).from(from).to(to).execute();

Market trade records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringtype = "1546935600"; // String | `C` for call, `P` for putIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsTrade> result = apiInstance.listOptionsTrades()
.contract(contract)
.type(type)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
typeString`C` for call, `P` for put[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsTrade>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsAccount

OptionsAccount listOptionsAccount()

Query account information

Query account information for classic option account and unified account

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
try {
OptionsAccountresult = apiInstance.listOptionsAccount();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

This endpoint does not need any parameter.

Return type

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsAccountBook

List<OptionsAccountBook> listOptionsAccountBook().limit(limit).offset(offset).from(from).to(to).type(type).execute();

Query account change history

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Integerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestampStringtype = "dnw"; // String | Change types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&Ltry {
List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]
typeStringChange types: - dnw: Deposit & Withdrawal - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: Settlement P&L[optional] [enum: dnw, prem, fee, refr, set]

Return type

List<OptionsAccountBook>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsPositions

List<OptionsPosition> listOptionsPositions().underlying(underlying).execute();

List user's positions of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsPosition> result = apiInstance.listOptionsPositions()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20211130-65000-C"; // String | try {
OptionsPositionresult = apiInstance.getOptionsPosition(contract);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractString

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

listOptionsPositionClose

List<OptionsPositionClose> listOptionsPositionClose(underlying).contract(contract).execute();

List user's liquidation history of specified underlying

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nametry {
List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
.contract(contract)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsPositionClose");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

listOptionsOrders

List<OptionsOrder> listOptionsOrders(status).contract(contract).underlying(underlying).limit(limit).offset(offset).from(from).to(to).execute();

List options orders

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringstatus = "open"; // String | Query order list based on statusStringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
.contract(contract)
.underlying(underlying)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
statusStringQuery order list based on status[enum: open, finished]
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsOrderoptionsOrder = newOptionsOrder(); // OptionsOrder | try {
OptionsOrderresult = apiInstance.createOptionsOrder(optionsOrder);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#createOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsOrderOptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Order detail-

cancelOptionsOrders

List<OptionsOrder> cancelOptionsOrders(contract, underlying, side)

Cancel all orders with 'open' status

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameStringunderlying = "BTC_USDT"; // String | UnderlyingStringside = "ask"; // String | Specify all bids or all asks, both included if not specifiedtry {
List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
contractStringOptions contract name[optional]
underlyingStringUnderlying[optional]
sideStringSpecify all bids or all asks, both included if not specified[optional] [enum: ask, bid]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Batch cancellation successful-

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Query single order details

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.getOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

amendOptionsOrder

OptionsOrder amendOptionsOrder(orderId, amendOptionsOrderRequest)

Option Order Modification

Modify the order price and/or quantity of a specified order; only orders with status 'open' are supported

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdAmendOptionsOrderRequestamendOptionsOrderRequest = newAmendOptionsOrderRequest(); // AmendOptionsOrderRequest | try {
OptionsOrderresult = apiInstance.amendOptionsOrder(orderId, amendOptionsOrderRequest);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#amendOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created
amendOptionsOrderRequestAmendOptionsOrderRequest

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel single order

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
LongorderId = 12345L; // Long | Order ID returned when order is successfully createdtry {
OptionsOrderresult = apiInstance.cancelOptionsOrder(orderId);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#cancelOptionsOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
orderIdLongOrder ID returned when order is successfully created

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Order detail-

countdownCancelAllOptions

TriggerTime countdownCancelAllOptions(countdownCancelAllOptionsTask)

Countdown cancel orders

Option order heartbeat detection, when the `timeout` time set by the user is reached, if the existing countdown is not canceled or a new countdown is set, the related `option pending order` will be automatically canceled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at intervals of 30 seconds, with each countdown `timeout` set to 30 (seconds). If this interface is not called again within 30 seconds, all pending orders on the `underlying` `contract` you specified will be automatically cancelled. If `underlying` `contract` is not specified, user will be automatically cancelled If `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the automatic order cancellation function will be cancelled.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
CountdownCancelAllOptionsTaskcountdownCancelAllOptionsTask = newCountdownCancelAllOptionsTask(); // CountdownCancelAllOptionsTask | try {
TriggerTimeresult = apiInstance.countdownCancelAllOptions(countdownCancelAllOptionsTask);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#countdownCancelAllOptions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
countdownCancelAllOptionsTaskCountdownCancelAllOptionsTask

Return type

TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Countdown set successfully-

listMyOptionsTrades

List<OptionsMyTrade> listMyOptionsTrades(underlying).contract(contract).limit(limit).offset(offset).from(from).to(to).execute();

Query personal trading records

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)Stringcontract = "BTC_USDT-20210916-5000-C"; // String | Options contract nameIntegerlimit = 100; // Integer | Maximum number of records returned in a single listIntegeroffset = 0; // Integer | List offset, starting from 0Longfrom = 1547706332L; // Long | Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)Longto = 1547706332L; // Long | Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamptry {
List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
.contract(contract)
.limit(limit)
.offset(offset)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#listMyOptionsTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying (Obtained by listing underlying endpoint)
contractStringOptions contract name[optional]
limitIntegerMaximum number of records returned in a single list[optional] [default to 100]
offsetIntegerList offset, starting from 0[optional] [default to 0]
fromLongStart timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)[optional]
toLongTermination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp[optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

getOptionsMMP

List<OptionsMMP> getOptionsMMP().underlying(underlying).execute();

MMP Query.

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
Stringunderlying = "BTC_USDT"; // String | Underlyingtry {
List<OptionsMMP> result = apiInstance.getOptionsMMP()
.underlying(underlying)
.execute();
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#getOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
underlyingStringUnderlying[optional]

Return type

List<OptionsMMP>

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

setOptionsMMP

OptionsMMP setOptionsMMP(optionsMMP)

MMP Settings

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPoptionsMMP = newOptionsMMP(); // OptionsMMP | try {
OptionsMMPresult = apiInstance.setOptionsMMP(optionsMMP);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#setOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPOptionsMMP

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-

resetOptionsMMP

OptionsMMP resetOptionsMMP(optionsMMPReset)

MMP Reset

Example

// Import classes:importio.gate.gateapi.ApiClient;
importio.gate.gateapi.ApiException;
importio.gate.gateapi.Configuration;
importio.gate.gateapi.GateApiException;
importio.gate.gateapi.auth.*;
importio.gate.gateapi.models.*;
importio.gate.gateapi.api.OptionsApi;
publicclassExample {
publicstaticvoidmain(String[] args) {
ApiClientdefaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
OptionsApiapiInstance = newOptionsApi(defaultClient);
OptionsMMPResetoptionsMMPReset = newOptionsMMPReset(); // OptionsMMPReset | try {
OptionsMMPresult = apiInstance.resetOptionsMMP(optionsMMPReset);
System.out.println(result);
} catch (GateApiExceptione) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiExceptione) {
System.err.println("Exception when calling OptionsApi#resetOptionsMMP");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}

Parameters

NameTypeDescriptionNotes
optionsMMPResetOptionsMMPReset

Return type

OptionsMMP

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200MMP Information-