Python Price-Following Strategy with Five-Percent Rebalance Triggers
Summary
This educational Python example follows price moves using a reference price that resets after each trade. When BTC/USDT rises more than the configured 5% threshold above the reference, the bot buys using a fraction of available cash, provided the calculated quantity clears a minimum size. When price falls more than 5% below the reference, it sells a fraction of its holdings under a similar minimum-size check. The program polls the ticker repeatedly and logs market and account information.
The code also cancels outstanding orders periodically, although its market buy and sell calls may not create resting orders. The published backtest settings specify one-minute data for OKEX from February 2019 through January 2020, but no return, drawdown, or trade statistics are given. The example has no explicit stop-loss, profit target, or portfolio-level risk control; its fixed threshold and position fractions can behave quite differently across volatility regimes, and execution costs are not discussed.
Key ideas
- The bot compares the current price with a reference level that resets after each trade.
- A rise or fall greater than 5% triggers a buy or sell using a fraction of available account assets.
- Minimum trade-size checks prevent orders below the configured threshold.
- The code polls prices frequently and periodically cancels outstanding orders.
- The published backtest settings give a market and date range but no performance evidence or explicit risk controls.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.