Three ways minimum order sizes break a trading bot
Every exchange has a minimum order size and a lot step for each market. On paper it is a footnote. In a trading bot that manages small positions it is the source of a whole family of quiet bugs: nothing crashes, the dashboard looks normal, and a position sits there unprotected or half closed. We met three of them while building the execution engine behind Volantius. Each one, with the numbers, and what fixed it.
1. Take-profits that were never placed
The engine split a position into equal parts, one per target. A long of 0.04 BNB with six targets gives 0.00667 per part. The exchange minimum for that market was 0.01. Every one of the six take-profit orders was refused.
The position stayed open with a stop and no targets. It ran for 35 hours, went through the first and second target prices, and booked nothing. Because no target filled, the stop was never moved to breakeven either. The only trace was one warning line in the log at the moment the trade opened.
The fix: before placing targets, work out how many whole minimum lots the position holds and trim the target list to that number. For the position above that is four targets of 0.01. The same check runs when the engine re-places missing orders, so positions that were already open repaired themselves on the next cycle.
Take the minimum as the largest of three numbers: the market's minimum amount, its amount step, and its minimum order value divided by the price. Exchanges enforce all three.
2. A position that could not be closed
A long of 0.03 BNB had two parts of 0.01 filled. The amount left should have been 0.01. In floating-point arithmetic it was 0.009999999999999997.
The exchange library rounds amounts down to the lot step, so that became zero, and an order for zero is rejected. The close button in the app failed. Re-arming the stop failed for the same reason. The safety routine tried again every cycle, for hours, with the same result.
The fix has two parts. First, snap an amount to the nearest lot step when it is within a tenth of a percent of one, before any rounding down. Second, when a close order would still be under the minimum and the exchange reports that the position exists, use the exchange's close-position call for that market, which ignores lot size.
3. Specks left behind after closed trades
The engine subtracted the exact part from its own record of the position, while the exchange had rounded each order down to the lot step. After a few fills the record said 0.0267 BNB and the exchange held 0.04.
The stop was sized from the record, so when it fired it closed less than the real position and left a remainder. The monitoring loop treated anything under 2% of the original size as gone and marked the trade closed. The remainder stayed on the exchange account, too small to notice and too small to close with a normal order.
The fix: size the stop from what the exchange reports whenever that is larger than the record, and flatten any remainder on every path that ends a trade. We also ran a one-time sweep over the connected accounts, with a dry run first, which closed 79 leftover positions.
What the three have in common
- None of them raised an error a person would see. Each was one log line, or none.
- All three appear only on small positions in markets with a coarse lot step, which is exactly where a new user starts.
- The exchange is the source of truth. A bot's own record of a position is a cache, and every decision that protects money should be checked against what the exchange reports.
A checklist for your own bot
- Read the minimum amount, amount step and minimum order value for every market at start-up, and refuse to open a position that cannot hold at least one minimum lot per planned order.
- Do arithmetic on amounts in lot-step units, or snap to the step before rounding.
- Size protective orders from the exchange's position, not from your own bookkeeping.
- After every close, ask the exchange whether anything is left, and close it.
- Test with the smallest position your users are allowed to open, not with a comfortable round number.
Volantius is our tool for executing Telegram trading signals on your own exchange account, with the stop and targets placed as real orders on the exchange. It is not a signal provider and it makes no promise of profit.
Risk note: this is not investment advice. Trading crypto derivatives with leverage can lose your whole deposit, and automation does not change that.