feat(): update basic spot/futures examples with initial types

This commit is contained in:
Tiago Siebler
2023-11-14 12:15:26 +00:00
parent b1b3ee926e
commit ea8fac777e
19 changed files with 499 additions and 63 deletions

View File

@@ -1,3 +1,4 @@
export * from './rest-client-v2';
export * from './broker-client';
export * from './futures-client';
export * from './spot-client';

View File

@@ -1,27 +1,9 @@
import {
NewBatchSpotOrder,
NewSpotOrder,
NewWalletTransfer,
Pagination,
APIResponse,
CoinBalance,
SymbolRules,
NewSpotSubTransfer,
NewSpotWithdraw,
CancelSpotOrderV2,
BatchCancelSpotOrderV2,
SpotOrderResult,
NewSpotPlanOrder,
ModifySpotPlanOrder,
CancelSpotPlanOrderParams,
GetSpotPlanOrdersParams,
SpotPlanOrder,
GetHistoricPlanOrdersParams,
SpotMarketTrade,
GetHistoricTradesParams,
VIPFeeRate,
SpotKlineInterval,
MarginType,
FuturesAccountBillRequestV2,
FuturesCandlesRequestV2,
SpotCandlesRequestV2,
} from './types';
import { REST_CLIENT_TYPE_ENUM, assertMarginType } from './util';
import BaseRestClient from './util/BaseRestClient';
@@ -223,11 +205,11 @@ export class RestClientV2 extends BaseRestClient {
return this.getPrivate(`/api/v2/spot/market/orderbook`, params);
}
getSpotCandlestickData(params: object): Promise<APIResponse<any>> {
getSpotCandles(params: SpotCandlesRequestV2): Promise<APIResponse<any>> {
return this.getPrivate(`/api/v2/spot/market/candles`, params);
}
getSpotHistoricCandlestickData(params: object): Promise<APIResponse<any>> {
getSpotHistoricCandles(params: object): Promise<APIResponse<any>> {
return this.getPrivate(`/api/v2/spot/market/history-candles`, params);
}
@@ -394,21 +376,23 @@ export class RestClientV2 extends BaseRestClient {
return this.get(`/api/v2/mix/market/merge-depth`, params);
}
getFuturesCandlestickData(params: object): Promise<APIResponse<any>> {
getFuturesCandles(
params: FuturesCandlesRequestV2,
): Promise<APIResponse<any>> {
return this.get(`/api/v2/mix/market/candles`, params);
}
getFuturesHistoricCandlestickData(params: object): Promise<APIResponse<any>> {
getFuturesHistoricCandles(params: object): Promise<APIResponse<any>> {
return this.get(`/api/v2/mix/market/history-candles`, params);
}
getFuturesHistoricIndexPriceCandlestick(
getFuturesHistoricIndexPriceCandles(
params: object,
): Promise<APIResponse<any>> {
return this.get(`/api/v2/mix/market/history-index-candles`, params);
}
getFuturesHistoricMarkPriceCandlestick(
getFuturesHistoricMarkPriceCandles(
params: object,
): Promise<APIResponse<any>> {
return this.get(`/api/v2/mix/market/history-mark-candles`, params);
@@ -484,7 +468,9 @@ export class RestClientV2 extends BaseRestClient {
return this.postPrivate(`/api/v2/mix/account/set-position-mode`, params);
}
getFuturesAccountBills(params: object): Promise<APIResponse<any>> {
getFuturesAccountBills(
params: FuturesAccountBillRequestV2,
): Promise<APIResponse<any>> {
return this.getPrivate(`/api/v2/mix/account/bill`, params);
}

View File

@@ -1,4 +1,6 @@
export * from './broker';
export * from './futures';
export * from './v1/brokerV1';
export * from './v1/futuresV1';
export * from './v1/spotV1';
export * from './v2/futures';
export * from './v2/spot';
export * from './shared';
export * from './spot';

View File

@@ -1,4 +1,4 @@
import { OrderTimeInForce } from './shared';
import { OrderTimeInForce } from '../shared';
export type FuturesProductType =
| 'umcbl'

View File

@@ -1,4 +1,4 @@
import { OrderTimeInForce } from './shared';
import { OrderTimeInForce } from '../shared';
export type WalletType = 'spot' | 'mix_usdt' | 'mix_usd';

View File

@@ -0,0 +1,32 @@
import { FuturesKlineInterval } from '../v1/futuresV1';
export type FuturesProductTypeV2 =
| 'USDT-FUTURES'
| 'COIN-FUTURES'
| 'USDC-FUTURES'
| 'SUSDT-FUTURES'
| 'SCOIN-FUTURES'
| 'SUSDC-FUTURES';
export type FuturesKlineTypeV2 = 'MARKET' | 'MARK' | 'INDEX';
export interface FuturesAccountBillRequestV2 {
productType: FuturesProductTypeV2;
symbol?: string;
coin?: string;
businessType?: string;
idLessThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
}
export interface FuturesCandlesRequestV2 {
symbol: string;
productType: FuturesProductTypeV2;
granularity: FuturesKlineInterval;
startTime?: string;
endTime?: string;
kLineType?: FuturesKlineTypeV2;
limit?: string;
}

View File

@@ -0,0 +1,9 @@
import { SpotKlineInterval } from '../v1/spotV1';
export interface SpotCandlesRequestV2 {
symbol: string;
granularity: SpotKlineInterval;
startTime?: string;
endTime?: string;
limit?: string;
}