remove dead inverse method, add write tests, update read tests, add error enums used by tests

This commit is contained in:
tiagosiebler
2022-05-10 13:22:28 +01:00
parent c94b4d16ff
commit c6758b65cc
6 changed files with 285 additions and 90 deletions

View File

@@ -1,10 +1,11 @@
export * from "./inverse-client";
export * from "./inverse-futures-client";
export * from "./linear-client";
export * from "./spot-client";
export * from "./websocket-client";
export * from "./logger";
export * from "./types/shared";
export * from "./types/spot";
export * from "./util/WsStore";
export * from "./constants/enum";
export * from './inverse-client';
export * from './inverse-futures-client';
export * from './linear-client';
export * from './spot-client';
export * from './websocket-client';
export * from './logger';
export * from './types/shared';
export * from './types/spot';
export * from './util/WsStore';
export * from './util/enum';
export * from './constants/enum';

View File

@@ -7,11 +7,9 @@ import {
} from './util/requestUtils';
import RequestWrapper from './util/requestWrapper';
import {
APIResponse,
APIResponseWithTime,
AssetExchangeRecordsReq,
CoinParam,
SymbolFromLimitParam,
SymbolInfo,
SymbolIntervalFromLimitParam,
SymbolLimitParam,
@@ -382,10 +380,6 @@ export class InverseClient extends BaseRestClient {
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
}
setPositionMode(params: { symbol: string; mode: 0 | 3 }): GenericAPIResponse {
return this.requestWrapper.post('v2/private/position/switch-mode', params);
}
setSlTpPositionMode(params: {
symbol: string;
tp_sl_mode: 'Full' | 'Partial';

View File

@@ -131,8 +131,7 @@ export default abstract class BaseRestClient {
await this.syncTime();
}
const signedRequest = await this.signRequest(params);
return signedRequest;
return this.signRequest(params);
}
/**

12
src/util/enum.ts Normal file
View File

@@ -0,0 +1,12 @@
export const API_ERROR_CODE = {
ORDER_NOT_FOUND_OR_TOO_LATE: 20001,
CANNOT_SET_TRADING_STOP_FOR_ZERO_POS: 30024,
/** Seen when placing an order */
INSUFFICIENT_BALANCE_FOR_ORDER_COST: 30031,
/** Seen if a conditional order is too large */
INSUFFICIENT_BALANCE: 30042,
/** E.g. trying to change position margin while on cross */
POSITION_IS_CROSS_MARGIN: 30056,
RISK_LIMIT_NOT_EXISTS: 30090,
SAME_SLTP_MODE: 37002,
} as const;