Repairing frozen trading positions#

Automatically managed positions may end up to a “frozen” state in the case the trade execution logic encounters and error and a safety trips.

  • Trading position is marked as frozen if a trade executor attempts to trade a position, but the trade fails for a reason or another

  • Positions are shown on Frozen positions list

  • Frozen positions are not included in the total equity of a strategy

  • Frozen positions need manual intervention

The reasons why a trade executor may mark a position as a frozen

  • The gas fee needed to complete the trade was higher than the allowed limit

  • A blockchain node was down

  • The blockchain itself was halted (see BNB Chain incident)

  • Internal error that needs to be patched

  • Out of gas money

Fixing frozen positions#

Currently the frozen positions can be fixed manually on the server where the trade executor is running.

First clear any obstacles that might be blocking the frozen position trades, like topping up the gas wallet.

Go to the server and docker-compose.yml folder where the trade executor is running.

Choose the trade executor Docker image version (you can peak the current version using docker ps command):

source scripts/set-latest-tag.sh

# Or manualy:
# Tell docker-compose.yaml the pinned software version
# export TRADE_EXECUTOR_VERSION=v106

# Executor name for the following commmands
EXECUTOR_ID=quickswap-matic-usd-ema

Check running strategies

docker-compose ps

For any strategy to be repaired, its trade executor must be stopped first.

docker-compose stop $EXECUTOR_ID

Now you can start the repair:

docker-compose run $EXECUTOR_ID repair

This will attempt to re-execute all trades that failed prior.

Note

The process is interactive and will prompt you the trades before attempting to fix them, so it is safe to run.

After the repair command is run you get a report:

Saved state to state/quickswap-matic-usd-ema.json, total 1623881 chars

Restarting the executor#

For any strategy to be repaired, its trade executor must be stopped first.

docker-compose up -d $EXECUTOR_ID