Skip to main content

Auto-Squareoff

Auto Squareoff

Have you ever thought about what would happen if your algorithm encountered an error because of a margin issue? Will your position remain open, or will you need to handle it manually through your broker?

With AlgoTest, you don't have to worry. Our "Auto Squareoff on Margin Error" feature enables your algorithm to automatically square off positions if your strategy encounters a margin error due to insufficient funds in your broker account.

Stay confident and focused on your trading, knowing that AlgoTest has got you covered!

How to Enable Auto Squareoff Feature

Here are the steps to enable the auto squareoff feature for your strategy:

  • Visit the Live Trade page onAlgoTest website.

  • Scroll down and click on "Setup/Edit Execution Settings" for the strategy you want to use for auto square-off.

  • Please enable the auto squareoff feature, as demonstrated in the image below.

Please note: This feature is only applicable to errors caused by margin insufficiency in your account. In the event of a margin error, we will instruct the broker to close the positions. However, there is a slim possibility that your broker may reject this instruction. In such cases, it is recommended to also check with your broker after the strategy has been closed due to a margin error.

Reasons for Margin Error & Solution

There could be several reasons why a broker might reject your order due to insufficient funds.

Insufficient Funds

Your broker may reject orders if you don't have sufficient funds in your account to execute the strategy. Make sure to know beforehand how much margin is required to execute the strategy.

To determine this, you can use the "Estimate Margin" feature in AlgoTest. Backtest your strategy in AlgoTest and click on the "Calculate Margin" button to calculate the required margin for running this strategy.

Hedges

It's important to remember that some traders use hedges or buy legs to obtain margin benefits in an Option Selling/Futures strategy. If you're not familiar with using hedges properly, your broker may reject your orders.

To get margin benefits, for entry, you first need to execute hedges or buy legs, and then you can execute sell legs. For exit, you first need to execute sell legs, and then hedges or buy legs. AlgoTest provides a ":delay entry" feature in execution settings, allowing you to delay entry of sell legs to obtain margin benefit. During exit, AlgoTest will send buy orders after sell orders by default.