Merge pull request #7 from tiagosiebler/trailfut
v1.0.4: feat(#6) add futures trailing stop endpoint, add missing types for new order endpoint
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bitget-api",
|
"name": "bitget-api",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "Node.js connector for Bitget REST APIs and WebSockets, with TypeScript & end-to-end tests.",
|
"description": "Node.js connector for Bitget REST APIs and WebSockets, with TypeScript & end-to-end tests.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const API_ERROR_CODE = {
|
|||||||
INSUFFICIENT_BALANCE: '40754',
|
INSUFFICIENT_BALANCE: '40754',
|
||||||
QTY_GREATER_THAN_MAX_OPEN: '40762',
|
QTY_GREATER_THAN_MAX_OPEN: '40762',
|
||||||
FUTURES_ORDER_CANCEL_NOT_FOUND: '40768',
|
FUTURES_ORDER_CANCEL_NOT_FOUND: '40768',
|
||||||
|
FUTURES_INSUFFICIENT_POSITION_NO_TPSL: '40891',
|
||||||
QTY_LESS_THAN_MINIMUM: '43006',
|
QTY_LESS_THAN_MINIMUM: '43006',
|
||||||
/** Parameter verification exception margin mode == FIXED */
|
/** Parameter verification exception margin mode == FIXED */
|
||||||
PARAMETER_EXCEPTION: '40808',
|
PARAMETER_EXCEPTION: '40808',
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
FuturesSymbolRule,
|
FuturesSymbolRule,
|
||||||
FuturesMarginMode,
|
FuturesMarginMode,
|
||||||
FuturesPosition,
|
FuturesPosition,
|
||||||
|
NewFuturesPlanTrailingStopOrder,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
@@ -417,6 +418,13 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
return this.postPrivate('/api/mix/v1/plan/placeTPSL', params);
|
return this.postPrivate('/api/mix/v1/plan/placeTPSL', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Place Trailing Stop order */
|
||||||
|
submitTrailingStopOrder(
|
||||||
|
params: NewFuturesPlanTrailingStopOrder
|
||||||
|
): Promise<APIResponse<any>> {
|
||||||
|
return this.postPrivate('/api/mix/v1/plan/placeTrailStop', params);
|
||||||
|
}
|
||||||
|
|
||||||
/** Place Position TPSL */
|
/** Place Position TPSL */
|
||||||
submitPositionTPSL(
|
submitPositionTPSL(
|
||||||
params: NewFuturesPlanPositionTPSL
|
params: NewFuturesPlanPositionTPSL
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ export type FuturesOrderSide =
|
|||||||
| 'open_long'
|
| 'open_long'
|
||||||
| 'open_short'
|
| 'open_short'
|
||||||
| 'close_long'
|
| 'close_long'
|
||||||
| 'close_short';
|
| 'close_short'
|
||||||
|
| 'buy_single'
|
||||||
|
| 'sell_single';
|
||||||
|
|
||||||
export interface NewFuturesOrder {
|
export interface NewFuturesOrder {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
@@ -100,15 +102,27 @@ export interface ModifyFuturesPlanOrderTPSL {
|
|||||||
presetStopLossPrice?: string;
|
presetStopLossPrice?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FuturesPlanType = 'profit_plan' | 'loss_plan';
|
export type FuturesPlanType = 'profit_plan' | 'loss_plan' | 'moving_plan';
|
||||||
|
|
||||||
export interface NewFuturesPlanStopOrder {
|
export interface NewFuturesPlanStopOrder {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
marginCoin: string;
|
marginCoin: string;
|
||||||
planType: FuturesPlanType;
|
planType: FuturesPlanType;
|
||||||
triggerPrice: string;
|
triggerPrice: string;
|
||||||
holdSide?: FuturesHoldSide;
|
triggerType?: 'fill_price' | 'market_price';
|
||||||
|
holdSide: FuturesHoldSide;
|
||||||
size?: string;
|
size?: string;
|
||||||
|
rangeRate?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NewFuturesPlanTrailingStopOrder {
|
||||||
|
symbol: string;
|
||||||
|
marginCoin: string;
|
||||||
|
triggerPrice: string;
|
||||||
|
triggerType?: 'fill_price' | 'market_price';
|
||||||
|
size?: string;
|
||||||
|
side: FuturesOrderSide;
|
||||||
|
rangeRate?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NewFuturesPlanPositionTPSL {
|
export interface NewFuturesPlanPositionTPSL {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ describe('Private Futures REST API POST Endpoints', () => {
|
|||||||
data: {},
|
data: {},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`submitOrder() exception: `, e.body);
|
// console.log(`submitOrder() exception: `, e.body);
|
||||||
expect(e.body).toMatchObject({
|
expect(e.body).toMatchObject({
|
||||||
// seems to be the new "insufficient balance" error, informed bitget on 7th feb
|
// seems to be the new "insufficient balance" error, informed bitget on 7th feb
|
||||||
code: API_ERROR_CODE.QTY_GREATER_THAN_MAX_OPEN,
|
code: API_ERROR_CODE.QTY_GREATER_THAN_MAX_OPEN,
|
||||||
@@ -227,6 +227,7 @@ describe('Private Futures REST API POST Endpoints', () => {
|
|||||||
marginCoin,
|
marginCoin,
|
||||||
symbol,
|
symbol,
|
||||||
planType: 'profit_plan',
|
planType: 'profit_plan',
|
||||||
|
holdSide: 'long',
|
||||||
triggerPrice: '100',
|
triggerPrice: '100',
|
||||||
})
|
})
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
@@ -234,8 +235,9 @@ describe('Private Futures REST API POST Endpoints', () => {
|
|||||||
data: {},
|
data: {},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// console.log(e.body);
|
||||||
expect(e.body).toMatchObject({
|
expect(e.body).toMatchObject({
|
||||||
code: API_ERROR_CODE.FUTURES_POSITION_DIRECTION_EMPTY,
|
code: API_ERROR_CODE.FUTURES_INSUFFICIENT_POSITION_NO_TPSL,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user