> For the complete documentation index, see [llms.txt](https://docs.compendium.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.compendium.finance/pendax/using-pendax-sdk/bybit-functions/spot-margin-trade-uta.md).

# Spot Margin Trade (UTA)

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

## Toggle Margin Trade

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

<https://bybit-exchange.github.io/docs/v5/spot-margin-uta/switch-mode>
{% endhint %}

#### Function name:

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

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

<https://bybit-exchange.github.io/docs/v5/spot-margin-uta/set-leverage>
{% endhint %}

#### Function name:

```javascript
setLeverageMargin(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 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"
    });
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/spot-margin-trade-uta.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.
