All URIs are relative to https://api.gateio.ws/api/v4
| Method | HTTP request | Description |
|---|---|---|
| queryOptionFeeRate | GET /stock_options/fee-rate | Get option trading fee rates |
| queryOptionSymbols | GET /stock_options/underlyings | List option underlyings |
| queryOptionContracts | GET /stock_options/contracts | List option contracts |
| queryOptionExpirations | GET /stock_options/market/expirations | List option expiration dates |
| queryOptionChain | GET /stock_options/market/chain | Get the option chain |
| queryOptionOrderBook | GET /stock_options/market/{symbol}/orderbook | Get the option order book |
| queryOptionPositions | GET /stock_options/positions | List current option positions |
| closeOptionPosition | POST /stock_options/positions/close | Close an option position |
| queryOptionOrderList | GET /stock_options/orders | List current option orders |
| createOptionOrder | POST /stock_options/orders | Create an option order |
| cancelAllOptionOrders | DELETE /stock_options/orders | Cancel all option limit orders |
| queryOptionOrderDetail | GET /stock_options/orders/{order_id} | Get option order details |
| updateOptionOrder | PUT /stock_options/orders/{order_id} | Amend an option limit order |
| cancelOptionOrder | DELETE /stock_options/orders/{order_id} | Cancel an option limit order |
| queryOptionOrderHistory | GET /stock_options/orders/history | List historical option orders |
StockOptionConfigResponse queryOptionFeeRate()
Get option trading fee rates
Query the fee configuration for options trading before placing an order. Returns the rates and applicable minimum and maximum fees for SEC, TAF, OCC, ORF and CAT charges.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
try {
StockOptionConfigResponse result = apiInstance.queryOptionFeeRate();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionFeeRate");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Option trading fee configuration | - |
| 400 | Request failed | - |
StockOptionSymbolListResponse queryOptionSymbols().underlyings(underlyings).execute();
List option underlyings
Query available option underlyings before looking up contracts, expiration dates and option chains. Returns underlying symbols, names, multilingual descriptions, icons, price precision and order quantity limits. `underlyings` accepts multiple comma-separated symbols; omit it to query all available underlyings.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String underlyings = "AAPL,TSLA"; // String | Comma-separated option underlying symbols, for example AAPL,TSLA. Omit to query all available underlyings.
try {
StockOptionSymbolListResponse result = apiInstance.queryOptionSymbols()
.underlyings(underlyings)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionSymbols");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| underlyings | String | Comma-separated option underlying symbols, for example AAPL,TSLA. Omit to query all available underlyings. | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Option underlying list | - |
| 400 | Request failed | - |
StockOptionContractListResponse queryOptionContracts(underlying).exchange(exchange).expirationDate(expirationDate).optionType(optionType).page(page).pageSize(pageSize).execute();
List option contracts
Query option contracts for an underlying, including contract symbols, strike prices, expiration dates and trading rules. `underlying` is required. Filter by expiration date and call or put type; only US market (`us`) contracts are currently available. Results are paginated in ascending contract symbol order, with total records, total pages and the current page. The default and maximum `page_size` are both 1000. Use price precision and minimum and maximum order quantities to check an order before submission.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String underlying = "AAPL"; // String | Option underlying symbol, for example AAPL. This is one underlying symbol, not an option contract symbol.
String exchange = "us"; // String | Trading market filter. Only US market (us) contracts are currently available. Omitted or empty values use us. - us: US market.
LocalDate expirationDate = new LocalDate(); // LocalDate | Option expiration date in YYYY-MM-DD format. Omit to disable expiration date filtering.
StockOptionOptionType optionType = new StockOptionOptionType(); // StockOptionOptionType | Option type filter for the contract list. Omit for both types. - call: Call option. - put: Put option.
Integer page = 1; // Integer | Page number, starting from 1. Defaults to 1 when omitted.
Integer pageSize = 1000; // Integer | Contracts per page. Defaults to 1000 when omitted; values above 1000 are capped at 1000.
try {
StockOptionContractListResponse result = apiInstance.queryOptionContracts(underlying)
.exchange(exchange)
.expirationDate(expirationDate)
.optionType(optionType)
.page(page)
.pageSize(pageSize)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionContracts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| underlying | String | Option underlying symbol, for example AAPL. This is one underlying symbol, not an option contract symbol. | |
| exchange | String | Trading market filter. Only US market (us) contracts are currently available. Omitted or empty values use us. - us: US market. | [optional] [enum: us] |
| expirationDate | LocalDate | Option expiration date in YYYY-MM-DD format. Omit to disable expiration date filtering. | [optional] |
| optionType | StockOptionOptionType | Option type filter for the contract list. Omit for both types. - call: Call option. - put: Put option. | [optional] [enum: call, put] |
| page | Integer | Page number, starting from 1. Defaults to 1 when omitted. | [optional] [default to 1] |
| pageSize | Integer | Contracts per page. Defaults to 1000 when omitted; values above 1000 are capped at 1000. | [optional] [default to 1000] |
StockOptionContractListResponse
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Option contract list | - |
| 400 | Request failed | - |
StockOptionExpirationListResponse queryOptionExpirations(underlying)
List option expiration dates
Query expiration dates for an option underlying before selecting a contract expiration. `underlying` is required. Returns dates and their Unix timestamps; use the selected date to query the option chain.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String underlying = "AAPL"; // String | Option underlying symbol, for example AAPL. This is one underlying symbol, not an option contract symbol.
try {
StockOptionExpirationListResponse result = apiInstance.queryOptionExpirations(underlying);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionExpirations");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| underlying | String | Option underlying symbol, for example AAPL. This is one underlying symbol, not an option contract symbol. |
StockOptionExpirationListResponse
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Option expiration date list | - |
| 400 | Request failed | - |
StockOptionOptionChainResponse queryOptionChain(underlying, expirationDate).optionType(optionType).execute();
Get the option chain
Query option quotes at different strike prices for the same underlying and expiration date to compare call and put contracts. `underlying` and `expiration_date` are required. Set `option_type` to `call` or `put` to filter; omit it or use `all` for both types. Returns contract symbols, strike prices, bid and ask quotes, last prices, mark prices, implied volatility and Greeks.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String underlying = "AAPL"; // String | Option underlying symbol, for example AAPL. This is one underlying symbol, not an option contract symbol.
LocalDate expirationDate = new LocalDate(); // LocalDate | Required option expiration date in YYYY-MM-DD format, obtained from the expiration date list.
String optionType = "optionType_example"; // String | Option type filter for the option chain. - call: Call options only. - put: Put options only. - all: Both types, equivalent to omitting this parameter.
try {
StockOptionOptionChainResponse result = apiInstance.queryOptionChain(underlying, expirationDate)
.optionType(optionType)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionChain");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| underlying | String | Option underlying symbol, for example AAPL. This is one underlying symbol, not an option contract symbol. | |
| expirationDate | LocalDate | Required option expiration date in YYYY-MM-DD format, obtained from the expiration date list. | |
| optionType | String | Option type filter for the option chain. - call: Call options only. - put: Put options only. - all: Both types, equivalent to omitting this parameter. | [optional] [enum: call, put, all] |
StockOptionOptionChainResponse
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Option chain | - |
| 400 | Request failed | - |
StockOptionOrderBookResponse queryOptionOrderBook(symbol)
Get the option order book
Query the best bid and ask for an option contract. `symbol` is the option contract symbol. Each of `bids` and `asks` contains at most one price level, without order quantities. A side without an available quote is an empty array. Both sides are empty arrays when the contract is not found.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String symbol = "AAPL260814P00130000"; // String | Option contract symbol
try {
StockOptionOrderBookResponse result = apiInstance.queryOptionOrderBook(symbol);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | String | Option contract symbol |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Option order book | - |
| 400 | Request failed | - |
StockOptionPositionListResponse queryOptionPositions().underlying(underlying).symbol(symbol).priceType(priceType).execute();
List current option positions
Query the current user's option positions, market values and profit and loss. Filter by `underlying` or `symbol`. A specified `symbol` must identify an existing option contract; no position returns an empty list. `price_type` selects the price for market value, unrealized PnL and today's PnL: `latest` (default) uses the last traded price; `mark` uses the mark price. Aggregate `today_pnl` includes current positions and contracts fully closed today. Results are sorted by `open_time` descending, then `symbol` ascending.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String underlying = "AAPL"; // String | Option underlying symbol, for example AAPL. Omit to disable underlying filtering. Current orders support only one underlying.
String symbol = "AAPL260814P00130000"; // String | Full option contract symbol, for example AAPL260814P00130000. Omit to disable contract filtering.
StockOptionPositionPnlPriceType priceType = new StockOptionPositionPnlPriceType(); // StockOptionPositionPnlPriceType | Valuation price type for position market value, unrealized PnL, and daily PnL. Options: `latest` (last traded price) or `mark` (mark price). Defaults to `latest` when omitted or empty.
try {
StockOptionPositionListResponse result = apiInstance.queryOptionPositions()
.underlying(underlying)
.symbol(symbol)
.priceType(priceType)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| underlying | String | Option underlying symbol, for example AAPL. Omit to disable underlying filtering. Current orders support only one underlying. | [optional] |
| symbol | String | Full option contract symbol, for example AAPL260814P00130000. Omit to disable contract filtering. | [optional] |
| priceType | StockOptionPositionPnlPriceType | Valuation price type for position market value, unrealized PnL, and daily PnL. Options: `latest` (last traded price) or `mark` (mark price). Defaults to `latest` when omitted or empty. | [optional] [default to latest] [enum: latest, mark] |
StockOptionPositionListResponse
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Current option position list | - |
| 400 | Request failed | - |
StockOptionClosePositionResponse closeOptionPosition(stockOptionClosePositionRequest)
Close an option position
Submit a closing order for part or all of an option position. `symbol` and `quantity` are required. The positive quantity must not exceed the available position and must satisfy the contract's minimum, maximum and quantity increment rules. Omit `order_type` or pass an empty value for a `market` order. A `limit` order requires a positive `price`; a market order ignores `price`. The closing side is derived from the position and time in force is fixed to `day`. The response returns the closing `order_id`; query the order for its subsequent status.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
StockOptionClosePositionRequest stockOptionClosePositionRequest = new StockOptionClosePositionRequest(); // StockOptionClosePositionRequest |
try {
StockOptionClosePositionResponse result = apiInstance.closeOptionPosition(stockOptionClosePositionRequest);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#closeOptionPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| stockOptionClosePositionRequest | StockOptionClosePositionRequest |
StockOptionClosePositionResponse
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Position closing response | - |
| 400 | Request failed | - |
StockOptionOrderListResponse queryOptionOrderList().underlying(underlying).symbol(symbol).side(side).execute();
List current option orders
Query the current user's unfinished option orders, including open and partially filled orders. Filter by `underlying`, `symbol` or `side`. `underlying` accepts only one symbol, not a comma-separated list. `status` includes only 1 (new) and 2 (partially filled). Query order history for terminal orders. Matching orders are sorted by creation time `time_setup` descending. This endpoint has no pagination parameters.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String underlying = "AAPL"; // String | Option underlying symbol, for example AAPL. Omit to disable underlying filtering. Current orders support only one underlying.
String symbol = "AAPL260814P00130000"; // String | Full option contract symbol, for example AAPL260814P00130000. Omit to disable contract filtering.
StockOptionOrderListSide side = new StockOptionOrderListSide(); // StockOptionOrderListSide | Order side filter. Omit to query both sides. - 1: Sell orders only. - 2: Buy orders only.
try {
StockOptionOrderListResponse result = apiInstance.queryOptionOrderList()
.underlying(underlying)
.symbol(symbol)
.side(side)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionOrderList");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| underlying | String | Option underlying symbol, for example AAPL. Omit to disable underlying filtering. Current orders support only one underlying. | [optional] |
| symbol | String | Full option contract symbol, for example AAPL260814P00130000. Omit to disable contract filtering. | [optional] |
| side | StockOptionOrderListSide | Order side filter. Omit to query both sides. - 1: Sell orders only. - 2: Buy orders only. | [optional] [enum: 1, 2] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Current option order list | - |
| 400 | Request failed | - |
StockOptionPutOrderResponse createOptionOrder(stockOptionPutOrderRequest)
Create an option order
Submit a buy or sell order for an option contract and return the order ID on success. `symbol`, `side`, `order_type`, `time_in_force` and `quantity` are required. `side` is 1 (sell) or 2 (buy). Limit orders require a positive `price` and support `day` or `gtc`. Market orders ignore `price` and support only `day`. Quantity is a positive decimal string within the contract's minimum and maximum order quantities. Sell orders require sufficient available long positions. `client_order_id` is optional and is generated automatically when omitted or whitespace-only. Query current orders or order details to track the returned order ID.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
StockOptionPutOrderRequest stockOptionPutOrderRequest = new StockOptionPutOrderRequest(); // StockOptionPutOrderRequest |
try {
StockOptionPutOrderResponse result = apiInstance.createOptionOrder(stockOptionPutOrderRequest);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#createOptionOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| stockOptionPutOrderRequest | StockOptionPutOrderRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Order creation response | - |
| 400 | Request failed | - |
StockOptionCancelAllOrdersResponse cancelAllOptionOrders(stockOptionCancelAllOrdersRequest)
Cancel all option limit orders
Cancel all or a filtered set of the current user's option limit orders. The request body may be omitted or an empty object. Without filters, all limit orders are cancelled. Filter by `underlying`, `symbol` or `side`. `side` supports 1 (sell) and 2 (buy); omit it to include both sides. The response reports the cancellation request result. Query the orders to confirm their subsequent status.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
StockOptionCancelAllOrdersRequest stockOptionCancelAllOrdersRequest = new StockOptionCancelAllOrdersRequest(); // StockOptionCancelAllOrdersRequest |
try {
StockOptionCancelAllOrdersResponse result = apiInstance.cancelAllOptionOrders(stockOptionCancelAllOrdersRequest);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#cancelAllOptionOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| stockOptionCancelAllOrdersRequest | StockOptionCancelAllOrdersRequest | [optional] |
StockOptionCancelAllOrdersResponse
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Bulk order cancellation response | - |
| 400 | Request failed | - |
StockOptionOrderDetailResponse queryOptionOrderDetail(orderId)
Get option order details
Query one of the current user's orders by ID to track its status, filled quantity and average fill price. `order_id` is required and must be a positive integer represented as a string. Both current and finished orders can be queried, without filtering by terminal status. Returns price, quantity, filled quantity, status description, average fill price, fees and timestamps.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String orderId = "8000000001"; // String | Option order ID as a positive integer string, obtained from order submission or query results.
try {
StockOptionOrderDetailResponse result = apiInstance.queryOptionOrderDetail(orderId);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionOrderDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | String | Option order ID as a positive integer string, obtained from order submission or query results. |
StockOptionOrderDetailResponse
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Option order details | - |
| 400 | Request failed | - |
StockOptionUpdateOrderResponse updateOptionOrder(orderId, stockOptionUpdateOrderRequest)
Amend an option limit order
Update the price and total quantity of one of the current user's option limit orders. The path `order_id` and body `price` and `quantity` are required. Market orders cannot be amended. `quantity` is the new total order quantity, not the remaining unfilled quantity, and must be at least `filled_quantity`. Amending a sell order also requires sufficient available positions for the new unfilled quantity. Returns the order ID; query the order for its subsequent status.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String orderId = "72057594037983901"; // String | Option order ID as a positive integer string, obtained from order submission or query results.
StockOptionUpdateOrderRequest stockOptionUpdateOrderRequest = new StockOptionUpdateOrderRequest(); // StockOptionUpdateOrderRequest |
try {
StockOptionUpdateOrderResponse result = apiInstance.updateOptionOrder(orderId, stockOptionUpdateOrderRequest);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#updateOptionOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | String | Option order ID as a positive integer string, obtained from order submission or query results. | |
| stockOptionUpdateOrderRequest | StockOptionUpdateOrderRequest |
StockOptionUpdateOrderResponse
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Order amendment response | - |
| 400 | Request failed | - |
StockOptionCancelOrderResponse cancelOptionOrder(orderId)
Cancel an option limit order
Cancel one of the current user's option limit orders by ID. `order_id` is required. Only limit orders can be cancelled; already filled quantities are unaffected. Returns the order ID. Query order details or order history for the final status.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String orderId = "72057594037983901"; // String | Option order ID as a positive integer string, obtained from order submission or query results.
try {
StockOptionCancelOrderResponse result = apiInstance.cancelOptionOrder(orderId);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#cancelOptionOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | String | Option order ID as a positive integer string, obtained from order submission or query results. |
StockOptionCancelOrderResponse
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Order cancellation response | - |
| 400 | Request failed | - |
StockOptionOrderHistoryResponse queryOptionOrderHistory().underlying(underlying).symbol(symbol).beginTime(beginTime).endTime(endTime).side(side).page(page).pageSize(pageSize).execute();
List historical option orders
Query the current user's finished option orders with pagination to check orders, fills and fees. `status` includes only 3 (filled), 4 (cancelled) and 5 (rejected). Filter by underlying, contract, side or order creation time. `begin_time` and `end_time` are Unix timestamps in seconds; when both are provided, the start must not be later than the end. Returns total records, total pages and the current page. The default and maximum `page_size` are both 100.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.StockOptionsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
StockOptionsApi apiInstance = new StockOptionsApi(defaultClient);
String underlying = "AAPL"; // String | Option underlying symbol, for example AAPL. Omit to disable underlying filtering. Current orders support only one underlying.
String symbol = "AAPL260814P00130000"; // String | Full option contract symbol, for example AAPL260814P00130000. Omit to disable contract filtering.
Long beginTime = 56L; // Long | Order creation time filter start, as a Unix timestamp in seconds. Omit for no lower bound; must not exceed end_time when both are provided.
Long endTime = 56L; // Long | Order creation time filter end, as a Unix timestamp in seconds. Omit for no upper bound; must not precede begin_time when both are provided.
StockOptionOrderListSide side = new StockOptionOrderListSide(); // StockOptionOrderListSide | Order side filter. Omit to query both sides. - 1: Sell orders only. - 2: Buy orders only.
Integer page = 1; // Integer | Page number, starting from 1. Defaults to 1 when omitted.
Integer pageSize = 100; // Integer | Number of items per page, up to 100. Defaults to 100 when omitted; values above 100 are capped at 100.
try {
StockOptionOrderHistoryResponse result = apiInstance.queryOptionOrderHistory()
.underlying(underlying)
.symbol(symbol)
.beginTime(beginTime)
.endTime(endTime)
.side(side)
.page(page)
.pageSize(pageSize)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling StockOptionsApi#queryOptionOrderHistory");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| underlying | String | Option underlying symbol, for example AAPL. Omit to disable underlying filtering. Current orders support only one underlying. | [optional] |
| symbol | String | Full option contract symbol, for example AAPL260814P00130000. Omit to disable contract filtering. | [optional] |
| beginTime | Long | Order creation time filter start, as a Unix timestamp in seconds. Omit for no lower bound; must not exceed end_time when both are provided. | [optional] |
| endTime | Long | Order creation time filter end, as a Unix timestamp in seconds. Omit for no upper bound; must not precede begin_time when both are provided. | [optional] |
| side | StockOptionOrderListSide | Order side filter. Omit to query both sides. - 1: Sell orders only. - 2: Buy orders only. | [optional] [enum: 1, 2] |
| page | Integer | Page number, starting from 1. Defaults to 1 when omitted. | [optional] [default to 1] |
| pageSize | Integer | Number of items per page, up to 100. Defaults to 100 when omitted; values above 100 are capped at 100. | [optional] [default to 100] |
StockOptionOrderHistoryResponse
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Historical option order list | - |
| 400 | Request failed | - |