Skip to content

Commit

Permalink
Merge pull request #29 from t0chk/master
Browse files Browse the repository at this point in the history
rest v1 spot & futures update
  • Loading branch information
tiagosiebler committed Dec 4, 2023
2 parents 3b4b7c9 + 3e91b99 commit bcd7554
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "bitget-api",
"version": "2.0.2",
"version": "2.0.3",
"description": "Node.js & JavaScript SDK for Bitget REST APIs & WebSockets, with TypeScript & end-to-end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
20 changes: 17 additions & 3 deletions src/futures-client.ts
Expand Up @@ -26,6 +26,7 @@ import {
FuturesKlineInterval,
FuturesHistoricPositions,
ModifyFuturesOrder,
FuturesCandleData,
} from './types';
import { REST_CLIENT_TYPE_ENUM } from './util';
import BaseRestClient from './util/BaseRestClient';
Expand Down Expand Up @@ -104,14 +105,16 @@ export class FuturesClient extends BaseRestClient {
symbol: string,
granularity: FuturesKlineInterval,
startTime: string,
endTime: string,
endTime: string,
limit?: string,
): Promise<any> {
kLineType?: 'market' | 'mark' | 'index'
): Promise<FuturesCandleData[]> {
return this.get('/api/mix/v1/market/candles', {
symbol,
granularity,
startTime,
endTime,
kLineType,
limit,
});
}
Expand Down Expand Up @@ -559,13 +562,24 @@ export class FuturesClient extends BaseRestClient {
return this.postPrivate('/api/mix/v1/plan/modifyTPSLPlan', params);
}

/** Cancel Plan Order TPSL */
/** Cancel Plan Order (TPSL) */
cancelPlanOrderTPSL(
params: CancelFuturesPlanTPSL,
): Promise<APIResponse<any>> {
return this.postPrivate('/api/mix/v1/plan/cancelPlan', params);
}

/** Cancel Symbol Plan Order (TPSL) */
cancelSymbolPlanOrders(
symbol: string,
planType: FuturesPlanType,
): Promise<APIResponse<any>> {
return this.postPrivate('/api/mix/v1/plan/cancelSymbolPlan', {
symbol,
planType,
});
}

/** Cancel All Trigger Order (TPSL) */
cancelAllPlanOrders(
productType: FuturesProductType,
Expand Down
5 changes: 3 additions & 2 deletions src/spot-client.ts
Expand Up @@ -21,6 +21,7 @@ import {
GetHistoricTradesParams,
VIPFeeRate,
SpotKlineInterval,
SpotCandleData,
} from './types';
import { REST_CLIENT_TYPE_ENUM } from './util';
import BaseRestClient from './util/BaseRestClient';
Expand Down Expand Up @@ -111,8 +112,8 @@ export class SpotClient extends BaseRestClient {
getCandles(
symbol: string,
period: SpotKlineInterval,
pagination?: Pagination,
): Promise<APIResponse<any>> {
pagination?: Pagination,
): Promise<APIResponse<SpotCandleData[]>> {
return this.get('/api/spot/v1/market/candles', {
symbol,
period,
Expand Down
12 changes: 12 additions & 0 deletions src/types/request/v1/futuresV1.ts
Expand Up @@ -215,3 +215,15 @@ export interface HistoricPlanOrderTPSLRequest {
isPre?: boolean;
isPlan?: string;
}

/**
* @typedef {string[6]} FuturesCandleData
* @property {Array[0]} Timestamp in milliseconds
* @property {Array[1]} Opening price
* @property {Array[2]} Highest price
* @property {Array[3]} Lowest price
* @property {Array[4]} Closing price - Value of the latest candle stick might change
* @property {Array[5]} Base currency trading volume
* @property {Array[6]} Quote currency trading volume
*/
export type FuturesCandleData = string[6];
44 changes: 28 additions & 16 deletions src/types/request/v1/spotV1.ts
Expand Up @@ -3,22 +3,23 @@ import { OrderTimeInForce } from '../shared';
export type WalletType = 'spot' | 'mix_usdt' | 'mix_usd';

export type SpotKlineInterval =
| '1min'
| '5min'
| '15min'
| '30min'
| '1h'
| '4h'
| '6h'
| '12h'
| '1M'
| '1W'
| '1week'
| '6Hutc'
| '12Hutc'
| '1Dutc'
| '3Dutc'
| '1Wutc'
| '1min'
| '5min'
| '15min'
| '30min'
| '1h'
| '4h'
| '6h'
| '12h'
| '1day'
| '3day'
| '1week'
| '1M'
| '6Hutc'
| '12Hutc'
| '1Dutc'
| '3Dutc'
| '1Wutc'
| '1Mutc';

export interface NewWalletTransfer {
Expand Down Expand Up @@ -124,3 +125,14 @@ export interface GetHistoricPlanOrdersParams {
startTime: string;
endTime: string;
}

export interface SpotCandleData {
open: string;
high: string;
low: string;
close: string;
quoteVol: string;
baseVol: string;
usdtVol: string;
ts: string;
}
9 changes: 9 additions & 0 deletions src/types/response/futures.ts
Expand Up @@ -35,8 +35,14 @@ export interface FuturesSymbolRule {
baseCoin: string;
buyLimitPriceRatio: string;
feeRateUpRatio: string;
limitOpenTime: string;
maintainTime: string;
makerFeeRate: string;
maxOrderNum: string;
maxPositionNum: string;
minTradeNum: string;
minTradeUSDT: string;
offTime: string;
openCostUpRatio: string;
priceEndStep: string;
pricePlace: string;
Expand All @@ -45,6 +51,9 @@ export interface FuturesSymbolRule {
sizeMultiplier: string;
supportMarginCoins: string[];
symbol: string;
symbolName: string;
symbolStatus: string;
symbolType: string;
takerFeeRate: string;
volumePlace: string;
}
Expand Down

0 comments on commit bcd7554

Please sign in to comment.