Skip to content

Latest commit

History

History
1543 lines (1215 loc) · 48.2 KB

File metadata and controls

1543 lines (1215 loc) · 48.2 KB

Io.Gate.GateApi.Api.CFDApi

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

MethodHTTP requestDescription
QueryMt5AccountInfoGET /tradfi/users/mt5-accountQuery MT5 account information
QueryCategoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
QuerySymbolCommissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
QuerySymbolsGET /tradfi/symbolsQuery trading symbol list
QuerySymbolDetailGET /tradfi/symbols/detailQuery trading symbol details
QuerySymbolKlineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
QuerySymbolTickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
CreateTradFiUserPOST /tradfi/usersCreate CFD user
QueryUserAssetsGET /tradfi/users/assetsQuery account assets
QueryTransactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
CreateTransactionPOST /tradfi/transactionsFund transfer
QueryOrderListGET /tradfi/ordersQuery active order list
CreateTradFiOrderPOST /tradfi/ordersCreate order
UpdateOrderPUT /tradfi/orders/{order_id}Modify order
DeleteOrderDELETE /tradfi/orders/{order_id}Cancel order
QueryOrderHistoryListGET /tradfi/orders/historyQuery historical order list
QueryOrderLogGET /tradfi/orders/log/{log_id}Get order details by log ID
QueryPositionListGET /tradfi/positionsQuery active position list
UpdatePositionPUT /tradfi/positions/{position_id}Modify position
ClosePositionPOST /tradfi/positions/{position_id}/closeClose position
QueryPositionHistoryListGET /tradfi/positions/historyQuery historical position list

QueryMt5AccountInfo

Mt5Account QueryMt5AccountInfo ()

Query MT5 account information

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryCategories

Categories QueryCategories ()

Query trading symbol categories

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolCommissions

SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)

Query symbol commission rates

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
categoryCodestringList 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]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbols

Symbols QuerySymbols ()

Query trading symbol list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolDetail

ContractDetail QuerySymbolDetail (string symbols)

Query trading symbol details

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolKline

Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)

Query trading symbol klines

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code
klineTypestringKline type (time period)
beginTimelong?Start time (Unix timestamp in seconds)[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
limitint?Kline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolTicker

TradFiTicker QuerySymbolTicker (string symbol)

Query trading symbol ticker

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiUser

CreateUserResp CreateTradFiUser ()

Create CFD user

Example

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

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryUserAssets

UserAssetResp QueryUserAssets ()

Query account assets

Query account assets

Example

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

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryTransaction

TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)

Query Fund Transfer In/Out Records

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start Time (Second-level Timestamp)[optional]
endTimelong?End Time (Second-level Timestamp)[optional]
typestringTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageint?page number[optional]
pageSizeint?Number per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTransaction

CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)

Fund transfer

Example

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

Parameters

NameTypeDescriptionNotes
tradFiTransactionRequestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderList

OrderList QueryOrderList ()

Query active order list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiOrder

CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)

Create order

Example

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

Parameters

NameTypeDescriptionNotes
tradFiOrderRequestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdateOrder

UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)

Modify order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID
tradFiOrderUpdateRequestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

DeleteOrder

Object DeleteOrder (int orderId)

Cancel order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID

Return type

Object

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderHistoryList

OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)

Query historical order list

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start time (Unix timestamp in seconds), earliest query is one month ago[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
symbolstringCurrency pair[optional]
sideint?Side (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderLog

OrderLog QueryOrderLog (int logId)

Get order details by log ID

Example

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

Parameters

NameTypeDescriptionNotes
logIdintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionList

PositionList QueryPositionList ()

Query active position list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdatePosition

UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)

Modify position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiPositionUpdateRequestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

ClosePosition

DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)

Close position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiClosePositionRequestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionHistoryList

PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)

Query historical position list

Example

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

Parameters

NameTypeDescriptionNotes
pagelong?Page number; defaults to 1 if omitted.[optional]
pageSizelong?Page size; defaults to 10 if omitted. Maximum 100.[optional]
beginTimelong?Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
endTimelong?End time (timestamp in seconds)[optional]
symbolstringTrading symbol (e.g., EURUSD)[optional]
positionDirstringPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

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

Latest commit

History

History
1543 lines (1215 loc) · 48.2 KB

File metadata and controls

1543 lines (1215 loc) · 48.2 KB

Io.Gate.GateApi.Api.CFDApi

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

