dabo/README.md

427 lines
15 KiB
Markdown
Raw Normal View History

2024-08-21 22:47:35 +02:00
# Dabo (crypto bot)
The software provided here is called dabo (crypto bot).
## Warning / Disclaimer
2023-04-28 17:07:43 +02:00
The software provided here does not guarantee any profits or function as well as sufficient security. Use at your own risk!!!
This is a private project, which is based on amateur knowledge. Trading cryptocurrencies involves an enormous amount of risks and is considered highly speculative.
It is strongly recommended to deal intensively with the subject and this bot before using it. Also, when using the possibility should be considered that due to an unfavorable market development, technical errors, bugs or other reasons, the entire invested capital can be lost. This software should therefore only be used if it is justifiable to lose the entire invested capital!
2024-08-21 22:47:35 +02:00
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
It is still under development and is currently only partially functional.
## Copyright / License
Copyright (c) 2022-2024 Oliver Bohlen
The software provided here is called dabo (crypto bot)
dabo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
dabo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with dabo (see COPYING file). If not, see <http://www.gnu.org/licenses/>.
## Data sources
Various data sources such as finance.yahoo.com and crypto exchanges available via ccxt are used. please check whether this is legal in your region before use.
- query1.finance.yahoo.com (economic data,...)
- 30rates.com (forecast)
- api.coingecko.com (Market-Cap)
- fapi.binance.com (OpenInterest,...)
- api.alternative.me (Fear and Greed)
- https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js (TradingView Lightweitgt Charts)
- ...
## dependencies on other software products
- CCXT (https://www.ccxt.com | https://github.com/ccxt/ccxt)
2024-08-21 22:54:55 +02:00
- TradingView Lightweitgt Charts (https://www.tradingview.com/lightweight-charts/ | https://github.com/tradingview/lightweight-charts)
2024-08-21 22:47:35 +02:00
- bash, python
- several linux programs like bc, wget,...
- ...
## Objective
2024-06-20 20:57:43 +02:00
The dabo-bot is intended to help make and execute timely buy and sell decisions automatically in the fast-paced crypto environment.
These decisions are made using one or more self-definable strategies.
Various market data are available as a basis for decision-making, such as price trends, RSI, MACD and EMA indicators of various time intervals, Fear and Greed Index, S&P500 data,...
2023-04-28 17:24:32 +02:00
2024-08-21 22:47:35 +02:00
## Naming
2023-04-28 17:24:32 +02:00
The name Dabo comes from the Star Trek universe.
Dabo was a roulette-style game of chance developed by the Ferengi.
More information here:
https://memory-alpha.fandom.com/wiki/Dabo
2023-07-19 11:50:29 +02:00
I thought this fits quite well to the cryptotrading world and that's why I chose this name ;-)
2023-04-28 17:07:43 +02:00
2024-08-21 22:47:35 +02:00
## Structure
2024-06-20 20:57:43 +02:00
The Bot is splitted in the following parts:
- dabo-bot: Basic Bot woth buy and sell decisions based on self-definable strategies
- dabo-symbols_ticker: Ticker for current symbols and prices
- dabo-ohlcv-candles: Continuously collect OHLCV data
- dabo-indicators: Continuously calculate indicators and other data
- dabo-orders: Continuously collect current orders placed by bot and others
- dabo-transaction-history: Continuously creates overview of historic trades
- dabo-webpage: Continuously creates webpage overview (readonly)
- dabo-web: Webserver for webpage overview
For cummunicating with the exchange APIs CCXT is used: https://github.com/ccxt/ccxt
2024-06-20 21:22:14 +02:00
2024-08-21 22:47:35 +02:00
gaboshlib
2024-06-20 21:22:14 +02:00
2024-06-20 20:57:43 +02:00
Each part runs parallel to the others in its own docker-container.
2024-08-21 22:47:35 +02:00
## Features
### General:
2024-06-20 21:17:14 +02:00
- theoretically compatible to supported CCXT exchanges. Tested with Phemex. Please let me know if there are problems with other exchanges.
2024-06-20 20:57:43 +02:00
- parallel processing in separate docker containers
2024-08-21 22:47:35 +02:00
### Dabo Bot
2024-06-20 21:15:18 +02:00
- place limit and market orders and supports ...
- ... leverage trading
- ... short trades
- ... margins cross and isolated
2024-08-21 22:47:35 +02:00
### Dabo Symbol Ticker
2024-06-20 21:15:18 +02:00
- automatically finds all supported tokens and pairs and fetches continiously ...
- ... symbols
- ... and prices
2024-08-21 22:47:35 +02:00
### Dabo OHLCV Candle data
2024-06-20 21:15:18 +02:00
OHLCV = Open, High, Low, Close and Volume of a time unit
- time units 1w, 1d, 4h, 1h, 15m and 5m
- 4h, 1h, 15m and 5m from the respective stock exchange
- 1d and 1w data from yahoo finace to have longer terms
2024-08-21 22:47:35 +02:00
### Dabo Indicators
2024-06-20 21:15:18 +02:00
- data per time unit
- time units 1w, 1d, 4h, 1h, 15m and 5m
- self-calculated EMA12, 26 ,50, 100, 200, 400 and 800
- self-calculated RSI5, 14, 21
- self-calculated MACD
2024-08-21 22:47:35 +02:00
### Dabo Market Data
2024-06-20 21:15:18 +02:00
- Yahoo Finance
2024-08-21 22:47:35 +02:00
### Dabo Orders
2024-06-20 20:57:43 +02:00
## Dabo Transaction History
2024-06-20 21:15:18 +02:00
- Support of additional Exchnages/Brokers JustTrade (CSV-Import) and Bitpanda (API+CSV-Import)
2024-08-21 22:47:35 +02:00
### Dabo Webpage
2024-06-20 21:15:18 +02:00
- ReadOnly Overview
2024-06-20 20:57:43 +02:00
2023-04-28 17:07:43 +02:00
- Consideration of trading fees
- Automatic selection of cryptocurrencies to invest in
- Filtering of cryptocurrencies by market capitalization (data via coingecko API) e.g. only trade the 50 largest by market capitalization if available on the exchange
2024-08-21 22:47:35 +02:00
- Notifications via Matrix Messenger to groups
2023-04-28 17:07:43 +02:00
- Individually selectable percentage of available capital per trade
- automatic definition of time intervals (e.g. every minute / every five minutes) based on the change of the rates
2023-06-19 13:48:06 +02:00
- Monitoring of overall market performance via own market performance index based for example on the MSCI World, leading currencies like BTC and ETH and their forecasts.
2023-04-28 17:07:43 +02:00
- Emergency stop if balance falls below defined value
- Recording of available price values incl. RSI and MACD indicators of available cryptocurrencies
- Analysis tool for collected historical values to try out buy or sell conditions based on them
- ReadOnly web interface for overview
2023-05-09 17:04:02 +02:00
- Runnable in a non-root docker containe
- multiple different buy and sell strategies possible at the same time
2023-04-28 17:07:43 +02:00
2024-06-14 22:45:01 +02:00
- Hedge mode (long and short positions the same time) not supported
2024-08-21 22:47:35 +02:00
### Buy conditions
2023-04-28 17:07:43 +02:00
- definable RSI Indicator signals min/max (RSI5, 14 and 21)
- definable MACD signals min/max
- definable minimum growth in a definable time period
2024-08-21 22:47:35 +02:00
### Sell conditions
2023-04-28 17:07:43 +02:00
- sell at defined loss limit
- hold if the result would be negative
- sell after certain time even if loss exists
- definable RSI Indicator signals min/max
- definable MACD signals min/max
2024-08-21 22:47:35 +02:00
## Why bash?
2024-06-20 20:57:43 +02:00
Yes, bash is not a language in which you write something like this in a normal way.
2024-06-20 21:15:18 +02:00
2024-06-20 20:57:43 +02:00
To be honest, I'm more of a Linux admin than a programmer, so I do a lot of my work using bash.
Simply it's the language I'm most familiar with.
2024-06-20 21:15:18 +02:00
2024-06-20 20:57:43 +02:00
Originally this project was supposed to be a simple script to monitor prices of equities and ETFs and set alarms at certain marks. Over time it has expanded a lot and a complete rewrite in another language would have meant a lot of additional work. So it has stayed that way until now.
2024-06-20 21:15:18 +02:00
2024-06-20 21:22:14 +02:00
Finally, it's a hobby project and I have to see how and when I can find time for it, because there also has to be time for family, friends, work and other hobbies.
2024-06-20 20:57:43 +02:00
If there is someone who would like to rewrite this bot in e.g. Python, I would be happy to support them as best I can with this task. Just let me know.
2024-08-21 22:47:35 +02:00
## How to use/install
2023-04-28 17:07:43 +02:00
Linux knowledge required!
Needed a running Docker install. Traefik suggested, see
2023-05-09 12:04:13 +02:00
https://gitea.ds9.dedyn.io/olli/debian.ansible.docker
2023-05-09 12:04:13 +02:00
https://gitea.ds9.dedyn.io/olli/debian.ansible.traefik.server
2023-05-09 12:04:13 +02:00
2024-08-21 22:47:35 +02:00
### Download
2023-04-28 17:07:43 +02:00
```
2023-04-28 17:24:32 +02:00
git clone https://gitea.ds9.dedyn.io/olli/dabo.git
cd dabo
2023-04-28 17:07:43 +02:00
```
2023-05-02 10:49:04 +02:00
2024-08-21 22:47:35 +02:00
### Build container
2023-05-02 10:49:04 +02:00
```
docker -l warn compose --ansi never build --progress=plain --pull --no-cache --force-rm
```
2024-08-21 22:47:35 +02:00
### Configure
Edit docker-compose.yml or create docker-compose.override.yml to fit yout needs e.g. domain and network settings or basic auth, e.g. for traefik and letsencrypt:
```
echo '
services:
dabo-bot:
networks:
- YOURNETWORK
dabo-web:
labels:
2023-05-09 10:57:14 +02:00
- traefik.enable=true
# DOMAIN
- traefik.http.routers.dabo-YOURINSTANCENAME.rule=Host(`YOURDOMAIN`)
- traefik.http.routers.dabo-YOURINSTANCENAME.entrypoints=https
- traefik.http.routers.dabo-YOURINSTANCENAME.tls=true
# Proxy to service-port
- traefik.http.services.dabo-YOURINSTANCENAME.loadbalancer.server.port=80
- traefik.http.routers.dabo-YOURINSTANCENAME.service=dabo-YOURINSTANCENAME
# cert via letsencrypt
- traefik.http.routers.dabo-YOURINSTANCENAME.tls.certresolver=letsencrypt
# activate secHeaders@file & basic auth
2023-05-09 10:57:14 +02:00
- traefik.http.routers.dabo-YOURINSTANCENAME.middlewares=secHeaders@file,dabo-YOURINSTANCENAME-basicauth
# Generate crypted password string with: echo $(htpasswd -nB YOURUSER) | sed -e s/\\$/\\$\\$/g
2023-05-09 10:57:14 +02:00
- traefik.http.middlewares.dabo-YOURINSTANCENAME-basicauth.basicauth.users=YOURUSER:YOUR-GENERATED-CRYPTED-PASSWORD-STRING
# Traefik network
- traefik.docker.network=traefik
networks:
- traefik
networks:
YOURNETWORK:
driver: bridge
driver_opts:
com.docker.network.bridge.name: YOURBRIDGE
traefik:
external: true
' >docker-compose.override.yml
```
2023-05-09 11:14:32 +02:00
2024-08-21 22:47:35 +02:00
Optional: If you use matrix/matrix-commander (https://gitea.ds9.dedyn.io/olli/debian.ansible.matrix.server) and want do receive Matrix-Messages from the bot you can create an SSH-Key to allow sending Matrix-Messages e.g.:
2023-05-09 11:14:32 +02:00
```
2023-05-09 12:04:13 +02:00
mkdir -p home/.ssh
2023-05-09 11:14:32 +02:00
ssh-keygen -f home/.ssh/id_ed25519 -N "" -t ed25519
2023-05-09 12:04:13 +02:00
chmod 700 home/.ssh
2023-05-09 11:14:32 +02:00
cat home/.ssh/id_ed25519.pub
```
2024-08-21 22:47:35 +02:00
and add Key on your matrix-Server to the authorized_keys of the matrix-User
2023-05-09 11:14:32 +02:00
Create Secrets file for your API Key(s)
```
2023-07-19 11:50:29 +02:00
# for OneTrading.com (ex BitpandaPro)
2023-07-19 11:43:17 +02:00
echo 'local API_TOKEN=YOUR_VERY_LOOOOOOONNNNGGGG_API_TOKEN_FROM_BITPANDA' >dabo/.bitpanda-secrets
2023-05-09 12:05:14 +02:00
chmod 400 dabo/.bitpanda-secrets
# or for Binance
echo 'local API_SECRET="YOUR_LONG_API_SECRET_FROM_BINANCE"
2023-07-19 11:43:17 +02:00
local API_KEY="YOUR_LONG_API_KEY_FROM_BINANCE" '>dabo/.binance-secrets
chmod 400 dabo/.binance-secrets
```
2023-05-09 17:04:02 +02:00
Create Config
Especially set URL, STOCK_EXCHANGE, FEE, CURRENCY,... to fit your needs.
```
2023-05-09 17:04:02 +02:00
vim dabo-bot.conf
```
2023-05-09 17:04:02 +02:00
Defaults in dabo/dabo-bot.conf
2023-05-09 11:14:32 +02:00
2024-08-21 22:47:35 +02:00
### Prepare/Create a stretegy
2023-05-09 10:31:47 +02:00
2023-05-09 17:04:02 +02:00
IMPORTANT!!!
2023-05-09 17:04:02 +02:00
THE DEFAULT STRATEGY MAY NOT FIT YOUR NEEDS OR WORK PROPERLY. SO YOU CAN LOOSE ALL YOUR MONEY!!! USE ON YOUR OWN RISK!!!
2023-05-09 17:04:02 +02:00
TEST YOUR OWN STRATEGY COMPREHENSIVELY AND OVER A LOGNER PERIOD OF TIME WITH analyze.sh!!! USE ON YOUR OWN RISK!!!
Strategie files can be put in the "strategies"-directory the defaults
There is an example for a buy and a sell strategy file (deactivated by "return 0" in the forst line):
```
ls strategies/buy.example.conf
ls strategies/sell.example.conf
```
Aditional strategies can be created with Name
```
strategies/buy.<name>.conf
strategies/sell.<name>.conf
```
e.g named "mannover-sulu-1" for buy strategy and "command-kirk-3" for sell strategy
2023-05-09 12:04:13 +02:00
```
2023-05-09 17:04:02 +02:00
strategies/buy.mannover-sulu-1.conf
strategies/sell.command-kirk-3.conf
2023-05-09 12:04:13 +02:00
```
2024-08-21 22:47:35 +02:00
### Create individual watch-assets.csv
2024-02-06 16:28:02 +01:00
```
cp dabo/watch-assets.csv watch-assets.csv
```
Optional:
You can edit this file if you want do generate warnings or track your asstes/trades.
```
nano watch-assets.csv
```
2024-08-21 22:47:35 +02:00
### Set Rights
2023-05-09 17:04:02 +02:00
Set Rights (UID 10000 for non-root-User in running container):
```
2024-02-06 16:28:02 +01:00
chown -R 10000:10000 dabo data home strategies dabo-bot.conf watch-assets.csv
2023-05-09 17:04:02 +02:00
```
2023-05-09 12:04:13 +02:00
2024-08-21 22:47:35 +02:00
### Operational commands
Run/Restart:
2023-05-02 10:49:04 +02:00
```
2023-05-09 17:04:02 +02:00
docker compose down # if an old instance is running
docker compose up -d
2023-05-02 10:49:04 +02:00
```
2023-05-09 17:04:02 +02:00
Check
```
docker compose ps
```
2023-05-09 11:14:32 +02:00
Logs/Output:
2023-05-02 10:49:04 +02:00
```
2023-05-09 17:04:02 +02:00
docker compose logs -f
2023-05-02 10:49:04 +02:00
```
2023-05-10 09:29:53 +02:00
Update:
```
# Optinal: Remove local data
git reset --hard HEAD^ # Remove local commits
git clean -fd # Remove local uncommited files
2023-06-19 13:37:56 +02:00
# Update and restart
git pull https://gitea.ds9.dedyn.io/olli/dabo.git main -f
docker compose down
docker compose up -d
2023-05-10 09:29:53 +02:00
```
2023-05-02 10:49:04 +02:00
2023-05-09 17:04:02 +02:00
dabo-bot.sh is the bot that trades and collects the quotes and analyze.sh is the tool with which you can try out strategies with the historical data.
The configuration files are called dabo-bot.conf and analyze.conf. analyze.sh also uses bot.conf but its variables are overwritten by analyze.conf if duplicated.
2023-04-28 17:07:43 +02:00
2023-07-19 11:50:29 +02:00
A Binance or OneTrading.com (ex BitpandaPro) account must exist and the API must be enabled.
2023-04-28 17:07:43 +02:00
The access data is stored in the file .binance-secrets in the project directory in the variables API_SECRET and API_KEY.
The access rights to this file should be set to the minimum necessary for security reasons.
2024-08-21 22:47:35 +02:00
## Strategies
You can put your own code into the strateghies it will be sourced by the bot.
You can use available variables to set and read things.
2024-08-21 22:47:35 +02:00
### Variables to set
You can simply use the following varaibles to define things:
```
local GOOD_MARKET_PERFORMANCE_INDEX
local BUY_RSI5_SIGNAL_UNTIL
local BUY_RSI14_SIGNAL_UNTIL
local BUY_RSI21_SIGNAL_UNTIL
local BUY_RSI60_SIGNAL_UNTIL
local BUY_RSI120_SIGNAL_UNTIL
local BUY_RSI240_SIGNAL_UNTIL
local BUY_RSI420_SIGNAL_UNTIL
local BUY_RSI720_SIGNAL_UNTIL
local BUY_RSI5_SIGNAL_FROM
local BUY_RSI14_SIGNAL_FROM
local BUY_RSI21_SIGNAL_FROM
local BUY_RSI60_SIGNAL_FROM
local BUY_RSI120_SIGNAL_FROM
local BUY_RSI240_SIGNAL_FROM
local BUY_RSI420_SIGNAL_FROM
local BUY_RSI720_SIGNAL_FROM
local BUY_MACD_RELATION_FROM
local BUY_MACD_RELATION_TO
local BUY_MIN_PRICE_CHANGE_LAST_1_DAY
local BUY_MIN_PRICE_CHANGE_LAST_7_DAY
local BUY_MIN_PRICE_CHANGE_LAST_14_DAY
local BUY_MIN_PRICE_CHANGE_LAST_30_DAY
local BUY_MINGROWTH_PERIOD
local BUY_MINGROWTH
```
2024-08-21 22:47:35 +02:00
### Variables with current values from the CSV files
```
# date from current timeframe
${f_date}
# current price
${f_price}
# price change percentage from timeframe before
${f_price_change}
# EMA
${f_ema12}
${f_ema26}
2023-10-27 10:44:54 +02:00
${f_ema50}
${f_ema100}
${f_ema200}
${f_ema800}
# MACD with EMA 12/16/9
${f_macd_histogram}
${f_macd_signal_relation}
${f_macd_histogram_relation}
${f_macd_histogram_signal}
# RSI from last ?? timeframes
${f_rsi5}
${f_rsi14}
${f_rsi21}
${f_rsi720}
${f_rsi60}
${f_rsi120}
${f_rsi240}
${f_rsi420}
2023-10-27 10:44:54 +02:00
# Price change from coingecko.com
${f_price_change_1_day}
${f_price_change_7_day}
${f_price_change_14_day}
${f_price_change_30_day}
${f_price_change_1_year}
# Market Capitalization change from coingecko.com
${f_marketcap_change_1_day}
2023-10-27 10:44:54 +02:00
# Ranges, Pivpot Point and Fibonacci based support and resist levels support/resist2 aka as "Golden Pocket"
${f_range_periods}
${f_lowest_in_range}
${f_highest_in_range}
${f_pivot_point}
${f_support1}
${f_resist1}
${f_golden_pocket_support}
${f_golden_pocket_resist}
${f_golden_pocket65_support}
${f_golden_pocket65_resist}
${f_support3}
${f_resist3}
```
2024-08-21 22:47:35 +02:00
## Future ideas/featrues
2023-04-28 17:07:43 +02:00
- Crypto preferences (While/Blacklist for certain currencies)
- Overview trades/profits/losses for tax declaration
- Support for decentralized exchanges like uniswap to gain more "security"
2023-05-10 14:44:08 +02:00
- Archive/compress old or large CSV-History-files