Using B113.
I have a strategy for which Max Open Pos = 5.
For data till 2/25/25, it had 3 open positions and there were 3 'Buy at Market' signals. All trades are assigned a priority.
With data updated to 2/26/25, the strategy correctly shows a total open positions as 5 (3 previous + 2 new based on priority).
However, the open position count incorrectly shows the open position count as 6; it appears it added all 3 market orders to existing position count w/o checking the Max Open Pos limit. The error lies here:
Kindly fix.
I have a strategy for which Max Open Pos = 5.
For data till 2/25/25, it had 3 open positions and there were 3 'Buy at Market' signals. All trades are assigned a priority.
With data updated to 2/26/25, the strategy correctly shows a total open positions as 5 (3 previous + 2 new based on priority).
However, the open position count incorrectly shows the open position count as 6; it appears it added all 3 market orders to existing position count w/o checking the Max Open Pos limit. The error lies here:
CODE:
int opc1 = OpenPositionsAllSymbols.Count;
Kindly fix.
Rename
By design.
During Strategy execution, OpenPositionsAllSymbols includes all Backtester open positions for all symbols in any context, including NSF Positions. You can go through the list and remove the NSF positions, or if it's applicable for your strategy, uncheck "Retain NSF Positions" in the Strategy Settings.
This will work if you want to ignore NSFs for this call -
Depending how you use it, your strategy won't process the NSFs, which will remain as "open positions" forever, which will likely change your strategy results in a major way. Your call.
During Strategy execution, OpenPositionsAllSymbols includes all Backtester open positions for all symbols in any context, including NSF Positions. You can go through the list and remove the NSF positions, or if it's applicable for your strategy, uncheck "Retain NSF Positions" in the Strategy Settings.
This will work if you want to ignore NSFs for this call -
CODE:Warning!
using System.Linq; public List<Position> OpenPositionsAllSymbolsNoNSF() { OpenPositionsAllSymbols.Where(p => p.NSF == false).ToList(); }
Depending how you use it, your strategy won't process the NSFs, which will remain as "open positions" forever, which will likely change your strategy results in a major way. Your call.
I can understand the confusion. We should probably address this somehow by allowing callers to specify whether or not that want to include NSF positions. Maybe deprecate the existing methods/properties and introduce new ones with a parameter?
I find Cone's answer confusing and rather impractical.
@Glitch,
I'm 100% with you on creating a simple, unambiguous way to specify the count of all open positions across all symbols (p'folio backtest) in a strategy at each bar.
Should be fairly straightforward, one would think: If 'Retain NSF Positions' box is checked in Strategy Settings tab they should be counted in open posn count, if UNchecked then not.
If at all possible, try to work with existing methods so existing code won't get broken.
@Glitch,
I'm 100% with you on creating a simple, unambiguous way to specify the count of all open positions across all symbols (p'folio backtest) in a strategy at each bar.
Should be fairly straightforward, one would think: If 'Retain NSF Positions' box is checked in Strategy Settings tab they should be counted in open posn count, if UNchecked then not.
If at all possible, try to work with existing methods so existing code won't get broken.
Update
I went back and checked that strategy... the Retain NSF Posns box was checked, I must have done it while backtesting to see % of NSF posns.
With the box UNchecked and the strategy refreshed in Strategy Monitor its showing the correct OpenPosn count in the trade signal.
So I guess that part is working OK. 🤔
However, the discrepancy between # of Open Posns shown (5, NSF posn not shown) in P'folio Backtest in the strategy's Positions tab vs the count displayed in the trade signal (6) with Retain NSF Posns box checked is unresolved, if the developers wish to tackle that.
I went back and checked that strategy... the Retain NSF Posns box was checked, I must have done it while backtesting to see % of NSF posns.
With the box UNchecked and the strategy refreshed in Strategy Monitor its showing the correct OpenPosn count in the trade signal.
So I guess that part is working OK. 🤔
However, the discrepancy between # of Open Posns shown (5, NSF posn not shown) in P'folio Backtest in the strategy's Positions tab vs the count displayed in the trade signal (6) with Retain NSF Posns box checked is unresolved, if the developers wish to tackle that.
Yes I guess it makes sense, if you are retaining NSFs then you want to preserve the integrity of the strategy so you would want even the NSF positions. I guess not always, like for purposes of position sizing? Seems like it's not an open and shut case. Maybe we do think about providing an option.
Your Response
Post
Edit Post
Login is required