Dollar-cost averaging (DCA) is an investment technique of buying a fixed dollar amount of a particular investment on a regular schedule, regardless of the share price. The investor purchases more shares when prices are low and fewer shares when prices are high. http://www.investopedia.com/terms/d/dollarcostaveraging.asp
This script aims to help you use it to buy BTC using the Brazilian exchange Foxbit.
PS: Python 3 only.
- Clone the repo
- Create a virtualenv and activate it.
pip install pipenv
pipenv install
- Create a
.env
file:cp .env.example .env
- Edit
.env
following the Doc section below.
.env
variables:
- DEBUG:
True
to use the test blinktrade testnet orFalse
to use production. - BLINKTRADE_API_KEY: Your API key from foxbit website.
- BLINKTRADE_API_SECRET: Your API secret from foxbit website
- PER_ORDER_IN_REAL: the amount in real each order will be
- MAX_ACCEPTABLE_PRICE_IN_REAL: the maximum amount you are willing to pay per BTC.
- Make sure you created
.env
file following Doc section above. - Run the script
python buy_btc.py
- The script uses the following algorithm:
- Delete pending orders it created on previous runs that didn't complete.
- Get the second highest price that someone used in a buy order.
- Use the second highest price to place an order with volume as defined in PER_ORDER_IN_REAL
- Exit
This script just run once, to use DCA you need to either run it manually at the interval you desire or schedule it with cron or another job scheduler.