QuantConnect / Lean.Brokerages.InteractiveBrokers

InteractiveBrokers Brokerage Plugin
Apache License 2.0
27 stars 17 forks source link

Portfolio.Values Not Actually Correct at All Times #102

Open superichmann opened 3 months ago

superichmann commented 3 months ago

Portfolio.Values not shows holding quantities from the broker even though there are holdings. In the example I give it is called from Initialize function but this can happen throughout the strategy.

I know its a hard bug to fix. Please instruct me on how to actually yes check for the current actual holdings through a quantconnect c# strat. maybe I am doing something wrong.

If Portfolio.Values are not reliable at any point during the strat runtime please also say it so I could implement a different mechanism for positions tracking.

Expected Behavior

In live mode with broker Portfolio.Values should return the actual portfolio values or indicate in some manner that we dont have the current holdings at the moment.

Actual Behavior

Portfolio.Values returns 0 from holding.Quantity even if holding.Quantity is not 0.

Potential Solution

Populate Portfolio.Values before any user code is running.

Reproducing the Problem

in live mode, AddEquity to the maximum amount of tickers (100) minute data and have one position at ONE of the tickers. in Initialize() go through Portfolio.Values in order to find the one position with holding.Quantity not 0. no such position is found although actually yes exists in the broker.

System Information

Checklist

jaredbroad commented 3 months ago

Please submit live logs of the situation it happens