Trading

Documentation on interacting with ByBit's Trading API functions through the PENDAX Javascript SDK.

Place Order

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

https://bybit-exchange.github.io/docs/v5/order/create-order

Function name:

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

const result = await placeOrder(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       side: 'Buy',
       orderType: 'Market',
       qty: '10'
     });

Amend Order

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

https://bybit-exchange.github.io/docs/v5/order/amend-order

Function name:

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

const result = await amendOrder(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       qty: '0.000034',
       orderId: '12345'
     })

Cancel Order

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

https://bybit-exchange.github.io/docs/v5/order/cancel-order

Function name:

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

const result = await cancelOrder(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       orderId: '12345'
     });

Get Open Orders

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

https://bybit-exchange.github.io/docs/v5/order/open-order

Function name:

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

const result = await getOpenOrders(myByBitAccount, 
    {
       category: 'linear'
       
     });

Cancel All Orders

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

https://bybit-exchange.github.io/docs/v5/order/cancel-all

Function name:

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

const result = await cancelAllOrders(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD'
     });

Get Order History

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

https://bybit-exchange.github.io/docs/v5/order/order-list

Function name:

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

const result = await getOrderHistory(myByBitAccount, 
    {
       category: 'linear'
     });

Batch Place Order

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

https://bybit-exchange.github.io/docs/v5/order/batch-place

Function name:

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

const result = await placeBatchOrder(myByBitAccount, 
    {
       category: 'linear',
       request: [
           {
               category: 'linear',
               symbol: 'BTCPERP',
               side: 'Buy',
               orderType: 'Market',
               qty: '0.000033'
           },
           {
               category: 'linear',
               symbol: 'BTCPERP',
               side: 'Buy',
               orderType: 'Market',
               qty: '0.000030'
           }
       ]
     });

Batch Amend Order

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

https://bybit-exchange.github.io/docs/v5/order/batch-amend

Function name:

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

const result = await amendBatchOrder(myByBitAccount, 
    {
       category: 'linear',
       request: [
           {
               symbol: 'BTCPERP',
               qty: '0.000034',
               orderId: '12345'
             },
           {
               symbol: 'BTCPERP',
               orderId: '12346'
               qty: '0.000030'
           }
       ]
     });

Batch Cancel Order

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

https://bybit-exchange.github.io/docs/v5/order/batch-cancel

Function name:

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

const result = await cancelBatchOrder(myByBitAccount, 
    {
       category: 'linear',
       request: [
           {
               symbol: 'BTCUSD',
               orderId: '12345'
             },
           {
               symbol: 'BTCUSD',
               orderId: '12346'
           }
       ]
     });

Get Borrow Quota

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

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

Function name:

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

const result = await getBorrowQuotaSpot(myByBitAccount, 
    {
       category: 'spot',
       symbol: 'BTCUSDT',
       side: 'buy'
     });

Set Disconnect Cancel All

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

https://bybit-exchange.github.io/docs/v5/order/dcp

Function name:

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

const result = await setDcp(myByBitAccount, 
    {
       timeWindow: '100'
     });

Last updated