MethodHTTP requestDescription
QueryMt5AccountInfoGET /tradfi/users/mt5-accountQuery MT5 account information
QueryCategoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
QuerySymbolCommissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
QuerySymbolsGET /tradfi/symbolsQuery trading symbol list
QuerySymbolDetailGET /tradfi/symbols/detailQuery trading symbol details
QuerySymbolKlineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
QuerySymbolTickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
CreateTradFiUserPOST /tradfi/usersCreate CFD user
QueryUserAssetsGET /tradfi/users/assetsQuery account assets
QueryTransactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
CreateTransactionPOST /tradfi/transactionsFund transfer
QueryOrderListGET /tradfi/ordersQuery active order list
CreateTradFiOrderPOST /tradfi/ordersCreate order
UpdateOrderPUT /tradfi/orders/{order_id}Modify order
DeleteOrderDELETE /tradfi/orders/{order_id}Cancel order
QueryOrderHistoryListGET /tradfi/orders/historyQuery historical order list
QueryOrderLogGET /tradfi/orders/log/{log_id}Get order details by log ID
QueryPositionListGET /tradfi/positionsQuery active position list
UpdatePositionPUT /tradfi/positions/{position_id}Modify position
ClosePositionPOST /tradfi/positions/{position_id}/closeClose position
QueryPositionHistoryListGET /tradfi/positions/historyQuery historical position list

QueryMt5AccountInfo

Mt5Account QueryMt5AccountInfo ()

Query MT5 account information

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryCategories

Categories QueryCategories ()

Query trading symbol categories

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolCommissions

SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)

Query symbol commission rates

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
categoryCodestringList 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]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbols

Symbols QuerySymbols ()

Query trading symbol list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolDetail

ContractDetail QuerySymbolDetail (string symbols)

Query trading symbol details

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolKline

Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)

Query trading symbol klines

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code
klineTypestringKline type (time period)
beginTimelong?Start time (Unix timestamp in seconds)[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
limitint?Kline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolTicker

TradFiTicker QuerySymbolTicker (string symbol)

Query trading symbol ticker

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiUser

CreateUserResp CreateTradFiUser ()

Create CFD user

Example

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

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryUserAssets

UserAssetResp QueryUserAssets ()

Query account assets

Query account assets

Example

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

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryTransaction

TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)

Query Fund Transfer In/Out Records

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start Time (Second-level Timestamp)[optional]
endTimelong?End Time (Second-level Timestamp)[optional]
typestringTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageint?page number[optional]
pageSizeint?Number per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTransaction

CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)

Fund transfer

Example

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

Parameters

NameTypeDescriptionNotes
tradFiTransactionRequestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderList

OrderList QueryOrderList ()

Query active order list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiOrder

CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)

Create order

Example

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

Parameters

NameTypeDescriptionNotes
tradFiOrderRequestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdateOrder

UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)

Modify order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID
tradFiOrderUpdateRequestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

DeleteOrder

Object DeleteOrder (int orderId)

Cancel order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID

Return type

Object

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderHistoryList

OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)

Query historical order list

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start time (Unix timestamp in seconds), earliest query is one month ago[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
symbolstringCurrency pair[optional]
sideint?Side (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderLog

OrderLog QueryOrderLog (int logId)

Get order details by log ID

Example

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

Parameters

NameTypeDescriptionNotes
logIdintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionList

PositionList QueryPositionList ()

Query active position list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdatePosition

UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)

Modify position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiPositionUpdateRequestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

ClosePosition

DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)

Close position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiClosePositionRequestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionHistoryList

PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)

Query historical position list

Example

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

Parameters

NameTypeDescriptionNotes
pagelong?Page number; defaults to 1 if omitted.[optional]
pageSizelong?Page size; defaults to 10 if omitted. Maximum 100.[optional]
beginTimelong?Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
endTimelong?End time (timestamp in seconds)[optional]
symbolstringTrading symbol (e.g., EURUSD)[optional]
positionDirstringPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

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

Latest commit

History

History
1543 lines (1215 loc) · 48.2 KB

File metadata and controls

1543 lines (1215 loc) · 48.2 KB

Io.Gate.GateApi.Api.CFDApi

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

