Skip to content

Fix swapped unrealized/realized PnL in IB updatePortfolio#222

Open
katchke wants to merge 1 commit intoQuantConnect:masterfrom
katchke:fix/update-portfolio-pnl-order
Open

Fix swapped unrealized/realized PnL in IB updatePortfolio#222
katchke wants to merge 1 commit intoQuantConnect:masterfrom
katchke:fix/update-portfolio-pnl-order

Conversation

@katchke
Copy link
Copy Markdown

@katchke katchke commented Apr 7, 2026

Summary

Aligns InteractiveBrokersClient.updatePortfolio parameter names with IB EWrapper.updatePortfolio: averageCost, unrealizedPNL, realizedPNL, accountName.

The previous names (realisedPnl, unrealisedPnl) were reversed relative to the actual slot binding, so UpdatePortfolioEventArgs received swapped values—e.g. closed position P&L appearing under UnrealisedPnl (see #112).

Change

  • Rename the last two double parameters to unrealisedPnl, realisedPnl in declaration order. The UpdatePortfolioEventArgs(...) call is unchanged and is now correct.

Fixes #112

IB EWrapper passes unrealizedPNL then realizedPNL after averageCost.
Parameter names were reversed relative to binding, so values were
swapped when passed to UpdatePortfolioEventArgs (logs showed closed
P&L under UnrealisedPnl).

Fixes QuantConnect#112

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lean logs have 'UnrealisedPnL' and 'RealisedPnl' backwards

1 participant