DCA-BOT is a serverless javascript function app that can be deployed to AWS Lambda or other serverless providers to take advantage of a dollar-cost average purchasing strategy, which buys when the asset has dipped below a specified threshold from the 24 hour high. It currently only works with coinbase pro and USD-based products. It never sells assets.
The bot checks current prices and makes purchasing decisions everytime it is run, then it exits. If you'd like to run the bot at scheduled intervals (IE 15 minutes), you can set up a cron job in Amazon EventBridge. The bot can be run via npm start
.
-
npm install
-
You must specify the following .env variables for the function to work properly.
HIGH_DOLLARS=20
This is the amount you'd like to invest when the 'HIGH' trigger is hit
LOW_DOLLARS=10
This is the amount you'd like to invest when the 'LOW' trigger is hit
HIGH_CHANGE=0.2
This specifies the target change from 24hr high, which is the 'HIGH' trigger. IE 20% dip from the 24 hour high.
LOW_CHANGE=0.1
This specifies the target change from 24hr high, which is the 'LOW' trigger. IE 10% dip from the 24 hour high.
PRODUCTS=ETH-USD,SOL-USD,LINK-USD
This specifies the assets to purchase.
SLACK_LINK=https://hooks.slack.com/services/
Slack webhook link to send notifications to
COINBASE_KEY=aaa
Coinbase pro api key
COINBASE_SECRET=bbb
Coinbase pro api secret
COINBASE_PASSPHRASE=ccc
Coinbase pro api passphrase
HOURS=24
IE if ETH-USD is purchased 12 hours ago, it will not try to purchase ETH-USD again for another 12 hours. This is a mandatory wait period that applies after a particular asset is purchased.
git clone https://github.com/amplicity/dca-bot.git
zip -r deploy-to-lambda.zip .
- Navigate to 'Lambda' from AWS, click 'Create Function'
- Under 'Author from scratch', specify a 'Function name', and the 'Runtime' should be Node.js 16.x. Architecture should be x86_64, click 'Create function' to save
- Click 'Configuration'
- From the left, click 'Environment variables'
- Populate the environment variables specified in the installation section above.
- Click 'code' from the top nav bar
- Choose 'Upload from' and select '.zip'
- You can test by choosing 'Test', and leaving the arguments as-is.
- Choose 'Configuration', and then 'Triggers', 'Add trigger'.
- Choose 'EventBridge'
- This allows you to specify when dca-bot runs. You can specify a 'rule name', a 'rule description', and then provide a cron pattern via 'Schedule expression'. IE every 15 minutes would be
cron(0/15 * * * ? *)
Use this bot responsibly and at your own risk. I take no responsibility for any actions resulting from the usage of this application. You may turn the 'sandbox' to true
within index.js if you'd like to test the application out before using live api keys. The sandbox supports fewer products than production coinbase, but BTC-USD
is supported.
Send crypto my way if you like what I build! Send ethereum-based crypto to amplicity.eth