# Managing an Active DCA-Deal

> How to manage a DCA-bot deal in Veles — close at market price on the platform, add an extra averaging, or cancel.

Managing an active deal in Veles allows you to quickly respond to market changes.
You can **close a deal at market price**, **average a deal**, or **cancel a bot deal** to take it under manual control.

Managing an Active deal via the [**trade card**](https://help.veles.finance/en/platform/components/trade-card/) in Veles allows you to respond quickly to market changes. You can:
- close the deal at market price (fix the current loss or profit),
- average the deal (add an unscheduled top-up order),
- cancel the bot's deal (remove orders on the exchange and stop the bot) to take manual control of the situation.

:::note
If you need to stop the bot only **after the current deal complete**, use the **Stop** button on the [bot card](https://help.veles.finance/en/platform/components/bot-card/).
If the deal is in the invest state, closing it may take a long time.
:::

## Close Deal at Market Price

This function closes the deal immediately, without waiting for the Take Profit or Stop Loss to be executed.

The dialog box displays the parameters of your deal (the data is static — close and reopen the window to see the updated values).

After confirmation, the system will:

1. Close the deal on the exchange:
   - on futures, the bot will close the contracts;
   - on spot, the coin will be sold or bought back.
2. Fix the current **PnL** (profit or loss).
3. Delete all remaining bot orders.
4. Set the bot status to **"Awaiting signal"**.

----------------------------------------
## Averaging a deal manually

If the price has moved too far from the Take Profit, you can add an averaging order. This will bring the average deal price closer to the current price.

:::note[Example]
The bot bought **10 coins at 4 USDT**, and the price dropped to 2-3 USDT.
If you buy another **30 coins at 2 USDT**, then:

(10×4 + 30×2) / (10+30) = 2,5 USDT.

The average deal price will drop to **2.5 USDT**, and if the price returns to this range, you can exit without a loss.
:::

**Averaging formula**:

P = (Q1×P1 + Q2×P2) / (Q1+Q2)

- P — new average price,
- Q1, P1 — quantity and price of the first purchase,
- Q2, P2 — quantity and price of averaging.

### Important rules for averaging

:::caution[Be careful]
1. If you set a price higher than the current one for a Long deal (or lower than the current one for a Short deal), the order will be executed as a market order.
2. It is **impossible** to delete an erroneous averaging order. If the order is deleted on the exchange, the bot will stop with an error, and the order will be recreated when the deal is restarted.
3. If there is insufficient free margin, the bot will stop with the error "Insufficient balance."

:::

In the averaging window, specify:

- **Price** — the price at which the order will be placed (replace the suggested value with your own, calculated using the formula above).
- **Amount** — can be specified in coins or USDT (replace the suggested value with your own).

To find out the amount of your own funds in the averaging order, divide the "Amount" by the leverage used in the bot.

To safely average a position on futures in your exchange account, it is recommended to hold this "Amount" in USDT (in addition to the bot balance [calculated before startup](https://help.veles.finance/en/getting-started/strategies/reduce-risks/)).

:::note
If the price of this new order is too far from the current asset price, the exchange may return the error "Order price does not meet requirements." In this case, the bot cannot run the deal and the user should take it under manual control.
:::

## Cancel the deal

The "Cancel" function completely removes the bot from running the deal.

After cancellation:

1. The bot will delete all its unfilled orders.
2. The bot will switch to the "Terminated" status.
3. The trade will disappear from the "Active Deals" section.
4. The funds reserved for unfilled orders will be released.
5. For futures, the liquidation price may shift.

----------------------------------------
:::danger[Important!]
- **On futures, the position will remain open.** It must be closed manually through the exchange interface (by a limit or market order).
- **On spot,** you must record the average buy/sell price and volume before cancelling to know at what price to close the deal manually.
:::

## How to manually close a position on the exchange

1. Log into the exchange app or website.
2. Open your trading account (**Futures / Derivatives / Unified Trading Account**).
3. Go to the **"Positions"** tab and find the desired coin.
4. Select "Close by" -> "Limit Order" and set the price (with a profit or an acceptable loss, the exchange will display the expected result). 
5. Confirm the order; it will appear in "Current Orders."
6. Wait for the limit order to fill, or close the position by market price if you need to immediately.

### Difference between PnL

- **Realized PnL** — already reflected on the balance of the trading account.
- **Unrealized PnL** — potential result after closing the position.

:::note[Example]
You transferred 300 USDT to the trading account.
After canceling the deal, the bot stopped, but the position remained open.

- Realized PnL = -0.14 USDT
- Unrealized PnL = -30.54 USDT

After closing this position by market price, on the balance will remain:
300 – 0,14 – 30,54 = **269,32 USDT**.
:::

## Why is it important to delete orders?

Forgotten orders on the exchange can:

- block your funds,
- cause bot errors such as "Insufficient Balance",
- lead to unpredictable losses or even liquidation.

The bot automatically deletes unnecessary orders. However, if it stops with an error, the user is responsible for finding and deleting them.

:::tip[Tip]
Regularly check the "Orders" tab on the exchange and monitor your margin.
For more details, see the article [How to Reduce Liquidation Risks](https://help.veles.finance/en/getting-started/strategies/reduce-risks/).
:::

## Restart the deal

Sometimes, after stopping with an error, the bot can be restarted. It will continue trading from the place where it left off.

Examples:

- "Orders cancelled by 3rd party" due to accidental deletion of the order,
- "Insufficient balance" due to lack of margin for an order or coins for a Spot bot commission.

In such cases, the bot recreates orders, picks up a position on Futures, or continues to run the same volume that was traded on the Spot by that time.

:::note[Note]
If a manual averaging order has been added to the Futures bot's deal, it becomes part of the deal, and after restarting it will also be restored (if it was deleted).
:::

After errors like "Liquidation", "Position reduced" or "Unknown error", the bot believes that there is nothing left to restart or it is dangerous. Therefore, the "Restart the Deal" button will not be displayed.

:::note[Note]
If more than 14 days have passed since the stop, it will not be possible to restart the deal after any error.
:::

To restart the deal:

1. Go to the main page of your personal account: https://veles.finance/cabinet

2. Find the stopped bot and expand its card.

3. In the drop-down list, click **Run**.

4. In the pop-up window, select **Restart the deal**.
