Merge pull request #197 from tiagosiebler/cptrade

update tests for copy trading client
This commit is contained in:
Tiago
2022-11-14 10:45:04 +00:00
committed by GitHub
3 changed files with 15 additions and 11 deletions

View File

@@ -45,6 +45,8 @@ export const API_ERROR_CODE = {
RISK_LIMIT_NOT_EXISTS: 30090, RISK_LIMIT_NOT_EXISTS: 30090,
LEVERAGE_NOT_MODIFIED: 34036, LEVERAGE_NOT_MODIFIED: 34036,
SAME_SLTP_MODE: 37002, SAME_SLTP_MODE: 37002,
COPY_TRADE_NOT_OPEN_ORDER: 39426,
QTY_EXCEEDS_MAX_LIMIT: 130006,
ORDER_NOT_FOUND_OR_TOO_LATE_LINEAR: 130010, ORDER_NOT_FOUND_OR_TOO_LATE_LINEAR: 130010,
ORDER_COST_NOT_AVAILABLE: 130021, ORDER_COST_NOT_AVAILABLE: 130021,
CANNOT_SET_LINEAR_TRADING_STOP_FOR_ZERO_POS: 130024, CANNOT_SET_LINEAR_TRADING_STOP_FOR_ZERO_POS: 130024,

View File

@@ -1,4 +1,5 @@
import { API_ERROR_CODE, CopyTradingClient } from '../../src'; import { API_ERROR_CODE, CopyTradingClient } from '../../src';
import { successResponseObjectV3 } from '../response.util';
describe('Private Copy Trading REST API GET Endpoints', () => { describe('Private Copy Trading REST API GET Endpoints', () => {
const API_KEY = process.env.API_KEY_COM; const API_KEY = process.env.API_KEY_COM;
@@ -19,20 +20,22 @@ describe('Private Copy Trading REST API GET Endpoints', () => {
// (just make sure auth works and endpoint doesn't throw) // (just make sure auth works and endpoint doesn't throw)
it('getActiveOrders()', async () => { it('getActiveOrders()', async () => {
expect(await api.getActiveOrders()).toMatchObject({ expect(await api.getActiveOrders()).toMatchObject(
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS, successResponseObjectV3()
}); );
}); });
it('getPositions()', async () => { it('getPositions()', async () => {
expect(await api.getPositions()).toMatchObject({ expect(await api.getPositions()).toMatchObject(successResponseObjectV3());
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
});
}); });
it('getBalances()', async () => { it('getBalances()', async () => {
expect(await api.getBalances()).toMatchObject({ expect(await api.getBalances()).toMatchObject(successResponseObjectV3());
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS, });
it('closePosition()', async () => {
expect(await api.closePosition('SOLUSDT', '1')).toMatchObject({
retCode: API_ERROR_CODE.COPY_TRADE_NOT_OPEN_ORDER,
}); });
}); });
}); });

View File

@@ -75,17 +75,16 @@ describe('Private Linear REST API POST Endpoints', () => {
order_type: 'Limit', order_type: 'Limit',
side: 'Buy', side: 'Buy',
symbol, symbol,
qty: 1, qty: 1000000,
price: 8100, price: 8100,
base_price: 8300, base_price: 8300,
stop_px: 8150, stop_px: 8150,
time_in_force: 'GoodTillCancel', time_in_force: 'GoodTillCancel',
order_link_id: 'cus_order_id_1',
reduce_only: false, reduce_only: false,
trigger_by: 'LastPrice', trigger_by: 'LastPrice',
}) })
).toMatchObject({ ).toMatchObject({
ret_code: API_ERROR_CODE.INSUFFICIENT_BALANCE_FOR_ORDER_COST_LINEAR, ret_code: API_ERROR_CODE.QTY_EXCEEDS_MAX_LIMIT,
}); });
}); });