As a Software Engineer I’m constantly thinking about efficiency. What’s the time complexity of this algorithm, can this be parallelized, where is the bottleneck? So when I setup reoccurring Bitcoin buys on Coinbase it bothered me quite a bit that they took a 4% fee and my newly purchased Bitcoin wasn’t available for withdrawal for 3-5 business days.
Github repo: https://github.com/bford21/coinbase-api-scripts
Coinbase reoccurring buys incur a 4% fee. This compounded over time can be a significant amount of BTC. Your funds are also not available for withdrawal for 3-5 business days.
Use the Coinbase API to place limit orders that only incur a 0.15% fee. Leverage your OS task scheduler to run the script at a specified interval.
- Your Coinbase Pro account must be preloaded with enough USD to place the trades
- Greater chance of trades not going through
- Create a Coinbase Pro account and generate an api key
- Link a bank account and deposit USD into coinbase
- pip installed
git clone https://github.com/bford21/coinbase-api-scripts.git
pip install -r requirements.txt
Create environment variables
- Create 3 different environment variables with the following names and values
<Your Coinbase API Key>
<Your Secret Key>
Alternatively you can set these in your config.yml
config.yml is located in the root directory and can be used to set the amount of btc to buy as well as your Coinbase Pro credentials
dollar_amount_to_buy: 50.0 CB_API_KEY: CB_SECRET_KEY: CB_PASSPHRASE:
Use the native Windows task scheduler. Create a bsic task and point it at
run.bat. Set it to run at the interval of your choosing.
On Mac OS & Linux leverage crontab to run
run.sh at your specified interval. (https://en.wikipedia.org/wiki/Cron)
How it works
The first thing the script checks for are the current fee rates for placing both limit and market order via the Coinbase Pro API.
Placing a limit order is almost always cheaper so a limit order will be constructed based on the dollar amount specified in your
Limit orders require a minimum BTC size of 0.002 so if your order is below this value a market order will be placed and will incur a slightly higher fee.
- Multi coin support