Skip to content
All library documents

Diagnosing NaN Prices in a Commodity Spread Strategy

Article vn.py community

Summary

A trader reports an error while running an rb-hc spread strategy in a simulated environment. The failure occurs when the strategy attempts to convert its current grid position into an integer target position, but the value is NaN. The trader suspects that a spread bar's close price may be NaN and asks why this could happen.

A respondent suggests checking whether data for one leg of the spread is missing or whether the underlying dataset contains zero-valued fields, and asks how the data was downloaded. The discussion therefore points to input data integrity and synchronization between spread legs as possible diagnostic areas. It does not establish the actual cause, provide a repair, or include a successful reproduction. The exchange is brief and concerns troubleshooting rather than a complete spread trading method, so its practical lesson is limited to inspecting both leg histories and their source data when spread calculations produce invalid values.

Key ideas

  • A spread strategy can fail when a calculated target position becomes NaN and cannot be converted to an integer.
  • Missing observations in either leg may lead to invalid spread-bar values.
  • Zero-valued fields in the underlying data are another possible source of the problem.
  • The discussion does not confirm the cause or document a fix.

Tags

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