Spot Margin Trade (UTA)

Documentation on interacting with ByBit's Spot Margin Trade (UTA) API functions through the PENDAX Javascript SDK.

All parameters of type INTEGER listed in the Bybit API docs need to be passed in as a string.

Toggle Margin Trade

Please refer to the official ByBit API Docs for the required parameters.

https://bybit-exchange.github.io/docs/v5/spot-margin-uta/switch-mode

Function name:

toggleUnifiedMarginTrade(options)

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function toggleUnifiedMarginTrade(exchange, options) {
    try {
        let result = await exchange.toggleUnifiedMarginTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await toggleUnifiedMarginTrade(myByBitAccount,
    {
        spotMarginMode: "1"
    });

Get Leveraged Token Market

Please refer to the official ByBit API Docs for the required parameters.

https://bybit-exchange.github.io/docs/v5/spot-margin-uta/set-leverage

Function name:

setLeverageMargin(options)

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setLeverageMargin(exchange, options) {
    try {
        let result = await exchange.setLeverageMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setLeverageMargin(myByBitAccount,
    {
       leverage: "4"
    });

Last updated