So far we haven't been able to reproduce this issue. What error message are you seeing - is it the "Margin allowance exceeded" message, or something else?
"Insufficient Funds"
OK, thanks - the "Insufficient Funds" message means that the system thinks you don't have sufficient balance in marginable currencies (BTC, EUR, USD) to cover the initial margin requirement of the order. So if there's an issue, it sounds like
the system may not be accounting for the overall initial margin required for long and short orders. I'll make sure the devs look into this if they aren't already.
Yes, that could be true: the system calculates the required margin by adding up all positions and open orders. But since the orders could cancel open positions, such a summing seems not to be correct.
The system does calculate the required margin by adding up all positions and unfilled orders (both buy and sell). The reason is to avoid "fake" orders on the book that can't be taken because they aren't backed by anything. If you have 10 BTC in your account, you can put in a leveraged buy order for 30 BTC at 3:1 leverage. But if you are also allowed to put in a leveraged sell order for 30 BTC at 3:1 leverage and the buy order is later filled, then you now have a fake 30 BTC sell order on the book that isn't backed by anything. And you could iterate this process to create more fake orders.
The sell order is not unbacked but backed by the long position of 30BTC. E.g. the buy order is accepted, the user is 30BTC long and can put a 30BTC sell order. The same is true when the sell order is accepted, where he can then open a 30BTC long order. So why not allow both orders to be placed?
I'm not sure I'd say the short order is "backed" by the long position, but since the short order could only be used to close the long position, it may be unnecessary to require additional margin for it. So I see your question and am checking to see about the possibility of allowing it.
This would not be possible to be iterated, since 2x 30BTC long and 2x 30BTC sell orders make no sense, it would add to 60BTC instead of 30BTC.
Agreed - you couldn't iterate this to get an order larger than 30 BTC. I realized this after posting, but was away from the keyboard and couldn't correct it.
Great you look into it. Here is a fresh example from a second ago to show that it is currently inconsistent: order sequence counts, but it should not
- I am 5BTC short
- I have 25BTC open short orders
- I can place another 5BTC short order, I can also place a 30BTC long order
- If I place the 5BTC short order before the 30BTC long order, it goes through
- If I place the 30BT long order first, I cannot place the 5BTC short order anymore. I then need to cancel the 30BTC long order, place the short order and replace the long order.
edit: another feature request: let users close their positions with their balances. For example, someone is 10BTC short, sends 10 BTC to kraken and has then the option to close his position with his balance.