IB positions caching issue? closed positions show up in blotter

I stop ibg overnight to prevent issues. I restarted it today, logged in when prompted using the IB app. I ran some code that uses the positions HTTP endpoint and was surprised to see only a list of positions that correspond to trades I did yesterday and which were closed out at the end of the session. Additionally a couple of positions that are in that IB account long-term do not show up in the list of positions. So is blotter only concerned with positions that originated from QR? And why is it remembering these old positions?

Here is the output when I run blotter from the cli:
jupyter:/codeload $ quantrocket blotter positions
Account,OrderRef,Sid,Quantity
U4296736,FIBBG0024QY1Y6opening,FIBBG0024QY1Y6,2612
U4296736,FIBBG0024TG624opening,FIBBG0024TG624,4746
U4296736,FIBBG014HVF3N5opening,FIBBG014HVF3N5,5182
U4296736,FIBBG014HVGDK5opening,FIBBG014HVGDK5,13333
jupyter:/codeload $ quantrocket ibg status
ibg1:
status: running

thanks
George Coles

Here is the explanation you can find by running quantrocket blotter positions -h:

There are two ways to view positions: blotter view (default) and broker view.

The default "blotter view" returns positions by account, sid, and order ref. Positions
are tracked based on execution records saved to the blotter database.

"Broker view" (using the --broker option) returns positions by account and sid (but
not order ref) as reported directly by the broker.

So, to see your portfolio as it exists with your broker, can you run:

quantrocket blotter positions --broker | csvlook 

Alternatively, you can see your portfolio as it exists with the broker by running:

quantrocket account portfolio | csvlook

In contrast, when you run:

quantrocket blotter positions

you are correct that you are seeing only positions that originated within QuantRocket. These positions are tracked based on execution records received from IB Gateway. You can think of the blotter view as a virtual portfolio. In theory, you could be long 100 AAPL in strategy A and short 100 AAPL in strategy B; as a result, you would have no AAPL position with IBKR but the blotter would still be tracking the two virtual AAPL positions.

What I assume happened is that you closed the positions manually in TWS and/or didn't assign an order ref; as a result, QuantRocket may not have received any execution records or it may have received them but didn't know what order ref they were associated with. Thus, as far as the blotter knows, you still hold those positions.

QuantRocket provides an API to record executions that happened outside of its knowledge, which is described in the usage guide and API Reference. You could use this API to record that the positions have already been closed out.

Thanks for the clarifications. I am sorry to be less prepared than I normally might be and ask poor questions. While the documentation is good, I am suffering a bit I think from needing to navigate QR as a wrapper for IB and IB itself is not documented as far as I can see with an emphasis on non-screen trading. There are some semantics that fall between QR and IB, for example what to expect back from IB in order statuses, and why I got an error submitting an order with one mistake but another mistake was flagged by IB and I. need to introspect the order status JSON.

best
George Coles