All URIs are relative to https://api.gateio.ws/api/v4
| Method | HTTP request | Description |
|---|---|---|
| QueryStockUserAssets | GET /stock/users/assets | Query user assets |
| SetStockMarginFeature | PUT /stock/users/margin-feature | Set margin financing availability |
| QueryStockSymbols | GET /stock/symbols | Query symbol list |
| QueryStockSymbolDetail | GET /stock/symbols/detail | Query symbol details |
| QueryStockOrderBook | GET /stock/market/{symbol}/orderbook | Query market order book |
| QueryStockOrderList | GET /stock/orders | Query open order list |
| CreateStockOrder | POST /stock/orders | Create order |
| DeleteAllStockOrders | DELETE /stock/orders | Cancel all open orders |
| QueryStockOrderHistory | GET /stock/orders/history | Query historical order list |
| QueryStockOrderDeals | GET /stock/orders/deals | Query order trade records |
| UpdateStockOrder | PUT /stock/orders/{order_id} | Modify order |
| DeleteStockOrder | DELETE /stock/orders/{order_id} | Cancel order |
| QueryStockPositions | GET /stock/positions | Query current position list |
| CloseStockPosition | POST /stock/positions/close | Close position |
| QueryStockTransactions | GET /stock/transactions | Query transaction records |
| CreateStockTransaction | POST /stock/transactions | Fund transfer |
| QueryStockBalanceRecords | GET /stock/users/balance-records | Query user balance records |
| QueryStockExchanges | GET /stock/exchanges | Query supported exchanges |
| QueryStockFeeRate | GET /stock/fee-rate | Query fee rates for Japanese and Korean stocks |
UserAssetResp2 QueryStockUserAssets (int? pnlCalcType = null, int? pnlCalcPrice = null)
Query user assets
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockUserAssetsExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var pnlCalcType = 1; // int? | PnL calculation cost type. Defaults to average cost price when omitted (1 = average cost price, 2 = diluted cost price) (optional)
var pnlCalcPrice = 1; // int? | PnL calculation price type. Defaults to intraday price when omitted (1 = intraday price, 2 = latest extended-hours price) (optional)
try
{
// Query user assets
UserAssetResp2 result = apiInstance.QueryStockUserAssets(pnlCalcType, pnlCalcPrice);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockUserAssets: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| pnlCalcType | int? | PnL calculation cost type. Defaults to average cost price when omitted (1 = average cost price, 2 = diluted cost price) | [optional] |
| pnlCalcPrice | int? | PnL calculation price type. Defaults to intraday price when omitted (1 = intraday price, 2 = latest extended-hours price) | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
SetMarginFeature SetStockMarginFeature (TradFiSpotSetMarginFeatureRequest tradFiSpotSetMarginFeatureRequest)
Set margin financing availability
Rate limit: 5 requests per second. Enable or disable margin financing for the user.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class SetStockMarginFeatureExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var tradFiSpotSetMarginFeatureRequest = new TradFiSpotSetMarginFeatureRequest(); // TradFiSpotSetMarginFeatureRequest |
try
{
// Set margin financing availability
SetMarginFeature result = apiInstance.SetStockMarginFeature(tradFiSpotSetMarginFeatureRequest);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.SetStockMarginFeature: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiSpotSetMarginFeatureRequest | TradFiSpotSetMarginFeatureRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Symbols2 QueryStockSymbols (string symbols = null, string exchange = null, bool? withDescI18n = null, int? page = null, int? pageSize = null)
Query symbol list
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockSymbolsExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
var apiInstance = new StockApi(config);
var symbols = "AAPL,TSLA"; // string | Symbol list, multiple separated by commas (optional)
var exchange = "us"; // string | Trading market code. - us: US stocks. - hk: Hong Kong stocks. - kr: South Korean stocks. - jp: Japanese stocks. (optional)
var withDescI18n = true; // bool? | Whether to return multilingual symbol description (optional)
var page = 1; // int? | Page number, defaults to 1 (optional)
var pageSize = 100; // int? | Page size, defaults to 10, max 500; server caps at 500 (optional)
try
{
// Query symbol list
Symbols2 result = apiInstance.QueryStockSymbols(symbols, exchange, withDescI18n, page, pageSize);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockSymbols: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbols | string | Symbol list, multiple separated by commas | [optional] |
| exchange | string | Trading market code. - us: US stocks. - hk: Hong Kong stocks. - kr: South Korean stocks. - jp: Japanese stocks. | [optional] |
| withDescI18n | bool? | Whether to return multilingual symbol description | [optional] |
| page | int? | Page number, defaults to 1 | [optional] |
| pageSize | int? | Page size, defaults to 10, max 500; server caps at 500 | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
SymbolDetail QueryStockSymbolDetail (string symbols = null, string exchange = null, int? page = null, int? pageSize = null)
Query symbol details
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockSymbolDetailExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
var apiInstance = new StockApi(config);
var symbols = "AAPL,TSLA"; // string | Symbol list, multiple separated by commas (optional)
var exchange = "us"; // string | Exchange. - us: US stocks. - hk: Hong Kong stocks. - kr: Korean stocks. - jp: Japanese stocks. (optional)
var page = 1; // int? | Page number, defaults to 1 (optional)
var pageSize = 100; // int? | Page size, defaults to 10, max 500; server caps at 500 (optional)
try
{
// Query symbol details
SymbolDetail result = apiInstance.QueryStockSymbolDetail(symbols, exchange, page, pageSize);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockSymbolDetail: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbols | string | Symbol list, multiple separated by commas | [optional] |
| exchange | string | Exchange. - us: US stocks. - hk: Hong Kong stocks. - kr: Korean stocks. - jp: Japanese stocks. | [optional] |
| page | int? | Page number, defaults to 1 | [optional] |
| pageSize | int? | Page size, defaults to 10, max 500; server caps at 500 | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
OrderBook2 QueryStockOrderBook (string symbol)
Query market order book
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockOrderBookExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
var apiInstance = new StockApi(config);
var symbol = "AAPL"; // string | Symbol
try
{
// Query market order book
OrderBook2 result = apiInstance.QueryStockOrderBook(symbol);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockOrderBook: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | string | Symbol |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
OrderList2 QueryStockOrderList (string symbol = null)
Query open order list
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockOrderListExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var symbol = "AAPL"; // string | Symbol (optional)
try
{
// Query open order list
OrderList2 result = apiInstance.QueryStockOrderList(symbol);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockOrderList: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | string | Symbol | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
CreateOrder2 CreateStockOrder (TradFiSpotOrderRequest tradFiSpotOrderRequest)
Create order
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class CreateStockOrderExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var tradFiSpotOrderRequest = new TradFiSpotOrderRequest(); // TradFiSpotOrderRequest |
try
{
// Create order
CreateOrder2 result = apiInstance.CreateStockOrder(tradFiSpotOrderRequest);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.CreateStockOrder: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiSpotOrderRequest | TradFiSpotOrderRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Order placed successfully | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
DeleteOrder DeleteAllStockOrders ()
Cancel all open orders
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class DeleteAllStockOrdersExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
try
{
// Cancel all open orders
DeleteOrder result = apiInstance.DeleteAllStockOrders();
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.DeleteAllStockOrders: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
OrderHistoryList2 QueryStockOrderHistory (string symbol = null, string orderIds = null, int? beginTime = null, int? endTime = null, int? side = null, int? page = null, int? pageSize = null)
Query historical order list
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockOrderHistoryExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var symbol = "AAPL"; // string | Symbol (optional)
var orderIds = "123456,123457"; // string | Order ID list, multiple separated by commas; max 20, each must be a positive integer (optional)
var beginTime = 1769378400; // int? | Start time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. (optional)
var endTime = 1769464800; // int? | End time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. (optional)
var side = 2; // int? | Side (1=sell, 2=buy) (optional)
var page = 1; // int? | Page number, defaults to 1 (optional)
var pageSize = 100; // int? | Page size, defaults to 10, max 500; server caps at 500 (optional)
try
{
// Query historical order list
OrderHistoryList2 result = apiInstance.QueryStockOrderHistory(symbol, orderIds, beginTime, endTime, side, page, pageSize);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockOrderHistory: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | string | Symbol | [optional] |
| orderIds | string | Order ID list, multiple separated by commas; max 20, each must be a positive integer | [optional] |
| beginTime | int? | Start time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. | [optional] |
| endTime | int? | End time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. | [optional] |
| side | int? | Side (1=sell, 2=buy) | [optional] |
| page | int? | Page number, defaults to 1 | [optional] |
| pageSize | int? | Page size, defaults to 10, max 500; server caps at 500 | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
OrderDealList QueryStockOrderDeals (long orderId, int? page = null, int? pageSize = null)
Query order trade records
Rate limit: 5 requests per second. Query the current user's trade records by order ID. price, value, and fee are denominated in the instrument trading currency (for example, USD for US stocks, HKD for Hong Kong stocks, JPY for Japanese stocks, and KRW for Korean stocks). role returns maker or taker.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockOrderDealsExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var orderId = 123456; // long | Order ID
var page = 1; // int? | Page number, defaults to 1 (optional)
var pageSize = 20; // int? | Records per page. Defaults to 10, maximum 100. The server caps values greater than 100 at 100. (optional)
try
{
// Query order trade records
OrderDealList result = apiInstance.QueryStockOrderDeals(orderId, page, pageSize);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockOrderDeals: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | long | Order ID | |
| page | int? | Page number, defaults to 1 | [optional] |
| pageSize | int? | Records per page. Defaults to 10, maximum 100. The server caps values greater than 100 at 100. | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
UpdateOrder2 UpdateStockOrder (long orderId, TradFiSpotOrderUpdateRequest tradFiSpotOrderUpdateRequest)
Modify order
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class UpdateStockOrderExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var orderId = 123456; // long | Order ID
var tradFiSpotOrderUpdateRequest = new TradFiSpotOrderUpdateRequest(); // TradFiSpotOrderUpdateRequest |
try
{
// Modify order
UpdateOrder2 result = apiInstance.UpdateStockOrder(orderId, tradFiSpotOrderUpdateRequest);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.UpdateStockOrder: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | long | Order ID | |
| tradFiSpotOrderUpdateRequest | TradFiSpotOrderUpdateRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
DeleteOrder DeleteStockOrder (long orderId)
Cancel order
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class DeleteStockOrderExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var orderId = 123456; // long | Order ID
try
{
// Cancel order
DeleteOrder result = apiInstance.DeleteStockOrder(orderId);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.DeleteStockOrder: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | long | Order ID |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
PositionList2 QueryStockPositions (int? pnlCalcType = null, int? pnlCalcPrice = null, string symbol = null, string exchange = null)
Query current position list
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockPositionsExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var pnlCalcType = 1; // int? | PnL calculation cost type. Defaults to average cost price when omitted (1 = average cost price, 2 = diluted cost price) (optional)
var pnlCalcPrice = 1; // int? | PnL calculation price type. Defaults to intraday price when omitted (1 = intraday price, 2 = latest extended-hours price) (optional)
var symbol = "AAPL"; // string | Symbol (optional)
var exchange = "us"; // string | Exchange. - us: US stocks. - hk: Hong Kong stocks. - kr: Korean stocks. - jp: Japanese stocks. (optional)
try
{
// Query current position list
PositionList2 result = apiInstance.QueryStockPositions(pnlCalcType, pnlCalcPrice, symbol, exchange);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockPositions: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| pnlCalcType | int? | PnL calculation cost type. Defaults to average cost price when omitted (1 = average cost price, 2 = diluted cost price) | [optional] |
| pnlCalcPrice | int? | PnL calculation price type. Defaults to intraday price when omitted (1 = intraday price, 2 = latest extended-hours price) | [optional] |
| symbol | string | Symbol | [optional] |
| exchange | string | Exchange. - us: US stocks. - hk: Hong Kong stocks. - kr: Korean stocks. - jp: Japanese stocks. | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ClosePosition CloseStockPosition (TradFiSpotClosePositionRequest tradFiSpotClosePositionRequest)
Close position
Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class CloseStockPositionExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var tradFiSpotClosePositionRequest = new TradFiSpotClosePositionRequest(); // TradFiSpotClosePositionRequest |
try
{
// Close position
ClosePosition result = apiInstance.CloseStockPosition(tradFiSpotClosePositionRequest);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.CloseStockPosition: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiSpotClosePositionRequest | TradFiSpotClosePositionRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
TransactionList2 QueryStockTransactions (long? beginTime = null, long? endTime = null, string refId = null, string type = null, int? page = null, int? pageSize = null)
Query transaction records
Rate limit: 5 qps. Query stock account transaction records, including fund transfers, trades, fees, dividends, rewards, and stock transfers.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockTransactionsExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var beginTime = 1769378400; // long? | Start time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. (optional)
var endTime = 1769464800; // long? | End time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. (optional)
var refId = "transfer-202607070001"; // string | Business idempotent ID. When ref_id is provided, the server queries by ref_id, ignoring other parameters such as begin_time, end_time, type, page, page_size (optional)
var type = "deposit"; // string | 流水类型。 - deposit: 资金转入,从现货账户转入到股票账户。 - withdraw: 资金转出,从股票账户转出到现货账户。 - fee: 交易手续费。 - dividend: 分红派息。 - sell: 卖出股票入账。 - buy: 买入股票出账。 - award: 空投奖励。 - stock_transfer_in: 股票转入。 - stock_transfer_out: 股票转出。 (optional)
var page = 1; // int? | Page number, defaults to 1 (optional)
var pageSize = 100; // int? | Page size, defaults to 10, max 500; server caps at 500 (optional)
try
{
// Query transaction records
TransactionList2 result = apiInstance.QueryStockTransactions(beginTime, endTime, refId, type, page, pageSize);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockTransactions: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| beginTime | long? | Start time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. | [optional] |
| endTime | long? | End time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. | [optional] |
| refId | string | Business idempotent ID. When ref_id is provided, the server queries by ref_id, ignoring other parameters such as begin_time, end_time, type, page, page_size | [optional] |
| type | string | 流水类型。 - deposit: 资金转入,从现货账户转入到股票账户。 - withdraw: 资金转出,从股票账户转出到现货账户。 - fee: 交易手续费。 - dividend: 分红派息。 - sell: 卖出股票入账。 - buy: 买入股票出账。 - award: 空投奖励。 - stock_transfer_in: 股票转入。 - stock_transfer_out: 股票转出。 | [optional] |
| page | int? | Page number, defaults to 1 | [optional] |
| pageSize | int? | Page size, defaults to 10, max 500; server caps at 500 | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
CreateTransaction2 CreateStockTransaction (TradFiSpotTransactionRequest tradFiSpotTransactionRequest)
Fund transfer
Rate limit: 5 qps. Fund transfer moves USDT between the spot account and the stock account. - deposit: transfer from the spot account to the stock account. - withdraw: transfer from the stock account to the spot account.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class CreateStockTransactionExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var tradFiSpotTransactionRequest = new TradFiSpotTransactionRequest(); // TradFiSpotTransactionRequest |
try
{
// Fund transfer
CreateTransaction2 result = apiInstance.CreateStockTransaction(tradFiSpotTransactionRequest);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.CreateStockTransaction: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiSpotTransactionRequest | TradFiSpotTransactionRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
BalanceRecordList QueryStockBalanceRecords (string type = null, string business = null, string symbol = null, long? beginTime = null, long? endTime = null, long? startId = null, string sortDirection = null, bool? includeDetail = null, int? page = null, int? pageSize = null)
Query user balance records
Rate limit: 5 requests per second. Query the current user's raw balance records. User scope is derived from the request headers; a query parameter user_id is not supported. - type and business support multiple comma-separated values. - begin_time and end_time filter record creation time in seconds. When both are provided, end_time must be greater than begin_time. - Results are always sorted by primary key id; sort_direction accepts asc or desc. The default is id desc. With start_id and no sort_direction, the order is id asc, and only records with id > start_id are returned for incremental retrieval. - detail is omitted by default and returned only when include_detail=true. - stock_change is parsed from detail.amount for stock quantity records; balance is a cash balance snapshot, not a stock position balance.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockBalanceRecordsExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
config.SetGateApiV4KeyPair("YOUR_API_KEY", "YOUR_API_SECRET");
var apiInstance = new StockApi(config);
var type = "deposit,fee"; // string | Record types, separated by commas (optional)
var business = "transfer,trade"; // string | Business identifiers, separated by commas (optional)
var symbol = "AAPL"; // string | Symbol (optional)
var beginTime = 1769378400; // long? | Start time (Unix timestamp in seconds). When both begin_time and end_time are provided, end_time must be greater than begin_time. (optional)
var endTime = 1769464800; // long? | End time (Unix timestamp in seconds). When both begin_time and end_time are provided, end_time must be greater than begin_time. (optional)
var startId = 1000; // long? | Starting primary key ID for incremental queries. Only records with a greater id are returned. (optional)
var sortDirection = "desc"; // string | Sort direction by primary key id. - asc: Ascending. - desc: Descending. When omitted, defaults to desc without start_id, or asc with start_id. (optional)
var includeDetail = false; // bool? | Whether to return the raw detail field; defaults to false when omitted (optional)
var page = 1; // int? | Page number, defaults to 1 (optional)
var pageSize = 20; // int? | Records per page. Defaults to 10, maximum 100. The server caps values greater than 100 at 100. (optional)
try
{
// Query user balance records
BalanceRecordList result = apiInstance.QueryStockBalanceRecords(type, business, symbol, beginTime, endTime, startId, sortDirection, includeDetail, page, pageSize);
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockBalanceRecords: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| type | string | Record types, separated by commas | [optional] |
| business | string | Business identifiers, separated by commas | [optional] |
| symbol | string | Symbol | [optional] |
| beginTime | long? | Start time (Unix timestamp in seconds). When both begin_time and end_time are provided, end_time must be greater than begin_time. | [optional] |
| endTime | long? | End time (Unix timestamp in seconds). When both begin_time and end_time are provided, end_time must be greater than begin_time. | [optional] |
| startId | long? | Starting primary key ID for incremental queries. Only records with a greater id are returned. | [optional] |
| sortDirection | string | Sort direction by primary key id. - asc: Ascending. - desc: Descending. When omitted, defaults to desc without start_id, or asc with start_id. | [optional] |
| includeDetail | bool? | Whether to return the raw detail field; defaults to false when omitted | [optional] |
| page | int? | Page number, defaults to 1 | [optional] |
| pageSize | int? | Records per page. Defaults to 10, maximum 100. The server caps values greater than 100 at 100. | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Exchanges QueryStockExchanges ()
Query supported exchanges
Query stock spot supported exchanges and whether stock transfers are supported. Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockExchangesExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
var apiInstance = new StockApi(config);
try
{
// Query supported exchanges
Exchanges result = apiInstance.QueryStockExchanges();
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockExchanges: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
FeeRate QueryStockFeeRate ()
Query fee rates for Japanese and Korean stocks
Query fee rates for Japanese and Korean stocks. Rate limit: 5 qps.
using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;
namespace Example
{
public class QueryStockFeeRateExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.gateio.ws/api/v4";
var apiInstance = new StockApi(config);
try
{
// Query fee rates for Japanese and Korean stocks
FeeRate result = apiInstance.QueryStockFeeRate();
Debug.WriteLine(result);
}
catch (GateApiException e)
{
Debug.Print("Exception when calling StockApi.QueryStockFeeRate: " + e.Message);
Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]