feat(): expand v5 client with trade endpoints

This commit is contained in:
tiagosiebler
2023-02-15 11:12:27 +00:00
parent 5b44e31207
commit 145f17d4f1
7 changed files with 400 additions and 6 deletions

View File

@@ -9,3 +9,4 @@ export * from './usdc-shared';
export * from './unified-margin';
export * from './v5-market';
export * from './contract';
export * from './v5-trade';

View File

@@ -0,0 +1,107 @@
import {
CategoryV5,
OrderFilterV5,
OrderSideV5,
OrderTimeInForceV5,
OrderTriggerByV5,
OrderTypeV5,
PositionIdx,
} from '../v5-shared';
export interface OrderParamsV5 {
category: CategoryV5;
symbol: string;
isLeverage?: 0 | 1;
side: OrderSideV5;
orderType: OrderTypeV5;
qty: string;
price?: string;
triggerDirection?: 1 | 2;
orderFilter?: 'Order' | 'tpslOrder';
triggerPrice?: string;
triggerBy?: OrderTriggerByV5;
orderIv?: string;
timeInForce?: OrderTimeInForceV5;
positionIdx?: PositionIdx;
orderLinkId?: string;
takeProfit?: string;
stopLoss?: string;
tpTriggerBy?: OrderTriggerByV5;
slTriggerBy?: OrderTriggerByV5;
reduceOnly?: boolean;
closeOnTrigger?: boolean;
mmp?: boolean;
}
export interface AmendOrderParamsV5 {
category: CategoryV5;
symbol: string;
orderId?: string;
orderLinkId?: string;
orderIv?: string;
triggerPrice?: string;
qty?: string;
price?: string;
takeProfit?: string;
stopLoss?: string;
tpTriggerBy?: OrderTriggerByV5;
slTriggerBy?: OrderTriggerByV5;
triggerBy?: OrderTriggerByV5;
}
export interface CancelOrderParamsV5 {
category: CategoryV5;
symbol: string;
orderId?: string;
orderLinkId?: string;
orderFilter?: OrderFilterV5;
}
export interface GetAccountOrdersParams {
category: CategoryV5;
symbol?: string;
baseCoin?: string;
settleCoin?: string;
orderId?: string;
orderLinkId?: string;
openOnly?: 0 | 1 | 2;
orderFilter?: OrderFilterV5;
limit?: number;
cursor?: string;
}
export interface CancelAllOrdersParamsV5 {
category: CategoryV5;
symbol?: string;
baseCoin?: string;
settleCoin?: string;
orderFilter?: OrderFilterV5;
}
export interface BatchOrderParamsV5 {
symbol: string;
side: OrderSideV5;
orderType: OrderTypeV5;
qty: string;
price?: string;
orderIv?: string;
timeInForce?: OrderTimeInForceV5;
orderLinkId: string;
reduceOnly?: boolean;
mmp?: boolean;
}
export interface BatchAmendOrderParamsV5 {
symbol: string;
orderId?: string;
orderLinkId?: string;
qty?: string;
price?: string;
orderIv?: string;
}
export interface BatchCancelOrderParamsV5 {
symbol: string;
orderId?: string;
orderLinkId?: string;
}

View File

@@ -4,3 +4,5 @@ export * from './shared';
export * from './spot';
export * from './usdt-perp';
export * from './unified-margin';
export * from './v5-market';
export * from './v5-trade';

View File

@@ -0,0 +1,98 @@
import {
CategoryV5,
OrderSideV5,
OrderTimeInForceV5,
OrderTriggerByV5,
OrderTypeV5,
PositionIdx,
} from '../v5-shared';
export interface OrderResultV5 {
orderId: string;
orderLinkId: string;
}
export interface AccountOrderV5 {
orderId: string;
orderLinkId?: string;
blockTradeId?: string;
symbol: string;
price: string;
qty: string;
side: OrderSideV5;
isLeverage?: string;
positionIdx?: PositionIdx;
orderStatus: string;
cancelType?: string;
rejectReason?: string;
avgPrice: string;
leavesQty: string;
leavesValue: string;
cumExecQty: string;
cumExecValue: string;
cumExecFee: string;
timeInForce?: OrderTimeInForceV5;
orderType?: OrderTypeV5;
stopOrderType?: string;
orderIv?: string;
triggerPrice?: string;
takeProfit?: string;
stopLoss?: string;
tpTriggerBy?: OrderTriggerByV5;
slTriggerBy?: OrderTriggerByV5;
triggerDirection?: number;
triggerBy?: OrderTriggerByV5;
lastPriceOnCreated?: string;
reduceOnly?: boolean;
closeOnTrigger?: boolean;
createdTime: string;
updatedTime: string;
}
export interface AccountOrdersResultV5 {
category: CategoryV5;
nextPageCursor?: string;
list: AccountOrderV5[];
}
export interface BatchOrderResult {
category: CategoryV5;
symbol: string;
orderId: string;
orderLinkId: string;
createAt: string;
}
export interface BatchOrdersResult<T extends unknown[]> {
result: {
list: T;
};
retExtInfo: {
list: {
code: number;
msg: string;
}[];
};
}
export interface BatchAmendOrderResult {
category: CategoryV5;
symbol: string;
orderId: string;
orderLinkId: string;
}
export interface BatchCancelOrderResult {
category: CategoryV5;
symbol: string;
orderId: string;
orderLinkId: string;
}
export interface SpotBorrowCheckResult {
symbol: string;
side: OrderSideV5;
maxTradeQty: string;
maxTradeAmount: string;
borrowCoin: string;
}

View File

@@ -1 +1,8 @@
export type CategoryV5 = 'spot' | 'linear' | 'inverse' | 'option';
export type OrderFilterV5 = 'Order' | 'tpslOrder';
export type OrderSideV5 = 'Buy' | 'Sell';
export type OrderTimeInForceV5 = 'GTC' | 'IOC' | 'FOK' | 'PostOnly';
export type OrderTriggerByV5 = 'LastPrice' | 'IndexPrice' | 'MarkPrice';
export type OrderTypeV5 = 'Market' | 'Limit';
export type PositionIdx = 0 | 1 | 2;