feat(): add new futures endpoints & add new req property (clientOid)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"singleQuote": true
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ import {
|
|||||||
FuturesMarginMode,
|
FuturesMarginMode,
|
||||||
FuturesPosition,
|
FuturesPosition,
|
||||||
NewFuturesPlanTrailingStopOrder,
|
NewFuturesPlanTrailingStopOrder,
|
||||||
|
VIPFeeRate,
|
||||||
|
SpotMarketTrade,
|
||||||
|
GetHistoricTradesParams,
|
||||||
|
FuturesMarketTrade,
|
||||||
|
FuturesPlanType,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
@@ -40,7 +45,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Get Symbols : Get basic configuration information of all trading pairs (including rules) */
|
/** Get Symbols : Get basic configuration information of all trading pairs (including rules) */
|
||||||
getSymbols(
|
getSymbols(
|
||||||
productType: FuturesProductType
|
productType: FuturesProductType,
|
||||||
): Promise<APIResponse<FuturesSymbolRule[]>> {
|
): Promise<APIResponse<FuturesSymbolRule[]>> {
|
||||||
return this.get('/api/mix/v1/market/contracts', { productType });
|
return this.get('/api/mix/v1/market/contracts', { productType });
|
||||||
}
|
}
|
||||||
@@ -60,8 +65,33 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
return this.get('/api/mix/v1/market/tickers', { productType });
|
return this.get('/api/mix/v1/market/tickers', { productType });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get Market Trades */
|
/** Get VIP fee rates */
|
||||||
getMarketTrades(symbol: string, limit?: string): Promise<APIResponse<any>> {
|
getVIPFeeRates(): Promise<APIResponse<VIPFeeRate[]>> {
|
||||||
|
return this.get('/api/spot/v1/market/spot-vip-level');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get most recent trades (up to 500, 100 by default) */
|
||||||
|
getRecentTrades(
|
||||||
|
symbol: string,
|
||||||
|
limit?: string,
|
||||||
|
): Promise<APIResponse<FuturesMarketTrade[]>> {
|
||||||
|
return this.get('/api/mix/v1/market/fills', { symbol, limit });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get historic trades, up to 30 days at a time. Same-parameter responses are cached for 10 minutes. */
|
||||||
|
getHistoricTrades(
|
||||||
|
params: GetHistoricTradesParams,
|
||||||
|
): Promise<APIResponse<FuturesMarketTrade[]>> {
|
||||||
|
return this.get('/api/mix/v1/market/fills-history', params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use getRecentTrades() instead. This method will be removed soon.
|
||||||
|
*/
|
||||||
|
getMarketTrades(
|
||||||
|
symbol: string,
|
||||||
|
limit?: string,
|
||||||
|
): Promise<APIResponse<FuturesMarketTrade[]>> {
|
||||||
return this.get('/api/mix/v1/market/fills', { symbol, limit });
|
return this.get('/api/mix/v1/market/fills', { symbol, limit });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,13 +100,15 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
symbol: string,
|
symbol: string,
|
||||||
granularity: KlineInterval,
|
granularity: KlineInterval,
|
||||||
startTime: string,
|
startTime: string,
|
||||||
endTime: string
|
endTime: string,
|
||||||
|
limit?: string,
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
return this.get('/api/mix/v1/market/candles', {
|
return this.get('/api/mix/v1/market/candles', {
|
||||||
symbol,
|
symbol,
|
||||||
granularity,
|
granularity,
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
|
limit,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +127,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
symbol: string,
|
symbol: string,
|
||||||
pageSize?: string,
|
pageSize?: string,
|
||||||
pageNo?: string,
|
pageNo?: string,
|
||||||
nextPage?: boolean
|
nextPage?: boolean,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.get('/api/mix/v1/market/history-fundRate', {
|
return this.get('/api/mix/v1/market/history-fundRate', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -134,7 +166,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
/** Get Single Account */
|
/** Get Single Account */
|
||||||
getAccount(
|
getAccount(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
marginCoin: string
|
marginCoin: string,
|
||||||
): Promise<APIResponse<FuturesAccount>> {
|
): Promise<APIResponse<FuturesAccount>> {
|
||||||
return this.getPrivate('/api/mix/v1/account/account', {
|
return this.getPrivate('/api/mix/v1/account/account', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -147,6 +179,15 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
return this.getPrivate('/api/mix/v1/account/accounts', { productType });
|
return this.getPrivate('/api/mix/v1/account/accounts', { productType });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get Sub Account Contract Assets */
|
||||||
|
getSubAccountContractAssets(
|
||||||
|
productType: FuturesProductType,
|
||||||
|
): Promise<APIResponse<any>> {
|
||||||
|
return this.postPrivate('/api/mix/v1/account/sub-account-contract-assets', {
|
||||||
|
productType,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is only used to calculate the maximum number of positions that can be opened when the user does not hold a position by default.
|
* This interface is only used to calculate the maximum number of positions that can be opened when the user does not hold a position by default.
|
||||||
* The result does not represent the actual number of positions opened.
|
* The result does not represent the actual number of positions opened.
|
||||||
@@ -156,7 +197,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
openPrice: number,
|
openPrice: number,
|
||||||
openAmount: number,
|
openAmount: number,
|
||||||
leverage?: number
|
leverage?: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/account/open-count', {
|
return this.postPrivate('/api/mix/v1/account/open-count', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -172,7 +213,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
symbol: string,
|
symbol: string,
|
||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
leverage: string,
|
leverage: string,
|
||||||
holdSide?: string
|
holdSide?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/account/setLeverage', {
|
return this.postPrivate('/api/mix/v1/account/setLeverage', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -187,7 +228,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
symbol: string,
|
symbol: string,
|
||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
amount: string,
|
amount: string,
|
||||||
holdSide?: string
|
holdSide?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/account/setMargin', {
|
return this.postPrivate('/api/mix/v1/account/setMargin', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -201,7 +242,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
setMarginMode(
|
setMarginMode(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
marginMode: FuturesMarginMode
|
marginMode: FuturesMarginMode,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/account/setMarginMode', {
|
return this.postPrivate('/api/mix/v1/account/setMarginMode', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -210,10 +251,21 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Change Hold Mode */
|
||||||
|
setHoldMode(
|
||||||
|
productType: FuturesProductType,
|
||||||
|
holdMode: 'single_hold' | 'double_hold',
|
||||||
|
): Promise<APIResponse<any>> {
|
||||||
|
return this.postPrivate('/api/mix/v1/account/setPositionMode', {
|
||||||
|
productType,
|
||||||
|
holdMode,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** Get Symbol Position */
|
/** Get Symbol Position */
|
||||||
getPosition(
|
getPosition(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
marginCoin?: string
|
marginCoin?: string,
|
||||||
): Promise<APIResponse<FuturesPosition[]>> {
|
): Promise<APIResponse<FuturesPosition[]>> {
|
||||||
return this.getPrivate('/api/mix/v1/position/singlePosition', {
|
return this.getPrivate('/api/mix/v1/position/singlePosition', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -224,7 +276,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
/** Get All Position */
|
/** Get All Position */
|
||||||
getPositions(
|
getPositions(
|
||||||
productType: FuturesProductType,
|
productType: FuturesProductType,
|
||||||
marginCoin?: string
|
marginCoin?: string,
|
||||||
): Promise<APIResponse<FuturesPosition[]>> {
|
): Promise<APIResponse<FuturesPosition[]>> {
|
||||||
return this.getPrivate('/api/mix/v1/position/allPosition', {
|
return this.getPrivate('/api/mix/v1/position/allPosition', {
|
||||||
productType,
|
productType,
|
||||||
@@ -239,7 +291,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Get Business Account Bill */
|
/** Get Business Account Bill */
|
||||||
getBusinessBill(
|
getBusinessBill(
|
||||||
params: FuturesBusinessBillRequest
|
params: FuturesBusinessBillRequest,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/account/accountBusinessBill', params);
|
return this.getPrivate('/api/mix/v1/account/accountBusinessBill', params);
|
||||||
}
|
}
|
||||||
@@ -259,7 +311,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
batchSubmitOrder(
|
batchSubmitOrder(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
orders: NewBatchFuturesOrder[]
|
orders: NewBatchFuturesOrder[],
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/order/batch-orders', {
|
return this.postPrivate('/api/mix/v1/order/batch-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -272,12 +324,14 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
cancelOrder(
|
cancelOrder(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
orderId: string
|
orderId?: string,
|
||||||
|
clientOid?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/order/cancel-order', {
|
return this.postPrivate('/api/mix/v1/order/cancel-order', {
|
||||||
symbol,
|
symbol,
|
||||||
marginCoin,
|
marginCoin,
|
||||||
orderId,
|
orderId,
|
||||||
|
clientOid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +339,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
batchCancelOrder(
|
batchCancelOrder(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
orderIds: string[]
|
orderIds: string[],
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/order/cancel-batch-orders', {
|
return this.postPrivate('/api/mix/v1/order/cancel-batch-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -294,10 +348,23 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel all futures orders for a symbol
|
||||||
|
*/
|
||||||
|
cancelSymbolOrders(
|
||||||
|
symbol: string,
|
||||||
|
marginCoin: string,
|
||||||
|
): Promise<APIResponse<any>> {
|
||||||
|
return this.postPrivate('/api/mix/v1/order/cancel-symbol-orders', {
|
||||||
|
symbol,
|
||||||
|
marginCoin,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** Cancel All Order */
|
/** Cancel All Order */
|
||||||
cancelAllOrders(
|
cancelAllOrders(
|
||||||
productType: FuturesProductType,
|
productType: FuturesProductType,
|
||||||
marginCoin: string
|
marginCoin: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/order/cancel-all-orders', {
|
return this.postPrivate('/api/mix/v1/order/cancel-all-orders', {
|
||||||
productType,
|
productType,
|
||||||
@@ -313,7 +380,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
/** Get All Open Order */
|
/** Get All Open Order */
|
||||||
getOpenOrders(
|
getOpenOrders(
|
||||||
productType: FuturesProductType,
|
productType: FuturesProductType,
|
||||||
marginCoin: string
|
marginCoin: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/order/marginCoinCurrent', {
|
return this.getPrivate('/api/mix/v1/order/marginCoinCurrent', {
|
||||||
productType,
|
productType,
|
||||||
@@ -328,7 +395,8 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
endTime: string,
|
endTime: string,
|
||||||
pageSize: string,
|
pageSize: string,
|
||||||
lastEndId?: string,
|
lastEndId?: string,
|
||||||
isPre?: boolean
|
isPre?: boolean,
|
||||||
|
clientOid?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/order/history', {
|
return this.getPrivate('/api/mix/v1/order/history', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -337,6 +405,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
pageSize,
|
pageSize,
|
||||||
lastEndId,
|
lastEndId,
|
||||||
isPre,
|
isPre,
|
||||||
|
clientOid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +416,8 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
endTime: string,
|
endTime: string,
|
||||||
pageSize: string,
|
pageSize: string,
|
||||||
lastEndId?: string,
|
lastEndId?: string,
|
||||||
isPre?: boolean
|
isPre?: boolean,
|
||||||
|
clientOid?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/order/historyProductType', {
|
return this.getPrivate('/api/mix/v1/order/historyProductType', {
|
||||||
productType,
|
productType,
|
||||||
@@ -356,6 +426,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
pageSize,
|
pageSize,
|
||||||
lastEndId,
|
lastEndId,
|
||||||
isPre,
|
isPre,
|
||||||
|
clientOid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +434,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
getOrder(
|
getOrder(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
orderId?: string,
|
orderId?: string,
|
||||||
clientOid?: string
|
clientOid?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/order/detail', {
|
return this.getPrivate('/api/mix/v1/order/detail', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -376,7 +447,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
getOrderFills(
|
getOrderFills(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
orderId?: string,
|
orderId?: string,
|
||||||
pagination?: FuturesPagination
|
pagination?: FuturesPagination,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/order/fills', {
|
return this.getPrivate('/api/mix/v1/order/fills', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -388,7 +459,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
/** Get ProductType Order fill detail */
|
/** Get ProductType Order fill detail */
|
||||||
getProductTypeOrderFills(
|
getProductTypeOrderFills(
|
||||||
productType: FuturesProductType,
|
productType: FuturesProductType,
|
||||||
pagination?: FuturesPagination
|
pagination?: FuturesPagination,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/order/allFills', {
|
return this.getPrivate('/api/mix/v1/order/allFills', {
|
||||||
productType: productType.toUpperCase(),
|
productType: productType.toUpperCase(),
|
||||||
@@ -408,7 +479,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Modify Plan Order TPSL */
|
/** Modify Plan Order TPSL */
|
||||||
modifyPlanOrderTPSL(
|
modifyPlanOrderTPSL(
|
||||||
params: ModifyFuturesPlanOrderTPSL
|
params: ModifyFuturesPlanOrderTPSL,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/plan/modifyPlanPreset', params);
|
return this.postPrivate('/api/mix/v1/plan/modifyPlanPreset', params);
|
||||||
}
|
}
|
||||||
@@ -420,37 +491,48 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Place Trailing Stop order */
|
/** Place Trailing Stop order */
|
||||||
submitTrailingStopOrder(
|
submitTrailingStopOrder(
|
||||||
params: NewFuturesPlanTrailingStopOrder
|
params: NewFuturesPlanTrailingStopOrder,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/plan/placeTrailStop', params);
|
return this.postPrivate('/api/mix/v1/plan/placeTrailStop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Place Position TPSL */
|
/** Place Position TPSL */
|
||||||
submitPositionTPSL(
|
submitPositionTPSL(
|
||||||
params: NewFuturesPlanPositionTPSL
|
params: NewFuturesPlanPositionTPSL,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/plan/placePositionsTPSL', params);
|
return this.postPrivate('/api/mix/v1/plan/placePositionsTPSL', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Modify Stop Order */
|
/** Modify Stop Order */
|
||||||
modifyStopOrder(
|
modifyStopOrder(
|
||||||
params: ModifyFuturesPlanStopOrder
|
params: ModifyFuturesPlanStopOrder,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/plan/modifyTPSLPlan', params);
|
return this.postPrivate('/api/mix/v1/plan/modifyTPSLPlan', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cancel Plan Order TPSL */
|
/** Cancel Plan Order TPSL */
|
||||||
cancelPlanOrderTPSL(
|
cancelPlanOrderTPSL(
|
||||||
params: CancelFuturesPlanTPSL
|
params: CancelFuturesPlanTPSL,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/plan/cancelPlan', params);
|
return this.postPrivate('/api/mix/v1/plan/cancelPlan', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Cancel All Trigger Order (TPSL) */
|
||||||
|
cancelAllPlanOrders(
|
||||||
|
productType: FuturesProductType,
|
||||||
|
planType: FuturesPlanType,
|
||||||
|
): Promise<APIResponse<any>> {
|
||||||
|
return this.postPrivate('/api/mix/v1/plan/cancelAllPlan', {
|
||||||
|
productType,
|
||||||
|
planType,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** Get Plan Order (TPSL) List */
|
/** Get Plan Order (TPSL) List */
|
||||||
getPlanOrderTPSLs(
|
getPlanOrderTPSLs(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
isPlan?: string,
|
isPlan?: string,
|
||||||
productType?: FuturesProductType
|
productType?: FuturesProductType,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/plan/currentPlan', {
|
return this.getPrivate('/api/mix/v1/plan/currentPlan', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -461,14 +543,14 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Get History Plan Orders (TPSL) */
|
/** Get History Plan Orders (TPSL) */
|
||||||
getHistoricPlanOrdersTPSL(
|
getHistoricPlanOrdersTPSL(
|
||||||
params: HistoricPlanOrderTPSLRequest
|
params: HistoricPlanOrderTPSLRequest,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/plan/historyPlan', params);
|
return this.getPrivate('/api/mix/v1/plan/historyPlan', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Trade Endpoints
|
* Copy Trade Endpoints
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -477,7 +559,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
symbol: string,
|
symbol: string,
|
||||||
productType: FuturesProductType,
|
productType: FuturesProductType,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
pageNo: number
|
pageNo: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/trace/currentTrack', {
|
return this.getPrivate('/api/mix/v1/trace/currentTrack', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -492,7 +574,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
symbol: string,
|
symbol: string,
|
||||||
productType: FuturesProductType,
|
productType: FuturesProductType,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
pageNo: number
|
pageNo: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/trace/followerOrder', {
|
return this.getPrivate('/api/mix/v1/trace/followerOrder', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -505,7 +587,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
/** Trader Close Position */
|
/** Trader Close Position */
|
||||||
closeCopyTraderPosition(
|
closeCopyTraderPosition(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
trackingNo: string
|
trackingNo: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/trace/closeTrackOrder', {
|
return this.postPrivate('/api/mix/v1/trace/closeTrackOrder', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -520,7 +602,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
changes?: {
|
changes?: {
|
||||||
stopProfitPrice?: number;
|
stopProfitPrice?: number;
|
||||||
stopLossPrice?: number;
|
stopLossPrice?: number;
|
||||||
}
|
},
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/trace/modifyTPSL', {
|
return this.postPrivate('/api/mix/v1/trace/modifyTPSL', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -534,7 +616,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
startTime: string,
|
startTime: string,
|
||||||
endTime: string,
|
endTime: string,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
pageNo: number
|
pageNo: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/trace/historyTrack', {
|
return this.getPrivate('/api/mix/v1/trace/historyTrack', {
|
||||||
startTime,
|
startTime,
|
||||||
@@ -559,7 +641,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
dateMs: string,
|
dateMs: string,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
pageNo: number
|
pageNo: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/trace/profitDateGroupList', {
|
return this.getPrivate('/api/mix/v1/trace/profitDateGroupList', {
|
||||||
marginCoin,
|
marginCoin,
|
||||||
@@ -574,7 +656,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
marginCoin: string,
|
marginCoin: string,
|
||||||
dateMs: string,
|
dateMs: string,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
pageNo: number
|
pageNo: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/trace/profitDateList', {
|
return this.getPrivate('/api/mix/v1/trace/profitDateList', {
|
||||||
marginCoin,
|
marginCoin,
|
||||||
@@ -587,7 +669,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
/** Get Trader Profits Details */
|
/** Get Trader Profits Details */
|
||||||
getCopyTraderProfitDetails(
|
getCopyTraderProfitDetails(
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
pageNo: number
|
pageNo: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/mix/v1/trace/waitProfitDateList', {
|
return this.getPrivate('/api/mix/v1/trace/waitProfitDateList', {
|
||||||
pageSize,
|
pageSize,
|
||||||
@@ -603,7 +685,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
/** Trader Change CopyTrade symbol */
|
/** Trader Change CopyTrade symbol */
|
||||||
setCopyTraderSymbols(
|
setCopyTraderSymbols(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
operation: 'add' | 'delete'
|
operation: 'add' | 'delete',
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/mix/v1/trace/setUpCopySymbols', {
|
return this.postPrivate('/api/mix/v1/trace/setUpCopySymbols', {
|
||||||
symbol,
|
symbol,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
GetHistoricPlanOrdersParams,
|
GetHistoricPlanOrdersParams,
|
||||||
SpotMarketTrade,
|
SpotMarketTrade,
|
||||||
GetHistoricTradesParams,
|
GetHistoricTradesParams,
|
||||||
SpotVIPFeeRate,
|
VIPFeeRate,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
@@ -83,14 +83,14 @@ export class SpotClient extends BaseRestClient {
|
|||||||
/** Get most recent trades (up to 500, 100 by default) */
|
/** Get most recent trades (up to 500, 100 by default) */
|
||||||
getRecentTrades(
|
getRecentTrades(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
limit?: string
|
limit?: string,
|
||||||
): Promise<APIResponse<SpotMarketTrade[]>> {
|
): Promise<APIResponse<SpotMarketTrade[]>> {
|
||||||
return this.get('/api/spot/v1/market/fills', { symbol, limit });
|
return this.get('/api/spot/v1/market/fills', { symbol, limit });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get historic trades, up to 30 days at a time. Same-parameter responses are cached for 10 minutes. */
|
/** Get historic trades, up to 30 days at a time. Same-parameter responses are cached for 10 minutes. */
|
||||||
getHistoricTrades(
|
getHistoricTrades(
|
||||||
params: GetHistoricTradesParams
|
params: GetHistoricTradesParams,
|
||||||
): Promise<APIResponse<SpotMarketTrade[]>> {
|
): Promise<APIResponse<SpotMarketTrade[]>> {
|
||||||
return this.get('/api/spot/v1/market/fills-history', params);
|
return this.get('/api/spot/v1/market/fills-history', params);
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
getMarketTrades(
|
getMarketTrades(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
limit?: string
|
limit?: string,
|
||||||
): Promise<APIResponse<SpotMarketTrade[]>> {
|
): Promise<APIResponse<SpotMarketTrade[]>> {
|
||||||
return this.get('/api/spot/v1/market/fills', { symbol, limit });
|
return this.get('/api/spot/v1/market/fills', { symbol, limit });
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
getCandles(
|
getCandles(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
period: KlineInterval,
|
period: KlineInterval,
|
||||||
pagination?: Pagination
|
pagination?: Pagination,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.get('/api/spot/v1/market/candles', {
|
return this.get('/api/spot/v1/market/candles', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -122,13 +122,13 @@ export class SpotClient extends BaseRestClient {
|
|||||||
getDepth(
|
getDepth(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
type: 'step0' | 'step1' | 'step2' | 'step3' | 'step4' | 'step5',
|
type: 'step0' | 'step1' | 'step2' | 'step3' | 'step4' | 'step5',
|
||||||
limit?: string
|
limit?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.get('/api/spot/v1/market/depth', { symbol, type, limit });
|
return this.get('/api/spot/v1/market/depth', { symbol, type, limit });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get VIP fee rates */
|
/** Get VIP fee rates */
|
||||||
getVIPFeeRates(): Promise<APIResponse<SpotVIPFeeRate[]>> {
|
getVIPFeeRates(): Promise<APIResponse<VIPFeeRate[]>> {
|
||||||
return this.get('/api/spot/v1/market/spot-vip-level');
|
return this.get('/api/spot/v1/market/spot-vip-level');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
coin: string,
|
coin: string,
|
||||||
toUid: string,
|
toUid: string,
|
||||||
amount: string,
|
amount: string,
|
||||||
clientOid?: string
|
clientOid?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/spot/v1/wallet/withdrawal-inner', {
|
return this.postPrivate('/api/spot/v1/wallet/withdrawal-inner', {
|
||||||
coin,
|
coin,
|
||||||
@@ -193,7 +193,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
coin: string,
|
coin: string,
|
||||||
toUid: string,
|
toUid: string,
|
||||||
amount: string,
|
amount: string,
|
||||||
clientOid?: string
|
clientOid?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/spot/v1/wallet/withdrawal-inner-v2', {
|
return this.postPrivate('/api/spot/v1/wallet/withdrawal-inner-v2', {
|
||||||
coin,
|
coin,
|
||||||
@@ -210,7 +210,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
endTime: string,
|
endTime: string,
|
||||||
pageSize?: string,
|
pageSize?: string,
|
||||||
pageNo?: string,
|
pageNo?: string,
|
||||||
clientOid?: string
|
clientOid?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/spot/v1/wallet/withdrawal-list', {
|
return this.getPrivate('/api/spot/v1/wallet/withdrawal-list', {
|
||||||
coin,
|
coin,
|
||||||
@@ -228,7 +228,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
startTime: string,
|
startTime: string,
|
||||||
endTime: string,
|
endTime: string,
|
||||||
pageSize?: string,
|
pageSize?: string,
|
||||||
pageNo?: string
|
pageNo?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/api/spot/v1/wallet/deposit-list', {
|
return this.getPrivate('/api/spot/v1/wallet/deposit-list', {
|
||||||
coin,
|
coin,
|
||||||
@@ -298,7 +298,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
/** Place orders in batches, up to 50 at a time */
|
/** Place orders in batches, up to 50 at a time */
|
||||||
batchSubmitOrder(
|
batchSubmitOrder(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
orderList: NewBatchSpotOrder[]
|
orderList: NewBatchSpotOrder[],
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/spot/v1/trade/batch-orders', {
|
return this.postPrivate('/api/spot/v1/trade/batch-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -331,7 +331,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
/** Cancel order in batch (per symbol) */
|
/** Cancel order in batch (per symbol) */
|
||||||
batchCancelOrder(
|
batchCancelOrder(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
orderIds: string[]
|
orderIds: string[],
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/spot/v1/trade/cancel-batch-orders', {
|
return this.postPrivate('/api/spot/v1/trade/cancel-batch-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -341,11 +341,11 @@ export class SpotClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Cancel order in batch (per symbol). V2 endpoint, supports orderIds or clientOids. */
|
/** Cancel order in batch (per symbol). V2 endpoint, supports orderIds or clientOids. */
|
||||||
batchCancelOrderV2(
|
batchCancelOrderV2(
|
||||||
params: BatchCancelSpotOrderV2
|
params: BatchCancelSpotOrderV2,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/api/spot/v1/trade/cancel-batch-orders-v2',
|
'/api/spot/v1/trade/cancel-batch-orders-v2',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
getOrder(
|
getOrder(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
orderId: string,
|
orderId: string,
|
||||||
clientOrderId?: string
|
clientOrderId?: string,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/spot/v1/trade/orderInfo', {
|
return this.postPrivate('/api/spot/v1/trade/orderInfo', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -370,7 +370,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
/** Get order history for a symbol */
|
/** Get order history for a symbol */
|
||||||
getOrderHistory(
|
getOrderHistory(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
pagination?: Pagination
|
pagination?: Pagination,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/spot/v1/trade/history', {
|
return this.postPrivate('/api/spot/v1/trade/history', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -382,7 +382,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
getOrderFills(
|
getOrderFills(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
orderId: string,
|
orderId: string,
|
||||||
pagination?: Pagination
|
pagination?: Pagination,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/api/spot/v1/trade/fills', {
|
return this.postPrivate('/api/spot/v1/trade/fills', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -393,21 +393,21 @@ export class SpotClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Place plan order */
|
/** Place plan order */
|
||||||
submitPlanOrder(
|
submitPlanOrder(
|
||||||
params: NewSpotPlanOrder
|
params: NewSpotPlanOrder,
|
||||||
): Promise<APIResponse<SpotOrderResult>> {
|
): Promise<APIResponse<SpotOrderResult>> {
|
||||||
return this.postPrivate('/api/spot/v1/plan/placePlan', params);
|
return this.postPrivate('/api/spot/v1/plan/placePlan', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Modify plan order */
|
/** Modify plan order */
|
||||||
modifyPlanOrder(
|
modifyPlanOrder(
|
||||||
params: ModifySpotPlanOrder
|
params: ModifySpotPlanOrder,
|
||||||
): Promise<APIResponse<SpotOrderResult>> {
|
): Promise<APIResponse<SpotOrderResult>> {
|
||||||
return this.postPrivate('/api/spot/v1/plan/modifyPlan', params);
|
return this.postPrivate('/api/spot/v1/plan/modifyPlan', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cancel plan order */
|
/** Cancel plan order */
|
||||||
cancelPlanOrder(
|
cancelPlanOrder(
|
||||||
params: CancelSpotPlanOrderParams
|
params: CancelSpotPlanOrderParams,
|
||||||
): Promise<APIResponse<string>> {
|
): Promise<APIResponse<string>> {
|
||||||
return this.postPrivate('/api/spot/v1/plan/cancelPlan', params);
|
return this.postPrivate('/api/spot/v1/plan/cancelPlan', params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ export interface NewFuturesOrder {
|
|||||||
orderType: FuturesOrderType;
|
orderType: FuturesOrderType;
|
||||||
timeInForceValue?: OrderTimeInForce;
|
timeInForceValue?: OrderTimeInForce;
|
||||||
clientOid?: string;
|
clientOid?: string;
|
||||||
|
reduceOnly?: boolean;
|
||||||
|
reverse?: boolean;
|
||||||
presetTakeProfitPrice?: string;
|
presetTakeProfitPrice?: string;
|
||||||
presetStopLossPrice?: string;
|
presetStopLossPrice?: string;
|
||||||
}
|
}
|
||||||
@@ -82,6 +84,7 @@ export interface NewFuturesPlanOrder {
|
|||||||
clientOid?: string;
|
clientOid?: string;
|
||||||
presetTakeProfitPrice?: string;
|
presetTakeProfitPrice?: string;
|
||||||
presetStopLossPrice?: string;
|
presetStopLossPrice?: string;
|
||||||
|
reduceOnly?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModifyFuturesPlanOrder {
|
export interface ModifyFuturesPlanOrder {
|
||||||
@@ -90,12 +93,13 @@ export interface ModifyFuturesPlanOrder {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
executePrice?: string;
|
executePrice?: string;
|
||||||
triggerPrice: string;
|
triggerPrice: string;
|
||||||
triggerType: string;
|
triggerType: 'fill_price' | 'market_price';
|
||||||
orderType: FuturesOrderType;
|
orderType: FuturesOrderType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModifyFuturesPlanOrderTPSL {
|
export interface ModifyFuturesPlanOrderTPSL {
|
||||||
orderId: string;
|
orderId?: string;
|
||||||
|
clientOid?: string;
|
||||||
marginCoin: string;
|
marginCoin: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
presetTakeProfitPrice?: string;
|
presetTakeProfitPrice?: string;
|
||||||
@@ -113,6 +117,7 @@ export interface NewFuturesPlanStopOrder {
|
|||||||
holdSide: FuturesHoldSide;
|
holdSide: FuturesHoldSide;
|
||||||
size?: string;
|
size?: string;
|
||||||
rangeRate?: string;
|
rangeRate?: string;
|
||||||
|
clientOid?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NewFuturesPlanTrailingStopOrder {
|
export interface NewFuturesPlanTrailingStopOrder {
|
||||||
@@ -123,6 +128,7 @@ export interface NewFuturesPlanTrailingStopOrder {
|
|||||||
size?: string;
|
size?: string;
|
||||||
side: FuturesOrderSide;
|
side: FuturesOrderSide;
|
||||||
rangeRate?: string;
|
rangeRate?: string;
|
||||||
|
clientOid?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NewFuturesPlanPositionTPSL {
|
export interface NewFuturesPlanPositionTPSL {
|
||||||
@@ -130,18 +136,23 @@ export interface NewFuturesPlanPositionTPSL {
|
|||||||
marginCoin: string;
|
marginCoin: string;
|
||||||
planType: FuturesPlanType;
|
planType: FuturesPlanType;
|
||||||
triggerPrice: string;
|
triggerPrice: string;
|
||||||
|
triggerType?: 'fill_price' | 'market_price';
|
||||||
holdSide: FuturesHoldSide;
|
holdSide: FuturesHoldSide;
|
||||||
|
clientOid?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModifyFuturesPlanStopOrder {
|
export interface ModifyFuturesPlanStopOrder {
|
||||||
orderId: string;
|
orderId?: string;
|
||||||
|
clientOid?: string;
|
||||||
marginCoin: string;
|
marginCoin: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
triggerPrice?: string;
|
triggerPrice?: string;
|
||||||
|
planType: FuturesPlanType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CancelFuturesPlanTPSL {
|
export interface CancelFuturesPlanTPSL {
|
||||||
orderId: string;
|
orderId?: string;
|
||||||
|
clientOid?: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
marginCoin: string;
|
marginCoin: string;
|
||||||
planType: FuturesPlanType;
|
planType: FuturesPlanType;
|
||||||
|
|||||||
@@ -9,3 +9,11 @@ export interface Pagination {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc';
|
export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc';
|
||||||
|
|
||||||
|
export interface GetHistoricTradesParams {
|
||||||
|
symbol: string;
|
||||||
|
limit?: string;
|
||||||
|
tradeId?: string;
|
||||||
|
startTime?: string;
|
||||||
|
endTime?: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
import { OrderTimeInForce } from './shared';
|
import { OrderTimeInForce } from './shared';
|
||||||
|
|
||||||
export interface GetHistoricTradesParams {
|
|
||||||
symbol: string;
|
|
||||||
limit?: string;
|
|
||||||
tradeId?: string;
|
|
||||||
startTime?: string;
|
|
||||||
endTime?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type WalletType = 'spot' | 'mix_usdt' | 'mix_usd';
|
export type WalletType = 'spot' | 'mix_usdt' | 'mix_usd';
|
||||||
|
|
||||||
export interface NewWalletTransfer {
|
export interface NewWalletTransfer {
|
||||||
|
|||||||
@@ -4,6 +4,15 @@ import {
|
|||||||
FuturesMarginMode,
|
FuturesMarginMode,
|
||||||
} from '../request';
|
} from '../request';
|
||||||
|
|
||||||
|
export interface FuturesMarketTrade {
|
||||||
|
tradeId: string;
|
||||||
|
price: string;
|
||||||
|
size: string;
|
||||||
|
side: 'buy' | 'sell';
|
||||||
|
timestamp: string;
|
||||||
|
symbol: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface FuturesAccount {
|
export interface FuturesAccount {
|
||||||
marginCoin: string;
|
marginCoin: string;
|
||||||
locked: number;
|
locked: number;
|
||||||
|
|||||||
@@ -4,3 +4,13 @@ export interface APIResponse<T> {
|
|||||||
msg: 'success' | string;
|
msg: 'success' | string;
|
||||||
requestTime: number;
|
requestTime: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface VIPFeeRate {
|
||||||
|
level: number;
|
||||||
|
dealAmount: string;
|
||||||
|
assetAmount: string;
|
||||||
|
takerFeeRate?: string;
|
||||||
|
makerFeeRate?: number;
|
||||||
|
withdrawAmount: string;
|
||||||
|
withdrawAmountUSDT: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,17 +20,6 @@ export interface SymbolRules {
|
|||||||
quantityScale: string;
|
quantityScale: string;
|
||||||
status: string;
|
status: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SpotVIPFeeRate {
|
|
||||||
level: number;
|
|
||||||
dealAmount: string;
|
|
||||||
assetAmount: string;
|
|
||||||
takerFeeRate?: string;
|
|
||||||
makerFeeRate?: number;
|
|
||||||
withdrawAmount: string;
|
|
||||||
withdrawAmountUSDT: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SpotOrderResult {
|
export interface SpotOrderResult {
|
||||||
orderId: string;
|
orderId: string;
|
||||||
clientOrderId: string;
|
clientOrderId: string;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export default abstract class BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
restOptions: RestClientOptions = {},
|
restOptions: RestClientOptions = {},
|
||||||
networkOptions: AxiosRequestConfig = {}
|
networkOptions: AxiosRequestConfig = {},
|
||||||
) {
|
) {
|
||||||
this.options = {
|
this.options = {
|
||||||
recvWindow: 5000,
|
recvWindow: 5000,
|
||||||
@@ -77,7 +77,7 @@ export default abstract class BaseRestClient {
|
|||||||
credentials.some((v) => typeof v === 'string')
|
credentials.some((v) => typeof v === 'string')
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'API Key, Secret & Passphrase are ALL required to use the authenticated REST client'
|
'API Key, Secret & Passphrase are ALL required to use the authenticated REST client',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,11 +109,11 @@ export default abstract class BaseRestClient {
|
|||||||
method: Method,
|
method: Method,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
params?: any,
|
params?: any,
|
||||||
isPublicApi?: boolean
|
isPublicApi?: boolean,
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
// Sanity check to make sure it's only ever prefixed by one forward slash
|
// Sanity check to make sure it's only ever prefixed by one forward slash
|
||||||
const requestUrl = [this.baseUrl, endpoint].join(
|
const requestUrl = [this.baseUrl, endpoint].join(
|
||||||
endpoint.startsWith('/') ? '' : '/'
|
endpoint.startsWith('/') ? '' : '/',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Build a request and handle signature process
|
// Build a request and handle signature process
|
||||||
@@ -122,7 +122,7 @@ export default abstract class BaseRestClient {
|
|||||||
endpoint,
|
endpoint,
|
||||||
requestUrl,
|
requestUrl,
|
||||||
params,
|
params,
|
||||||
isPublicApi
|
isPublicApi,
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.log('full request: ', options);
|
// console.log('full request: ', options);
|
||||||
@@ -188,7 +188,7 @@ export default abstract class BaseRestClient {
|
|||||||
data: T,
|
data: T,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
method: Method,
|
method: Method,
|
||||||
signMethod: SignMethod
|
signMethod: SignMethod,
|
||||||
): Promise<SignedRequest<T>> {
|
): Promise<SignedRequest<T>> {
|
||||||
const timestamp = Date.now();
|
const timestamp = Date.now();
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ export default abstract class BaseRestClient {
|
|||||||
|
|
||||||
console.error(
|
console.error(
|
||||||
new Date(),
|
new Date(),
|
||||||
neverGuard(signMethod, `Unhandled sign method: "${signMessage}"`)
|
neverGuard(signMethod, `Unhandled sign method: "${signMessage}"`),
|
||||||
);
|
);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -239,21 +239,21 @@ export default abstract class BaseRestClient {
|
|||||||
endpoint: string,
|
endpoint: string,
|
||||||
signMethod: SignMethod,
|
signMethod: SignMethod,
|
||||||
params?: TParams,
|
params?: TParams,
|
||||||
isPublicApi?: true
|
isPublicApi?: true,
|
||||||
): Promise<UnsignedRequest<TParams>>;
|
): Promise<UnsignedRequest<TParams>>;
|
||||||
private async prepareSignParams<TParams extends object | undefined>(
|
private async prepareSignParams<TParams extends object | undefined>(
|
||||||
method: Method,
|
method: Method,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
signMethod: SignMethod,
|
signMethod: SignMethod,
|
||||||
params?: TParams,
|
params?: TParams,
|
||||||
isPublicApi?: false | undefined
|
isPublicApi?: false | undefined,
|
||||||
): Promise<SignedRequest<TParams>>;
|
): Promise<SignedRequest<TParams>>;
|
||||||
private async prepareSignParams<TParams extends object | undefined>(
|
private async prepareSignParams<TParams extends object | undefined>(
|
||||||
method: Method,
|
method: Method,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
signMethod: SignMethod,
|
signMethod: SignMethod,
|
||||||
params?: TParams,
|
params?: TParams,
|
||||||
isPublicApi?: boolean
|
isPublicApi?: boolean,
|
||||||
) {
|
) {
|
||||||
if (isPublicApi) {
|
if (isPublicApi) {
|
||||||
return {
|
return {
|
||||||
@@ -275,7 +275,7 @@ export default abstract class BaseRestClient {
|
|||||||
endpoint: string,
|
endpoint: string,
|
||||||
url: string,
|
url: string,
|
||||||
params?: any,
|
params?: any,
|
||||||
isPublicApi?: boolean
|
isPublicApi?: boolean,
|
||||||
): Promise<AxiosRequestConfig> {
|
): Promise<AxiosRequestConfig> {
|
||||||
const options: AxiosRequestConfig = {
|
const options: AxiosRequestConfig = {
|
||||||
...this.globalRequestOptions,
|
...this.globalRequestOptions,
|
||||||
@@ -301,7 +301,7 @@ export default abstract class BaseRestClient {
|
|||||||
endpoint,
|
endpoint,
|
||||||
'bitget',
|
'bitget',
|
||||||
params,
|
params,
|
||||||
isPublicApi
|
isPublicApi,
|
||||||
);
|
);
|
||||||
|
|
||||||
const authHeaders = {
|
const authHeaders = {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ interface WebsocketClientEvents {
|
|||||||
export declare interface WebsocketClient {
|
export declare interface WebsocketClient {
|
||||||
on<U extends keyof WebsocketClientEvents>(
|
on<U extends keyof WebsocketClientEvents>(
|
||||||
event: U,
|
event: U,
|
||||||
listener: WebsocketClientEvents[U]
|
listener: WebsocketClientEvents[U],
|
||||||
): this;
|
): this;
|
||||||
|
|
||||||
emit<U extends keyof WebsocketClientEvents>(
|
emit<U extends keyof WebsocketClientEvents>(
|
||||||
@@ -77,7 +77,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
options: WSClientConfigurableOptions,
|
options: WSClientConfigurableOptions,
|
||||||
logger?: typeof DefaultLogger
|
logger?: typeof DefaultLogger,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
public subscribe(
|
public subscribe(
|
||||||
wsTopics: WsTopicSubscribeEventArgs[] | WsTopicSubscribeEventArgs,
|
wsTopics: WsTopicSubscribeEventArgs[] | WsTopicSubscribeEventArgs,
|
||||||
isPrivateTopic?: boolean
|
isPrivateTopic?: boolean,
|
||||||
) {
|
) {
|
||||||
const topics = Array.isArray(wsTopics) ? wsTopics : [wsTopics];
|
const topics = Array.isArray(wsTopics) ? wsTopics : [wsTopics];
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
return this.requestSubscribeTopics(
|
return this.requestSubscribeTopics(
|
||||||
wsKey,
|
wsKey,
|
||||||
topics.filter((topic) => !isPrivateChannel(topic.channel))
|
topics.filter((topic) => !isPrivateChannel(topic.channel)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return this.requestSubscribeTopics(wsKey, topics);
|
return this.requestSubscribeTopics(wsKey, topics);
|
||||||
@@ -132,11 +132,11 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
if (
|
if (
|
||||||
!this.wsStore.isConnectionState(
|
!this.wsStore.isConnectionState(
|
||||||
wsKey,
|
wsKey,
|
||||||
WsConnectionStateEnum.CONNECTING
|
WsConnectionStateEnum.CONNECTING,
|
||||||
) &&
|
) &&
|
||||||
!this.wsStore.isConnectionState(
|
!this.wsStore.isConnectionState(
|
||||||
wsKey,
|
wsKey,
|
||||||
WsConnectionStateEnum.RECONNECTING
|
WsConnectionStateEnum.RECONNECTING,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return this.connect(wsKey);
|
return this.connect(wsKey);
|
||||||
@@ -151,11 +151,11 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
public unsubscribe(
|
public unsubscribe(
|
||||||
wsTopics: WsTopicSubscribeEventArgs[] | WsTopicSubscribeEventArgs,
|
wsTopics: WsTopicSubscribeEventArgs[] | WsTopicSubscribeEventArgs,
|
||||||
isPrivateTopic?: boolean
|
isPrivateTopic?: boolean,
|
||||||
) {
|
) {
|
||||||
const topics = Array.isArray(wsTopics) ? wsTopics : [wsTopics];
|
const topics = Array.isArray(wsTopics) ? wsTopics : [wsTopics];
|
||||||
topics.forEach((topic) =>
|
topics.forEach((topic) =>
|
||||||
this.wsStore.deleteTopic(getWsKeyForTopic(topic, isPrivateTopic), topic)
|
this.wsStore.deleteTopic(getWsKeyForTopic(topic, isPrivateTopic), topic),
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: should this really happen on each wsKey?? seems weird
|
// TODO: should this really happen on each wsKey?? seems weird
|
||||||
@@ -207,7 +207,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
if (this.wsStore.isWsOpen(wsKey)) {
|
if (this.wsStore.isWsOpen(wsKey)) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
'Refused to connect to ws with existing active connection',
|
'Refused to connect to ws with existing active connection',
|
||||||
{ ...LOGGER_CATEGORY, wsKey }
|
{ ...LOGGER_CATEGORY, wsKey },
|
||||||
);
|
);
|
||||||
return this.wsStore.getWs(wsKey);
|
return this.wsStore.getWs(wsKey);
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
) {
|
) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
'Refused to connect to ws, connection attempt already active',
|
'Refused to connect to ws, connection attempt already active',
|
||||||
{ ...LOGGER_CATEGORY, wsKey }
|
{ ...LOGGER_CATEGORY, wsKey },
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
`${context} due to unexpected response error: "${
|
`${context} due to unexpected response error: "${
|
||||||
error?.msg || error?.message || error
|
error?.msg || error?.message || error
|
||||||
}"`,
|
}"`,
|
||||||
{ ...LOGGER_CATEGORY, wsKey, error }
|
{ ...LOGGER_CATEGORY, wsKey, error },
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
apiKey,
|
apiKey,
|
||||||
apiSecret,
|
apiSecret,
|
||||||
apiPass,
|
apiPass,
|
||||||
recvWindow
|
recvWindow,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.logger.info(`Sending auth request...`, {
|
this.logger.info(`Sending auth request...`, {
|
||||||
@@ -375,7 +375,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
private requestSubscribeTopics(
|
private requestSubscribeTopics(
|
||||||
wsKey: WsKey,
|
wsKey: WsKey,
|
||||||
topics: WsTopicSubscribeEventArgs[]
|
topics: WsTopicSubscribeEventArgs[],
|
||||||
) {
|
) {
|
||||||
if (!topics.length) {
|
if (!topics.length) {
|
||||||
return;
|
return;
|
||||||
@@ -384,7 +384,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
const maxTopicsPerEvent = getMaxTopicsPerSubscribeEvent(wsKey);
|
const maxTopicsPerEvent = getMaxTopicsPerSubscribeEvent(wsKey);
|
||||||
if (maxTopicsPerEvent && topics.length > maxTopicsPerEvent) {
|
if (maxTopicsPerEvent && topics.length > maxTopicsPerEvent) {
|
||||||
this.logger.silly(
|
this.logger.silly(
|
||||||
`Subscribing to topics in batches of ${maxTopicsPerEvent}`
|
`Subscribing to topics in batches of ${maxTopicsPerEvent}`,
|
||||||
);
|
);
|
||||||
for (var i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
for (var i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
||||||
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
||||||
@@ -392,7 +392,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
this.requestSubscribeTopics(wsKey, batch);
|
this.requestSubscribeTopics(wsKey, batch);
|
||||||
}
|
}
|
||||||
this.logger.silly(
|
this.logger.silly(
|
||||||
`Finished batch subscribing to ${topics.length} topics`
|
`Finished batch subscribing to ${topics.length} topics`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -410,7 +410,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
private requestUnsubscribeTopics(
|
private requestUnsubscribeTopics(
|
||||||
wsKey: WsKey,
|
wsKey: WsKey,
|
||||||
topics: WsTopicSubscribeEventArgs[]
|
topics: WsTopicSubscribeEventArgs[],
|
||||||
) {
|
) {
|
||||||
if (!topics.length) {
|
if (!topics.length) {
|
||||||
return;
|
return;
|
||||||
@@ -419,7 +419,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
const maxTopicsPerEvent = getMaxTopicsPerSubscribeEvent(wsKey);
|
const maxTopicsPerEvent = getMaxTopicsPerSubscribeEvent(wsKey);
|
||||||
if (maxTopicsPerEvent && topics.length > maxTopicsPerEvent) {
|
if (maxTopicsPerEvent && topics.length > maxTopicsPerEvent) {
|
||||||
this.logger.silly(
|
this.logger.silly(
|
||||||
`Unsubscribing to topics in batches of ${maxTopicsPerEvent}`
|
`Unsubscribing to topics in batches of ${maxTopicsPerEvent}`,
|
||||||
);
|
);
|
||||||
for (var i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
for (var i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
||||||
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
||||||
@@ -427,7 +427,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
this.requestUnsubscribeTopics(wsKey, batch);
|
this.requestUnsubscribeTopics(wsKey, batch);
|
||||||
}
|
}
|
||||||
this.logger.silly(
|
this.logger.silly(
|
||||||
`Finished batch unsubscribing to ${topics.length} topics`
|
`Finished batch unsubscribing to ${topics.length} topics`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -449,13 +449,13 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
});
|
});
|
||||||
if (!wsKey) {
|
if (!wsKey) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Cannot send message due to no known websocket for this wsKey'
|
'Cannot send message due to no known websocket for this wsKey',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const ws = this.getWs(wsKey);
|
const ws = this.getWs(wsKey);
|
||||||
if (!ws) {
|
if (!ws) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`${wsKey} socket not connected yet, call "connectAll()" first then try again when the "open" event arrives`
|
`${wsKey} socket not connected yet, call "connectAll()" first then try again when the "open" event arrives`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ws.send(wsMessage);
|
ws.send(wsMessage);
|
||||||
@@ -512,13 +512,13 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
// Private topics will be resubscribed to once reconnected
|
// Private topics will be resubscribed to once reconnected
|
||||||
const topics = [...this.wsStore.getTopics(wsKey)];
|
const topics = [...this.wsStore.getTopics(wsKey)];
|
||||||
const publicTopics = topics.filter(
|
const publicTopics = topics.filter(
|
||||||
(topic) => !isPrivateChannel(topic.channel)
|
(topic) => !isPrivateChannel(topic.channel),
|
||||||
);
|
);
|
||||||
this.requestSubscribeTopics(wsKey, publicTopics);
|
this.requestSubscribeTopics(wsKey, publicTopics);
|
||||||
|
|
||||||
this.wsStore.get(wsKey, true)!.activePingTimer = setInterval(
|
this.wsStore.get(wsKey, true)!.activePingTimer = setInterval(
|
||||||
() => this.ping(wsKey),
|
() => this.ping(wsKey),
|
||||||
this.options.pingInterval
|
this.options.pingInterval,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,7 +529,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
|
|
||||||
const topics = [...this.wsStore.getTopics(wsKey)];
|
const topics = [...this.wsStore.getTopics(wsKey)];
|
||||||
const privateTopics = topics.filter((topic) =>
|
const privateTopics = topics.filter((topic) =>
|
||||||
isPrivateChannel(topic.channel)
|
isPrivateChannel(topic.channel),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (privateTopics.length) {
|
if (privateTopics.length) {
|
||||||
@@ -665,7 +665,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
public subscribeTopic(
|
public subscribeTopic(
|
||||||
instType: BitgetInstType,
|
instType: BitgetInstType,
|
||||||
topic: WsTopic,
|
topic: WsTopic,
|
||||||
instId: string = 'default'
|
instId: string = 'default',
|
||||||
) {
|
) {
|
||||||
return this.subscribe({
|
return this.subscribe({
|
||||||
instType,
|
instType,
|
||||||
@@ -683,7 +683,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
public unsubscribeTopic(
|
public unsubscribeTopic(
|
||||||
instType: BitgetInstType,
|
instType: BitgetInstType,
|
||||||
topic: WsTopic,
|
topic: WsTopic,
|
||||||
instId: string = 'default'
|
instId: string = 'default',
|
||||||
) {
|
) {
|
||||||
return this.unsubscribe({
|
return this.unsubscribe({
|
||||||
instType,
|
instType,
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ describe('Private Spot REST API GET Endpoints', () => {
|
|||||||
it('getCurrentPlanOrders()', async () => {
|
it('getCurrentPlanOrders()', async () => {
|
||||||
try {
|
try {
|
||||||
expect(
|
expect(
|
||||||
await api.getCurrentPlanOrders({ symbol, pageSize: '20' })
|
await api.getCurrentPlanOrders({ symbol, pageSize: '20' }),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...sucessEmptyResponseObject(),
|
...sucessEmptyResponseObject(),
|
||||||
data: {
|
data: {
|
||||||
@@ -185,7 +185,7 @@ describe('Private Spot REST API GET Endpoints', () => {
|
|||||||
pageSize: '20',
|
pageSize: '20',
|
||||||
startTime: '1667889483000',
|
startTime: '1667889483000',
|
||||||
endTime: '1668134732000',
|
endTime: '1668134732000',
|
||||||
})
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...sucessEmptyResponseObject(),
|
...sucessEmptyResponseObject(),
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
coin,
|
coin,
|
||||||
fromType: 'spot',
|
fromType: 'spot',
|
||||||
toType: 'mix_usdt',
|
toType: 'mix_usdt',
|
||||||
})
|
}),
|
||||||
).toStrictEqual('');
|
).toStrictEqual('');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// console.error('transfer: ', e);
|
// console.error('transfer: ', e);
|
||||||
@@ -49,7 +49,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
coin,
|
coin,
|
||||||
fromType: 'spot',
|
fromType: 'spot',
|
||||||
toType: 'mix_usdt',
|
toType: 'mix_usdt',
|
||||||
})
|
}),
|
||||||
).toStrictEqual('');
|
).toStrictEqual('');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// console.error('transferV2: ', e);
|
// console.error('transferV2: ', e);
|
||||||
@@ -71,7 +71,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
coin,
|
coin,
|
||||||
fromType: 'spot',
|
fromType: 'spot',
|
||||||
toType: 'mix_usdt',
|
toType: 'mix_usdt',
|
||||||
})
|
}),
|
||||||
).toStrictEqual('');
|
).toStrictEqual('');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// console.error('transferV2: ', e);
|
// console.error('transferV2: ', e);
|
||||||
@@ -90,7 +90,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
coin,
|
coin,
|
||||||
chain: 'TRC20',
|
chain: 'TRC20',
|
||||||
address: `123456`,
|
address: `123456`,
|
||||||
})
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...sucessEmptyResponseObject(),
|
...sucessEmptyResponseObject(),
|
||||||
data: expect.any(Array),
|
data: expect.any(Array),
|
||||||
@@ -110,7 +110,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
coin,
|
coin,
|
||||||
chain: 'TRC20',
|
chain: 'TRC20',
|
||||||
address: `123456`,
|
address: `123456`,
|
||||||
})
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...sucessEmptyResponseObject(),
|
...sucessEmptyResponseObject(),
|
||||||
data: expect.any(Array),
|
data: expect.any(Array),
|
||||||
@@ -158,7 +158,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
orderType: 'market',
|
orderType: 'market',
|
||||||
quantity: '1',
|
quantity: '1',
|
||||||
force: 'normal',
|
force: 'normal',
|
||||||
})
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...sucessEmptyResponseObject(),
|
...sucessEmptyResponseObject(),
|
||||||
data: expect.any(Array),
|
data: expect.any(Array),
|
||||||
@@ -180,7 +180,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
quantity: '1',
|
quantity: '1',
|
||||||
force: 'normal',
|
force: 'normal',
|
||||||
},
|
},
|
||||||
])
|
]),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...sucessEmptyResponseObject(),
|
...sucessEmptyResponseObject(),
|
||||||
data: {
|
data: {
|
||||||
@@ -251,7 +251,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
orderType: 'market',
|
orderType: 'market',
|
||||||
triggerPrice: 100,
|
triggerPrice: 100,
|
||||||
orderId: '123456',
|
orderId: '123456',
|
||||||
})
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...sucessEmptyResponseObject(),
|
...sucessEmptyResponseObject(),
|
||||||
data: expect.any(Array),
|
data: expect.any(Array),
|
||||||
@@ -268,7 +268,7 @@ describe('Private Spot REST API POST Endpoints', () => {
|
|||||||
expect(
|
expect(
|
||||||
await api.cancelPlanOrder({
|
await api.cancelPlanOrder({
|
||||||
orderId: planOrderId || '123456',
|
orderId: planOrderId || '123456',
|
||||||
})
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...sucessEmptyResponseObject(),
|
...sucessEmptyResponseObject(),
|
||||||
data: expect.any(String),
|
data: expect.any(String),
|
||||||
|
|||||||
Reference in New Issue
Block a user