[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
1759 lines (1384 loc) · 61.4 KB

OptionsApi.md

File metadata and controls

1759 lines (1384 loc) · 61.4 KB

OptionsApi

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

Method HTTP request Description
listOptionsUnderlyings GET /options/underlyings List all underlyings
listOptionsExpirations GET /options/expirations List all expiration times
listOptionsContracts GET /options/contracts List all the contracts with specified underlying and expiration time
getOptionsContract GET /options/contracts/{contract} Query specified contract detail
listOptionsSettlements GET /options/settlements List settlement history
getOptionsSettlement GET /options/settlements/{contract} Get specified contract's settlement
listMyOptionsSettlements GET /options/my_settlements List my options settlements
listOptionsOrderBook GET /options/order_book Options order book
listOptionsTickers GET /options/tickers List tickers of options contracts
listOptionsUnderlyingTickers GET /options/underlying/tickers/{underlying} Get underlying ticker
listOptionsCandlesticks GET /options/candlesticks Get options candlesticks
listOptionsUnderlyingCandlesticks GET /options/underlying/candlesticks Mark price candlesticks of an underlying
listOptionsTrades GET /options/trades Options trade history
listOptionsAccount GET /options/accounts List options account
listOptionsAccountBook GET /options/account_book List account changing history
listOptionsPositions GET /options/positions List user's positions of specified underlying
getOptionsPosition GET /options/positions/{contract} Get specified contract position
listOptionsPositionClose GET /options/position_close List user's liquidation history of specified underlying
listOptionsOrders GET /options/orders List options orders
createOptionsOrder POST /options/orders Create an options order
cancelOptionsOrders DELETE /options/orders Cancel all `open` orders matched
getOptionsOrder GET /options/orders/{order_id} Get a single order
cancelOptionsOrder DELETE /options/orders/{order_id} Cancel a single order
listMyOptionsTrades GET /options/my_trades List personal trading history

listOptionsUnderlyings

List<OptionsUnderlying> listOptionsUnderlyings()

List all underlyings

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        try {
            List<OptionsUnderlying> result = apiInstance.listOptionsUnderlyings();
            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 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 code Description Response headers
200 List retrieved -

listOptionsExpirations

List<Long> listOptionsExpirations(underlying)

List all expiration times

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        try {
            List<Long> result = apiInstance.listOptionsExpirations(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 OptionsApi#listOptionsExpirations");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying (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 code Description Response headers
200 List expiration times of specified underlying -

listOptionsContracts

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

List all the contracts with specified underlying and expiration time

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        Long expiration = 1636588800L; // Long | Unix timestamp of the expiration time
        try {
            List<OptionsContract> result = apiInstance.listOptionsContracts(underlying)
                        .expiration(expiration)
                        .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 OptionsApi#listOptionsContracts");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying (Obtained by listing underlying endpoint)
expiration Long Unix timestamp of the expiration time [optional]

Return type

List<OptionsContract>

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

getOptionsContract

OptionsContract getOptionsContract(contract)

Query specified contract detail

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String contract = "BTC_USDT-20211130-65000-C"; // String | 
        try {
            OptionsContract result = apiInstance.getOptionsContract(contract);
            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 OptionsApi#getOptionsContract");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
contract String

Return type

OptionsContract

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listOptionsSettlements

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

List settlement history

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
        Integer offset = 0; // Integer | List offset, starting from 0
        Long from = 1547706332L; // Long | Start timestamp
        Long to = 1547706332L; // Long | End timestamp
        try {
            List<OptionsSettlement> result = apiInstance.listOptionsSettlements(underlying)
                        .limit(limit)
                        .offset(offset)
                        .from(from)
                        .to(to)
                        .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 OptionsApi#listOptionsSettlements");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying (Obtained by listing underlying endpoint)
limit Integer Maximum number of records to be returned in a single list [optional] [default to 100]
offset Integer List offset, starting from 0 [optional] [default to 0]
from Long Start timestamp [optional]
to Long End timestamp [optional]

Return type

List<OptionsSettlement>

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

getOptionsSettlement

OptionsSettlement getOptionsSettlement(contract, underlying, at)

Get specified contract's settlement

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String contract = "BTC_USDT-20211130-65000-C"; // String | 
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        Long at = 56L; // Long | 
        try {
            OptionsSettlement result = apiInstance.getOptionsSettlement(contract, underlying, at);
            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 OptionsApi#getOptionsSettlement");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
contract String
underlying String Underlying (Obtained by listing underlying endpoint)
at Long

Return type

OptionsSettlement

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listMyOptionsSettlements

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

List my options settlements

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        String contract = "BTC_USDT-20210916-5000-C"; // String | Options contract name
        Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
        Integer offset = 0; // Integer | List offset, starting from 0
        Long from = 1547706332L; // Long | Start timestamp
        Long to = 1547706332L; // Long | End timestamp
        try {
            List<OptionsMySettlements> result = apiInstance.listMyOptionsSettlements(underlying)
                        .contract(contract)
                        .limit(limit)
                        .offset(offset)
                        .from(from)
                        .to(to)
                        .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 OptionsApi#listMyOptionsSettlements");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying (Obtained by listing underlying endpoint)
contract String Options contract name [optional]
limit Integer Maximum number of records to be returned in a single list [optional] [default to 100]
offset Integer List offset, starting from 0 [optional] [default to 0]
from Long Start timestamp [optional]
to Long End timestamp [optional]

Return type

List<OptionsMySettlements>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

listOptionsOrderBook

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

Options order book

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

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String contract = "BTC_USDT-20210916-5000-C"; // String | Options contract name
        String interval = "0"; // String | Order depth. 0 means no aggregation is applied. default to 0
        Integer limit = 10; // Integer | Maximum number of order depth data in asks or bids
        Boolean withId = false; // Boolean | Whether the order book update ID will be returned. This ID increases by 1 on every order book update
        try {
            FuturesOrderBook result = apiInstance.listOptionsOrderBook(contract)
                        .interval(interval)
                        .limit(limit)
                        .withId(withId)
                        .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 OptionsApi#listOptionsOrderBook");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
contract String Options contract name
interval String Order depth. 0 means no aggregation is applied. default to 0 [optional] [default to 0] [enum: 0, 0.1, 0.01]
limit Integer Maximum number of order depth data in asks or bids [optional] [default to 10]
withId Boolean Whether the order book update ID will be returned. This ID increases by 1 on every order book update [optional] [default to false]

Return type

FuturesOrderBook

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Order book retrieved -

listOptionsTickers

List<OptionsTicker> listOptionsTickers(underlying)

List tickers of options contracts

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        try {
            List<OptionsTicker> result = apiInstance.listOptionsTickers(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 OptionsApi#listOptionsTickers");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying (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 code Description Response headers
200 Successfully retrieved -

listOptionsUnderlyingTickers

OptionsUnderlyingTicker listOptionsUnderlyingTickers(underlying)

Get underlying ticker

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying
        try {
            OptionsUnderlyingTicker result = apiInstance.listOptionsUnderlyingTickers(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 OptionsApi#listOptionsUnderlyingTickers");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying

Return type

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listOptionsCandlesticks

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

Get options candlesticks

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String contract = "BTC_USDT-20210916-5000-C"; // String | Options contract name
        Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
        Long from = 1547706332L; // Long | Start timestamp
        Long to = 1547706332L; // Long | End timestamp
        String interval = "5m"; // String | Interval time between data points
        try {
            List<OptionsCandlestick> result = apiInstance.listOptionsCandlesticks(contract)
                        .limit(limit)
                        .from(from)
                        .to(to)
                        .interval(interval)
                        .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 OptionsApi#listOptionsCandlesticks");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
contract String Options contract name
limit Integer Maximum number of records to be returned in a single list [optional] [default to 100]
from Long Start timestamp [optional]
to Long End timestamp [optional]
interval String Interval time 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 code Description Response headers
200 Successfully retrieved -

listOptionsUnderlyingCandlesticks

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

Mark price candlesticks of an underlying

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
        Long from = 1547706332L; // Long | Start timestamp
        Long to = 1547706332L; // Long | End timestamp
        String interval = "5m"; // String | Interval time between data points
        try {
            List<FuturesCandlestick> result = apiInstance.listOptionsUnderlyingCandlesticks(underlying)
                        .limit(limit)
                        .from(from)
                        .to(to)
                        .interval(interval)
                        .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 OptionsApi#listOptionsUnderlyingCandlesticks");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying (Obtained by listing underlying endpoint)
limit Integer Maximum number of records to be returned in a single list [optional] [default to 100]
from Long Start timestamp [optional]
to Long End timestamp [optional]
interval String Interval time between data points [optional] [default to 5m] [enum: 1m, 5m, 15m, 30m, 1h]

Return type

List<FuturesCandlestick>

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listOptionsTrades

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

Options trade history

Example

// 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.OptionsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String contract = "BTC_USDT-20210916-5000-C"; // String | Options contract name
        String type = "1546935600"; // String | `C` is call, while `P` is put
        Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
        Integer offset = 0; // Integer | List offset, starting from 0
        Long from = 1547706332L; // Long | Start timestamp
        Long to = 1547706332L; // Long | End timestamp
        try {
            List<FuturesTrade> result = apiInstance.listOptionsTrades()
                        .contract(contract)
                        .type(type)
                        .limit(limit)
                        .offset(offset)
                        .from(from)
                        .to(to)
                        .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 OptionsApi#listOptionsTrades");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
contract String Options contract name [optional]
type String `C` is call, while `P` is put [optional]
limit Integer Maximum number of records to be returned in a single list [optional] [default to 100]
offset Integer List offset, starting from 0 [optional] [default to 0]
from Long Start timestamp [optional]
to Long End timestamp [optional]

Return type

List<FuturesTrade>

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

listOptionsAccount

OptionsAccount listOptionsAccount()

List options account

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        try {
            OptionsAccount result = apiInstance.listOptionsAccount();
            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 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 code Description Response headers
200 Successfully retrieved -

listOptionsAccountBook

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

List account changing history

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
        Integer offset = 0; // Integer | List offset, starting from 0
        Long from = 1547706332L; // Long | Start timestamp
        Long to = 1547706332L; // Long | End timestamp
        String type = "dnw"; // String | Changing Type: - dnw: Deposit & Withdraw - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: settlement PNL 
        try {
            List<OptionsAccountBook> result = apiInstance.listOptionsAccountBook()
                        .limit(limit)
                        .offset(offset)
                        .from(from)
                        .to(to)
                        .type(type)
                        .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 OptionsApi#listOptionsAccountBook");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
limit Integer Maximum number of records to be returned in a single list [optional] [default to 100]
offset Integer List offset, starting from 0 [optional] [default to 0]
from Long Start timestamp [optional]
to Long End timestamp [optional]
type String Changing Type: - dnw: Deposit & Withdraw - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: settlement PNL [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 code Description Response headers
200 List retrieved -

listOptionsPositions

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

List user's positions of specified underlying

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying
        try {
            List<OptionsPosition> result = apiInstance.listOptionsPositions()
                        .underlying(underlying)
                        .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 OptionsApi#listOptionsPositions");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying [optional]

Return type

List<OptionsPosition>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

getOptionsPosition

OptionsPosition getOptionsPosition(contract)

Get specified contract position

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String contract = "BTC_USDT-20211130-65000-C"; // String | 
        try {
            OptionsPosition result = apiInstance.getOptionsPosition(contract);
            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 OptionsApi#getOptionsPosition");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
contract String

Return type

OptionsPosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listOptionsPositionClose

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

List user's liquidation history of specified underlying

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        String contract = "BTC_USDT-20210916-5000-C"; // String | Options contract name
        try {
            List<OptionsPositionClose> result = apiInstance.listOptionsPositionClose(underlying)
                        .contract(contract)
                        .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 OptionsApi#listOptionsPositionClose");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying (Obtained by listing underlying endpoint)
contract String Options contract name [optional]

Return type

List<OptionsPositionClose>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

listOptionsOrders

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

List options orders

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String status = "open"; // String | Only list the orders with this status
        String contract = "BTC_USDT-20210916-5000-C"; // String | Options contract name
        String underlying = "BTC_USDT"; // String | Underlying
        Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
        Integer offset = 0; // Integer | List offset, starting from 0
        Long from = 1547706332L; // Long | Start timestamp
        Long to = 1547706332L; // Long | End timestamp
        try {
            List<OptionsOrder> result = apiInstance.listOptionsOrders(status)
                        .contract(contract)
                        .underlying(underlying)
                        .limit(limit)
                        .offset(offset)
                        .from(from)
                        .to(to)
                        .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 OptionsApi#listOptionsOrders");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
status String Only list the orders with this status [enum: open, finished]
contract String Options contract name [optional]
underlying String Underlying [optional]
limit Integer Maximum number of records to be returned in a single list [optional] [default to 100]
offset Integer List offset, starting from 0 [optional] [default to 0]
from Long Start timestamp [optional]
to Long End timestamp [optional]

Return type

List<OptionsOrder>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

createOptionsOrder

OptionsOrder createOptionsOrder(optionsOrder)

Create an options order

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        OptionsOrder optionsOrder = new OptionsOrder(); // OptionsOrder | 
        try {
            OptionsOrder result = apiInstance.createOptionsOrder(optionsOrder);
            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 OptionsApi#createOptionsOrder");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
optionsOrder OptionsOrder

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
201 Order detail -

cancelOptionsOrders

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

Cancel all `open` orders matched

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String contract = "BTC_USDT-20210916-5000-C"; // String | Options contract name
        String underlying = "BTC_USDT"; // String | Underlying
        String side = "ask"; // String | All bids or asks. Both included if not specified
        try {
            List<OptionsOrder> result = apiInstance.cancelOptionsOrders(contract, underlying, side);
            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 OptionsApi#cancelOptionsOrders");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
contract String Options contract name [optional]
underlying String Underlying [optional]
side String All bids or 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 code Description Response headers
200 All orders matched cancelled -

getOptionsOrder

OptionsOrder getOptionsOrder(orderId)

Get a single order

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        Long orderId = 12345L; // Long | Order ID returned on successful order creation
        try {
            OptionsOrder result = apiInstance.getOptionsOrder(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 OptionsApi#getOptionsOrder");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
orderId Long Order ID returned on successful order creation

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Order detail -

cancelOptionsOrder

OptionsOrder cancelOptionsOrder(orderId)

Cancel a single order

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        Long orderId = 12345L; // Long | Order ID returned on successful order creation
        try {
            OptionsOrder result = apiInstance.cancelOptionsOrder(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 OptionsApi#cancelOptionsOrder");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
orderId Long Order ID returned on successful order creation

Return type

OptionsOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Order detail -

listMyOptionsTrades

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

List personal trading history

Example

// 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.OptionsApi;

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");

        OptionsApi apiInstance = new OptionsApi(defaultClient);
        String underlying = "BTC_USDT"; // String | Underlying (Obtained by listing underlying endpoint)
        String contract = "BTC_USDT-20210916-5000-C"; // String | Options contract name
        Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
        Integer offset = 0; // Integer | List offset, starting from 0
        Long from = 1547706332L; // Long | Start timestamp
        Long to = 1547706332L; // Long | End timestamp
        try {
            List<OptionsMyTrade> result = apiInstance.listMyOptionsTrades(underlying)
                        .contract(contract)
                        .limit(limit)
                        .offset(offset)
                        .from(from)
                        .to(to)
                        .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 OptionsApi#listMyOptionsTrades");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
underlying String Underlying (Obtained by listing underlying endpoint)
contract String Options contract name [optional]
limit Integer Maximum number of records to be returned in a single list [optional] [default to 100]
offset Integer List offset, starting from 0 [optional] [default to 0]
from Long Start timestamp [optional]
to Long End timestamp [optional]

Return type

List<OptionsMyTrade>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -