Skip to content
All library documents

Handling Null Position and Order Data in Trading Scripts

Article FMZ forum · Author: Neo1898

Summary

This post reports an intermittent runtime error in a live trading script when code attempts to read a position’s price field. The author asks whether the cause could be a null custom field or missing price data, and whether wrapping the position query in a retry or caching helper would prevent the failure. The code also accesses nested position information and order prices while building status tables, illustrating several points where absent or incomplete API responses could cause errors.

The post does not provide a confirmed diagnosis or a tested fix, and it notes that simulation did not reproduce the problem. It therefore offers a useful troubleshooting case rather than a validated solution: live exchange responses may differ from simulated data, and checking that returned objects and nested fields exist before reading them is a relevant defensive-programming practice. The proposed wrapper alone is not shown to guarantee that the position data or its fields are non-null.

Key ideas

  • A live trading script failed while accessing a position price field.
  • The author considers missing position data and a null custom field as possible causes but does not establish which occurred.
  • The example accesses nested position fields and order prices that may also be absent.
  • Simulation did not reproduce the reported error, and no fix is confirmed.

Tags

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