Spot Margin Trade (Normal)

Documentation on interacting with ByBit's Spot Margin Trade (Normal) 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.

Get Margin Coin Info

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

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/margin-data

Function name:

getMarginCoinInfo(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 getMarginCoinInfo(exchange, options) {
    try {
        let result = await exchange.getMarginCoinInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarginCoinInfo(myByBitAccount);

Get Borrowable Coin Info

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

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/borrowable-data

Function name:

getBorrowableCoinInfo(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 getBorrowableCoinInfo(exchange, options) {
    try {
        let result = await exchange.getBorrowableCoinInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBorrowableCoinInfo(myByBitAccount, {coin: "ETH"});

Get Interest & Quota

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

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/interest-quota

Function name:

getInterestAndQuota(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 getInterestAndQuota(exchange, options) {
    try {
        let result = await exchange.getInterestAndQuota(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInterestAndQuota(myByBitAccount,
    {
        coin: "USDT"
    });

Get Loan Account Info

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

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/account-info

Function name:

getLoanAccountInfo(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 getLoanAccountInfo(exchange, options) {
    try {
        let result = await exchange.getLoanAccountInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLoanAccountInfo(myByBitAccount);

Borrow

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

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/borrow

Function name:

borrowMargin(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 borrowMargin(exchange, options) {
    try {
        let result = await exchange.borrowMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await borrowMargin(myByBitAccount,
    {
        coin: "USDT",
        qty: "10"
    });

Repay

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

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/repay

Function name:

repayMargin(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 repayMargin(exchange, options) {
    try {
        let result = await exchange.repayMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await repayMargin(myByBitAccount,
    {
        coin: "USDT",
        completeRepayments: "1"
    });

Get Borrow Order Detail

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

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/borrow-order

Function name:

getBorrowOrderDetail(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 getBorrowOrderDetail(exchange, options) {
    try {
        let result = await exchange.getBorrowOrderDetail(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBorrowOrderDetail(myByBitAccount);

Get Repayment Order Detail

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

https://bybit-exchange.github.io/docs/v5/spot-margin-normal/repay-order

Function name:

getRepaymentOrderDetail(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 getRepaymentOrderDetail(exchange, options) {
    try {
        let result = await exchange.getRepaymentOrderDetail(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getRepaymentOrderDetail(myByBitAccount);

Toggle Margin Trade

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

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

Function name:

toggleNormalMarginTrade(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 toggleNormalMarginTrade(exchange, options) {
    try {
        let result = await exchange.toggleNormalMarginTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await toggleNormalMarginTrade(myByBitAccount,
    {
        switch: "1"
    });

Last updated