fixing and tidying v5 request and response types

This commit is contained in:
tiagosiebler
2023-02-17 12:16:01 +00:00
parent 6d9e73bdda
commit 6a4e7c09ed
9 changed files with 231 additions and 107 deletions

View File

@@ -1,4 +1,10 @@
import { AccountTypeV5, CategoryV5, TransactionTypeV5 } from '../v5-shared';
import {
AccountMarginModeV5,
AccountTypeV5,
CategoryV5,
TransactionTypeV5,
UnifiedUpdateStatusV5,
} from '../v5-shared';
export interface WalletBalanceV5Coin {
coin: string;
@@ -30,8 +36,6 @@ export interface WalletBalanceV5 {
coin: WalletBalanceV5Coin[];
}
export type UnifiedUpdateStatusV5 = 'FAIL' | 'PROCESS' | 'SUCCESS';
export interface UnifiedAccountUpgradeResultV5 {
unifiedUpdateStatus: UnifiedUpdateStatusV5;
unifiedUpdateMsg: {
@@ -76,7 +80,7 @@ export interface FeeRateV5 {
export interface AccountInfoV5 {
unifiedMarginStatus: number;
marginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN';
marginMode: AccountMarginModeV5;
updatedTime: string;
}

View File

@@ -1,4 +1,4 @@
import { AccountTypeV5, OrderSideV5 } from '../v5-shared';
import { AccountTypeV5, OrderSideV5, WithdrawalTypeV5 } from '../v5-shared';
export interface CoinExchangeRecordV5 {
fromCoin: string;
@@ -135,7 +135,7 @@ export interface CoinInfoV5 {
export interface WithdrawalRecordV5 {
withdrawId: string;
txID: string;
withdrawType: string;
withdrawType: WithdrawalTypeV5;
coin: string;
chain: string;
amount: string;

View File

@@ -1,104 +1,121 @@
import {
CategoryCursorListV5,
ContractTypeV5,
InstrumentStatusV5,
OptionTypeV5,
OrderSideV5,
} from '../v5-shared';
/**
* OHLCVT candle used by v5 APIs
*
* > list[0]: startTime string Start time of the candle (ms)
*
* > list[1]: openPrice string Open price
*
* > list[2]: highPrice string Highest price
*
* > list[3]: lowPrice string Lowest price
*
* > list[4]: closePrice string Close price. Is the last traded price when the candle is not closed
*
* > list[5]: volume string Trade volume. Unit of contract: pieces of contract. Unit of spot: quantity of coins
*
* > list[6]: turnover string Turnover. Unit of figure: quantity of quota coin
* - list[0]: startTime string Start time of the candle (ms)
* - list[1]: openPrice string Open price
* - list[2]: highPrice string Highest price
* - list[3]: lowPrice string Lowest price
* - list[4]: closePrice string Close price. Is the last traded price when the candle is not closed
* - list[5]: volume string Trade volume. Unit of contract: pieces of contract. Unit of spot: quantity of coins
* - list[6]: turnover string Turnover. Unit of figure: quantity of quota coin
*/
export type KlineV5 = [string, string, string, string, string, string, string];
export type OHLCVKlineV5 = [
string,
string,
string,
string,
string,
string,
string
];
/**
* OHLC candle used by v5 APIs
*
* > list[0]: startTime string Start time of the candle (ms)
*
* > list[1]: openPrice string Open price
*
* > list[2]: highPrice string Highest price
*
* > list[3]: lowPrice string Lowest price
*
* > list[4]: closePrice string Close price. Is the last traded price when the candle is not closed
* - list[0]: startTime string Start time of the candle (ms)
* - list[1]: openPrice string Open price
* - list[2]: highPrice string Highest price
* - list[3]: lowPrice string Lowest price
* - list[4]: closePrice string Close price. Is the last traded price when the candle is not closed
*/
export type OHLCV5 = [string, string, string, string, string];
export type OHLCKlineV5 = [string, string, string, string, string];
export interface LinearInverseInstrumentInfoV5 {
category: 'linear' | 'inverse';
symbol: string;
contractType: string;
status: string;
contractType: ContractTypeV5;
status: InstrumentStatusV5;
baseCoin: string;
quoteCoin: string;
launchTime: string;
deliveryTime: string;
deliveryFeeRate: string;
deliveryTime?: string;
deliveryFeeRate?: string;
priceScale: string;
maxLeverage: string;
minOrderValue: string;
minOrderVolume: string;
makerFeeRate: string;
takerFeeRate: string;
leverageFilter: {
minLeverage: string;
maxLeverage: string;
leverageStep: string;
};
priceFilter: {
minPrice: string;
maxPrice: string;
tickSize: string;
};
lotSizeFilter: {
maxOrderQty: string;
minOrderQty: string;
qtyStep: string;
postOnlyMaxOrderQty?: string;
};
unifiedMarginTrade: boolean;
fundingInterval: number;
settleCoin: string;
}
export interface OptionInstrumentInfoV5 {
category: 'option';
symbol: string;
contractType: string;
status: string;
optionsType: OptionTypeV5;
status: InstrumentStatusV5;
baseCoin: string;
quoteCoin: string;
settleCoin: boolean;
launchTime: string;
deliveryTime: string;
deliveryFeeRate: string;
priceScale: string;
maxLeverage: string;
minOrderValue: string;
minOrderVolume: string;
makerFeeRate: string;
takerFeeRate: string;
settlementCurrency: string;
settlementPrice: string;
deliveryMethod: string;
optionType: string;
exercisePrice: string;
expirationTime: string;
blockMarginRatio: string;
marginType: string;
strike: string;
priceFilter: {
minPrice: string;
maxPrice: string;
tickSize: string;
};
lotSizeFilter: {
maxOrderQty: string;
minOrderQty: string;
qtyStep: string;
};
}
export interface SpotInstrumentInfoV5 {
category: 'spot';
symbol: string;
contractType: string;
status: string;
baseCoin: string;
quoteCoin: string;
launchTime: string;
priceScale: string;
maxLeverage: string;
minOrderValue: string;
minOrderVolume: string;
makerFeeRate: string;
takerFeeRate: string;
innovation: '0' | '1';
status: InstrumentStatusV5;
lotSizeFilter: {
basePrecision: string;
quotePrecision: string;
minOrderQty: string;
maxOrderQty: string;
minOrderAmt: string;
maxOrderAmt: string;
};
priceFilter: {
tickSize: string;
};
}
export type InstrumentInfoV5 =
| LinearInverseInstrumentInfoV5
| OptionInstrumentInfoV5
| SpotInstrumentInfoV5;
export type InstrumentInfoResponseV5 =
| CategoryCursorListV5<LinearInverseInstrumentInfoV5[], 'linear' | 'inverse'>
| CategoryCursorListV5<OptionInstrumentInfoV5[], 'option'>
| CategoryCursorListV5<SpotInstrumentInfoV5[], 'spot'>;
export interface OrderbookLevelV5 {
export default interface OrderbookLevelV5 {
price: string;
size: string;
}
@@ -192,16 +209,16 @@ export interface PublicTradeV5 {
symbol: string;
price: string;
size: string;
side: 'Buy' | 'Sell';
side: OrderSideV5;
time: string;
isBlockTrade: boolean;
}
/**
> openInterest string Open interest
> timestamp string The timestamp (ms)
*/
*
* - openInterest string Open interest
* - timestamp string The timestamp (ms)
*/
export type OpenInterestV5 = [string, string];
export interface OpenInterestResponseV5 {

View File

@@ -1,8 +1,10 @@
import {
CategoryV5,
ExecTypeV5,
OrderSideV5,
OrderTypeV5,
PositionIdx,
StopOrderTypeV5,
TPSLModeV5,
TradeModeV5,
} from '../v5-shared';
@@ -50,12 +52,12 @@ export interface ExecutionV5 {
orderQty: string;
leavesQty: string;
orderType: OrderTypeV5;
stopOrderType?: string;
stopOrderType?: StopOrderTypeV5;
execFee: string;
execId: string;
execPrice: string;
execQty: string;
execType: string;
execType: ExecTypeV5;
execValue: string;
execTime: string;
isMaker: boolean;
@@ -74,8 +76,8 @@ export interface ClosedPnLV5 {
side: string;
qty: string;
orderPrice: string;
orderType: string;
execType: string;
orderType: OrderTypeV5;
execType: ExecTypeV5;
closedSize: string;
cumEntryValue: string;
avgEntryPrice: string;

View File

@@ -1,10 +1,14 @@
import {
CategoryV5,
OrderCancelTypeV5,
OrderRejectReasonV5,
OrderSideV5,
OrderStatusV5,
OrderTimeInForceV5,
OrderTriggerByV5,
OrderTypeV5,
PositionIdx,
StopOrderTypeV5,
} from '../v5-shared';
export interface OrderResultV5 {
@@ -22,9 +26,9 @@ export interface AccountOrderV5 {
side: OrderSideV5;
isLeverage?: string;
positionIdx?: PositionIdx;
orderStatus: string;
cancelType?: string;
rejectReason?: string;
orderStatus: OrderStatusV5;
cancelType?: OrderCancelTypeV5;
rejectReason?: OrderRejectReasonV5;
avgPrice: string;
leavesQty: string;
leavesValue: string;
@@ -33,7 +37,7 @@ export interface AccountOrderV5 {
cumExecFee: string;
timeInForce?: OrderTimeInForceV5;
orderType?: OrderTypeV5;
stopOrderType?: string;
stopOrderType?: StopOrderTypeV5;
orderIv?: string;
triggerPrice?: string;
takeProfit?: string;