feat(#261): add missing tpsl req/response types
This commit is contained in:
@@ -54,7 +54,7 @@ export class ContractClient 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,
|
||||||
@@ -71,14 +71,14 @@ export class ContractClient 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<ContractListResult<ContractSymbolTicker>>> {
|
): Promise<APIResponseV3<ContractListResult<ContractSymbolTicker>>> {
|
||||||
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<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/derivatives/v3/public/instruments-info', params);
|
return this.get('/derivatives/v3/public/instruments-info', params);
|
||||||
}
|
}
|
||||||
@@ -98,18 +98,18 @@ export class ContractClient 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,
|
||||||
@@ -119,7 +119,7 @@ export class ContractClient 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);
|
||||||
}
|
}
|
||||||
@@ -150,9 +150,14 @@ export class ContractClient extends BaseRestClient {
|
|||||||
return this.postPrivate('/contract/v3/private/order/create', params);
|
return this.postPrivate('/contract/v3/private/order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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: ContractHistoricOrdersRequest
|
params: ContractHistoricOrdersRequest,
|
||||||
): Promise<APIResponseV3<PaginatedResult<ContractHistoricOrder>>> {
|
): Promise<APIResponseV3<PaginatedResult<ContractHistoricOrder>>> {
|
||||||
return this.getPrivate('/contract/v3/private/order/list', params);
|
return this.getPrivate('/contract/v3/private/order/list', params);
|
||||||
}
|
}
|
||||||
@@ -169,18 +174,25 @@ export class ContractClient extends BaseRestClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Replace order : Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time. Please request modification separately. */
|
/**
|
||||||
|
* Replace order
|
||||||
|
*
|
||||||
|
* Active order parameters (such as quantity, price) and stop order parameters
|
||||||
|
* cannot be modified in one request at the same time.
|
||||||
|
*
|
||||||
|
* Please request modification separately.
|
||||||
|
*/
|
||||||
modifyOrder(params: ContractModifyOrderRequest): Promise<APIResponseV3<any>> {
|
modifyOrder(params: ContractModifyOrderRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate('/contract/v3/private/order/replace', params);
|
return this.postPrivate('/contract/v3/private/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query Open Order(s) (real-time) */
|
/** Query Open Order(s) (real-time) */
|
||||||
getActiveOrders(
|
getActiveOrders(
|
||||||
params: ContractActiveOrdersRequest
|
params: ContractActiveOrdersRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/contract/v3/private/order/unfilled-orders',
|
'/contract/v3/private/order/unfilled-orders',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,31 +209,31 @@ export class ContractClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Set auto add margin, or Auto-Margin Replenishment. */
|
/** Set auto add margin, or Auto-Margin Replenishment. */
|
||||||
setAutoAddMargin(
|
setAutoAddMargin(
|
||||||
params: ContractSetAutoAddMarginRequest
|
params: ContractSetAutoAddMarginRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/contract/v3/private/position/set-auto-add-margin',
|
'/contract/v3/private/position/set-auto-add-margin',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Switch cross margin mode/isolated margin mode */
|
/** Switch cross margin mode/isolated margin mode */
|
||||||
setMarginSwitch(
|
setMarginSwitch(
|
||||||
params: ContractSetMarginSwitchRequest
|
params: ContractSetMarginSwitchRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/contract/v3/private/position/switch-isolated',
|
'/contract/v3/private/position/switch-isolated',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Supports switching between One-Way Mode and Hedge Mode at the coin level. */
|
/** Supports switching between One-Way Mode and Hedge Mode at the coin level. */
|
||||||
setPositionMode(
|
setPositionMode(
|
||||||
params: ContractSetPositionModeRequest
|
params: ContractSetPositionModeRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/contract/v3/private/position/switch-mode',
|
'/contract/v3/private/position/switch-mode',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +242,7 @@ export class ContractClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
setTPSLMode(
|
setTPSLMode(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
tpSlMode: 'Full' | 'Partial'
|
tpSlMode: 'Full' | 'Partial',
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate('/contract/v3/private/position/switch-tpsl-mode', {
|
return this.postPrivate('/contract/v3/private/position/switch-tpsl-mode', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -242,7 +254,7 @@ export class ContractClient extends BaseRestClient {
|
|||||||
setLeverage(
|
setLeverage(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
buyLeverage: string,
|
buyLeverage: string,
|
||||||
sellLeverage: string
|
sellLeverage: string,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate('/contract/v3/private/position/set-leverage', {
|
return this.postPrivate('/contract/v3/private/position/set-leverage', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -258,7 +270,7 @@ export class ContractClient extends BaseRestClient {
|
|||||||
setTPSL(params: ContractSetTPSLRequest): Promise<APIResponseV3<any>> {
|
setTPSL(params: ContractSetTPSLRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/contract/v3/private/position/trading-stop',
|
'/contract/v3/private/position/trading-stop',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +279,7 @@ export class ContractClient extends BaseRestClient {
|
|||||||
symbol: string,
|
symbol: string,
|
||||||
riskId: number,
|
riskId: number,
|
||||||
/** 0-one-way, 1-buy side, 2-sell side */
|
/** 0-one-way, 1-buy side, 2-sell side */
|
||||||
positionIdx: 0 | 1 | 2
|
positionIdx: 0 | 1 | 2,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate('/contract/v3/private/position/set-risk-limit', {
|
return this.postPrivate('/contract/v3/private/position/set-risk-limit', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -281,7 +293,7 @@ export class ContractClient extends BaseRestClient {
|
|||||||
* The results are ordered in descending order (the first item is the latest). Returns records up to 2 years old.
|
* The results are ordered in descending order (the first item is the latest). Returns records up to 2 years old.
|
||||||
*/
|
*/
|
||||||
getUserExecutionHistory(
|
getUserExecutionHistory(
|
||||||
params: ContractUserExecutionHistoryRequest
|
params: ContractUserExecutionHistoryRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate('/contract/v3/private/execution/list', params);
|
return this.getPrivate('/contract/v3/private/execution/list', params);
|
||||||
}
|
}
|
||||||
@@ -291,7 +303,7 @@ export class ContractClient extends BaseRestClient {
|
|||||||
* The results are ordered in descending order (the first item is the latest).
|
* The results are ordered in descending order (the first item is the latest).
|
||||||
*/
|
*/
|
||||||
getClosedProfitAndLoss(
|
getClosedProfitAndLoss(
|
||||||
params: ContractClosedPNLRequest
|
params: ContractClosedPNLRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate('/contract/v3/private/position/closed-pnl', params);
|
return this.getPrivate('/contract/v3/private/position/closed-pnl', params);
|
||||||
}
|
}
|
||||||
@@ -321,16 +333,18 @@ export class ContractClient extends BaseRestClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get wallet fund records.
|
* Get wallet fund records.
|
||||||
* This endpoint also shows exchanges from the Asset Exchange, where the types for the exchange are ExchangeOrderWithdraw and ExchangeOrderDeposit.
|
* This endpoint also shows exchanges from the Asset Exchange,
|
||||||
|
* where the types for the exchange are ExchangeOrderWithdraw and ExchangeOrderDeposit.
|
||||||
|
*
|
||||||
* This endpoint returns incomplete information for transfers involving the derivatives wallet.
|
* This endpoint returns incomplete information for transfers involving the derivatives wallet.
|
||||||
* Use the account asset API for creating and querying internal transfers.
|
* Use the account asset API for creating and querying internal transfers.
|
||||||
*/
|
*/
|
||||||
getWalletFundRecords(
|
getWalletFundRecords(
|
||||||
params?: ContractWalletFundRecordRequest
|
params?: ContractWalletFundRecordRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/contract/v3/private/account/wallet/fund-records',
|
'/contract/v3/private/account/wallet/fund-records',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,21 +5,24 @@ import { USDCOrderFilter, USDCTimeInForce } from './usdc-shared';
|
|||||||
export interface ContractOrderRequest {
|
export interface ContractOrderRequest {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
side: OrderSide;
|
side: OrderSide;
|
||||||
positionIdx?: '0' | '1' | '2';
|
|
||||||
orderType: UMOrderType;
|
orderType: UMOrderType;
|
||||||
qty: string;
|
qty: string;
|
||||||
|
timeInForce: USDCTimeInForce;
|
||||||
price?: string;
|
price?: string;
|
||||||
triggerDirection?: '1' | '2';
|
triggerDirection?: '1' | '2';
|
||||||
triggerPrice?: string;
|
triggerPrice?: string;
|
||||||
triggerBy?: string;
|
triggerBy?: string;
|
||||||
tpTriggerBy?: string;
|
positionIdx?: '0' | '1' | '2';
|
||||||
slTriggerBy?: string;
|
|
||||||
timeInForce: USDCTimeInForce;
|
|
||||||
orderLinkId?: string;
|
orderLinkId?: string;
|
||||||
takeProfit?: string;
|
takeProfit?: string;
|
||||||
stopLoss?: string;
|
stopLoss?: string;
|
||||||
|
tpTriggerBy?: string;
|
||||||
|
slTriggerBy?: string;
|
||||||
reduceOnly?: boolean;
|
reduceOnly?: boolean;
|
||||||
closeOnTrigger?: boolean;
|
closeOnTrigger?: boolean;
|
||||||
|
tpslMode?: 'Partial' | 'Full';
|
||||||
|
tpOrderType?: UMOrderType;
|
||||||
|
slOrderType?: UMOrderType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContractHistoricOrdersRequest {
|
export interface ContractHistoricOrdersRequest {
|
||||||
@@ -39,17 +42,19 @@ export interface ContractCancelOrderRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ContractModifyOrderRequest {
|
export interface ContractModifyOrderRequest {
|
||||||
|
symbol: string;
|
||||||
orderId?: string;
|
orderId?: string;
|
||||||
orderLinkId?: string;
|
orderLinkId?: string;
|
||||||
symbol: string;
|
|
||||||
qty?: string;
|
|
||||||
price?: string;
|
price?: string;
|
||||||
|
qty?: string;
|
||||||
|
triggerPrice?: string;
|
||||||
takeProfit?: string;
|
takeProfit?: string;
|
||||||
stopLoss?: string;
|
stopLoss?: string;
|
||||||
tpTriggerBy?: string;
|
tpTriggerBy?: string;
|
||||||
slTriggerBy?: string;
|
slTriggerBy?: string;
|
||||||
triggerBy?: string;
|
triggerBy?: string;
|
||||||
triggerPrice?: string;
|
tpLimitPrice?: string;
|
||||||
|
slLimitPrice?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContractActiveOrdersRequest {
|
export interface ContractActiveOrdersRequest {
|
||||||
@@ -91,12 +96,17 @@ export interface ContractSetTPSLRequest {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
takeProfit?: string;
|
takeProfit?: string;
|
||||||
stopLoss?: string;
|
stopLoss?: string;
|
||||||
activePrice?: string;
|
tpslMode?: 'Full' | 'Partial';
|
||||||
trailingStop?: string;
|
tpSize?: string;
|
||||||
|
slSize?: string;
|
||||||
tpTriggerBy?: string;
|
tpTriggerBy?: string;
|
||||||
slTriggerBy?: string;
|
slTriggerBy?: string;
|
||||||
slSize?: string;
|
trailingStop?: string;
|
||||||
tpSize?: string;
|
activePrice?: string;
|
||||||
|
tpLimitPrice?: string;
|
||||||
|
slLimitPrice?: string;
|
||||||
|
tpOrderType?: UMOrderType;
|
||||||
|
slOrderType?: UMOrderType;
|
||||||
/** 0-one-way, 1-buy side, 2-sell side */
|
/** 0-one-way, 1-buy side, 2-sell side */
|
||||||
positionIdx?: 0 | 1 | 2;
|
positionIdx?: 0 | 1 | 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,33 +10,43 @@ export interface ContractListResult<TList = any> {
|
|||||||
|
|
||||||
export interface ContractHistoricOrder {
|
export interface ContractHistoricOrder {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
|
orderId: string;
|
||||||
|
orderLinkId: string;
|
||||||
side: string;
|
side: string;
|
||||||
orderType: string;
|
orderType: string;
|
||||||
price: string;
|
price: string;
|
||||||
|
iv: string;
|
||||||
qty: string;
|
qty: string;
|
||||||
reduceOnly: boolean;
|
|
||||||
timeInForce: string;
|
timeInForce: string;
|
||||||
orderStatus: string;
|
orderStatus: string;
|
||||||
leavesQty: string;
|
positionIdx: number;
|
||||||
leavesValue: string;
|
|
||||||
cumExecQty: string;
|
|
||||||
cumExecValue: string;
|
|
||||||
cumExecFee: string;
|
|
||||||
lastPriceOnCreated: string;
|
lastPriceOnCreated: string;
|
||||||
rejectReason: string;
|
|
||||||
orderLinkId: string;
|
|
||||||
createdTime: string;
|
createdTime: string;
|
||||||
updatedTime: string;
|
updatedTime: string;
|
||||||
orderId: string;
|
cancelType: string;
|
||||||
|
rejectReason: string;
|
||||||
stopOrderType: string;
|
stopOrderType: string;
|
||||||
|
triggerDirection: number;
|
||||||
|
triggerBy: string;
|
||||||
|
triggerPrice: string;
|
||||||
|
cumExecValue: string;
|
||||||
|
cumExecFee: string;
|
||||||
|
cumExecQty: string;
|
||||||
|
leavesValue: string;
|
||||||
|
leavesQty: string;
|
||||||
takeProfit: string;
|
takeProfit: string;
|
||||||
stopLoss: string;
|
stopLoss: string;
|
||||||
|
tpslMode: string;
|
||||||
|
tpLimitPrice: string;
|
||||||
|
slLimitPrice: string;
|
||||||
tpTriggerBy: string;
|
tpTriggerBy: string;
|
||||||
slTriggerBy: string;
|
slTriggerBy: string;
|
||||||
triggerPrice: string;
|
reduceOnly: boolean;
|
||||||
closeOnTrigger: boolean;
|
closeOnTrigger: boolean;
|
||||||
triggerDirection: number;
|
blockTradeId: string;
|
||||||
positionIdx: number;
|
smpType: string;
|
||||||
|
smpGroup: number;
|
||||||
|
smpOrderId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContractSymbolTicker {
|
export interface ContractSymbolTicker {
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ export interface AccountOrderV5 {
|
|||||||
triggerPrice?: string;
|
triggerPrice?: string;
|
||||||
takeProfit?: string;
|
takeProfit?: string;
|
||||||
stopLoss?: string;
|
stopLoss?: string;
|
||||||
|
tpslMode: 'Full' | 'Partial' | '';
|
||||||
|
tpLimitPrice: string;
|
||||||
|
slLimitPrice: string;
|
||||||
tpTriggerBy?: OrderTriggerByV5;
|
tpTriggerBy?: OrderTriggerByV5;
|
||||||
slTriggerBy?: OrderTriggerByV5;
|
slTriggerBy?: OrderTriggerByV5;
|
||||||
triggerDirection?: number;
|
triggerDirection?: number;
|
||||||
@@ -49,6 +52,10 @@ export interface AccountOrderV5 {
|
|||||||
lastPriceOnCreated?: string;
|
lastPriceOnCreated?: string;
|
||||||
reduceOnly?: boolean;
|
reduceOnly?: boolean;
|
||||||
closeOnTrigger?: boolean;
|
closeOnTrigger?: boolean;
|
||||||
|
placeType: 'iv' | 'price' | '';
|
||||||
|
smpType: string;
|
||||||
|
smpGroup: string;
|
||||||
|
smpOrderId: string;
|
||||||
createdTime: string;
|
createdTime: string;
|
||||||
updatedTime: string;
|
updatedTime: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user