https://github.com/fooock/dca-cefi
Cryptocurrency bot to do DCA in more than 100 exchanges
https://github.com/fooock/dca-cefi
ccxt crypto-bot crypto-exchanges cryptocurrency dca python
Last synced: 5 months ago
JSON representation
Cryptocurrency bot to do DCA in more than 100 exchanges
- Host: GitHub
- URL: https://github.com/fooock/dca-cefi
- Owner: fooock
- Created: 2022-10-08T16:25:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-12T17:30:04.000Z (about 3 years ago)
- Last Synced: 2025-02-12T05:56:57.468Z (11 months ago)
- Topics: ccxt, crypto-bot, crypto-exchanges, cryptocurrency, dca, python
- Language: Python
- Homepage:
- Size: 58.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cryptocurrency `DCA` bot
>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`](https://github.com/ccxt/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`](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` |
#### Features
* 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`](https://github.com/fooock/dca-cefi/blob/main/dca.py#L249) method.
* You can implement your own logic to know when to create buy orders by implementing the [`should_create_buy_order_callback`](https://github.com/fooock/dca-cefi/blob/main/dca.py#L260) method.
* Be notified when an order is created by implementing the [`on_order_created_callback`](https://github.com/fooock/dca-cefi/blob/main/dca.py#L275) 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`.
## Install
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:
```sh
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.
## How it works?
See the following strategy file as an example to undestand better the bot functionality:
>You can use the [Binance Sandbox](https://testnet.binance.vision/) to test this script.
```yaml
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).
#### Strategy one:
| 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.
#### Strategy two:
| 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.
## Exchange keys
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:
```yaml
binance:
apiKey: dead
secret: beef
```
## Donate
If you want to be a supporter, you can use this address in any EVM network to send me donations `0x63335aA5efbfB9D591B047354DBb012ce1CAfc0A`.