All URIs are relative to https://api.gateio.ws/api/v4
| Method | HTTP request | Description |
|---|---|---|
| QueryMt5AccountInfo | GET /tradfi/users/mt5-account | Query MT5 account information |
| QueryCategories | GET /tradfi/symbols/categories | Query trading symbol categories |
| QuerySymbolCommissions | GET /tradfi/symbols/commissions | Query symbol commission rates |
| QuerySymbols | GET /tradfi/symbols | Query trading symbol list |
| QuerySymbolDetail | GET /tradfi/symbols/detail | Query trading symbol details |
| QuerySymbolKline | GET /tradfi/symbols/{symbol}/klines | Query trading symbol klines |
| QuerySymbolTicker | GET /tradfi/symbols/{symbol}/tickers | Query trading symbol ticker |
| CreateTradFiUser | POST /tradfi/users | Create CFD user |
| QueryUserAssets | GET /tradfi/users/assets | Query account assets |
| QueryTransaction | GET /tradfi/transactions | Query Fund Transfer In/Out Records |
| CreateTransaction | POST /tradfi/transactions | Fund transfer |
| QueryOrderList | GET /tradfi/orders | Query active order list |
| CreateTradFiOrder | POST /tradfi/orders | Create order |
| UpdateOrder | PUT /tradfi/orders/{order_id} | Modify order |
| DeleteOrder | DELETE /tradfi/orders/{order_id} | Cancel order |
| QueryOrderHistoryList | GET /tradfi/orders/history | Query historical order list |
| QueryOrderLog | GET /tradfi/orders/log/{log_id} | Get order details by log ID |
| QueryPositionList | GET /tradfi/positions | Query active position list |
| UpdatePosition | PUT /tradfi/positions/{position_id} | Modify position |
| ClosePosition | POST /tradfi/positions/{position_id}/close | Close position |
| QueryPositionHistoryList | GET /tradfi/positions/history | Query historical position list |
Mt5Account QueryMt5AccountInfo ()
Query MT5 account information
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryMt5AccountInfoExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);try{// Query MT5 account informationMt5Accountresult=apiInstance.QueryMt5AccountInfo();Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryMt5AccountInfo: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
Categories QueryCategories ()
Query trading symbol categories
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryCategoriesExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";varapiInstance=newCFDApi(config);try{// Query trading symbol categoriesCategoriesresult=apiInstance.QueryCategories();Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryCategories: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)
Query symbol commission rates
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQuerySymbolCommissionsExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";varapiInstance=newCFDApi(config);varsymbols="AUDUSD,XAUUSD";// string | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required (optional) varcategoryCode="forex-外汇,metal-金属,index-指数,commodity-大宗商品,stock-股票";// string | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required (optional) try{// Query symbol commission ratesSymbolCommissionsresult=apiInstance.QuerySymbolCommissions(symbols,categoryCode);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QuerySymbolCommissions: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| symbols | string | List of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required | [optional] |
| categoryCode | string | List of category codes (multiple codes separated by commas). When provided together with symbols, filters symbols by category. At least one of symbol and category_code is required | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
Symbols QuerySymbols ()
Query trading symbol list
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQuerySymbolsExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";varapiInstance=newCFDApi(config);try{// Query trading symbol listSymbolsresult=apiInstance.QuerySymbols();Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QuerySymbols: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
ContractDetail QuerySymbolDetail (string symbols)
Query trading symbol details
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQuerySymbolDetailExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";varapiInstance=newCFDApi(config);varsymbols="EURUSD,XAGUSD";// string | Trading symbol code list (comma-separated, max 10 symbols)try{// Query trading symbol detailsContractDetailresult=apiInstance.QuerySymbolDetail(symbols);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QuerySymbolDetail: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| symbols | string | Trading symbol code list (comma-separated, max 10 symbols) |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)
Query trading symbol klines
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQuerySymbolKlineExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";varapiInstance=newCFDApi(config);varsymbol="EURUSD";// string | Trading symbol codevarklineType="1m";// string | Kline type (time period)varbeginTime=1769378400;// long? | Start time (Unix timestamp in seconds) (optional) varendTime=1769464800;// long? | End time (Unix timestamp in seconds) (optional) varlimit=100;// int? | Kline limit (max 500, error if exceeded) (optional) try{// Query trading symbol klinesKlinesresult=apiInstance.QuerySymbolKline(symbol,klineType,beginTime,endTime,limit);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QuerySymbolKline: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | string | Trading symbol code | |
| klineType | string | Kline type (time period) | |
| beginTime | long? | Start time (Unix timestamp in seconds) | [optional] |
| endTime | long? | End time (Unix timestamp in seconds) | [optional] |
| limit | int? | Kline limit (max 500, error if exceeded) | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
TradFiTicker QuerySymbolTicker (string symbol)
Query trading symbol ticker
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQuerySymbolTickerExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";varapiInstance=newCFDApi(config);varsymbol="EURUSD";// string | Trading symbol codetry{// Query trading symbol tickerTradFiTickerresult=apiInstance.QuerySymbolTicker(symbol);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QuerySymbolTicker: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | string | Trading symbol code |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
CreateUserResp CreateTradFiUser ()
Create CFD user
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassCreateTradFiUserExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);try{// Create CFD userCreateUserRespresult=apiInstance.CreateTradFiUser();Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.CreateTradFiUser: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Account opened successfully | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UserAssetResp QueryUserAssets ()
Query account assets
Query account assets
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryUserAssetsExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);try{// Query account assetsUserAssetRespresult=apiInstance.QueryUserAssets();Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryUserAssets: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)
Query Fund Transfer In/Out Records
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryTransactionExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);varbeginTime=1704067200;// long? | Start Time (Second-level Timestamp) (optional) varendTime=1706745599;// long? | End Time (Second-level Timestamp) (optional) vartype="withdraw";// string | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) (optional) varpage=1;// int? | page number (optional) varpageSize=20;// int? | Number per page, default 10, maximum 50 (optional) try{// Query Fund Transfer In/Out RecordsTransactionListresult=apiInstance.QueryTransaction(beginTime,endTime,type,page,pageSize);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryTransaction: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| beginTime | long? | Start Time (Second-level Timestamp) | [optional] |
| endTime | long? | End Time (Second-level Timestamp) | [optional] |
| type | string | Transaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance) | [optional] |
| page | int? | page number | [optional] |
| pageSize | int? | Number per page, default 10, maximum 50 | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)
Fund transfer
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassCreateTransactionExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);vartradFiTransactionRequest=newTradFiTransactionRequest();// TradFiTransactionRequest | try{// Fund transferCreateTransactionresult=apiInstance.CreateTransaction(tradFiTransactionRequest);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.CreateTransaction: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiTransactionRequest | TradFiTransactionRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
OrderList QueryOrderList ()
Query active order list
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryOrderListExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);try{// Query active order listOrderListresult=apiInstance.QueryOrderList();Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryOrderList: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)
Create order
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassCreateTradFiOrderExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);vartradFiOrderRequest=newTradFiOrderRequest();// TradFiOrderRequest | try{// Create orderCreateOrder2result=apiInstance.CreateTradFiOrder(tradFiOrderRequest);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.CreateTradFiOrder: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiOrderRequest | TradFiOrderRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Order placed successfully | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)
Modify order
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassUpdateOrderExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);varorderId=1223;// int | Order IDvartradFiOrderUpdateRequest=newTradFiOrderUpdateRequest();// TradFiOrderUpdateRequest | try{// Modify orderUpdateOrderresult=apiInstance.UpdateOrder(orderId,tradFiOrderUpdateRequest);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.UpdateOrder: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | int | Order ID | |
| tradFiOrderUpdateRequest | TradFiOrderUpdateRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
Object DeleteOrder (int orderId)
Cancel order
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassDeleteOrderExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);varorderId=1223;// int | Order IDtry{// Cancel orderObjectresult=apiInstance.DeleteOrder(orderId);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.DeleteOrder: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | int | Order ID |
Object
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Deleted successfully | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)
Query historical order list
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryOrderHistoryListExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);varbeginTime=1769397000;// long? | Start time (Unix timestamp in seconds), earliest query is one month ago (optional) varendTime=1769398000;// long? | End time (Unix timestamp in seconds) (optional) varsymbol="USDCAD";// string | Currency pair (optional) varside=2;// int? | Side (1=sell, 2=buy) (optional) try{// Query historical order listOrderHistoryListresult=apiInstance.QueryOrderHistoryList(beginTime,endTime,symbol,side);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryOrderHistoryList: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| beginTime | long? | Start time (Unix timestamp in seconds), earliest query is one month ago | [optional] |
| endTime | long? | End time (Unix timestamp in seconds) | [optional] |
| symbol | string | Currency pair | [optional] |
| side | int? | Side (1=sell, 2=buy) | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
OrderLog QueryOrderLog (int logId)
Get order details by log ID
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryOrderLogExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);varlogId=1223;// int | log_id returned from the order placement APItry{// Get order details by log IDOrderLogresult=apiInstance.QueryOrderLog(logId);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryOrderLog: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| logId | int | log_id returned from the order placement API |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
PositionList QueryPositionList ()
Query active position list
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryPositionListExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);try{// Query active position listPositionListresult=apiInstance.QueryPositionList();Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryPositionList: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)
Modify position
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassUpdatePositionExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);varpositionId=1223;// int | Position IDvartradFiPositionUpdateRequest=newTradFiPositionUpdateRequest();// TradFiPositionUpdateRequest | try{// Modify positionUpdatePositionresult=apiInstance.UpdatePosition(positionId,tradFiPositionUpdateRequest);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.UpdatePosition: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| positionId | int | Position ID | |
| tradFiPositionUpdateRequest | TradFiPositionUpdateRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)
Close position
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassClosePositionExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);varpositionId=1223;// int | Position IDvartradFiClosePositionRequest=newTradFiClosePositionRequest();// TradFiClosePositionRequest | try{// Close positionDeletePositionresult=apiInstance.ClosePosition(positionId,tradFiClosePositionRequest);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.ClosePosition: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| positionId | int | Position ID | |
| tradFiClosePositionRequest | TradFiClosePositionRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]
PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)
Query historical position list
usingSystem.Collections.Generic;usingSystem.Diagnostics;usingIo.Gate.GateApi.Api;usingIo.Gate.GateApi.Client;usingIo.Gate.GateApi.Model;namespaceExample{publicclassQueryPositionHistoryListExample{publicstaticvoidMain(){Configurationconfig=newConfiguration();config.BasePath="https://api.gateio.ws/api/v4";config.SetGateApiV4KeyPair("YOUR_API_KEY","YOUR_API_SECRET");varapiInstance=newCFDApi(config);varpage=1;// long? | Page number; defaults to 1 if omitted. (optional) varpageSize=10;// long? | Page size; defaults to 10 if omitted. Maximum 100. (optional) varbeginTime=56;// long? | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago (optional) varendTime=56;// long? | End time (timestamp in seconds) (optional) varsymbol="symbol_example";// string | Trading symbol (e.g., EURUSD) (optional) varpositionDir="positionDir_example";// string | Position direction (Long=long position, Short=short position) (optional) try{// Query historical position listPositionHistoryListresult=apiInstance.QueryPositionHistoryList(page,pageSize,beginTime,endTime,symbol,positionDir);Debug.WriteLine(result);}catch(GateApiExceptione){Debug.Print("Exception when calling CFDApi.QueryPositionHistoryList: "+e.Message);Debug.Print("Exception label: {0}, message: {1}",e.ErrorLabel,e.ErrorMessage);Debug.Print("Status Code: "+e.ErrorCode);Debug.Print(e.StackTrace);}}}}| Name | Type | Description | Notes |
|---|---|---|---|
| page | long? | Page number; defaults to 1 if omitted. | [optional] |
| pageSize | long? | Page size; defaults to 10 if omitted. Maximum 100. | [optional] |
| beginTime | long? | Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago | [optional] |
| endTime | long? | End time (timestamp in seconds) | [optional] |
| symbol | string | Trading symbol (e.g., EURUSD) | [optional] |
| positionDir | string | Position direction (Long=long position, Short=short position) | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top][Back to API list][Back to Model list][Back to README]