Closing all positions (blotter vs. broker)

Looking here in the API docs, I can’t find if quantrocket.blotter.close_positions closes all positions including any diff between blotter & broker.

The goal is to re-establish an account to 100% of Strategy1 although there are 3 OrderRef’s of varying position size the blotter sees. Here is an example for 1 Sid:

list_positions(orders_file)

>>'OrderRefs': {'Strategy2': 6,   # Not running
              'Strategy1': 81,  # Currently running algo
              'uncategorized': 241 # Manual Trades
              }
  'BrokerQuantity': 45 # TRUE IB Positions
  'QuantityDiff': 283

If I were to run:

close_positions(orders_file)
place_orders(orders_file)

It would submit the OrderRefs dictionary:

Strategy2: Sell 6
Strategy1: Sell 81
Uncategorized: Buy 241

But the reality is that BrokerQuantity is accurate; 45 are in the account.
I’d like the blotter cleared so it looks like the account is fresh again. I plan to manually bring the account to cash.
Checking /var/lib/quantrocket doesn’t seem to show an easy way to rm -r this specific blotter.

Side note: In the IB app you can’t specify order-ref as you can in TWS mentioned here for manual trading. If a manual trade has to happen in the app, will this occur every time?

It would be easiest to use new order refs for your strategies in which case the old order refs are irrelevant and don’t need to be cleaned up as they’re not harming anything.

Positions are stored in the LatestPosition table in quantrocket.v2.blotter.executions.sqlite but you’re on your own if you decide to edit that table.