MethodHTTP requestDescription
QueryMt5AccountInfoGET /tradfi/users/mt5-accountQuery MT5 account information
QueryCategoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
QuerySymbolCommissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
QuerySymbolsGET /tradfi/symbolsQuery trading symbol list
QuerySymbolDetailGET /tradfi/symbols/detailQuery trading symbol details
QuerySymbolKlineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
QuerySymbolTickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
CreateTradFiUserPOST /tradfi/usersCreate CFD user
QueryUserAssetsGET /tradfi/users/assetsQuery account assets
QueryTransactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
CreateTransactionPOST /tradfi/transactionsFund transfer
QueryOrderListGET /tradfi/ordersQuery active order list
CreateTradFiOrderPOST /tradfi/ordersCreate order
UpdateOrderPUT /tradfi/orders/{order_id}Modify order
DeleteOrderDELETE /tradfi/orders/{order_id}Cancel order
QueryOrderHistoryListGET /tradfi/orders/historyQuery historical order list
QueryOrderLogGET /tradfi/orders/log/{log_id}Get order details by log ID
QueryPositionListGET /tradfi/positionsQuery active position list
UpdatePositionPUT /tradfi/positions/{position_id}Modify position
ClosePositionPOST /tradfi/positions/{position_id}/closeClose position
QueryPositionHistoryListGET /tradfi/positions/historyQuery historical position list

QueryMt5AccountInfo

Mt5Account QueryMt5AccountInfo ()

Query MT5 account information

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryCategories

Categories QueryCategories ()

Query trading symbol categories

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolCommissions

SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)

Query symbol commission rates

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
categoryCodestringList 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]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbols

Symbols QuerySymbols ()

Query trading symbol list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolDetail

ContractDetail QuerySymbolDetail (string symbols)

Query trading symbol details

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolKline

Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)

Query trading symbol klines

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code
klineTypestringKline type (time period)
beginTimelong?Start time (Unix timestamp in seconds)[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
limitint?Kline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolTicker

TradFiTicker QuerySymbolTicker (string symbol)

Query trading symbol ticker

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiUser

CreateUserResp CreateTradFiUser ()

Create CFD user

Example

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

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryUserAssets

UserAssetResp QueryUserAssets ()

Query account assets

Query account assets

Example

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

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryTransaction

TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)

Query Fund Transfer In/Out Records

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start Time (Second-level Timestamp)[optional]
endTimelong?End Time (Second-level Timestamp)[optional]
typestringTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageint?page number[optional]
pageSizeint?Number per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTransaction

CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)

Fund transfer

Example

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

Parameters

NameTypeDescriptionNotes
tradFiTransactionRequestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderList

OrderList QueryOrderList ()

Query active order list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiOrder

CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)

Create order

Example

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

Parameters

NameTypeDescriptionNotes
tradFiOrderRequestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdateOrder

UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)

Modify order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID
tradFiOrderUpdateRequestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

DeleteOrder

Object DeleteOrder (int orderId)

Cancel order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID

Return type

Object

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderHistoryList

OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)

Query historical order list

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start time (Unix timestamp in seconds), earliest query is one month ago[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
symbolstringCurrency pair[optional]
sideint?Side (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderLog

OrderLog QueryOrderLog (int logId)

Get order details by log ID

Example

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

Parameters

NameTypeDescriptionNotes
logIdintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionList

PositionList QueryPositionList ()

Query active position list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdatePosition

UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)

Modify position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiPositionUpdateRequestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

ClosePosition

DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)

Close position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiClosePositionRequestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionHistoryList

PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)

Query historical position list

Example

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

Parameters

NameTypeDescriptionNotes
pagelong?Page number; defaults to 1 if omitted.[optional]
pageSizelong?Page size; defaults to 10 if omitted. Maximum 100.[optional]
beginTimelong?Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
endTimelong?End time (timestamp in seconds)[optional]
symbolstringTrading symbol (e.g., EURUSD)[optional]
positionDirstringPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

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

Latest commit

History

History
1543 lines (1215 loc) · 48.2 KB

File metadata and controls

1543 lines (1215 loc) · 48.2 KB

Io.Gate.GateApi.Api.CFDApi

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

MethodHTTP requestDescription
QueryMt5AccountInfoGET /tradfi/users/mt5-accountQuery MT5 account information
QueryCategoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
QuerySymbolCommissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
QuerySymbolsGET /tradfi/symbolsQuery trading symbol list
QuerySymbolDetailGET /tradfi/symbols/detailQuery trading symbol details
QuerySymbolKlineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
QuerySymbolTickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
CreateTradFiUserPOST /tradfi/usersCreate CFD user
QueryUserAssetsGET /tradfi/users/assetsQuery account assets
QueryTransactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
CreateTransactionPOST /tradfi/transactionsFund transfer
QueryOrderListGET /tradfi/ordersQuery active order list
CreateTradFiOrderPOST /tradfi/ordersCreate order
UpdateOrderPUT /tradfi/orders/{order_id}Modify order
DeleteOrderDELETE /tradfi/orders/{order_id}Cancel order
QueryOrderHistoryListGET /tradfi/orders/historyQuery historical order list
QueryOrderLogGET /tradfi/orders/log/{log_id}Get order details by log ID
QueryPositionListGET /tradfi/positionsQuery active position list
UpdatePositionPUT /tradfi/positions/{position_id}Modify position
ClosePositionPOST /tradfi/positions/{position_id}/closeClose position
QueryPositionHistoryListGET /tradfi/positions/historyQuery historical position list

