|
|
|
@@ -57,7 +57,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
getOrderBook(
|
|
|
|
getOrderBook(
|
|
|
|
symbol: string,
|
|
|
|
symbol: string,
|
|
|
|
category: string,
|
|
|
|
category: string,
|
|
|
|
limit?: number
|
|
|
|
limit?: number,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.get('/derivatives/v3/public/order-book/L2', {
|
|
|
|
return this.get('/derivatives/v3/public/order-book/L2', {
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
@@ -74,14 +74,14 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
/** Get a symbol price/statistics ticker */
|
|
|
|
/** Get a symbol price/statistics ticker */
|
|
|
|
getSymbolTicker(
|
|
|
|
getSymbolTicker(
|
|
|
|
category: UMCategory,
|
|
|
|
category: UMCategory,
|
|
|
|
symbol?: string
|
|
|
|
symbol?: string,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.get('/derivatives/v3/public/tickers', { category, symbol });
|
|
|
|
return this.get('/derivatives/v3/public/tickers', { category, symbol });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Get trading rules per symbol/contract, incl price/amount/value/leverage filters */
|
|
|
|
/** Get trading rules per symbol/contract, incl price/amount/value/leverage filters */
|
|
|
|
getInstrumentInfo(
|
|
|
|
getInstrumentInfo(
|
|
|
|
params: UMInstrumentInfoRequest
|
|
|
|
params: UMInstrumentInfoRequest,
|
|
|
|
): Promise<APIResponseV3<UMPaginatedResult<UMInstrumentInfo>>> {
|
|
|
|
): Promise<APIResponseV3<UMPaginatedResult<UMInstrumentInfo>>> {
|
|
|
|
return this.get('/derivatives/v3/public/instruments-info', params);
|
|
|
|
return this.get('/derivatives/v3/public/instruments-info', params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -101,18 +101,18 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
* For example, if a request is sent at 12:00 UTC, the funding rate generated earlier that day at 08:00 UTC will be sent.
|
|
|
|
* For example, if a request is sent at 12:00 UTC, the funding rate generated earlier that day at 08:00 UTC will be sent.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
getFundingRateHistory(
|
|
|
|
getFundingRateHistory(
|
|
|
|
params: UMFundingRateHistoryRequest
|
|
|
|
params: UMFundingRateHistoryRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.get(
|
|
|
|
return this.get(
|
|
|
|
'/derivatives/v3/public/funding/history-funding-rate',
|
|
|
|
'/derivatives/v3/public/funding/history-funding-rate',
|
|
|
|
params
|
|
|
|
params,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Get Risk Limit */
|
|
|
|
/** Get Risk Limit */
|
|
|
|
getRiskLimit(
|
|
|
|
getRiskLimit(
|
|
|
|
category: UMCategory,
|
|
|
|
category: UMCategory,
|
|
|
|
symbol: string
|
|
|
|
symbol: string,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.get('/derivatives/v3/public/risk-limit/list', {
|
|
|
|
return this.get('/derivatives/v3/public/risk-limit/list', {
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
@@ -122,7 +122,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
|
|
|
|
|
|
|
|
/** Get option delivery price */
|
|
|
|
/** Get option delivery price */
|
|
|
|
getOptionDeliveryPrice(
|
|
|
|
getOptionDeliveryPrice(
|
|
|
|
params: UMOptionDeliveryPriceRequest
|
|
|
|
params: UMOptionDeliveryPriceRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.get('/derivatives/v3/public/delivery-price', params);
|
|
|
|
return this.get('/derivatives/v3/public/delivery-price', params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -170,7 +170,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
|
|
|
|
|
|
|
|
/** Query order history. As order creation/cancellation is asynchronous, the data returned from the interface may be delayed. To access order information in real-time, call getActiveOrders() */
|
|
|
|
/** Query order history. As order creation/cancellation is asynchronous, the data returned from the interface may be delayed. To access order information in real-time, call getActiveOrders() */
|
|
|
|
getHistoricOrders(
|
|
|
|
getHistoricOrders(
|
|
|
|
params: UMHistoricOrdersRequest
|
|
|
|
params: UMHistoricOrdersRequest,
|
|
|
|
): Promise<APIResponseV3<UMPaginatedResult<UMHistoricOrder>>> {
|
|
|
|
): Promise<APIResponseV3<UMPaginatedResult<UMHistoricOrder>>> {
|
|
|
|
return this.getPrivate('/unified/v3/private/order/list', params);
|
|
|
|
return this.getPrivate('/unified/v3/private/order/list', params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -181,7 +181,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
batchSubmitOrders(
|
|
|
|
batchSubmitOrders(
|
|
|
|
category: UMCategory,
|
|
|
|
category: UMCategory,
|
|
|
|
orders: UMBatchOrder[]
|
|
|
|
orders: UMBatchOrder[],
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate('/unified/v3/private/order/create-batch', {
|
|
|
|
return this.postPrivate('/unified/v3/private/order/create-batch', {
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
@@ -197,7 +197,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
batchReplaceOrders(
|
|
|
|
batchReplaceOrders(
|
|
|
|
category: UMCategory,
|
|
|
|
category: UMCategory,
|
|
|
|
orders: UMBatchOrderReplace[]
|
|
|
|
orders: UMBatchOrderReplace[],
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate('/unified/v3/private/order/replace-batch', {
|
|
|
|
return this.postPrivate('/unified/v3/private/order/replace-batch', {
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
@@ -212,7 +212,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
batchCancelOrders(
|
|
|
|
batchCancelOrders(
|
|
|
|
category: UMCategory,
|
|
|
|
category: UMCategory,
|
|
|
|
orders: UMBatchOrderCancel[]
|
|
|
|
orders: UMBatchOrderCancel[],
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate('/unified/v3/private/order/cancel-batch', {
|
|
|
|
return this.postPrivate('/unified/v3/private/order/cancel-batch', {
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
@@ -226,7 +226,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
* If both futures and options orders are in one request, only the orders matching the category will be operated according to the category type.
|
|
|
|
* If both futures and options orders are in one request, only the orders matching the category will be operated according to the category type.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
cancelAllOrders(
|
|
|
|
cancelAllOrders(
|
|
|
|
params: UMCancelAllOrdersRequest
|
|
|
|
params: UMCancelAllOrdersRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate('/unified/v3/private/order/cancel-all', params);
|
|
|
|
return this.postPrivate('/unified/v3/private/order/cancel-all', params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -246,7 +246,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
category: UMCategory,
|
|
|
|
category: UMCategory,
|
|
|
|
symbol: string,
|
|
|
|
symbol: string,
|
|
|
|
buyLeverage: number,
|
|
|
|
buyLeverage: number,
|
|
|
|
sellLeverage: number
|
|
|
|
sellLeverage: number,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate('/unified/v3/private/position/set-leverage', {
|
|
|
|
return this.postPrivate('/unified/v3/private/position/set-leverage', {
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
@@ -263,7 +263,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
setTPSLMode(
|
|
|
|
setTPSLMode(
|
|
|
|
category: UMCategory,
|
|
|
|
category: UMCategory,
|
|
|
|
symbol: string,
|
|
|
|
symbol: string,
|
|
|
|
tpSlMode: 1 | 0
|
|
|
|
tpSlMode: 1 | 0,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate('/unified/v3/private/position/tpsl/switch-mode', {
|
|
|
|
return this.postPrivate('/unified/v3/private/position/tpsl/switch-mode', {
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
@@ -277,7 +277,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
category: UMCategory,
|
|
|
|
category: UMCategory,
|
|
|
|
symbol: string,
|
|
|
|
symbol: string,
|
|
|
|
riskId: number,
|
|
|
|
riskId: number,
|
|
|
|
positionIdx: number
|
|
|
|
positionIdx: number,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate('/unified/v3/private/position/set-risk-limit', {
|
|
|
|
return this.postPrivate('/unified/v3/private/position/set-risk-limit', {
|
|
|
|
category,
|
|
|
|
category,
|
|
|
|
@@ -295,7 +295,7 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
setTPSL(params: UMSetTPSLRequest): Promise<APIResponseV3<any>> {
|
|
|
|
setTPSL(params: UMSetTPSLRequest): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate(
|
|
|
|
return this.postPrivate(
|
|
|
|
'/unified/v3/private/position/trading-stop',
|
|
|
|
'/unified/v3/private/position/trading-stop',
|
|
|
|
params
|
|
|
|
params,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -304,21 +304,21 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
* There might be multiple filled histories for an order.
|
|
|
|
* There might be multiple filled histories for an order.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
get7DayTradingHistory(
|
|
|
|
get7DayTradingHistory(
|
|
|
|
params: UM7DayTradingHistoryRequest
|
|
|
|
params: UM7DayTradingHistoryRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.getPrivate('/unified/v3/private/execution/list', params);
|
|
|
|
return this.getPrivate('/unified/v3/private/execution/list', params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Query the settlement history, ranked by time in descending order. */
|
|
|
|
/** Query the settlement history, ranked by time in descending order. */
|
|
|
|
getOptionsSettlementHistory(
|
|
|
|
getOptionsSettlementHistory(
|
|
|
|
params: UMOptionsSettlementHistoryRequest
|
|
|
|
params: UMOptionsSettlementHistoryRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.getPrivate('/unified/v3/private/delivery-record', params);
|
|
|
|
return this.getPrivate('/unified/v3/private/delivery-record', params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Query session settlement records, only for USDC perpetual */
|
|
|
|
/** Query session settlement records, only for USDC perpetual */
|
|
|
|
getUSDCPerpetualSettlementHistory(
|
|
|
|
getUSDCPerpetualSettlementHistory(
|
|
|
|
params: UMPerpSettlementHistoryRequest
|
|
|
|
params: UMPerpSettlementHistoryRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.getPrivate('/unified/v3/private/settlement-record', params);
|
|
|
|
return this.getPrivate('/unified/v3/private/settlement-record', params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -338,17 +338,17 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
upgradeToUnifiedMargin(): Promise<APIResponseV3<any>> {
|
|
|
|
upgradeToUnifiedMargin(): Promise<APIResponseV3<any>> {
|
|
|
|
return this.postPrivate(
|
|
|
|
return this.postPrivate(
|
|
|
|
'/unified/v3/private/account/upgrade-unified-account'
|
|
|
|
'/unified/v3/private/account/upgrade-unified-account',
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Query trading history */
|
|
|
|
/** Query trading history */
|
|
|
|
getTransactionLog(
|
|
|
|
getTransactionLog(
|
|
|
|
params: UMTransactionLogRequest
|
|
|
|
params: UMTransactionLogRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.getPrivate(
|
|
|
|
return this.getPrivate(
|
|
|
|
'/unified/v3/private/account/transaction-log',
|
|
|
|
'/unified/v3/private/account/transaction-log',
|
|
|
|
params
|
|
|
|
params,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -359,21 +359,21 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
|
|
|
|
|
|
|
|
/** Exchange Coins */
|
|
|
|
/** Exchange Coins */
|
|
|
|
getCoinExchangeHistory(
|
|
|
|
getCoinExchangeHistory(
|
|
|
|
params?: UMExchangeCoinsRequest
|
|
|
|
params?: UMExchangeCoinsRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.getPrivate(
|
|
|
|
return this.getPrivate(
|
|
|
|
'/asset/v2/private/exchange/exchange-order-all',
|
|
|
|
'/asset/v2/private/exchange/exchange-order-all',
|
|
|
|
params
|
|
|
|
params,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Get Borrow History */
|
|
|
|
/** Get Borrow History */
|
|
|
|
getBorrowHistory(
|
|
|
|
getBorrowHistory(
|
|
|
|
params?: UMBorrowHistoryRequest
|
|
|
|
params?: UMBorrowHistoryRequest,
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
): Promise<APIResponseV3<any>> {
|
|
|
|
return this.getPrivate(
|
|
|
|
return this.getPrivate(
|
|
|
|
'/unified/v3/private/account/borrow-history',
|
|
|
|
'/unified/v3/private/account/borrow-history',
|
|
|
|
params
|
|
|
|
params,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -393,8 +393,4 @@ export class UnifiedMarginClient extends BaseRestClient {
|
|
|
|
getServerTime(): Promise<APIResponseWithTime> {
|
|
|
|
getServerTime(): Promise<APIResponseWithTime> {
|
|
|
|
return this.get('/v2/public/time');
|
|
|
|
return this.get('/v2/public/time');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getAnnouncements(): Promise<APIResponseV3<any>> {
|
|
|
|
|
|
|
|
return this.get('/v2/public/announcement');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|