nunoloureiro / birdtradebot

Cryptocurrency Bot that receives trading advice and performs transactions (manages wallets)
MIT License
13 stars 3 forks source link

Rounds in coins ? #3

Closed edgardurao closed 6 years ago

edgardurao commented 6 years ago

For some reason i've about 0.00100457 BTC in my GDAX account.

For other reason, the bot sees it as 0.00100458, and when tries to sell it, it goes wrong.

Maybe it's a round of a value somewhere?

2018-01-29 04:01:23,737 - init - INFO - Tweet rule match || @ BirdpersonBorg: Going short @ BTCEUR
(Mon, 29 Jan 2018 04:00:26 +0000) 2018-01-29 04:01:24,488 - init - INFO - Current balance in wallet: LTC: 0.00000000, ETH: 0.00000000, BCH: 0.00000000, BTC: 0.00100458, EUR: 0.00000000 2018-01-29 04:01:24,491 - init - INFO - Placing order: {'price': '9185.00', 'product_id': 'BTC-EUR', 'type': 'limit', 'side': 'sell', 'size': '0.00100458'} 2018-01-29 04:01:24,883 - init - INFO - Order placed. Server reply: {u'message': u'Insufficient funds'}

nunoloureiro commented 6 years ago

GDAX only allows 8 decimal digits, not sure why the API reports something different than what you see on the interface.

In regard to the insufficient funds, I hopefully fixed it this morning (I had the same problem).

When the bot gets that error, it truncates the last decimal digit and tries to submit another order. The bot was already doing that but for buying, not selling. I added the same behavior for selling as well, so hopefully, it's fixed.

https://github.com/nunoloureiro/birdtradebot/commit/57d077049ce5168e591e632ca975885cafd56d0a#diff-c9736bc3748c2a7cb4ba9dc9e4c6bef9

edgardurao commented 6 years ago

@nunoloureiro well i've tried to track this down a bit... debugging the values available in account i get "available=0.0010045759230424", so this fits in rounding to 0.00100458. Any idea how to solve this? The only way i see to get around is to previlege market instead of limit, but that's not my favourite approach

nunoloureiro commented 6 years ago

It shouldn't be a problem. It'll truncate (not round) when it gets the insufficient funds error.

edgardurao commented 6 years ago

ok, i will enable the permissions to trade and let's test it in next short. Thanks

nunoloureiro commented 6 years ago

@edgardurao this was actually not fixed.. the function to truncate that was only using for long orders actually set that the transaction was to buy.

It's fixed now in head. Please git pull.

edgardurao commented 6 years ago

I confirm... It seems to be fixed, and now i see all the digits which i get through API

2018-02-01 21:21:33,288 - init - DEBUG - Got the following tweet: Going short @ BTCEUR 2018-02-01 21:21:33,292 - init - INFO - Tweet rule match || @ mytwitter: Going short @ BTCEUR 2018-02-01 21:21:34,541 - init - INFO - Current balance in wallet: LTC: 0.0, ETH: 0.0, BCH: 0.0, BTC: 0.00100457, EUR: 2.74590583 2018-02-01 21:21:34,543 - init - INFO - Placing order: {'price': '7320.01', 'product_id': 'BTC-EUR', 'type': 'limit', 'side': 'sell', 'size': '0.00100457'} 2018-02-01 21:21:34,918 - init - INFO - csv 2018-02-01 21:21:34.918445,BTC-EUR,sell,0.00100457,7320.01,,limit,None 2018-02-01 21:21:34,920 - init - INFO - Order placed. .......................