QueryMt5AccountInfo

Mt5Account QueryMt5AccountInfo ()

Query MT5 account information

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryCategories

Categories QueryCategories ()

Query trading symbol categories

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolCommissions

SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)

Query symbol commission rates

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
categoryCodestringList 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]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbols

Symbols QuerySymbols ()

Query trading symbol list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolDetail

ContractDetail QuerySymbolDetail (string symbols)

Query trading symbol details

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolKline

Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)

Query trading symbol klines

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code
klineTypestringKline type (time period)
beginTimelong?Start time (Unix timestamp in seconds)[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
limitint?Kline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolTicker

TradFiTicker QuerySymbolTicker (string symbol)

Query trading symbol ticker

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiUser

CreateUserResp CreateTradFiUser ()

Create CFD user

Example

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

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryUserAssets

UserAssetResp QueryUserAssets ()

Query account assets

Query account assets

Example

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

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryTransaction

TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)

Query Fund Transfer In/Out Records

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start Time (Second-level Timestamp)[optional]
endTimelong?End Time (Second-level Timestamp)[optional]
typestringTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageint?page number[optional]
pageSizeint?Number per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTransaction

CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)

Fund transfer

Example

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

Parameters

NameTypeDescriptionNotes
tradFiTransactionRequestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderList

OrderList QueryOrderList ()

Query active order list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiOrder

CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)

Create order

Example

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

Parameters

NameTypeDescriptionNotes
tradFiOrderRequestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdateOrder

UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)

Modify order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID
tradFiOrderUpdateRequestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

DeleteOrder

Object DeleteOrder (int orderId)

Cancel order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID

Return type

Object

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderHistoryList

OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)

Query historical order list

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start time (Unix timestamp in seconds), earliest query is one month ago[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
symbolstringCurrency pair[optional]
sideint?Side (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderLog

OrderLog QueryOrderLog (int logId)

Get order details by log ID

Example

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

Parameters

NameTypeDescriptionNotes
logIdintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionList

PositionList QueryPositionList ()

Query active position list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdatePosition

UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)

Modify position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiPositionUpdateRequestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

ClosePosition

DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)

Close position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiClosePositionRequestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionHistoryList

PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)

Query historical position list

Example

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

Parameters

NameTypeDescriptionNotes
pagelong?Page number; defaults to 1 if omitted.[optional]
pageSizelong?Page size; defaults to 10 if omitted. Maximum 100.[optional]
beginTimelong?Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
endTimelong?End time (timestamp in seconds)[optional]
symbolstringTrading symbol (e.g., EURUSD)[optional]
positionDirstringPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

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

Latest commit

History

History
1543 lines (1215 loc) · 48.2 KB

File metadata and controls

1543 lines (1215 loc) · 48.2 KB

Io.Gate.GateApi.Api.CFDApi

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

MethodHTTP requestDescription
QueryMt5AccountInfoGET /tradfi/users/mt5-accountQuery MT5 account information
QueryCategoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
QuerySymbolCommissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
QuerySymbolsGET /tradfi/symbolsQuery trading symbol list
QuerySymbolDetailGET /tradfi/symbols/detailQuery trading symbol details
QuerySymbolKlineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
QuerySymbolTickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
CreateTradFiUserPOST /tradfi/usersCreate CFD user
QueryUserAssetsGET /tradfi/users/assetsQuery account assets
QueryTransactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
CreateTransactionPOST /tradfi/transactionsFund transfer
QueryOrderListGET /tradfi/ordersQuery active order list
CreateTradFiOrderPOST /tradfi/ordersCreate order
UpdateOrderPUT /tradfi/orders/{order_id}Modify order
DeleteOrderDELETE /tradfi/orders/{order_id}Cancel order
QueryOrderHistoryListGET /tradfi/orders/historyQuery historical order list
QueryOrderLogGET /tradfi/orders/log/{log_id}Get order details by log ID
QueryPositionListGET /tradfi/positionsQuery active position list
UpdatePositionPUT /tradfi/positions/{position_id}Modify position
ClosePositionPOST /tradfi/positions/{position_id}/closeClose position
QueryPositionHistoryListGET /tradfi/positions/historyQuery historical position list

QueryMt5AccountInfo

Mt5Account QueryMt5AccountInfo ()

Query MT5 account information

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryCategories

Categories QueryCategories ()

Query trading symbol categories

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolCommissions

SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)

Query symbol commission rates

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
categoryCodestringList 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]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbols

Symbols QuerySymbols ()

Query trading symbol list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolDetail

ContractDetail QuerySymbolDetail (string symbols)

Query trading symbol details

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolKline

Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)

Query trading symbol klines

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code
klineTypestringKline type (time period)
beginTimelong?Start time (Unix timestamp in seconds)[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
limitint?Kline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolTicker

TradFiTicker QuerySymbolTicker (string symbol)

Query trading symbol ticker

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiUser

CreateUserResp CreateTradFiUser ()

Create CFD user

Example

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

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryUserAssets

UserAssetResp QueryUserAssets ()

Query account assets

Query account assets

Example

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

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryTransaction

TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)

Query Fund Transfer In/Out Records

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start Time (Second-level Timestamp)[optional]
endTimelong?End Time (Second-level Timestamp)[optional]
typestringTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageint?page number[optional]
pageSizeint?Number per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTransaction

CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)

Fund transfer

Example

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

Parameters

NameTypeDescriptionNotes
tradFiTransactionRequestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderList

OrderList QueryOrderList ()

Query active order list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiOrder

CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)

Create order

Example

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

Parameters

NameTypeDescriptionNotes
tradFiOrderRequestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdateOrder

UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)

Modify order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID
tradFiOrderUpdateRequestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

DeleteOrder

Object DeleteOrder (int orderId)

Cancel order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID

Return type

Object

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderHistoryList

OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)

Query historical order list

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start time (Unix timestamp in seconds), earliest query is one month ago[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
symbolstringCurrency pair[optional]
sideint?Side (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderLog

OrderLog QueryOrderLog (int logId)

Get order details by log ID

Example

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

Parameters

NameTypeDescriptionNotes
logIdintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionList

PositionList QueryPositionList ()

Query active position list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdatePosition

UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)

Modify position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiPositionUpdateRequestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

ClosePosition

DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)

Close position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiClosePositionRequestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionHistoryList

PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)

Query historical position list

Example

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

Parameters

NameTypeDescriptionNotes
pagelong?Page number; defaults to 1 if omitted.[optional]
pageSizelong?Page size; defaults to 10 if omitted. Maximum 100.[optional]
beginTimelong?Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
endTimelong?End time (timestamp in seconds)[optional]
symbolstringTrading symbol (e.g., EURUSD)[optional]
positionDirstringPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

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

Latest commit

History

History
1543 lines (1215 loc) · 48.2 KB

File metadata and controls

1543 lines (1215 loc) · 48.2 KB

Io.Gate.GateApi.Api.CFDApi

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

MethodHTTP requestDescription
QueryMt5AccountInfoGET /tradfi/users/mt5-accountQuery MT5 account information
QueryCategoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
QuerySymbolCommissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
QuerySymbolsGET /tradfi/symbolsQuery trading symbol list
QuerySymbolDetailGET /tradfi/symbols/detailQuery trading symbol details
QuerySymbolKlineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
QuerySymbolTickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
CreateTradFiUserPOST /tradfi/usersCreate CFD user
QueryUserAssetsGET /tradfi/users/assetsQuery account assets
QueryTransactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
CreateTransactionPOST /tradfi/transactionsFund transfer
QueryOrderListGET /tradfi/ordersQuery active order list
CreateTradFiOrderPOST /tradfi/ordersCreate order
UpdateOrderPUT /tradfi/orders/{order_id}Modify order
DeleteOrderDELETE /tradfi/orders/{order_id}Cancel order
QueryOrderHistoryListGET /tradfi/orders/historyQuery historical order list
QueryOrderLogGET /tradfi/orders/log/{log_id}Get order details by log ID
QueryPositionListGET /tradfi/positionsQuery active position list
UpdatePositionPUT /tradfi/positions/{position_id}Modify position
ClosePositionPOST /tradfi/positions/{position_id}/closeClose position
QueryPositionHistoryListGET /tradfi/positions/historyQuery historical position list

QueryMt5AccountInfo

Mt5Account QueryMt5AccountInfo ()

Query MT5 account information

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryCategories

Categories QueryCategories ()

Query trading symbol categories

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolCommissions

SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)

Query symbol commission rates

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
categoryCodestringList 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]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbols

Symbols QuerySymbols ()

Query trading symbol list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolDetail

ContractDetail QuerySymbolDetail (string symbols)

Query trading symbol details

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolKline

Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)

