fix spot leverage token endpoint v5

This commit is contained in:
tiagosiebler
2023-02-21 13:30:25 +00:00
parent 6d24317022
commit 00a45e4cd0
4 changed files with 28 additions and 10 deletions

View File

@@ -7,20 +7,38 @@ const key = process.env.API_KEY_COM;
const secret = process.env.API_SECRET_COM; const secret = process.env.API_SECRET_COM;
const client = new RestClientV5({ const client = new RestClientV5({
key, key: key,
secret, secret: secret,
strict_param_validation: true,
}); });
(async () => { (async () => {
try { try {
/** Simple example for a private REST API call with bybit's V5 REST APIs */ /** Simple examples for private REST API calls with bybit's V5 REST APIs */
const response = await client.getPositionInfo({ const response = await client.getPositionInfo({
category: 'option', category: 'option',
symbol: 'BTCUSDT', symbol: 'BTCUSDT',
}); });
console.log('response:', response); console.log('response:', response);
// Trade USDT linear perps
const buyOrderResult = await client.submitOrder({
category: 'linear',
symbol: 'BTCUSDT',
orderType: 'Market',
qty: '1',
side: 'Buy',
});
console.log('buyOrderResult:', buyOrderResult);
const sellOrderResult = await client.submitOrder({
category: 'linear',
symbol: 'BTCUSDT',
orderType: 'Market',
qty: '1',
side: 'Sell',
});
console.log('sellOrderResult:', sellOrderResult);
} catch (e) { } catch (e) {
console.error('request failed: ', e); console.error('request failed: ', e);
} }

View File

@@ -78,6 +78,7 @@ export const API_ERROR_CODE = {
SUB_USER_NOT_FOUND: 141009, SUB_USER_NOT_FOUND: 141009,
SPOT_LEVERAGE_TOKEN_INSUFFICIENT_BALANCE: 175006, SPOT_LEVERAGE_TOKEN_INSUFFICIENT_BALANCE: 175006,
SPOT_LEVERAGE_TOKEN_ORDER_NOT_FOUND: 175007, SPOT_LEVERAGE_TOKEN_ORDER_NOT_FOUND: 175007,
SPOT_LEVERAGE_QUIZ_REQUIRED: 175010,
SPOT_MARGIN_NOT_ENABLED: 176008, SPOT_MARGIN_NOT_ENABLED: 176008,
SPOT_MARGIN_QUESTIONNAIRE_NOT_SUBMIT: 176037, SPOT_MARGIN_QUESTIONNAIRE_NOT_SUBMIT: 176037,
/** E.g. USDC Options trading, trying to access a symbol that is no longer active */ /** E.g. USDC Options trading, trying to access a symbol that is no longer active */

View File

@@ -2,7 +2,7 @@ import { LTOrderTypeV5 } from '../v5-shared';
export interface PurchaseSpotLeveragedTokenParamsV5 { export interface PurchaseSpotLeveragedTokenParamsV5 {
ltCoin: string; ltCoin: string;
ltAmount: string; amount: string;
serialNo?: string; serialNo?: string;
} }

View File

@@ -416,17 +416,16 @@ describe('Private WRITE V5 REST API Endpoints', () => {
leverageToken = tokenResult.result.list[0]; leverageToken = tokenResult.result.list[0];
}); });
// Still failing - in contact with bybit it('purchaseSpotLeveragedToken()', async () => {
it.skip('purchaseSpotLeveragedToken()', async () => {
expect( expect(
await api.purchaseSpotLeveragedToken({ await api.purchaseSpotLeveragedToken({
ltAmount: '100', amount: '100',
ltCoin: leverageToken.ltCoin, ltCoin: leverageToken.ltCoin,
}) })
).toMatchObject({ ).toMatchObject({
// ...successResponseObjectV3(), // ...successResponseObjectV3(),
retCode: API_ERROR_CODE.SPOT_LEVERAGE_TOKEN_INSUFFICIENT_BALANCE, retCode: API_ERROR_CODE.SPOT_LEVERAGE_QUIZ_REQUIRED,
retMsg: '', // retMsg: '',
}); });
}); });