Skip to content
All library documents

Dynamic Position Sizing in Backtests When Cash Is Not Exposed

Article vn.py community

Summary

A forum discussion considers how to size orders dynamically during a backtest as account equity changes. The trader describes a strategy that may lose capital after a position closes and then needs to size a new entry using the reduced balance. They explain that examples using a fixed order size do not model this behavior meaningfully for their use case.

The response says the framework does not currently expose real-time remaining capital for this purpose. It suggests tracking cash after each trade and caching the value as a workaround, while pointing to a course lesson on using a risk level to control order quantity. Other participants echo the need for real-time capital access, but the thread offers no implementation details, tested example, or comparison of the approaches. Any custom tracking would need careful handling of fills, fees, open positions, and realized equity; those mechanics are not covered here.

Key ideas

  • The discussion asks how to calculate order size from current account capital during a backtest.
  • The framework described does not provide a supported way to read real-time remaining capital.
  • One suggested workaround is to update and cache capital after each trade.
  • A risk-level setting is mentioned as another way to control order quantity.
  • The thread does not demonstrate either approach or explain its accounting assumptions.

Tags

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