Skip to content
All library documents

Practical Data Handling and State Management for Trading Strategies

Article FMZ digest · Author: 发明者量化-小小梦

Summary

This guide presents implementation practices for market-data-driven strategies, with examples for ticker quotes, order book depth, recent trades, and candlesticks. It recommends checking incoming data for null values and implausible conditions, then discarding and reacquiring suspect observations so faulty inputs do not drive trading logic. For indicator use, it explains that the bar history must be long enough for the chosen lookback and that the first valid moving average appears only after enough bars are available.

The article also describes detecting a completed bar by tracking changes in the latest bar’s timestamp, measuring API call duration, limiting quantities to account balances or minimum order sizes, and controlling price and quantity precision. Finally, it outlines timestamp-based scheduled actions and saving strategy state at shutdown for recovery on restart. These are general engineering examples tied to a specific platform; they do not assess strategy returns, and data validation rules should reflect the venue and instrument.

Key ideas

  • Validate market data before using it, and retry or discard observations that fail checks.
  • Indicator calculations need sufficient bar history for their lookback period.
  • A change in the latest bar timestamp can signal that a new bar has begun and the previous one has completed.
  • Quantity limits and numeric precision controls help prevent invalid orders.
  • Strategies can schedule actions with timestamps and persist key state for recovery after restart.

Tags

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