Phantom Positions in the Blotter

@Brian I've got some phantom positions showing up in the blotter. I'm doing some clean up so I closed my strategy positions and then double checked what is showing up in my brokerage account and confirmed the positions I closed out are no longer show up in my IBKR account. However, if I run the below:

'''''
from quantrocket.blotter import download_positions
import io, pandas as pd

f = io.StringIO()
download_positions(f)
positions = pd.read_csv(f)
positions
'''''''

It gives me a list of positions that do not exist. To remove them from the blotter should I run the purge script in the CLI you provided me last year with the order_ref of the positions still showing in the blotter? Please advise. Thanks.

The purge script is appropriate if you want to completely remove the order_ref from the blotter, including not only the positions but the historical orders, executions, and PNL.

If you want to keep the historical records but clear out the positions table to reconcile it with the brokerage positions, you can use the workflow described for delisted positions in the Usage Guide (https://www.quantrocket.com/docs/#orders-detect-delisted-positions). This approach is more work as it requires you to set a price at which the closing transaction occurred. You would want to go sid by sid through the order ref, like this:

quantrocket blotter close --order-refs 'myorderfer' --sids 'FIBBG12345' --params 'Price:XX.XX' | quantrocket blotter record -f '-'
1 Like