Dollar cost averaging bot for centralized exchanges.
This is a simple script to buy fixed amounts of some cryptocurrency assets in your preferred
exchanges. It supports any exchange available in CCXT
(more than 100).
You can run multiple strategies using the same bot.
A strategy is a file where we define the list of buy actions our bot is going to execute. See for example
the file strategy.yaml
for more information. As a summary, each strategy will
contain the following info:
Field | Description |
---|---|
amount |
This is the maximum amount our bot will buy per asset and exchange |
base_asset |
The asset we are going to use as a base currency |
assets |
List of cryptocurrencies to buy |
exchanges |
List of exchanges used to buy assets |
period |
The period where this strategy should be executed. monthly , weekly or daily |
- Supports more than 100 exchanges.
- Buy multiple cryptocurrencies at once.
- You can be notified when no funds are available in the exchange by implementing the
on_balance_no_available_callback
method. - You can implement your own logic to know when to create buy orders by implementing the
should_create_buy_order_callback
method. - Be notified when an order is created by implementing the
on_order_created_callback
method. - The script is flexible enough to be run by hand, Docker, cronjob, or whatever you want.
- Execute buy orders when the period is met.
- Save all executed buy orders from all exchanges in a file called
orders.json
.
The best way to run this script is by using Docker. Just pull the image and run it with your own strategy and exchange keys:
docker pull fooock/dca-cefi:latest
docker run -v $(pwd):/app:ro fooock/dca-cefi --strategy strategy.yaml --keys keys.yaml --test
It is super important to mount the directory where your strategy and keys are located. The
--test
flag is only used in sandbox environments when the exchange supports it.
See the following strategy file as an example to undestand better the bot functionality:
You can use the Binance Sandbox to test this script.
strategy:
# Strategy 1
- amount: 50
period: monthly
base_asset: usdt
assets:
- btc
- eth
exchanges:
- binance
# Strategy 2
- amount: 20
period: weekly
base_asset: busd
assets:
- btc
exchanges:
- bitso
Our bot will execute two strategies in paralell.
Note that our strategy will interact with two exchanges, so we need to create the required API keys and secrets to be able to recover information from our account.
Defining the strategy period doesn't mean the script will execute automatically during that period. It is your responsibility
to configure the script and how it will be executed. The period
is just a measure to avoid buying the
asset when is not required (and avoid emptying your account base_asset
balance by mistake).
Field | Value |
---|---|
amount |
50 |
base_asset |
USDT |
assets |
BTC , ETH |
exchanges |
binance |
period |
monthly |
This first strategy will use a total of 100 USDT
to buy BTC
and ETH
from Binance (50
each one)
each month.
Field | Value |
---|---|
amount |
20 |
base_asset |
BUSD |
assets |
BTC |
exchanges |
bitso |
period |
weekly |
This second strategy will use a total of 20 BUSD
to buy BTC
from Bitso each week.
To be able to create orders in the selected exchanges you need to create your API keys and secrets. This is something that needs to be kept private, that's why you need to define it in a separate file from the strategy. Based on the exchange, the method can be different, so check your Exchange documentation.
In order to define the keys used by the exchanges we need to define it using a predefined format, the
exchange name as a key and apiKey
and secret
with the values provided by the exchange. For example:
binance:
apiKey: dead
secret: beef
If you want to be a supporter, you can use this address in any EVM network to send me donations 0x63335aA5efbfB9D591B047354DBb012ce1CAfc0A
.