Skip to content
All library documents

Initializing a Trading Strategy with Existing Positions

Article vn.py community

Summary

This community post asks how to start a live or simulated trading strategy with positions already held in the account, rather than having the strategy assume it begins flat. It also raises a related backtesting question: a user supplied an initial-position parameter, but daily profit-and-loss calculations did not reflect that holding. The excerpt points to the result-calculation routine, where the starting position is initialized to zero.

The post identifies a practical distinction between live strategy state and backtest accounting: loading current account positions may initialize trading behavior, but the backtest’s daily mark-to-market calculation must also account for the initial holding if its P&L is to include it. The excerpt provides no answer or proposed fix, and it does not explain how the platform synchronizes positions, prices, or cost basis. Readers should treat the zero initialization as the question’s observed code detail, not as a complete diagnosis of the framework’s behavior.

Key ideas

  • A live or simulated strategy may need to initialize from positions already held in its account.
  • The post asks whether an initial-position parameter is reflected in daily backtest profit and loss.
  • The shown result-calculation routine sets the starting position to zero.
  • Position initialization and backtest accounting may require separate handling.
  • The excerpt poses the issue but does not provide a solution or establish the full cause.

Tags

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