Query trading symbol klines

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code
klineTypestringKline type (time period)
beginTimelong?Start time (Unix timestamp in seconds)[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
limitint?Kline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolTicker

TradFiTicker QuerySymbolTicker (string symbol)

Query trading symbol ticker

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiUser

CreateUserResp CreateTradFiUser ()

Create CFD user

Example

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

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryUserAssets

UserAssetResp QueryUserAssets ()

Query account assets

Query account assets

Example

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

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryTransaction

TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)

Query Fund Transfer In/Out Records

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start Time (Second-level Timestamp)[optional]
endTimelong?End Time (Second-level Timestamp)[optional]
typestringTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageint?page number[optional]
pageSizeint?Number per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTransaction

CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)

Fund transfer

Example

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

Parameters

NameTypeDescriptionNotes
tradFiTransactionRequestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderList

OrderList QueryOrderList ()

Query active order list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiOrder

CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)

Create order

Example

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

Parameters

NameTypeDescriptionNotes
tradFiOrderRequestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdateOrder

UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)

Modify order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID
tradFiOrderUpdateRequestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

DeleteOrder

Object DeleteOrder (int orderId)

Cancel order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID

Return type

Object

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderHistoryList

OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)

Query historical order list

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start time (Unix timestamp in seconds), earliest query is one month ago[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
symbolstringCurrency pair[optional]
sideint?Side (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderLog

OrderLog QueryOrderLog (int logId)

Get order details by log ID

Example

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

Parameters

NameTypeDescriptionNotes
logIdintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionList

PositionList QueryPositionList ()

Query active position list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdatePosition

UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)

Modify position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiPositionUpdateRequestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

ClosePosition

DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)

Close position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiClosePositionRequestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionHistoryList

PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)

Query historical position list

Example

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

Parameters

NameTypeDescriptionNotes
pagelong?Page number; defaults to 1 if omitted.[optional]
pageSizelong?Page size; defaults to 10 if omitted. Maximum 100.[optional]
beginTimelong?Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
endTimelong?End time (timestamp in seconds)[optional]
symbolstringTrading symbol (e.g., EURUSD)[optional]
positionDirstringPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

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

Latest commit

History

History
1543 lines (1215 loc) · 48.2 KB

File metadata and controls

1543 lines (1215 loc) · 48.2 KB

Io.Gate.GateApi.Api.CFDApi

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

MethodHTTP requestDescription
QueryMt5AccountInfoGET /tradfi/users/mt5-accountQuery MT5 account information
QueryCategoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
QuerySymbolCommissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
QuerySymbolsGET /tradfi/symbolsQuery trading symbol list
QuerySymbolDetailGET /tradfi/symbols/detailQuery trading symbol details
QuerySymbolKlineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
QuerySymbolTickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
CreateTradFiUserPOST /tradfi/usersCreate CFD user
QueryUserAssetsGET /tradfi/users/assetsQuery account assets
QueryTransactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
CreateTransactionPOST /tradfi/transactionsFund transfer
QueryOrderListGET /tradfi/ordersQuery active order list
CreateTradFiOrderPOST /tradfi/ordersCreate order
UpdateOrderPUT /tradfi/orders/{order_id}Modify order
DeleteOrderDELETE /tradfi/orders/{order_id}Cancel order
QueryOrderHistoryListGET /tradfi/orders/historyQuery historical order list
QueryOrderLogGET /tradfi/orders/log/{log_id}Get order details by log ID
QueryPositionListGET /tradfi/positionsQuery active position list
UpdatePositionPUT /tradfi/positions/{position_id}Modify position
ClosePositionPOST /tradfi/positions/{position_id}/closeClose position
QueryPositionHistoryListGET /tradfi/positions/historyQuery historical position list

QueryMt5AccountInfo

Mt5Account QueryMt5AccountInfo ()

Query MT5 account information

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryCategories

Categories QueryCategories ()

Query trading symbol categories

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolCommissions

SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)

Query symbol commission rates

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
categoryCodestringList 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]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbols

Symbols QuerySymbols ()

Query trading symbol list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolDetail

ContractDetail QuerySymbolDetail (string symbols)

Query trading symbol details

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolKline

Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)

Query trading symbol klines

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code
klineTypestringKline type (time period)
beginTimelong?Start time (Unix timestamp in seconds)[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
limitint?Kline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolTicker

TradFiTicker QuerySymbolTicker (string symbol)

Query trading symbol ticker

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiUser

CreateUserResp CreateTradFiUser ()

Create CFD user

Example

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

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryUserAssets

UserAssetResp QueryUserAssets ()

Query account assets

Query account assets

Example

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

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryTransaction

TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)

Query Fund Transfer In/Out Records

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start Time (Second-level Timestamp)[optional]
endTimelong?End Time (Second-level Timestamp)[optional]
typestringTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageint?page number[optional]
pageSizeint?Number per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTransaction

CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)

Fund transfer

Example

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

Parameters

NameTypeDescriptionNotes
tradFiTransactionRequestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderList

OrderList QueryOrderList ()

Query active order list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiOrder

CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)

Create order

Example

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

Parameters

NameTypeDescriptionNotes
tradFiOrderRequestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdateOrder

UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)

Modify order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID
tradFiOrderUpdateRequestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

DeleteOrder

Object DeleteOrder (int orderId)

Cancel order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID

Return type

Object

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderHistoryList

OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)

Query historical order list

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start time (Unix timestamp in seconds), earliest query is one month ago[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
symbolstringCurrency pair[optional]
sideint?Side (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderLog

OrderLog QueryOrderLog (int logId)

Get order details by log ID

Example

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

Parameters

NameTypeDescriptionNotes
logIdintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionList

PositionList QueryPositionList ()

Query active position list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdatePosition

UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)

Modify position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiPositionUpdateRequestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

ClosePosition

DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)

Close position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiClosePositionRequestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionHistoryList

PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)

Query historical position list

Example

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

Parameters

NameTypeDescriptionNotes
pagelong?Page number; defaults to 1 if omitted.[optional]
pageSizelong?Page size; defaults to 10 if omitted. Maximum 100.[optional]
beginTimelong?Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
endTimelong?End time (timestamp in seconds)[optional]
symbolstringTrading symbol (e.g., EURUSD)[optional]
positionDirstringPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

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

Latest commit

History

History
1543 lines (1215 loc) · 48.2 KB

File metadata and controls

1543 lines (1215 loc) · 48.2 KB

Io.Gate.GateApi.Api.CFDApi

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

MethodHTTP requestDescription
QueryMt5AccountInfoGET /tradfi/users/mt5-accountQuery MT5 account information
QueryCategoriesGET /tradfi/symbols/categoriesQuery trading symbol categories
QuerySymbolCommissionsGET /tradfi/symbols/commissionsQuery symbol commission rates
QuerySymbolsGET /tradfi/symbolsQuery trading symbol list
QuerySymbolDetailGET /tradfi/symbols/detailQuery trading symbol details
QuerySymbolKlineGET /tradfi/symbols/{symbol}/klinesQuery trading symbol klines
QuerySymbolTickerGET /tradfi/symbols/{symbol}/tickersQuery trading symbol ticker
CreateTradFiUserPOST /tradfi/usersCreate CFD user
QueryUserAssetsGET /tradfi/users/assetsQuery account assets
QueryTransactionGET /tradfi/transactionsQuery Fund Transfer In/Out Records
CreateTransactionPOST /tradfi/transactionsFund transfer
QueryOrderListGET /tradfi/ordersQuery active order list
CreateTradFiOrderPOST /tradfi/ordersCreate order
UpdateOrderPUT /tradfi/orders/{order_id}Modify order
DeleteOrderDELETE /tradfi/orders/{order_id}Cancel order
QueryOrderHistoryListGET /tradfi/orders/historyQuery historical order list
QueryOrderLogGET /tradfi/orders/log/{log_id}Get order details by log ID
QueryPositionListGET /tradfi/positionsQuery active position list
UpdatePositionPUT /tradfi/positions/{position_id}Modify position
ClosePositionPOST /tradfi/positions/{position_id}/closeClose position
QueryPositionHistoryListGET /tradfi/positions/historyQuery historical position list

QueryMt5AccountInfo

Mt5Account QueryMt5AccountInfo ()

Query MT5 account information

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Mt5Account

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryCategories

Categories QueryCategories ()

Query trading symbol categories

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Categories

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolCommissions

SymbolCommissions QuerySymbolCommissions (string symbols = null, string categoryCode = null)

Query symbol commission rates

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringList of symbol codes (multiple codes separated by commas). At least one of symbol and category_code is required[optional]
categoryCodestringList 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]

Return type

SymbolCommissions

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbols

Symbols QuerySymbols ()

Query trading symbol list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

Symbols

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolDetail

ContractDetail QuerySymbolDetail (string symbols)

Query trading symbol details

Example

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

Parameters

NameTypeDescriptionNotes
symbolsstringTrading symbol code list (comma-separated, max 10 symbols)

Return type

ContractDetail

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolKline

Klines QuerySymbolKline (string symbol, string klineType, long? beginTime = null, long? endTime = null, int? limit = null)

