diff --git a/examples/rest-v5-private.ts b/examples/rest-v5-private.ts index bc66ec1..c38701d 100644 --- a/examples/rest-v5-private.ts +++ b/examples/rest-v5-private.ts @@ -7,20 +7,38 @@ const key = process.env.API_KEY_COM; const secret = process.env.API_SECRET_COM; const client = new RestClientV5({ - key, - secret, - strict_param_validation: true, + key: key, + secret: secret, }); (async () => { 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({ category: 'option', symbol: 'BTCUSDT', }); 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) { console.error('request failed: ', e); } diff --git a/src/constants/enum.ts b/src/constants/enum.ts index 8ea22a0..8ade830 100644 --- a/src/constants/enum.ts +++ b/src/constants/enum.ts @@ -78,6 +78,7 @@ export const API_ERROR_CODE = { SUB_USER_NOT_FOUND: 141009, SPOT_LEVERAGE_TOKEN_INSUFFICIENT_BALANCE: 175006, SPOT_LEVERAGE_TOKEN_ORDER_NOT_FOUND: 175007, + SPOT_LEVERAGE_QUIZ_REQUIRED: 175010, SPOT_MARGIN_NOT_ENABLED: 176008, SPOT_MARGIN_QUESTIONNAIRE_NOT_SUBMIT: 176037, /** E.g. USDC Options trading, trying to access a symbol that is no longer active */ diff --git a/src/types/request/v5-spot-leverage-token.ts b/src/types/request/v5-spot-leverage-token.ts index 189f5fd..b60e306 100644 --- a/src/types/request/v5-spot-leverage-token.ts +++ b/src/types/request/v5-spot-leverage-token.ts @@ -2,7 +2,7 @@ import { LTOrderTypeV5 } from '../v5-shared'; export interface PurchaseSpotLeveragedTokenParamsV5 { ltCoin: string; - ltAmount: string; + amount: string; serialNo?: string; } diff --git a/test/v5/private.write.test.ts b/test/v5/private.write.test.ts index 8e56efc..cd3b958 100644 --- a/test/v5/private.write.test.ts +++ b/test/v5/private.write.test.ts @@ -416,17 +416,16 @@ describe('Private WRITE V5 REST API Endpoints', () => { leverageToken = tokenResult.result.list[0]; }); - // Still failing - in contact with bybit - it.skip('purchaseSpotLeveragedToken()', async () => { + it('purchaseSpotLeveragedToken()', async () => { expect( await api.purchaseSpotLeveragedToken({ - ltAmount: '100', + amount: '100', ltCoin: leverageToken.ltCoin, }) ).toMatchObject({ // ...successResponseObjectV3(), - retCode: API_ERROR_CODE.SPOT_LEVERAGE_TOKEN_INSUFFICIENT_BALANCE, - retMsg: '', + retCode: API_ERROR_CODE.SPOT_LEVERAGE_QUIZ_REQUIRED, + // retMsg: '', }); });