BTCMarkets / API

API
120 stars 30 forks source link

Insufficient funds - non fiat pairs #81

Closed mmihira closed 4 years ago

mmihira commented 6 years ago

The algorithm which checks the sufficient funds looks to be incorrect ?

Given the example I'm buying bcash for bitcoin. Using a real example where I place a bid for BCH in the BCH/BTC pair

Volume: 0.00632 BCH Price: 0.18062804 Spend Total: 0.00114408 (from the front-end)

It calculates the spend total assuming the bitcoin paid includes the fee. However, when the transaction is completed: the fee is deducted from the bch bought NOT the btc paid.

So in my transaction history -0.00114156 BTC is deducted 0.00632 * 0.18062804 = 0.00114156 (NOT 0.00114408 and stated in the required funds) And then 0.00632 BCH is credited, from which 0.0000139 BCH fee is taken.

Only enough btc is actually consumed in the transaction to pay for the gross BCH bought. So the spend total is erroneous. If you don't have the btc equivalent of the bch fee as extra funds the transaction doesn't even happen !

This also is a pain when working with the API because I do have enough funds for the transaction, but I actually need some extra BTC to make the trade engine happy even though it's not included in the transaction.

This is just weird or have I got something wrong ?

cheriff commented 6 years ago

+1, seeing something similar when selling LTC for BTC:

Even the web interface is strange (not taking into account the API for the moment):

  1. Buy/Sell page says I have available 0.22110844 LTC
  2. Clicking "sell all" will pre-populate the volume field with 0.22062306
    • this is 0.22% less. So perhaps BTCM is taking their fee in LTC?
  3. Set a price of 1 BTC/LTC, just to make the conversion easy and ensure we never actually match
  4. Observe the Receive Total is 0.22013768 BTC
    • This is 0.22% less again! So perhaps BTCM is taking their fee in BTC after conversion?

If via the API I try sell all 0.22110844 LTC I also get 'insufficient funds' (see #78). However via the API I can place an order for 0.2110844*0.9978 = 0.22062200 LTC


Edit: did a test and removed some speculation:

I did the above trade at market price:{"currency":"BTC", "instrument":"LTC", "price":0, "volume":22062200, "orderSide":"Ask", "ordertype":"Market", "clientRequestId":"nop"}

This succeeded and was Fully Matched with a single trade: {"id":1057576436, "creationTime":1514670191193 ,"description":null, "price":1650471, "volume":22062200, "side":"Ask", "fee":48536, "orderId":1057576410}

My LTC balance is now 0.00000108 LTC. Now 22062200+48536+108=22110844 so fee was taken as 0.00048536 LTC. Weird that it's "on top" of the order and not taken out of the proceeds, but fair enough.

My BTC balance has grown by 0.00364130, and given 0.22062200* 0.01650471 = 0.00364130212962, that seems close enough (the difference is around 0.003 of 1 cent)


So it seems that altcoin/BTC trades have the fee deducted in alt (the instrument), whereas coin/AUD seem to take more/give you less aud (the currency), no?

So for these trades, rather than selling all my LTC and expecting to receive 0.22% less of the BTC proceeds, I'll just put in the order for 99.78% of what I have on hand and expect the full amount of BTC at the matched price.

It's a bit awkward that I now have a tiny amount of LTC that's effectively unusable as it stands now, i'd much rather all fees be taken in the currency, for consistency's sake.

mmihira commented 6 years ago

So it seems that altcoin/BTC trades have the fee deducted in alt (the instrument), whereas coin/AUD seem to take more/give you less aud (the currency), no?

This was my conclusion as well.

So for these trades, rather than selling all my LTC and expecting to receive 0.22% less of the BTC proceeds, I'll just put in the order for 99.78% of what I have on hand and expect the full amount of BTC at the matched price.

This is probably why the spend total is calculated in btc ( otherwise the spend total would be different for each altcoin/btc pair). What I've ended up doing is just to make sure I have a little extra btc in my account at all times to ensure the system won't complain I don't have insufficient funds.

martin-nginio commented 4 years ago

Hi @mmihira

Thank you for your feedback.

We have recently introduced a more simplified fee scheme for non fiat pairs (including rewards when you provide liquidity as a market maker)

Please feel free to check it out and let us know if you have any questions: https://support.btcmarkets.net/hc/en-us/articles/360038037153

I'm now closing this issue.

Thank you.

Regards, Martin