# Locks for API Bindings

> How to limit the number of bots running simultaneously on a single trading account to avoid margin overruns and execution errors.

If you have many bots started and your trading account balance only allows you to safely run a limited number of deals, we recommend **setting up locks** at the API Binding level.

For example, if 10 bots are connected to one trading account and the lock allows **only 3 bots to open deals** at the same time, this ensures margin safety and stable operation of all bots.

:::caution[Important!]
1. The setting applies **only to bots with filters for a deal start**. \
Bots without filters ignore locks and can exceed the limit. \
GRID bots are also not affected by a block. We recommend that you personally ensure that GRID and DCA bots for the same coin and in the same direction are not running simultaneously on a single account.
2. A bot that stops with an error (for example, "Insufficient balance") **releases a slot**, and another bot can take its place.
Review our margin management recommendations to avoid such situations.
:::

👉 For more information about bot errors, see the article [Bot Errors](https://help.veles.finance/en/platform/components/bot-errors/).

👉 For more information about risk management, see the article [How to Reduce Trading Risks](https://help.veles.finance/en/getting-started/strategies/reduce-risks/).

## How to set up Locks

1. Go to **profile settings** by clicking on the "Profile" icon in the upper right corner.

2. On the settings page, find the **"Locks"** section.

3. Click **"Add lock"**.

4. Select the desired API key Binding (for example, *BingX Futures*) and configure the Lock settings for it.

> In the [mobile app](https://help.veles.finance/en/platform/dashboard/applications/#trade), locks are set/removed on a special tab within each API binding.

## How to Remove a Lock

**Locks** — to disable a lock, go to the "Locks" section on the platform or in the Binding settings: click on "Locks" → delete.

## Lock by Position

On Futures, one trading account can have **only one position for each coin and direction**.
For example: one Long position on ETH and one Short position on ETH.

If three Futures bots for one coin in Long will open their deals at the same time, all three deals will be visible in your Veles cabinet, but on the exchange it is actually **one common position**.
This can cause distortions in PnL and order price calculation, leading to incorrect data and losses.

**Lock by Position** solves this problem — it allows only **one active deal per pair and direction** on the selected API Binding.
If one bot in Long on ETH is already running, the second bot will not be able to open a deal until the first one completes the trade.

:::caution[Important!]
If several Futures bots for one coin are subject to position locking, **they must have the same leverage**.
Lock is triggered after the leverage is set on the exchange, so a difference in leverage can affect a deal, that is already open.
:::

Lock "By position" is created simultaneously with the API binding — a special checkbox is activated by default.

Lock "By position" works on both Futures and Spot bindings - although there is no position on the spot, the lock also prevents two bots for the same coin and direction from opening the trade.

## Lock by bots (by number of deals)

This setting is useful if you have created many bots (for different assets), but their signals are rare.
For example, you can run **100 bots**, but allow only **10** of them to trade simultaneously — within a safe margin.

## Lock by Long and Short 

You can set separate limits for **Long** and **Short** directions.
For example, out of 10 bots allowed to work simultaneously, no more than 2 can be Short.

:::caution[Important!]
If several API Bindings are linked to the same trading account, keep an eye on the **combined total effect** of all Locks.
Otherwise, you may accidentally have simultaneous deals for one coin and direction on one account.
:::
