add examples for placing orders with ws updates. Add some response types.
This commit is contained in:
@@ -15,6 +15,8 @@ import {
|
||||
CancelFuturesPlanTPSL,
|
||||
HistoricPlanOrderTPSLRequest,
|
||||
NewFuturesPlanStopOrder,
|
||||
FuturesAccount,
|
||||
FuturesSymbolRule,
|
||||
} from './types';
|
||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||
import BaseRestClient from './util/BaseRestClient';
|
||||
@@ -34,7 +36,9 @@ export class FuturesClient extends BaseRestClient {
|
||||
*/
|
||||
|
||||
/** Get Symbols : Get basic configuration information of all trading pairs (including rules) */
|
||||
getSymbols(productType: FuturesProductType): Promise<APIResponse<any[]>> {
|
||||
getSymbols(
|
||||
productType: FuturesProductType
|
||||
): Promise<APIResponse<FuturesSymbolRule[]>> {
|
||||
return this.get('/api/mix/v1/market/contracts', { productType });
|
||||
}
|
||||
|
||||
@@ -125,7 +129,10 @@ export class FuturesClient extends BaseRestClient {
|
||||
*/
|
||||
|
||||
/** Get Single Account */
|
||||
getAccount(symbol: string, marginCoin: string): Promise<APIResponse<any>> {
|
||||
getAccount(
|
||||
symbol: string,
|
||||
marginCoin: string
|
||||
): Promise<APIResponse<FuturesAccount>> {
|
||||
return this.getPrivate('/api/mix/v1/account/account', {
|
||||
symbol,
|
||||
marginCoin,
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
Pagination,
|
||||
APIResponse,
|
||||
KlineInterval,
|
||||
CoinBalance,
|
||||
SymbolRules,
|
||||
} from './types';
|
||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||
import BaseRestClient from './util/BaseRestClient';
|
||||
@@ -39,7 +41,7 @@ export class SpotClient extends BaseRestClient {
|
||||
}
|
||||
|
||||
/** Get Symbols : Get basic configuration information of all trading pairs (including rules) */
|
||||
getSymbols(): Promise<APIResponse<any[]>> {
|
||||
getSymbols(): Promise<APIResponse<SymbolRules[]>> {
|
||||
return this.get('/api/spot/v1/public/products');
|
||||
}
|
||||
|
||||
@@ -184,7 +186,7 @@ export class SpotClient extends BaseRestClient {
|
||||
}
|
||||
|
||||
/** Get Account : get account assets */
|
||||
getBalance(coin?: string): Promise<APIResponse<any>> {
|
||||
getBalance(coin?: string): Promise<APIResponse<CoinBalance[]>> {
|
||||
return this.getPrivate('/api/spot/v1/account/assets', { coin });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { OrderTimeInForce } from './shared';
|
||||
|
||||
export type FuturesProductType =
|
||||
| 'umcbl'
|
||||
| 'dmcbl'
|
||||
@@ -39,7 +41,7 @@ export interface NewFuturesOrder {
|
||||
price?: string;
|
||||
side: FuturesOrderSide;
|
||||
orderType: FuturesOrderType;
|
||||
timeInForceValue?: string;
|
||||
timeInForceValue?: OrderTimeInForce;
|
||||
clientOid?: string;
|
||||
presetTakeProfitPrice?: string;
|
||||
presetStopLossPrice?: string;
|
||||
|
||||
@@ -7,3 +7,5 @@ export interface Pagination {
|
||||
/** Elements per page */
|
||||
limit?: string;
|
||||
}
|
||||
|
||||
export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc';
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { numberInString, OrderSide } from '../shared';
|
||||
|
||||
export type OrderTypeSpot = 'LIMIT' | 'MARKET' | 'LIMIT_MAKER';
|
||||
export type OrderTimeInForce = 'GTC' | 'FOK' | 'IOC';
|
||||
import { OrderTimeInForce } from './shared';
|
||||
|
||||
export type WalletType = 'spot' | 'mix_usdt' | 'mix_usd';
|
||||
|
||||
@@ -15,9 +12,9 @@ export interface NewWalletTransfer {
|
||||
|
||||
export interface NewSpotOrder {
|
||||
symbol: string;
|
||||
side: string;
|
||||
orderType: string;
|
||||
force: string;
|
||||
side: 'buy' | 'sell';
|
||||
orderType: 'limit' | 'market';
|
||||
force: OrderTimeInForce;
|
||||
price?: string;
|
||||
quantity: string;
|
||||
clientOrderId?: string;
|
||||
|
||||
35
src/types/response/futures.ts
Normal file
35
src/types/response/futures.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
export interface FuturesAccount {
|
||||
marginCoin: string;
|
||||
locked: number;
|
||||
available: number;
|
||||
crossMaxAvailable: number;
|
||||
fixedMaxAvailable: number;
|
||||
maxTransferOut: number;
|
||||
equity: number;
|
||||
usdtEquity: number;
|
||||
btcEquity: number;
|
||||
crossRiskRate: number;
|
||||
crossMarginLeverage: number;
|
||||
fixedLongLeverage: number;
|
||||
fixedShortLeverage: number;
|
||||
marginMode: string;
|
||||
holdMode: string;
|
||||
}
|
||||
|
||||
export interface FuturesSymbolRule {
|
||||
baseCoin: string;
|
||||
buyLimitPriceRatio: string;
|
||||
feeRateUpRatio: string;
|
||||
makerFeeRate: string;
|
||||
minTradeNum: string;
|
||||
openCostUpRatio: string;
|
||||
priceEndStep: string;
|
||||
pricePlace: string;
|
||||
quoteCoin: string;
|
||||
sellLimitPriceRatio: string;
|
||||
sizeMultiplier: string;
|
||||
supportMarginCoins: string[];
|
||||
symbol: string;
|
||||
takerFeeRate: string;
|
||||
volumePlace: string;
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
export * from './shared';
|
||||
export * from './spot';
|
||||
export * from './futures';
|
||||
|
||||
22
src/types/response/spot.ts
Normal file
22
src/types/response/spot.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export interface CoinBalance {
|
||||
coinId: number;
|
||||
coinName: string;
|
||||
available: string;
|
||||
frozen: string;
|
||||
lock: string;
|
||||
uTime: string;
|
||||
}
|
||||
|
||||
export interface SymbolRules {
|
||||
symbol: string;
|
||||
symbolName: string;
|
||||
baseCoin: string;
|
||||
quoteCoin: string;
|
||||
minTradeAmount: string;
|
||||
maxTradeAmount: string;
|
||||
takerFeeRate: string;
|
||||
makerFeeRate: string;
|
||||
priceScale: string;
|
||||
quantityScale: string;
|
||||
status: string;
|
||||
}
|
||||
Reference in New Issue
Block a user