Query trading symbol klines

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code
klineTypestringKline type (time period)
beginTimelong?Start time (Unix timestamp in seconds)[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
limitint?Kline limit (max 500, error if exceeded)[optional]

Return type

Klines

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QuerySymbolTicker

TradFiTicker QuerySymbolTicker (string symbol)

Query trading symbol ticker

Example

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

Parameters

NameTypeDescriptionNotes
symbolstringTrading symbol code

Return type

TradFiTicker

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiUser

CreateUserResp CreateTradFiUser ()

Create CFD user

Example

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

Parameters

This endpoint does not need any parameter.

Return type

CreateUserResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Account opened successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryUserAssets

UserAssetResp QueryUserAssets ()

Query account assets

Query account assets

Example

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

Parameters

This endpoint does not need any parameter.

Return type

UserAssetResp

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryTransaction

TransactionList QueryTransaction (long? beginTime = null, long? endTime = null, string type = null, int? page = null, int? pageSize = null)

Query Fund Transfer In/Out Records

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start Time (Second-level Timestamp)[optional]
endTimelong?End Time (Second-level Timestamp)[optional]
typestringTransaction Type (deposit - transfer in, withdraw - transfer out, dividend - dividend payment, fill_negative - cover negative balance)[optional]
pageint?page number[optional]
pageSizeint?Number per page, default 10, maximum 50[optional]

Return type

TransactionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTransaction

CreateTransaction CreateTransaction (TradFiTransactionRequest tradFiTransactionRequest)

Fund transfer

Example

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

Parameters

NameTypeDescriptionNotes
tradFiTransactionRequestTradFiTransactionRequest

Return type

CreateTransaction

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderList

OrderList QueryOrderList ()

Query active order list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

OrderList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

CreateTradFiOrder

CreateOrder2 CreateTradFiOrder (TradFiOrderRequest tradFiOrderRequest)

Create order

Example

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

Parameters

NameTypeDescriptionNotes
tradFiOrderRequestTradFiOrderRequest

Return type

CreateOrder2

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Order placed successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdateOrder

UpdateOrder UpdateOrder (int orderId, TradFiOrderUpdateRequest tradFiOrderUpdateRequest)

Modify order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID
tradFiOrderUpdateRequestTradFiOrderUpdateRequest

Return type

UpdateOrder

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

DeleteOrder

Object DeleteOrder (int orderId)

Cancel order

Example

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

Parameters

NameTypeDescriptionNotes
orderIdintOrder ID

Return type

Object

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Deleted successfully-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderHistoryList

OrderHistoryList QueryOrderHistoryList (long? beginTime = null, long? endTime = null, string symbol = null, int? side = null)

Query historical order list

Example

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

Parameters

NameTypeDescriptionNotes
beginTimelong?Start time (Unix timestamp in seconds), earliest query is one month ago[optional]
endTimelong?End time (Unix timestamp in seconds)[optional]
symbolstringCurrency pair[optional]
sideint?Side (1=sell, 2=buy)[optional]

Return type

OrderHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryOrderLog

OrderLog QueryOrderLog (int logId)

Get order details by log ID

Example

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

Parameters

NameTypeDescriptionNotes
logIdintlog_id returned from the order placement API

Return type

OrderLog

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionList

PositionList QueryPositionList ()

Query active position list

Example

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

Parameters

This endpoint does not need any parameter.

Return type

PositionList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

UpdatePosition

UpdatePosition UpdatePosition (int positionId, TradFiPositionUpdateRequest tradFiPositionUpdateRequest)

Modify position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiPositionUpdateRequestTradFiPositionUpdateRequest

Return type

UpdatePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

ClosePosition

DeletePosition ClosePosition (int positionId, TradFiClosePositionRequest tradFiClosePositionRequest)

Close position

Example

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

Parameters

NameTypeDescriptionNotes
positionIdintPosition ID
tradFiClosePositionRequestTradFiClosePositionRequest

Return type

DeletePosition

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]

QueryPositionHistoryList

PositionHistoryList QueryPositionHistoryList (long? page = null, long? pageSize = null, long? beginTime = null, long? endTime = null, string symbol = null, string positionDir = null)

Query historical position list

Example

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

Parameters

NameTypeDescriptionNotes
pagelong?Page number; defaults to 1 if omitted.[optional]
pageSizelong?Page size; defaults to 10 if omitted. Maximum 100.[optional]
beginTimelong?Start Time (Unix Timestamp, seconds). The earliest queryable time is one month ago[optional]
endTimelong?End time (timestamp in seconds)[optional]
symbolstringTrading symbol (e.g., EURUSD)[optional]
positionDirstringPosition direction (Long=long position, Short=short position)[optional]

Return type

PositionHistoryList

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Request success-
400Request failed-

[Back to top][Back to API list][Back to Model list][Back to README]