A Ratio-Based Grid Strategy for Digital Currency Pairs
Summary
The document walks through a JavaScript implementation of a two-asset digital currency pair strategy on a trading platform. It estimates an average price ratio from aligned hourly candles, compares the current ratio with that average, and converts the deviation into target position values for the two contracts. When the deviation crosses a configured trade-value threshold, the strategy submits offsetting buy or sell orders, limits position values, accounts for contract multipliers and precision, and cancels orders after submission. The article also explains persistent storage for initial equity, retry handling for API calls, multi-pair market data, and status reporting.
The source is presented as an educational example, not as evidence of profitability. It depends on a suitable pair and a meaningful average ratio, and the configurable lookback, thresholds, position caps, and order values shape its behavior. The article notes differences in account-equity reporting across exchanges and requires a sufficiently recent platform connector for the multi-pair API. It does not provide performance results or a full treatment of execution costs, funding, or risk from persistent divergence between the paired assets.
Key ideas
- The strategy compares the live price ratio of two contracts with a historical average ratio.
- Ratio deviations determine target holdings, and trade-value thresholds control when position adjustments are submitted.
- Position limits, contract multipliers, and exchange precision are included in order sizing.
- Persistent storage and retry handling help preserve state and tolerate temporary API failures.
- Pair selection, exchange behavior, execution costs, and prolonged ratio divergence remain important risks.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.