This problem seems to occur when you have a strategy which has multiple partial entries and exits (i.e. rebalancing).
The strategy I have runs on two instruments (same problem with single instrument though), and rebalances every week or every other week (leading to a large amount of partial entries and exits). The strategy calculates the desired position sizes by using the current net capital of the strategy by summing the realized P&L and the open P&L for all instruments with an open position. Profits or losses in a short leg then require a rebalance in both positions.
Unfortunately, I'm not able to provide a sample strategy as there is far too much use of custom methods/framework and I don't have the time to strip stuff out. I've already spent way too much time helping report/debug/resolve problems with NT8. However, if you'd like me to help print any outputs to help resolve this issue, I'd be happy to do so as it's considerably less effort.
Here is a code snippet though which will help explain the output further below:
double RealizedPL = SystemPerformance.AllTrades.TradesPerformance.Currency.CumProfit; double OpenPL = 0; foreach (InstrumentClass o in TradedList) { if (o.HasPosition) { OpenPL = OpenPL + Positions[o.Index].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Closes[o.Index][0]); Print("[" + o.Index + "] Unrealized P/L = " + Positions[o.Index].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Closes[o.Index][0]).ToString("C")); } } Print(RealizedPL.ToString("C") + " + " + OpenPL.ToString("C") + " = " + (RealizedPL + OpenPL).ToString("C")); Print("[Stats] Total P&L = " + Metrics.TotalProfitLoss.ToString("C") + " / " + (Metrics.TotalProfitLoss / Metrics.InitialCapital).ToString("P")); if (States.HasPositions && Times[0][0] >= new DateTime(2015, 1, 30)) { Print("Closing Positions"); DoFlatten(); }
-------------------- [1398] Session Open: January 29, 2015 @ 09:30:00 -------------------- [Capital Management] Current Capital = $1,779,056.46 [2] Unrealized P/L = $579,751.77 [1] Unrealized P/L = $501,303.60 $617,822.32 + $1,081,055.37 = $1,698,877.69 [Stats] Total P&L = $1,698,877.69 / 1,698.88 % -------------------- [1399] Session Open: January 30, 2015 @ 09:30:00 -------------------- [Capital Management] Current Capital = $1,798,877.69 | Previous Capital = $1,779,056.46 [2] Unrealized P/L = $610,763.38 [1] Unrealized P/L = $452,764.71 $617,822.32 + $1,063,528.09 = $1,681,350.42 [Stats] Total P&L = $1,681,350.42 / 1,681.35 % Closing Positions -------------------- [1400] Session Open: February 2, 2015 @ 09:30:00 -------------------- [Capital Management] Current Capital = $1,131,536.93 | Previous Capital = $1,798,877.69 [2] Unrealized P/L = ($335.01) [1] Unrealized P/L = ($252.96) $1,031,412.14 + ($587.97) = $1,030,824.17 [Stats] Total P&L = $1,030,824.17 / 1,030.82 %
Comment