-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
88 lines (65 loc) · 3.71 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Usage: hodl-cli [OPTIONS]
Dollar-cost averaging for crypto on the command line using Coinbase Pro.
When run, hodl-cli will check whether a deposit needs to be made and, if
so, initiate the deposit using a linked bank account.
Then, if there is enough available fiat in the Pro account, hodl-cli will
buy currencies using the specified fiat amount, given a user-specified
asset allocation. Currencies are traded at market price at the time the
script is run.
hodl-cli is meant to be run as a cron. The cron can be run at any interval
less than the `interval` -- I recommend daily. The script will ensure that
deposits and buys are only made every `interval` days irrespective of how
often it is run. This is done by searching account history in the past
`interval` days and ensuring that no deposit or buy for a given amount has
been executed.
hodl-cli does *not* protect against concurrency issues. Please make sure
that only one instance of hodl-cli is running at a time to prevent
duplicate deposits and buys (PRs welcome).
In addition to the CLI options, a few environment variables must be
present:
COINBASE_PRO_API_KEY
COINBASE_PRO_API_SECRET
COINBASE_PRO_PASSPHRASE
Installation:
pip install hodl-cli
Example usage:
export COINBASE_PRO_API_KEY=<your_api_key>
export COINBASE_PRO_API_SECRET=<your_api_secret>
export COINBASE_PRO_PASSPHRASE=<your_passphrase>
hodl-cli -i 15 -d 100.00 -b 95.00 -a LTC 0.10 -a ETH 0.60 -a BTC 0.30
Explanation:
The above invocation will deposit $100.00 every 15 days. In addition,
if the Pro account has $95.00 available to trade, $95.00 will used to
buy other currencies as follows:
10% will be used to buy LTC
60% will be used to buy ETH
30% will be used to buy BTC
Options:
-n, --deposit-account TEXT Name string used to filter multiple bank
accounts. If not specified, the first
account found with `deposit-account-type` is
used.
-t, --deposit-account-type TEXT
Account type used in conjunction with
`deposit-account` to find an account from
which to deposit fiat. [default:
ach_bank_account]
-d, --deposit-amount DECIMAL Amount to deposit every `interval` days.
[default: 0.00]
-i, --interval INTEGER Interval in days after which a deposit
and/or buy should be made. [default: 15]
-b, --buy-amount DECIMAL The amount of fiat to allocate every
`interval` days. [default: 0.00]
-a, --allocation-percentage <TEXT DECIMAL>...
A currency and the percentage of available
funds that should be allocated to it. This
option may be provided multiple times for
different currencies and the total
percentage should add up to 1. If the total
percentage is less than one, the remainder
will be left as fiat.
Example: -a ETH 0.25 -a BTC 0.25 -a LTC 0.5
--dry-run When present, print what we would have done
but don't actually deposit or buy anything
-v, --verbose When present, print debug logs.
-h, --help Show this message and exit.