Skip to content

Commit 55c40b3

Browse files
committed
add spot auto order API; trade time in spot currency pair
1 parent cf97934 commit 55c40b3

18 files changed

+948
-78
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## gate-api@4.19.4
1+
## gate-api@4.20.0
22

33
TypeScript NodeJS client for gate-api.
44

@@ -8,7 +8,7 @@ APIv4 provides spot, margin and futures trading operations. There are public API
88

99
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
1010

11-
- API version: 4.19.4
11+
- API version: 4.20.0
1212
- Package version:
1313
- Build package: org.openapitools.codegen.languages.TypeScriptNodeClientCodegen
1414
For more information, please visit [https://www.gate.io/page/contacts](https://www.gate.io/page/contacts)
@@ -214,6 +214,11 @@ Class | Method | HTTP request | Description
214214
*SpotApi* | [**getOrder**](docs/SpotApi.md#getOrder) | **GET** /spot/orders/{order_id} | Get a single order
215215
*SpotApi* | [**cancelOrder**](docs/SpotApi.md#cancelOrder) | **DELETE** /spot/orders/{order_id} | Cancel a single order
216216
*SpotApi* | [**listMyTrades**](docs/SpotApi.md#listMyTrades) | **GET** /spot/my_trades | List personal trading history
217+
*SpotApi* | [**listSpotPriceTriggeredOrders**](docs/SpotApi.md#listSpotPriceTriggeredOrders) | **GET** /spot/price_orders | Retrieve running auto order list
218+
*SpotApi* | [**createSpotPriceTriggeredOrder**](docs/SpotApi.md#createSpotPriceTriggeredOrder) | **POST** /spot/price_orders | Create a price-triggered order
219+
*SpotApi* | [**cancelSpotPriceTriggeredOrderList**](docs/SpotApi.md#cancelSpotPriceTriggeredOrderList) | **DELETE** /spot/price_orders | Cancel all open orders
220+
*SpotApi* | [**getSpotPriceTriggeredOrder**](docs/SpotApi.md#getSpotPriceTriggeredOrder) | **GET** /spot/price_orders/{order_id} | Get a single order
221+
*SpotApi* | [**cancelSpotPriceTriggeredOrder**](docs/SpotApi.md#cancelSpotPriceTriggeredOrder) | **DELETE** /spot/price_orders/{order_id} | Cancel a single order
217222
*WalletApi* | [**getDepositAddress**](docs/WalletApi.md#getDepositAddress) | **GET** /wallet/deposit_address | Generate currency deposit address
218223
*WalletApi* | [**listWithdrawals**](docs/WalletApi.md#listWithdrawals) | **GET** /wallet/withdrawals | Retrieve withdrawal records
219224
*WalletApi* | [**listDeposits**](docs/WalletApi.md#listDeposits) | **GET** /wallet/deposits | Retrieve deposit records
@@ -274,6 +279,9 @@ Class | Method | HTTP request | Description
274279
- [RepayRequest](docs/RepayRequest.md)
275280
- [Repayment](docs/Repayment.md)
276281
- [SpotAccount](docs/SpotAccount.md)
282+
- [SpotPricePutOrder](docs/SpotPricePutOrder.md)
283+
- [SpotPriceTrigger](docs/SpotPriceTrigger.md)
284+
- [SpotPriceTriggeredOrder](docs/SpotPriceTriggeredOrder.md)
277285
- [SubAccountBalance](docs/SubAccountBalance.md)
278286
- [SubAccountTransfer](docs/SubAccountTransfer.md)
279287
- [Ticker](docs/Ticker.md)

api/futuresApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ export class FuturesApi {
14211421
* Zero-fill order cannot be retrieved 60 seconds after cancellation
14221422
* @summary Get a single order
14231423
* @param settle Settle currency
1424-
* @param orderId ID returned on order successfully being created
1424+
* @param orderId Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted.
14251425
*/
14261426
public async getFuturesOrder(
14271427
settle: 'btc' | 'usdt',
@@ -1467,7 +1467,7 @@ export class FuturesApi {
14671467
*
14681468
* @summary Cancel a single order
14691469
* @param settle Settle currency
1470-
* @param orderId ID returned on order successfully being created
1470+
* @param orderId Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted.
14711471
*/
14721472
public async cancelFuturesOrder(
14731473
settle: 'btc' | 'usdt',

api/spotApi.ts

Lines changed: 232 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ import { OpenOrders } from '../model/openOrders';
1919
import { Order } from '../model/order';
2020
import { OrderBook } from '../model/orderBook';
2121
import { SpotAccount } from '../model/spotAccount';
22+
import { SpotPriceTriggeredOrder } from '../model/spotPriceTriggeredOrder';
2223
import { Ticker } from '../model/ticker';
2324
import { Trade } from '../model/trade';
2425
import { TradeFee } from '../model/tradeFee';
26+
import { TriggerOrderResponse } from '../model/triggerOrderResponse';
2527
import { ObjectSerializer } from '../model/models';
2628
import { ApiClient } from './apiClient';
2729
import { AxiosRequestConfig, AxiosResponse } from 'axios';
@@ -710,7 +712,7 @@ export class SpotApi {
710712
/**
711713
*
712714
* @summary Get a single order
713-
* @param orderId ID returned on order successfully being created
715+
* @param orderId Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted.
714716
* @param currencyPair Currency pair
715717
*/
716718
public async getOrder(orderId: string, currencyPair: string): Promise<{ response: AxiosResponse; body: Order }> {
@@ -753,7 +755,7 @@ export class SpotApi {
753755
/**
754756
*
755757
* @summary Cancel a single order
756-
* @param orderId ID returned on order successfully being created
758+
* @param orderId Order ID returned, or user custom ID(i.e., &#x60;text&#x60; field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted.
757759
* @param currencyPair Currency pair
758760
*/
759761
public async cancelOrder(orderId: string, currencyPair: string): Promise<{ response: AxiosResponse; body: Order }> {
@@ -847,4 +849,232 @@ export class SpotApi {
847849
const authSettings = ['apiv4'];
848850
return this.client.request<Array<Trade>>(config, 'Array<Trade>', authSettings);
849851
}
852+
853+
/**
854+
*
855+
* @summary Retrieve running auto order list
856+
* @param status List orders based on status
857+
* @param opts Optional parameters
858+
* @param opts.market 交易市场
859+
* @param opts.account Trading account
860+
* @param opts.limit Maximum number of records returned in one list
861+
* @param opts.offset List offset, starting from 0
862+
*/
863+
public async listSpotPriceTriggeredOrders(
864+
status: 'open' | 'finished',
865+
opts: { market?: string; account?: 'normal' | 'margin'; limit?: number; offset?: number },
866+
): Promise<{ response: AxiosResponse; body: Array<SpotPriceTriggeredOrder> }> {
867+
const localVarPath = this.client.basePath + '/spot/price_orders';
868+
const localVarQueryParameters: any = {};
869+
const localVarHeaderParams: any = (<any>Object).assign({}, this.client.defaultHeaders);
870+
const produces = ['application/json'];
871+
// give precedence to 'application/json'
872+
if (produces.indexOf('application/json') >= 0) {
873+
localVarHeaderParams.Accept = 'application/json';
874+
} else {
875+
localVarHeaderParams.Accept = produces.join(',');
876+
}
877+
878+
// verify required parameter 'status' is not null or undefined
879+
if (status === null || status === undefined) {
880+
throw new Error(
881+
'Required parameter status was null or undefined when calling listSpotPriceTriggeredOrders.',
882+
);
883+
}
884+
885+
opts = opts || {};
886+
localVarQueryParameters['status'] = ObjectSerializer.serialize(status, "'open' | 'finished'");
887+
888+
if (opts.market !== undefined) {
889+
localVarQueryParameters['market'] = ObjectSerializer.serialize(opts.market, 'string');
890+
}
891+
892+
if (opts.account !== undefined) {
893+
localVarQueryParameters['account'] = ObjectSerializer.serialize(opts.account, "'normal' | 'margin'");
894+
}
895+
896+
if (opts.limit !== undefined) {
897+
localVarQueryParameters['limit'] = ObjectSerializer.serialize(opts.limit, 'number');
898+
}
899+
900+
if (opts.offset !== undefined) {
901+
localVarQueryParameters['offset'] = ObjectSerializer.serialize(opts.offset, 'number');
902+
}
903+
904+
const config: AxiosRequestConfig = {
905+
method: 'GET',
906+
params: localVarQueryParameters,
907+
headers: localVarHeaderParams,
908+
url: localVarPath,
909+
};
910+
911+
const authSettings = ['apiv4'];
912+
return this.client.request<Array<SpotPriceTriggeredOrder>>(
913+
config,
914+
'Array<SpotPriceTriggeredOrder>',
915+
authSettings,
916+
);
917+
}
918+
919+
/**
920+
*
921+
* @summary Create a price-triggered order
922+
* @param spotPriceTriggeredOrder
923+
*/
924+
public async createSpotPriceTriggeredOrder(
925+
spotPriceTriggeredOrder: SpotPriceTriggeredOrder,
926+
): Promise<{ response: AxiosResponse; body: TriggerOrderResponse }> {
927+
const localVarPath = this.client.basePath + '/spot/price_orders';
928+
const localVarQueryParameters: any = {};
929+
const localVarHeaderParams: any = (<any>Object).assign({}, this.client.defaultHeaders);
930+
const produces = ['application/json'];
931+
// give precedence to 'application/json'
932+
if (produces.indexOf('application/json') >= 0) {
933+
localVarHeaderParams.Accept = 'application/json';
934+
} else {
935+
localVarHeaderParams.Accept = produces.join(',');
936+
}
937+
938+
// verify required parameter 'spotPriceTriggeredOrder' is not null or undefined
939+
if (spotPriceTriggeredOrder === null || spotPriceTriggeredOrder === undefined) {
940+
throw new Error(
941+
'Required parameter spotPriceTriggeredOrder was null or undefined when calling createSpotPriceTriggeredOrder.',
942+
);
943+
}
944+
945+
const config: AxiosRequestConfig = {
946+
method: 'POST',
947+
params: localVarQueryParameters,
948+
headers: localVarHeaderParams,
949+
url: localVarPath,
950+
data: ObjectSerializer.serialize(spotPriceTriggeredOrder, 'SpotPriceTriggeredOrder'),
951+
};
952+
953+
const authSettings = ['apiv4'];
954+
return this.client.request<TriggerOrderResponse>(config, 'TriggerOrderResponse', authSettings);
955+
}
956+
957+
/**
958+
*
959+
* @summary Cancel all open orders
960+
* @param opts Optional parameters
961+
* @param opts.market 交易市场
962+
* @param opts.account Trading account
963+
*/
964+
public async cancelSpotPriceTriggeredOrderList(opts: {
965+
market?: string;
966+
account?: 'normal' | 'margin';
967+
}): Promise<{ response: AxiosResponse; body: Array<SpotPriceTriggeredOrder> }> {
968+
const localVarPath = this.client.basePath + '/spot/price_orders';
969+
const localVarQueryParameters: any = {};
970+
const localVarHeaderParams: any = (<any>Object).assign({}, this.client.defaultHeaders);
971+
const produces = ['application/json'];
972+
// give precedence to 'application/json'
973+
if (produces.indexOf('application/json') >= 0) {
974+
localVarHeaderParams.Accept = 'application/json';
975+
} else {
976+
localVarHeaderParams.Accept = produces.join(',');
977+
}
978+
979+
opts = opts || {};
980+
if (opts.market !== undefined) {
981+
localVarQueryParameters['market'] = ObjectSerializer.serialize(opts.market, 'string');
982+
}
983+
984+
if (opts.account !== undefined) {
985+
localVarQueryParameters['account'] = ObjectSerializer.serialize(opts.account, "'normal' | 'margin'");
986+
}
987+
988+
const config: AxiosRequestConfig = {
989+
method: 'DELETE',
990+
params: localVarQueryParameters,
991+
headers: localVarHeaderParams,
992+
url: localVarPath,
993+
};
994+
995+
const authSettings = ['apiv4'];
996+
return this.client.request<Array<SpotPriceTriggeredOrder>>(
997+
config,
998+
'Array<SpotPriceTriggeredOrder>',
999+
authSettings,
1000+
);
1001+
}
1002+
1003+
/**
1004+
*
1005+
* @summary Get a single order
1006+
* @param orderId ID returned on order successfully being created
1007+
*/
1008+
public async getSpotPriceTriggeredOrder(
1009+
orderId: string,
1010+
): Promise<{ response: AxiosResponse; body: SpotPriceTriggeredOrder }> {
1011+
const localVarPath =
1012+
this.client.basePath +
1013+
'/spot/price_orders/{order_id}'.replace('{' + 'order_id' + '}', encodeURIComponent(String(orderId)));
1014+
const localVarQueryParameters: any = {};
1015+
const localVarHeaderParams: any = (<any>Object).assign({}, this.client.defaultHeaders);
1016+
const produces = ['application/json'];
1017+
// give precedence to 'application/json'
1018+
if (produces.indexOf('application/json') >= 0) {
1019+
localVarHeaderParams.Accept = 'application/json';
1020+
} else {
1021+
localVarHeaderParams.Accept = produces.join(',');
1022+
}
1023+
1024+
// verify required parameter 'orderId' is not null or undefined
1025+
if (orderId === null || orderId === undefined) {
1026+
throw new Error(
1027+
'Required parameter orderId was null or undefined when calling getSpotPriceTriggeredOrder.',
1028+
);
1029+
}
1030+
1031+
const config: AxiosRequestConfig = {
1032+
method: 'GET',
1033+
params: localVarQueryParameters,
1034+
headers: localVarHeaderParams,
1035+
url: localVarPath,
1036+
};
1037+
1038+
const authSettings = ['apiv4'];
1039+
return this.client.request<SpotPriceTriggeredOrder>(config, 'SpotPriceTriggeredOrder', authSettings);
1040+
}
1041+
1042+
/**
1043+
*
1044+
* @summary Cancel a single order
1045+
* @param orderId ID returned on order successfully being created
1046+
*/
1047+
public async cancelSpotPriceTriggeredOrder(
1048+
orderId: string,
1049+
): Promise<{ response: AxiosResponse; body: SpotPriceTriggeredOrder }> {
1050+
const localVarPath =
1051+
this.client.basePath +
1052+
'/spot/price_orders/{order_id}'.replace('{' + 'order_id' + '}', encodeURIComponent(String(orderId)));
1053+
const localVarQueryParameters: any = {};
1054+
const localVarHeaderParams: any = (<any>Object).assign({}, this.client.defaultHeaders);
1055+
const produces = ['application/json'];
1056+
// give precedence to 'application/json'
1057+
if (produces.indexOf('application/json') >= 0) {
1058+
localVarHeaderParams.Accept = 'application/json';
1059+
} else {
1060+
localVarHeaderParams.Accept = produces.join(',');
1061+
}
1062+
1063+
// verify required parameter 'orderId' is not null or undefined
1064+
if (orderId === null || orderId === undefined) {
1065+
throw new Error(
1066+
'Required parameter orderId was null or undefined when calling cancelSpotPriceTriggeredOrder.',
1067+
);
1068+
}
1069+
1070+
const config: AxiosRequestConfig = {
1071+
method: 'DELETE',
1072+
params: localVarQueryParameters,
1073+
headers: localVarHeaderParams,
1074+
url: localVarPath,
1075+
};
1076+
1077+
const authSettings = ['apiv4'];
1078+
return this.client.request<SpotPriceTriggeredOrder>(config, 'SpotPriceTriggeredOrder', authSettings);
1079+
}
8501080
}

docs/CancelOrder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**currencyPair** | **string** | Order currency pair | [default to undefined]
8-
**id** | **string** | Order ID | [default to undefined]
8+
**id** | **string** | Order ID or user custom ID. Custom ID are accepted only within 30 minutes after order creation | [default to undefined]
99

docs/CurrencyPair.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Name | Type | Description | Notes
1313
**amountPrecision** | **number** | Amount scale | [optional] [default to undefined]
1414
**precision** | **number** | Price scale | [optional] [default to undefined]
1515
**tradeStatus** | **string** | How currency pair can be traded - untradable: cannot be bought or sold - buyable: can be bought - sellable: can be sold - tradable: can be bought or sold | [optional] [default to undefined]
16+
**sellStart** | **number** | 允许卖出时间,秒级 Unix 时间戳 | [optional] [default to undefined]
17+
**buyStart** | **number** | 允许买入时间,秒级 Unix 时间戳 | [optional] [default to undefined]
1618

1719
## Enum: CurrencyPair.TradeStatus
1820

docs/FuturesApi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
12621262

12631263
const api = new GateApi.FuturesApi(client);
12641264
const settle = "usdt"; // 'btc' | 'usdt' | Settle currency
1265-
const orderId = "12345"; // string | ID returned on order successfully being created
1265+
const orderId = "12345"; // string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted.
12661266
api.getFuturesOrder(settle, orderId)
12671267
.then(value => console.log('API called successfully. Returned data: ', value.body),
12681268
error => console.error(error));
@@ -1274,7 +1274,7 @@ api.getFuturesOrder(settle, orderId)
12741274
Name | Type | Description | Notes
12751275
------------- | ------------- | ------------- | -------------
12761276
**settle** | **Settle**| Settle currency | [default to undefined]
1277-
**orderId** | **string**| ID returned on order successfully being created | [default to undefined]
1277+
**orderId** | **string**| Order ID returned, or user custom ID(i.e., &#x60;text&#x60; field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. | [default to undefined]
12781278

12791279
### Return type
12801280

@@ -1307,7 +1307,7 @@ client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
13071307

13081308
const api = new GateApi.FuturesApi(client);
13091309
const settle = "usdt"; // 'btc' | 'usdt' | Settle currency
1310-
const orderId = "12345"; // string | ID returned on order successfully being created
1310+
const orderId = "12345"; // string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted.
13111311
api.cancelFuturesOrder(settle, orderId)
13121312
.then(value => console.log('API called successfully. Returned data: ', value.body),
13131313
error => console.error(error));
@@ -1319,7 +1319,7 @@ api.cancelFuturesOrder(settle, orderId)
13191319
Name | Type | Description | Notes
13201320
------------- | ------------- | ------------- | -------------
13211321
**settle** | **Settle**| Settle currency | [default to undefined]
1322-
**orderId** | **string**| ID returned on order successfully being created | [default to undefined]
1322+
**orderId** | **string**| Order ID returned, or user custom ID(i.e., &#x60;text&#x60; field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. | [default to undefined]
13231323

13241324
### Return type
13251325

0 commit comments

Comments
 (0)