Skip to content
All library documents

Implementing Cryptocurrency Pair Trading on FMZ

Article FMZ digest · Author: 小草

Summary

This document presents a JavaScript implementation of a two-asset cryptocurrency pair strategy on FMZ, along with platform features needed to run it. The strategy estimates a reference price ratio from hourly candles, compares the live ratio with that baseline, and adjusts opposing perpetual positions as the deviation changes. Position limits, trade-value thresholds, and iceberg order sizing govern order placement; the implementation then cancels submitted orders and reports account and position information.

The accompanying discussion covers persistent storage for initial account equity, retry and validity checks for API calls, multi-symbol market data and position requests, and contract-value conversions for instruments quoted in contract units. The example is intended as a compact practical demonstration rather than evidence of profitability: it gives no performance analysis or detailed trading evaluation. It notes that account equity fields can differ across exchanges and that using available balance may distort return tracking. Pair selection, fees, slippage, and parameter choices also require care, and the strategy assumes one-way position mode.

Key ideas

  • The strategy trades two perpetual contracts when their price ratio deviates from a historical average.
  • It adjusts opposing positions based on the deviation while enforcing per-asset position limits.
  • Contract values and amount precision must be accounted for when translating target exposure into order sizes.
  • Persistent storage and API error handling help a bot survive restarts and transient data failures.
  • The example does not establish profitability and depends on exchange-specific account fields and operating assumptions.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.