# 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"
    });
```
