Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lean logs have 'UnrealisedPnL' and 'RealisedPnl' backwards #112

Open
4 tasks done
tmills86 opened this issue May 9, 2024 · 1 comment
Open
4 tasks done

Lean logs have 'UnrealisedPnL' and 'RealisedPnl' backwards #112

tmills86 opened this issue May 9, 2024 · 1 comment

Comments

@tmills86
Copy link

tmills86 commented May 9, 2024

Expected Behavior

Lean logs should be showing UnrealisedPnl and RealisedPnl in their respective columns.

Actual Behavior

The logs have these two swapped. An example of the output I'm getting on my server looks like this:

2024-05-08T13:44:01.4882395Z TRACE:: InteractiveBrokersBrokerage.HandlePortfolioUpdates(): Contract: FUT MNQ USD , ConId: 620730945, Position: 0, MarketPrice: 18119.859375, MarketValue: 0, AverageCost: 0, UnrealisedPnl: 87.06, RealisedPnl: 0, AccountName: U########

As you can see, my position is 0, but I'm getting an UnrealisedPnl of 87.06, when this should be in the RealisedPnl column.

Reproducing the Problem

Take any position on interactive brokers and then close it. The UnrealisedPnl and RealisedPnl columns will be swapped.

System Information

Ubuntu 22.04.4 LTS

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
@jaredbroad
Copy link
Member

I think this might be a bug in IB: we just log the packet: https://github.com/QuantConnect/Lean.Brokerages.InteractiveBrokers/blob/dd264cf3470942151649005e921c129c68747a34/QuantConnect.InteractiveBrokersBrokerage/InteractiveBrokersBrokerage.cs#L2456C59-L2457C10

Log.Trace($"InteractiveBrokersBrokerage.HandlePortfolioUpdates(): {e}");

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

No branches or pull requests

2 participants