Skip to content
All library documents

Adapting Legacy Strategies to WebSocket Market Data with Function Hooks

Article FMZ digest · Author: 善

Summary

This article explains a platform-specific way to feed WebSocket quotes into an existing strategy without editing its core logic. It uses a reusable template library whose initialization function opens a supported exchange connection and replaces a market-data call such as GetTicker with a wrapper that reads pushed data. The example focuses on ticker data used by an older strategy and notes that similar hooks can be built for order books, trades, and candles.

The walkthrough outlines template parameters for enabling WebSocket mode and selecting the interface, then describes adding the template to a strategy and running it with an exchange and trading pair. Its example supports Binance and Huobi, so exchange coverage is limited, and the text does not provide latency measurements, reliability comparisons, or failure-recovery analysis. The approach depends on matching the pushed data format and lifecycle to what the original strategy expects; changing a data source through a hook can affect behavior even when the strategy’s main code is untouched.

Key ideas

  • A reusable template can replace a legacy strategy’s quote-fetching function with a WebSocket-backed wrapper.
  • The initialization routine can select a connection implementation and set up the subscription before strategy execution.
  • The example hooks ticker data and suggests extending the same pattern to depth, trades, and candles.
  • The demonstrated exchange implementations cover Binance and Huobi only.
  • The article describes integration mechanics but does not quantify speed or reliability gains.

Tags

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