cbpa
is now deprecated because Coinbase Pro is sunsetting for Coinbase Advanced Trade. You can check out the documentation for the new Advanced Trade API here.
I have no plans to update this library to use the new API, and will consider making a new library for the new API if users express interest. Cheers!
Coinbase Pro Automation for making buy orders from a default bank account.
-
Install with pip
pip install cbpa
-
Create a Coinbase API Key, you will need to select all fields of access.
-
(Optional). Create a Discord webhook.
-
Make your config file. See the examples for more.
--- api: key: "myKey" secret: "mySecret" passphrase: "myPassphrase" url: "https://api.pro.coinbase.com" discord: webhook: https://discord.com/api/webhooks/123/abc account: auto_funding_limit: 20 fiat_currency: USD buys: - send_currency: USD send_amount: 2 receive_currency: BTC - send_currency: USD send_amount: 2 receive_currency: ETH - send_currency: USD send_amount: 2 receive_currency: DOGE
-
Make your orders!
cbpa run -f my-buys.yaml
You can run cbpa
as a server in Google Cloud Run, which can called by Google Cloud Scheduler to automatically place buys for you each day, or on any cron schedule you like.
These steps assume you have installed and configured gcloud
already.
-
Store your buy order file as a secret in GCP.
gcloud secrets versions add my_buys --data-file=my-buys.yaml
-
Build and push your docker container to Google Cloud, and then deploy your container.
./scripts/docker-build.sh && ./scripts/docker-push.sh; SECRET_ID=my_buys ./scripts/gcloud-run-deploy.sh
-
Create an authenticated scheduler that uses an http target to hit the
buy
endpoint.