You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+89-34Lines changed: 89 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,13 @@
1
1
# gdax_bot
2
-
A basic GDAX buying bot that completes trades from fiat (government-backed currency: USD, EUR, GBP) to a target crypto asset (BTC, ETH, LTC, BCH).
2
+
A basic Coinbase Pro buying bot that completes trades in any of their available market pairings
3
3
4
4
Relies on [gdax-python](https://github.com/danpaquin/gdax-python). Props to [danpaquin](https://github.com/danpaquin) and thanks!
5
5
6
6
## Trading Philosophy
7
-
### GDAX overview; Trading with no fees
8
-
GDAX is the more professional cryptocurrency exchange that underlies Coinbase. If you have a Coinbase account, you have a GDAX account ([create a Coinbase account](https://www.coinbase.com/join/59384a753bfa9c00d764ac76)). All trades on Coinbase include a commission fee. But some trades on GDAX are free--specifically if you set your buy or sell price as a limit order. You are the "maker" of an offer and you await a "taker" to accept. The "takers" pay the fees, the "maker" pays none. The tradeoff is that limit orders may or may not be fulfilled; if you're selling X crypto at $Y value and no one likes your price, your sell order won't go anywhere.
7
+
### Coinbase Pro overview
8
+
Coinbase Pro is the more professional cryptocurrency exchange that underlies Coinbase. If you have a Coinbase account, you have a Coinbase Pro account ([create a Coinbase account](https://www.coinbase.com/join/59384a753bfa9c00d764ac76)). All trades on Coinbase include expensive tiered flat fees ($0.99+/tx) or 1.49%, plus a 0.5% spread on the market price (or up to 2% spread on crypto-to-crypto trades). Ouch.
9
+
10
+
But some trades on Coinbase Pro can be made at a greatly reduced rate (0.5%) or even free, depending on your transaction tier over the last 30 days. You just have to submit your buy or sell as a limit order. You are the "maker" of an offer and you await a "taker" to accept. The "takers" pay the fees, the "maker" pays a reduced fee (depending on your transaction tier). The tradeoff is that limit orders may or may not be fulfilled; if you're selling X crypto at $Y value and no one likes your price, your sell order won't go anywhere.
9
11
10
12
### Basic investing strategy: Dollar Cost Averaging
11
13
You have to be extremely lucky or extremely good to time the market perfectly. Rather than trying to achieve the perfect timing for when to execute a purchase just set up your investment on a regular schedule. Buy X amount every Y days. Sometimes the market will be up, sometimes down. But over time your cache will more closely reflect the average market price with volatile peaks and valleys averaged out.
@@ -15,12 +17,12 @@ This approach is common for retirement accounts; you invest a fixed amount into
15
17
### Micro Dollar Cost Averaging for cryptos
16
18
While I believe strongly in dollar cost averaging, the crypto world is so volatile that making a single, regular buy once a month is still leaving too much to chance. The market can swing 30%, 50%, even 100%+ in a single day. I'd rather invest $20 every day for a month than agonize over deciding on just the right time to do a single $600 buy.
17
19
18
-
And because we can do buy orders on GDAX with no fees (so long as they're submitted as limit orders), there's no penalty for splitting an order down to smaller intervals.
20
+
And because we can do buy orders on Coinbase Pro with no fees (so long as they're submitted as limit orders), there's no penalty for splitting an order down to smaller intervals.
19
21
20
22
### How far can you push micro dollar cost averaging?
21
-
GDAX sets different minimum order sizes for each crypto.
23
+
Coinbase Pro sets different minimum order sizes for each crypto.
22
24
23
-
[Current minimums](https://blog.gdax.com/market-structure-update-2650072c6e3b) as of 2018-01-11 are:
25
+
[Current minimums](https://blog.Coinbase Pro.com/market-structure-update-2650072c6e3b) as of 2018-01-11 are:
24
26
```
25
27
BTC: 0.001
26
28
ETH: 0.01
@@ -43,10 +45,10 @@ If the crypto price keeps increasing, eventually your schedule will run up again
43
45
44
46
## Technical Details
45
47
### Basic approach
46
-
gdax_bot pulls the current market price, subtracts a small spread to generate a valid buy price, then submits the buy as a limit order.
48
+
gdax_bot pulls the current bid and ask prices, averages the two to set our order's price, then submits it as a limit order.
47
49
48
-
### Making a valid limit buy
49
-
Buy orders will be rejected if they are at or above the lowest sell order (think: too far right on the order book) (see: https://stackoverflow.com/a/47447663). When the price is plummeting this is likely to happen. In this case gdax_bot will pause for a minute and then grab the latest price and re-place the order. It will currently attempt this 100 times before it gives up.
50
+
### Making a valid limit order
51
+
Buy orders will be rejected if they are at or above the lowest sell order (think: too far right on the order book) (see: https://stackoverflow.com/a/47447663) and vice-versa for sells. When the price is plummeting this is likely to happen. In this case gdax_bot will pause for a minute and then grab the latest price and re-place the order. It will currently attempt this 100 times before it gives up.
50
52
51
53
_*Longer pauses are probably advantageous--if the price is crashing, you don't want to be rushing in._
52
54
@@ -63,11 +65,11 @@ There's plenty of info elsewhere for the hows and whys.
63
65
pip install -r requirements.txt
64
66
```
65
67
66
-
#### Create GDAX API key
67
-
Try this out on GDAX's sandbox first. The sandbox is a test environment that is not connected to your actual fiat or crypto balances.
68
+
#### Create Coinbase Pro API key
69
+
Try this out on Coinbase Pro's sandbox first. The sandbox is a test environment that is not connected to your actual fiat or crypto balances.
68
70
69
-
Log into your Coinbase/GDAX account in their test sandbox:
70
-
https://public.sandbox.gdax.com
71
+
Log into your Coinbase/Coinbase Pro account in their test sandbox:
72
+
https://public.sandbox.pro.coinbase.com/
71
73
72
74
Find and follow existing guides for creating an API key. Only grant the "Trade" permission. Note the passphrase, the new API key, and API key's secret.
73
75
@@ -89,11 +91,11 @@ _TODO: Add support to read these values from environment vars_
89
91
90
92
91
93
#### Try a basic test run
92
-
Run against the GDAX sandbox by including the ```-sandbox``` flag. Remember that the sandbox is just test data. The sandbox only supports BTC trading.
94
+
Run against the Coinbase Pro sandbox by including the ```-sandbox``` flag. Remember that the sandbox is just test data. The sandbox only supports BTC trading.
93
95
94
-
Activate your virtualenv and try a basic $100 USD BTC buy:
96
+
Activate your virtualenv and try a basic buy of $100 USD worth of BTC:
Check the sandbox UI and you'll see your limit order listed. Unfortunately your order probably won't fill unless there's other activity in the sandbox.
@@ -103,24 +105,30 @@ Check the sandbox UI and you'll see your limit order listed. Unfortunately your
103
105
Run ```python gdax_bot.py -h``` for usage information:
*The ```-u``` option makes python output ```stdout``` and ```stderr``` unbuffered so that you can watch the progress in real time by running ```tail -f cron.log```.*
Your Coinbase/GDAX account must obviously have enough USD in it to cover the buy order/series of buy orders.
150
-
151
157
152
158
### Unfilled orders will happen
153
159
The volatility may quickly carry the market away from you. Here we see a bunch of unfilled orders that are well below the current market price of $887.86:
@@ -169,6 +175,55 @@ View the current crontab:
169
175
crontab -l
170
176
```
171
177
178
+
#### Raspberry Pi notes
179
+
Download and flash Raspbian to an SD card using Balena Etcher. You can use a "headless" version (Raspbian Lite) with no monitor, no keyboard, no mouse with the following steps.
180
+
181
+
Remove and re-insert the SD card into the computer.
182
+
183
+
Enable ssh:
184
+
```
185
+
touch /Volumes/boot/ssh
186
+
```
187
+
188
+
Preload wifi credentials. Begin editing a new file called:
_I built this to execute my own micro dollar cost-averaging crypto buys. Use and modify it at your own risk. This is also not investment advice. I am not an investment advisor. You should do your own research and invest in the way that best suits your needs and risk profile. Good luck and HODL strong._
0 commit comments