Ah, right. I understand now. If that's the case, would it be easier to send the maximum amount available (without slippage) on one exchange to both exchanges?
Ie: exchange 1 has ask price 550 with amount 5, exchange 2 has bid price 600 with amount 10. You then place buy/sell orders for an amount of 5 on both exchanges. Ensuring no slippage.
Out of curiosity do you only examine the order book prices to a depth of 1? Seems like by doing so there'd be a few missed opportunities. However to examine with a depth of two the maths is much more involved.