brndnmtthws / optimal-buy-cbpro

Scheduled buying of BTC, ETH, and LTC from Coinbase Pro, optimally!
The Unlicense
333 stars 68 forks source link

Not withdrawing #16

Closed coulterj closed 6 years ago

coulterj commented 6 years ago

I have not been watching when it stopped working, but it looks like the script is no longer moving my coins to my external wallets. Funds in BTC are over .05 Could this be part of the move to Coinbase Pro?

Anyway looking at the logs, and I don't see any obvious errors.

brndnmtthws commented 6 years ago

Anything relevant in the logs? I haven't had any issues recently, but there could have been changes I'm not aware of. Coinbase has quietly changed limits in the past (although the code should pull those values from the API).

coulterj commented 6 years ago

Let me know if there is another log I should pull. Here is when I run the following. I changed the BTC address.

journalctl -u optimal-buy-gdax-buy -e

-- Jul 17 17:31:13 btcNode systemd[1]: Starting optimal-buy-gdax-buy... Jul 17 17:31:13 btcNode docker[25887]: optimal-buy-gdax Jul 17 17:31:13 btcNode docker[25899]: optimal-buy-gdax Jul 17 17:31:14 btcNode docker[25905]: v1.1.0: Pulling from brndnmtthws/optimal-buy-gdax Jul 17 17:31:14 btcNode docker[25905]: Digest: sha256:2321f592a65f03719a67bfc21a3c3a859a1ccd23790f02cb79733d5c79065290 Jul 17 17:31:14 btcNode docker[25905]: Status: Image is up to date for brndnmtthws/optimal-buy-gdax:v1.1.0 Jul 17 17:31:14 btcNode systemd[1]: Started optimal-buy-gdax-buy. Jul 17 17:31:18 btcNode docker[25919]: --coins='{"BTC":{"name":"Bitcoin","withdrawal_address":"3BITCOINADDRESS","e Jul 17 17:31:18 btcNode docker[25919]: attempt 1 of 3 Jul 17 17:31:18 btcNode docker[25919]: starting buy and (maybe) withdrawal Jul 17 17:31:18 btcNode docker[25919]: first, cancelling orders Jul 17 17:31:18 btcNode docker[25919]: products=[{'id': 'BCH-BTC', 'base_currency': 'BCH', 'quote_currency': 'BTC', 'base_min_size': Jul 17 17:31:18 btcNode docker[25919]: e, 'min_market_funds': '0.001', 'max_market_funds': '50', 'post_only': False, 'limit_only': Fa Jul 17 17:31:18 btcNode docker[25919]: ement': '0.01', 'display_name': 'BCH/EUR', 'status': 'online', 'margin_enabled': False, 'statu Jul 17 17:31:18 btcNode docker[25919]: BTC ticker={'trade_id': 46614860, 'price': '7360.01000000', 'size': '0.00436924', 'bid': '7360 Jul 17 17:31:18 btcNode docker[25919]: ETH ticker={'trade_id': 37467305, 'price': '502.75000000', 'size': '1.90322381', 'bid': '502.7 Jul 17 17:31:18 btcNode docker[25919]: accounts=[{'id': 'e2bd955b-cc49-48ab-bfcf-b13d7496f22b', 'currency': 'BTC', 'balance': '0.0493 Jul 17 17:31:18 btcNode docker[25919]: prices={'BTC': 7360.01, 'ETH': 502.75} Jul 17 17:31:18 btcNode docker[25919]: withdrawn_balances={'BTC': 0.22143984, 'ETH': 1.31740537} Jul 17 17:31:18 btcNode docker[25919]: fiat_balances={'BTC': 1993.3408011398003, 'USD': 204.4699322732, 'ETH': 838.3969353625} Jul 17 17:31:18 btcNode docker[25919]: fiat balance above 5.0 USD, buying more Jul 17 17:31:18 btcNode docker[25919]: {'id': 1, 'name': 'Bitcoin', 'symbol': 'BTC', 'website_slug': 'bitcoin'} Jul 17 17:31:18 btcNode docker[25919]: {'data': {'id': 1, 'name': 'Bitcoin', 'symbol': 'BTC', 'website_slug': 'bitcoin', 'rank': 1, ' Jul 17 17:31:18 btcNode docker[25919]: {'id': 1, 'name': 'Bitcoin', 'symbol': 'BTC', 'website_slug': 'bitcoin'} Jul 17 17:31:18 btcNode docker[25919]: {'data': {'id': 1027, 'name': 'Ethereum', 'symbol': 'ETH', 'website_slug': 'ethereum', 'rank': Jul 17 17:31:18 btcNode docker[25919]: coin weights: Jul 17 17:31:18 btcNode docker[25919]: BTC: 0.7130 Jul 17 17:31:18 btcNode docker[25919]: ETH: 0.2870 Jul 17 17:31:18 btcNode docker[25919]: fiat_balance_sum=3036.2076687755007 Jul 17 17:31:18 btcNode docker[25919]: target_amount_fiat={'BTC': 2164.891474805666, 'ETH': 871.3161939698344} Jul 17 17:31:18 btcNode docker[25919]: balance_differences_fiat={'BTC': 171.55, 'ETH': 32.92} Jul 17 17:31:18 btcNode docker[25919]: amount_to_buy={'BTC': 171.54994317732408, 'ETH': 32.91998909587589} Jul 17 17:31:18 btcNode docker[25919]: placing order coin=BTC price=7323.21 size=0.00780805 Jul 17 17:31:18 btcNode docker[25919]: order={'id': '2b3f8431-6a45-4029-8683-e153b7e521f4', 'price': '7323.21000000', 'size': '0.0078

brndnmtthws commented 6 years ago

In your case it looks like since you have more than $5, it's not withdrawing. It won't withdraw until the balance drops below $5, although you can configure that.

On a somewhat related note, I noticed some weirdness with the Coinbase API this morning as well. In my case I had a fiat balance, and the Coinbase API returned an 'insufficient funds' error. I re-ran it and everything worked the second time around, so that sounds like a bug with Coinbase to me (perhaps they have some sort of eventually consistent data model underneath).

brndnmtthws commented 6 years ago

I ran a test, and the script is working correctly.

I noticed, however, that the Coinbase API is not working consistently. If I were to guess, it is probably under a lot of stress right now. I had to futz around with it for a bit in order to place an order.

coulterj commented 6 years ago

Thanks for the help! You were right. It was the withdraw balance. I originally changed that because that also controls how much BTC it will purchase. At the default of $25, it won't place bids if the balance drops below $25. I would like for it to use all of the cash if possible. Is there a setting I can have it attempt to transfer the BTC every time and spend all of my money?

brndnmtthws commented 6 years ago

Yeah, it's possible with code changes, but the current behaviour optimizes for doing one big transaction rather than many smaller transactions. I can add it to the pipeline as a feature request, or you can put together a patch :)

The logic is here: https://github.com/brndnmtthws/optimal-buy-gdax/blob/master/optimal_buy_gdax/optimal_buy_gdax.py#L309-L318

You could change the logic to withdraw when the balance is greater than the minimum withdraw amount, for example. Or you could even remove the check altogether and just always withdraw. Given that Coinbase eats the fee for withdrawals, I guess it doesn't matter, but if they start charging a fee then I might want to revert the behaviour to batch.

coulterj commented 6 years ago

Ok. not much of a coder, but maybe able to take that on. I will try to look at it this weekend. Thanks for the help, I do appreciate the script.