Refactoring a Single-Asset Python Strategy for Multiple Markets
Summary
This tutorial shows how to adapt a simple price-chasing strategy to trade several cryptocurrency pairs from one bot. Its central design change is to store market-specific values—such as reference prices, trade thresholds, minimum order sizes, and precision settings—in indexed arrays. Each exchange is then passed with its index to a shared processing function, so the same trading logic runs separately for each pair.
The article also describes periodically canceling outstanding orders and displaying each market’s ticker and account data in status tables. It includes a backtest configuration with three pairs, but offers no performance analysis or detailed assessment of the trading rule. The example is intended as a programming pattern: parameter arrays must match the number of configured markets, and the original logic remains a simple threshold-based chase strategy. The article recommends further testing and optimization, so the code should not be taken as evidence of profitability.
Key ideas
- Store per-market settings in arrays, using each market’s index to select its values.
- Put the shared trading logic in a function and call it once for each configured exchange.
- Keep account and ticker data indexed by market so monitoring reflects each pair separately.
- Check that every parameter array has an entry for each configured market.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.