Broker Position does not match QR Blotter

Hi Brian,

I've got a position in IBKR that my blotter says should not exist. I went through the history of orders in the blotter and the aggregate purchases tie out so that I should not have a current position in the brokerage account. However, I'm still showing a large position in IBKR (roughly double the size that my strategies held).

How do you suggest I trouble shoot to understand where they error occurred?

Thanks.

The most natural explanation would be if trades occurred in your IBKR account that were not submitted and managed by QuantRocket (e.g. manual orders in TWS), or submitted by a different deployment of QuantRocket (and thus not known by this QuantRocket's blotter).

As far as troubleshooting, you might try opening the trade history window in TWS for the last 7 days and comparing it to the blotter history to see if that reveals a non-QuantRocket trade; however, TWS history only goes back 7 days.

Going forward, you might try regularly running:

quantrocket blotter positions --broker --diff

to promptly spot any differences between the blotter positions and the broker positions, as any discrepancies will be easier to track down the sooner you catch them after they occur.

Brian, I got on the phone with IBKR and figured out what happened. The security in question is MNST (Monster Beverage) and if I add up all my purchases and sales I should be flat. The issue is that my last sale was on 8/12 and MNST had a 2:1 split on 8/11. So while the strategy sold shares equal to the amount the strategy purchased I held twice as many shares due to the split.

How do you recommend I reconcile this in my blotter?

How does Quantrocket track stock splits and how do I prevent this from happening again?

Thanks.

Here’s what I would do.

For illustration, assume you bought 100 shares of MNST at $100. After the 2-for-1 split, you held 200 shares with an adjusted price of $50 per share. Assume the market price did not otherwise change.

  • The blotter records the original purchase of 100 shares at $100, then the sale of 100 shares at $50. It therefore shows a $50-per-share realized loss and a flat position, even though you have 100 shares in IBKR.
  • Use quantrocket.blotter.record_executions to record an additional purchase, dated the same as the original purchase, for the number of MNST shares currently held at IBKR. Record the execution at a price of $0.
  • The zero-price execution restores the missing post-split shares without adding additional cost basis. In the example, it offsets the blotter’s artificial loss from selling 100 shares at the post-split price when the blotter still treats the original purchase as 100 pre-split shares.
  • After recording the adjustment, the blotter position should match the IBKR position. You can then close the position through QuantRocket, either through the strategy or (what I would do) with quantrocket.blotter.close_positions.

For future splits, QuantRocket provides an API to record stock splits, which is described in the usage guide along with tips for detecting stock splits. The API for recording stock splits only works for open positions, so it's important to promptly detect stock splits while the position is still open. If the blotter has already closed a position before you detect the split, a reconciliation approach like I describe above is necessary.

1 Like