# Trading

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Place Order

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/create-order>
{% endhint %}

#### Function name:

```javascript
placeOrder(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/amend-order>
{% endhint %}

#### Function name:

```javascript
amendOrder(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/cancel-order>
{% endhint %}

#### Function name:

```javascript
cancelOrder(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/open-order>
{% endhint %}

#### Function name:

```javascript
getOpenOrders(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/cancel-all>
{% endhint %}

#### Function name:

```javascript
cancelAllOrders(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/order-list>
{% endhint %}

#### Function name:

```javascript
getOrderHistory(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="warning" %}
This function is under construction and may behave unexpectedly&#x20;
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/batch-place>
{% endhint %}

#### Function name:

```javascript
placeBatchOrder(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="warning" %}
This function is under construction and may behave unexpectedly&#x20;
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/batch-amend>
{% endhint %}

#### Function name:

```javascript
amendBatchOrder(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="warning" %}
This function is under construction and may behave unexpectedly&#x20;
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/batch-cancel>
{% endhint %}

#### Function name:

```javascript
cancelBatchOrder(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/spot-borrow-quota>
{% endhint %}

#### Function name:

```javascript
getBorrowQuotaSpot(options)
```

#### Usage:&#x20;

```javascript
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

{% hint style="warning" %}
This function is under construction and may behave unexpectedly&#x20;
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/dcp>
{% endhint %}

#### Function name:

```javascript
setDcp(options)
```

#### Usage:&#x20;

```javascript
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'
     });
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.compendium.finance/pendax/using-pendax-sdk/bybit-functions/trading.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
