extract/clean inverse request types
This commit is contained in:
@@ -3,6 +3,22 @@ import {
|
|||||||
APIResponseWithTime,
|
APIResponseWithTime,
|
||||||
AssetExchangeRecordsReq,
|
AssetExchangeRecordsReq,
|
||||||
CoinParam,
|
CoinParam,
|
||||||
|
InverseActiveConditionalOrderRequest,
|
||||||
|
InverseActiveOrdersRequest,
|
||||||
|
InverseCancelConditionalOrderRequest,
|
||||||
|
InverseCancelOrderRequest,
|
||||||
|
InverseChangePositionMarginRequest,
|
||||||
|
InverseConditionalOrderRequest,
|
||||||
|
InverseGetClosedPnlRequest,
|
||||||
|
InverseGetOrderRequest,
|
||||||
|
InverseGetTradeRecordsRequest,
|
||||||
|
InverseOrderRequest,
|
||||||
|
InverseReplaceConditionalOrderRequest,
|
||||||
|
InverseReplaceOrderRequest,
|
||||||
|
InverseSetLeverageRequest,
|
||||||
|
InverseSetMarginTypeRequest,
|
||||||
|
InverseSetSlTpPositionModeRequest,
|
||||||
|
InverseSetTradingStopRequest,
|
||||||
SymbolInfo,
|
SymbolInfo,
|
||||||
SymbolIntervalFromLimitParam,
|
SymbolIntervalFromLimitParam,
|
||||||
SymbolLimitParam,
|
SymbolLimitParam,
|
||||||
@@ -165,39 +181,21 @@ export class InverseClient extends BaseRestClient {
|
|||||||
* Active orders
|
* Active orders
|
||||||
*/
|
*/
|
||||||
|
|
||||||
placeActiveOrder(orderRequest: {
|
placeActiveOrder(
|
||||||
side: string;
|
orderRequest: InverseOrderRequest
|
||||||
symbol: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
order_type: string;
|
|
||||||
qty: number;
|
|
||||||
price?: number;
|
|
||||||
time_in_force: string;
|
|
||||||
take_profit?: number;
|
|
||||||
stop_loss?: number;
|
|
||||||
reduce_only?: boolean;
|
|
||||||
tp_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice';
|
|
||||||
sl_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice';
|
|
||||||
close_on_trigger?: boolean;
|
|
||||||
order_link_id?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/order/create', orderRequest);
|
return this.postPrivate('v2/private/order/create', orderRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveOrderList(params: {
|
getActiveOrderList(
|
||||||
symbol: string;
|
params: InverseActiveOrdersRequest
|
||||||
order_status?: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
direction?: string;
|
|
||||||
limit?: number;
|
|
||||||
cursor?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.getPrivate('v2/private/order/list', params);
|
return this.getPrivate('v2/private/order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelActiveOrder(params: {
|
cancelActiveOrder(
|
||||||
symbol: string;
|
params: InverseCancelOrderRequest
|
||||||
order_id?: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
order_link_id?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/order/cancel', params);
|
return this.postPrivate('v2/private/order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,25 +205,15 @@ export class InverseClient extends BaseRestClient {
|
|||||||
return this.postPrivate('v2/private/order/cancelAll', params);
|
return this.postPrivate('v2/private/order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceActiveOrder(params: {
|
replaceActiveOrder(
|
||||||
order_id?: string;
|
params: InverseReplaceOrderRequest
|
||||||
order_link_id?: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
symbol: string;
|
|
||||||
p_r_qty?: number;
|
|
||||||
p_r_price?: string;
|
|
||||||
take_profit?: number;
|
|
||||||
stop_loss?: number;
|
|
||||||
tp_trigger_by?: string;
|
|
||||||
sl_trigger_by?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/order/replace', params);
|
return this.postPrivate('v2/private/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryActiveOrder(params: {
|
queryActiveOrder(
|
||||||
order_id?: string;
|
params: InverseGetOrderRequest
|
||||||
order_link_id?: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
symbol: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.getPrivate('v2/private/order', params);
|
return this.getPrivate('v2/private/order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,38 +221,22 @@ export class InverseClient extends BaseRestClient {
|
|||||||
* Conditional orders
|
* Conditional orders
|
||||||
*/
|
*/
|
||||||
|
|
||||||
placeConditionalOrder(params: {
|
placeConditionalOrder(
|
||||||
side: string;
|
params: InverseConditionalOrderRequest
|
||||||
symbol: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
order_type: string;
|
|
||||||
qty: string;
|
|
||||||
price?: string;
|
|
||||||
base_price: string;
|
|
||||||
stop_px: string;
|
|
||||||
time_in_force: string;
|
|
||||||
trigger_by?: string;
|
|
||||||
close_on_trigger?: boolean;
|
|
||||||
order_link_id?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/stop-order/create', params);
|
return this.postPrivate('v2/private/stop-order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
|
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
|
||||||
getConditionalOrder(params: {
|
getConditionalOrder(
|
||||||
symbol: string;
|
params: InverseActiveConditionalOrderRequest
|
||||||
stop_order_status?: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
direction?: string;
|
|
||||||
limit?: number;
|
|
||||||
cursor?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.getPrivate('v2/private/stop-order/list', params);
|
return this.getPrivate('v2/private/stop-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelConditionalOrder(params: {
|
cancelConditionalOrder(
|
||||||
symbol: string;
|
params: InverseCancelConditionalOrderRequest
|
||||||
stop_order_id?: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
order_link_id?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/stop-order/cancel', params);
|
return this.postPrivate('v2/private/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,22 +246,15 @@ export class InverseClient extends BaseRestClient {
|
|||||||
return this.postPrivate('v2/private/stop-order/cancelAll', params);
|
return this.postPrivate('v2/private/stop-order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceConditionalOrder(params: {
|
replaceConditionalOrder(
|
||||||
stop_order_id?: string;
|
params: InverseReplaceConditionalOrderRequest
|
||||||
order_link_id?: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
symbol: string;
|
|
||||||
p_r_qty?: number;
|
|
||||||
p_r_price?: string;
|
|
||||||
p_r_trigger_price?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/stop-order/replace', params);
|
return this.postPrivate('v2/private/stop-order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryConditionalOrder(params: {
|
queryConditionalOrder(
|
||||||
symbol: string;
|
params: InverseGetOrderRequest
|
||||||
stop_order_id?: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
order_link_id?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.getPrivate('v2/private/stop-order', params);
|
return this.getPrivate('v2/private/stop-order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,68 +268,45 @@ export class InverseClient extends BaseRestClient {
|
|||||||
return this.getPrivate('v2/private/position/list', params);
|
return this.getPrivate('v2/private/position/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
changePositionMargin(params: {
|
changePositionMargin(
|
||||||
symbol: string;
|
params: InverseChangePositionMarginRequest
|
||||||
margin: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('position/change-position-margin', params);
|
return this.postPrivate('position/change-position-margin', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTradingStop(params: {
|
setTradingStop(
|
||||||
symbol: string;
|
params: InverseSetTradingStopRequest
|
||||||
take_profit?: number;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
stop_loss?: number;
|
|
||||||
trailing_stop?: number;
|
|
||||||
tp_trigger_by?: string;
|
|
||||||
sl_trigger_by?: string;
|
|
||||||
new_trailing_active?: number;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/position/trading-stop', params);
|
return this.postPrivate('v2/private/position/trading-stop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setUserLeverage(params: {
|
setUserLeverage(
|
||||||
symbol: string;
|
params: InverseSetLeverageRequest
|
||||||
leverage: number;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
leverage_only?: boolean;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/position/leverage/save', params);
|
return this.postPrivate('v2/private/position/leverage/save', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTradeRecords(params: {
|
getTradeRecords(
|
||||||
order_id?: string;
|
params: InverseGetTradeRecordsRequest
|
||||||
symbol: string;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
start_time?: number;
|
|
||||||
page?: number;
|
|
||||||
limit?: number;
|
|
||||||
order?: string;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.getPrivate('v2/private/execution/list', params);
|
return this.getPrivate('v2/private/execution/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getClosedPnl(params: {
|
getClosedPnl(
|
||||||
symbol: string;
|
params: InverseGetClosedPnlRequest
|
||||||
start_time?: number;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
end_time?: number;
|
|
||||||
exec_type?: string;
|
|
||||||
page?: number;
|
|
||||||
limit?: number;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
|
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSlTpPositionMode(params: {
|
setSlTpPositionMode(
|
||||||
symbol: string;
|
params: InverseSetSlTpPositionModeRequest
|
||||||
tp_sl_mode: 'Full' | 'Partial';
|
): Promise<APIResponseWithTime<any>> {
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/tpsl/switch-mode', params);
|
return this.postPrivate('v2/private/tpsl/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMarginType(params: {
|
setMarginType(
|
||||||
symbol: string;
|
params: InverseSetMarginTypeRequest
|
||||||
is_isolated: boolean;
|
): Promise<APIResponseWithTime<any>> {
|
||||||
buy_leverage: number;
|
|
||||||
sell_leverage: number;
|
|
||||||
}): Promise<APIResponseWithTime<any>> {
|
|
||||||
return this.postPrivate('v2/private/position/switch-isolated', params);
|
return this.postPrivate('v2/private/position/switch-isolated', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from './account-asset';
|
export * from './account-asset';
|
||||||
export * from './copy-trading';
|
export * from './copy-trading';
|
||||||
|
export * from './inverse';
|
||||||
export * from './spot';
|
export * from './spot';
|
||||||
export * from './usdt-perp';
|
export * from './usdt-perp';
|
||||||
export * from './usdc-perp';
|
export * from './usdc-perp';
|
||||||
|
|||||||
135
src/types/request/inverse.ts
Normal file
135
src/types/request/inverse.ts
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
export interface InverseOrderRequest {
|
||||||
|
side: string;
|
||||||
|
symbol: string;
|
||||||
|
order_type: string;
|
||||||
|
qty: number;
|
||||||
|
price?: number;
|
||||||
|
time_in_force: string;
|
||||||
|
take_profit?: number;
|
||||||
|
stop_loss?: number;
|
||||||
|
reduce_only?: boolean;
|
||||||
|
tp_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice';
|
||||||
|
sl_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice';
|
||||||
|
close_on_trigger?: boolean;
|
||||||
|
order_link_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseActiveOrdersRequest {
|
||||||
|
symbol: string;
|
||||||
|
order_status?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: number;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseCancelOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
order_id?: string;
|
||||||
|
order_link_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseReplaceOrderRequest {
|
||||||
|
order_id?: string;
|
||||||
|
order_link_id?: string;
|
||||||
|
symbol: string;
|
||||||
|
p_r_qty?: number;
|
||||||
|
p_r_price?: string;
|
||||||
|
take_profit?: number;
|
||||||
|
stop_loss?: number;
|
||||||
|
tp_trigger_by?: string;
|
||||||
|
sl_trigger_by?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseGetOrderRequest {
|
||||||
|
order_id?: string;
|
||||||
|
order_link_id?: string;
|
||||||
|
symbol: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseConditionalOrderRequest {
|
||||||
|
side: string;
|
||||||
|
symbol: string;
|
||||||
|
order_type: string;
|
||||||
|
qty: string;
|
||||||
|
price?: string;
|
||||||
|
base_price: string;
|
||||||
|
stop_px: string;
|
||||||
|
time_in_force: string;
|
||||||
|
trigger_by?: string;
|
||||||
|
close_on_trigger?: boolean;
|
||||||
|
order_link_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseActiveConditionalOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
stop_order_status?: string;
|
||||||
|
direction?: string;
|
||||||
|
limit?: number;
|
||||||
|
cursor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseCancelConditionalOrderRequest {
|
||||||
|
symbol: string;
|
||||||
|
stop_order_id?: string;
|
||||||
|
order_link_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseReplaceConditionalOrderRequest {
|
||||||
|
stop_order_id?: string;
|
||||||
|
order_link_id?: string;
|
||||||
|
symbol: string;
|
||||||
|
p_r_qty?: number;
|
||||||
|
p_r_price?: string;
|
||||||
|
p_r_trigger_price?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseChangePositionMarginRequest {
|
||||||
|
symbol: string;
|
||||||
|
margin: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseSetTradingStopRequest {
|
||||||
|
symbol: string;
|
||||||
|
take_profit?: number;
|
||||||
|
stop_loss?: number;
|
||||||
|
trailing_stop?: number;
|
||||||
|
tp_trigger_by?: string;
|
||||||
|
sl_trigger_by?: string;
|
||||||
|
new_trailing_active?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseSetLeverageRequest {
|
||||||
|
symbol: string;
|
||||||
|
leverage: number;
|
||||||
|
leverage_only?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseGetTradeRecordsRequest {
|
||||||
|
order_id?: string;
|
||||||
|
symbol: string;
|
||||||
|
start_time?: number;
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
order?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseGetClosedPnlRequest {
|
||||||
|
symbol: string;
|
||||||
|
start_time?: number;
|
||||||
|
end_time?: number;
|
||||||
|
exec_type?: string;
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseSetSlTpPositionModeRequest {
|
||||||
|
symbol: string;
|
||||||
|
tp_sl_mode: 'Full' | 'Partial';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InverseSetMarginTypeRequest {
|
||||||
|
symbol: string;
|
||||||
|
is_isolated: boolean;
|
||||||
|
buy_leverage: number;
|
||||||
|
sell_leverage: number;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user