Scheduled buying of BTC, ETH, and LTC from GDAX optimally! Be your own index/hedge fund, and stop paying management fees to someone else!
This is a Python script you can use to automatically buy Bitcoin, Ethereum, and Litecoin using the GDAX API. It buys these 3 currencies, weighted by market cap (as reported by coinmarketcap.com), using a form of dollar cost averaging. according to the following logic:
- Check current balances of USD, BTC, ETH, and LTC
- If the USD balance is above $100, buy BTC, ETH, and LTC weighted by market cap
- If there's enough USD available, place 5 discounted limit orders at the current price minus 0.5% up to 0.55%, each order with 1/5th of the remaining amount to buy for each coin
- If there isn't enough USD available, place 1 buy order at 0.5% off the current price
- If the USD account balance is below $100, withdraw coins to desired addresses
You can also use the same script to schedule deposits from your bank account periodically, such as when you're paid.
Ideally, this script would help to make sure that when we dip—
we buy.
Duh. Not my fault if you lose everything.
Unless you place absolute trust in me, some guy from the Internet, I suggest you clone the repo and build your own container to protect yourself from any sort of funny business.
-
Set up a GDAX account, and link your bank account
-
Create the necessary API credentials for GDAX, with permissions to manage funds, withdraw without 2FA, and trade
-
Determine the payment_method_id value by using the GDAX API (you can use your browser's developer toolbar, here's a quick video showing how)
-
Get a machine somewhere (GCE, EC2, Digital Ocean) with Docker and systemd
-
Copy systemd files over:
$ sudo cp optimal-buy-gdax-*.{service,timer} /etc/systemd/system
-
Edit
/etc/systemd/system/optimal-buy-gdax-buy.service
,/etc/systemd/system/optimal-buy-gdax-buy.timer
,/etc/systemd/system/optimal-buy-gdax-deposit.service
, and/etc/systemd/system/optimal-buy-gdax-deposit.timer
to your liking. Make sure you:- Change the BTC, ETH, and LTC deposit addresses to deposit the coins into your wallet (use a Ledger or TREZOR)
- Put the correct API keys in
- Check the deposit amount (start with something small, like $150, to make sure it actually works first)
- Check the timer dates
-
Enable the systemd units:
$ sudo systemctl enable optimal-buy-gdax-buy.service $ sudo systemctl enable optimal-buy-gdax-buy.timer $ sudo systemctl enable optimal-buy-gdax-deposit.service $ sudo systemctl enable optimal-buy-gdax-deposit.timer
-
Start the systemd timers: $ sudo systemctl start optimal-buy-gdax-buy.timer $ sudo systemctl start optimal-buy-gdax-deposit.timer
-
Enjoy!
- Currently it only supports USD
- Some values are hardcoded, but if you want to change that feel free to send a PR!
- If you try to trade manually or using some other bot at the same time, you're probably going to have a bad time
- You might have a few dollars (<$100) sitting in your account at all times, even when all orders have been filled
If you got some value out of this, please send some kudos my way:
- BTC: 3EEAE1oKEMnmHGU5Qxibv9mBQyNnes8j8N
- LTC: 3MxmLzTf4sPsFBGYUnX9MMMbTMeaUSox46