Switching from long to short position at market close

I am trying to submit orders that close a long position (or a short position) and open a new position on the other side, i.e. go from long to short or vice versa. Rather than waiting for the sell order to fill before submitting the order to short, I would like to send all orders into the closing auction (setting time_in_force to ‘cls’), so that they are executed together at the same time and at the closing price.

When doing this I get the below error from the API response:

Exception: insufficient qty available for order (requested: 180, available: 145)