exported contract client request types

This commit is contained in:
tiagosiebler
2022-11-12 11:35:38 +00:00
parent d6ca73b08a
commit 38b798fd81
2 changed files with 87 additions and 62 deletions

View File

@@ -1,27 +1,26 @@
import { import {
APIResponseWithTime, APIResponseWithTime,
APIResponseV3, APIResponseV3,
InternalTransferRequest,
UM7DayTradingHistoryRequest,
UMBorrowHistoryRequest,
UMCandlesRequest, UMCandlesRequest,
UMCategory, UMCategory,
UMExchangeCoinsRequest,
UMFundingRateHistoryRequest, UMFundingRateHistoryRequest,
UMInstrumentInfoRequest, UMInstrumentInfoRequest,
UMOpenInterestRequest, UMOpenInterestRequest,
UMOptionDeliveryPriceRequest, UMOptionDeliveryPriceRequest,
UMOptionsSettlementHistoryRequest,
UMPerpSettlementHistoryRequest,
UMPublicTradesRequest, UMPublicTradesRequest,
UMSetTPSLRequest,
UMTransactionLogRequest,
ContractOrderRequest, ContractOrderRequest,
ContractHistoricOrdersRequest, ContractHistoricOrdersRequest,
ContractCancelOrderRequest, ContractCancelOrderRequest,
ContractModifyOrderRequest, ContractModifyOrderRequest,
ContractActiveOrdersRequest, ContractActiveOrdersRequest,
ContractPositionsRequest, ContractPositionsRequest,
ContractSetAutoAddMarginRequest,
ContractSetMarginSwitchRequest,
ContractSetPositionModeRequest,
ContractSetTPSLRequest,
ContractUserExecutionHistoryRequest,
ContractClosedPNLRequest,
ContractWalletFundRecordRequest,
} 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';
@@ -192,12 +191,9 @@ export class ContractClient extends BaseRestClient {
} }
/** Set auto add margin, or Auto-Margin Replenishment. */ /** Set auto add margin, or Auto-Margin Replenishment. */
setAuthAddMargin(params: { setAutoAddMargin(
symbol: string; params: ContractSetAutoAddMarginRequest
side: string; ): Promise<APIResponseV3<any>> {
autoAddMargin: 1 | 0;
positionIdx?: 0 | 1 | 2;
}): 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
@@ -205,12 +201,9 @@ export class ContractClient extends BaseRestClient {
} }
/** Switch cross margin mode/isolated margin mode */ /** Switch cross margin mode/isolated margin mode */
setMarginSwitch(params: { setMarginSwitch(
symbol: string; params: ContractSetMarginSwitchRequest
tradeMode: 0 | 1; ): Promise<APIResponseV3<any>> {
buyLeverage: string;
sellLeverage: string;
}): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/contract/v3/private/position/switch-isolated', '/contract/v3/private/position/switch-isolated',
params params
@@ -218,11 +211,9 @@ export class ContractClient extends BaseRestClient {
} }
/** 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(params: { setPositionMode(
symbol?: string; params: ContractSetPositionModeRequest
coin?: string; ): Promise<APIResponseV3<any>> {
mode: 0 | 3;
}): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/contract/v3/private/position/switch-mode', '/contract/v3/private/position/switch-mode',
params params
@@ -259,19 +250,7 @@ export class ContractClient extends BaseRestClient {
* Set take profit, stop loss, and trailing stop for your open position. * Set take profit, stop loss, and trailing stop for your open position.
* If using partial mode, TP/SL/TS orders will not close your entire position. * If using partial mode, TP/SL/TS orders will not close your entire position.
*/ */
setTPSL(params: { setTPSL(params: ContractSetTPSLRequest): Promise<APIResponseV3<any>> {
symbol: string;
takeProfit?: string;
stopLoss?: string;
activePrice?: string;
trailingStop?: string;
tpTriggerBy?: string;
slTriggerBy?: string;
slSize?: string;
tpSize?: string;
/** 0-one-way, 1-buy side, 2-sell side */
positionIdx?: 0 | 1 | 2;
}): Promise<APIResponseV3<any>> {
return this.postPrivate( return this.postPrivate(
'/contract/v3/private/position/trading-stop', '/contract/v3/private/position/trading-stop',
params params
@@ -296,15 +275,9 @@ export class ContractClient extends BaseRestClient {
* Get user's trading records. * Get user's trading records.
* 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(params: { getUserExecutionHistory(
symbol: string; params: ContractUserExecutionHistoryRequest
orderId?: string; ): Promise<APIResponseV3<any>> {
startTime?: number;
endTime?: number;
execType?: 'Trade' | 'AdlTrade' | 'Funding' | 'BustTrade';
limit?: number;
cursor?: string;
}): Promise<APIResponseV3<any>> {
return this.getPrivate('/contract/v3/private/execution/list', params); return this.getPrivate('/contract/v3/private/execution/list', params);
} }
@@ -312,13 +285,9 @@ export class ContractClient extends BaseRestClient {
* Get user's closed profit and loss records. * Get user's closed profit and loss records.
* 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(params: { getClosedProfitAndLoss(
symbol: string; params: ContractClosedPNLRequest
startTime?: number; ): Promise<APIResponseV3<any>> {
endTime?: number;
limit?: number;
cursor?: string;
}): Promise<APIResponseV3<any>> {
return this.getPrivate('/contract/v3/private/position/closed-pnl', params); return this.getPrivate('/contract/v3/private/position/closed-pnl', params);
} }
@@ -351,14 +320,9 @@ export class ContractClient extends BaseRestClient {
* 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(params?: { getWalletFundRecords(
startTime?: string; params?: ContractWalletFundRecordRequest
endTime?: string; ): Promise<APIResponseV3<any>> {
coin?: string;
walletFundType?: string;
limit?: string;
cursor?: string;
}): 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

View File

@@ -65,3 +65,64 @@ export interface ContractPositionsRequest {
settleCoin?: string; settleCoin?: string;
dataFilter?: string; dataFilter?: string;
} }
export interface ContractSetAutoAddMarginRequest {
symbol: string;
side: string;
autoAddMargin: 1 | 0;
positionIdx?: 0 | 1 | 2;
}
export interface ContractSetMarginSwitchRequest {
symbol: string;
tradeMode: 0 | 1;
buyLeverage: string;
sellLeverage: string;
}
export interface ContractSetPositionModeRequest {
symbol?: string;
coin?: string;
mode: 0 | 3;
}
export interface ContractSetTPSLRequest {
symbol: string;
takeProfit?: string;
stopLoss?: string;
activePrice?: string;
trailingStop?: string;
tpTriggerBy?: string;
slTriggerBy?: string;
slSize?: string;
tpSize?: string;
/** 0-one-way, 1-buy side, 2-sell side */
positionIdx?: 0 | 1 | 2;
}
export interface ContractUserExecutionHistoryRequest {
symbol: string;
orderId?: string;
startTime?: number;
endTime?: number;
execType?: 'Trade' | 'AdlTrade' | 'Funding' | 'BustTrade';
limit?: number;
cursor?: string;
}
export interface ContractClosedPNLRequest {
symbol: string;
startTime?: number;
endTime?: number;
limit?: number;
cursor?: string;
}
export interface ContractWalletFundRecordRequest {
startTime?: string;
endTime?: string;
coin?: string;
walletFundType?: string;
limit?: string;
cursor?: string;
}