Apologies, for some reason I misread your statement to mean that you had set CashQty to 3000000.
?
Whatever, the fact is that setting TotalQuantity to zero gives exactly the error message you quoted. If it works on a BUY, but not on a SELL, then perhaps you code is just not setting the field properly for a SELL.?