This is a fun exercise to see if fibonacci retracement levels and statistical tools can predict the value of cryptocurrencies. Have fun =)
This Project was meant to explore the concept of microservices, aswell as getting to know a couple of programming languages. In this project Python, Rust, R and JavaScript are used to write Binance marketdata to a database, make trading decisions, cache performance information and present it to the user in a website or through a Telegram Bot.
The Trading bot comes as a microservices architecture launched via docker-compose. Docker compose can be installed using the ansible Role go to github
After cloning the repository from GitHub using git clone https://github.com/joengelh/binance-fibonaccibot.git
copy the .env.sample file to .env and fill in your information.
apiKey = your binance api key
apiSecret = your binance api secret
dbName = set to preferences or leave default
dbUser = set to preferences or leave default
dbTable = set to preferences or leave default
POSTGRES_PASSWORD = set to preferences or leave default
dbHost = set to preferences or leave default
dbPort = set to preferences or leave default
liveTrading = enable or disable live trading, while the backtesting method is not as accurate
liveVolume = amount of base currency used per signal
botToken = telegram bot token, given by the bot father
baseCurrency = base currency to grow
brokerFees = binance fees depending on VIP status and BNB use
Thereafter the service can be started using docker-compose up -d --build
and stopped using docker-compose down
.
The bot consists of the following components:
Component | Function | Ports | Volumes |
---|---|---|---|
fibonacci-db | postgres database | 5432 | /private/db:/var/lib/postgresql/data:rw ./container-db/initdb.d:/docker-entrypoint-initdb.d |
fibonacci-validator | profit calculator | ||
fibonacci-webui | result display | 13000 | |
fibonacci-cache | redis database | 6379 | |
fibonacci-predictor | calculating present trades performance | ||
fibonacci-analyzer | writing past performance stats to cache | ||
fobonacci-telegram | can use bot to give live performance overview |
Currenty, only for the component container-analyzer
proper unittests have been developed.
These can be run after installing Rust using the following command:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
The unittests can be run using the command cargo run
⚠️ Loading dotenv vars: Unit tests will fail without them
The .env file from the parent directory can be brought into scope using:
export $(cat ../.env | xargs)
The Webui Displays Information about the Bot´s performance.
- Free Spot gives an information about how buch selected base currency is still available to open more positions.
- Open Trades displays the amount of trades opened and not closed yet.
- Sum Result can either show how much base currency has been earned yet in live mode or how many percent growth based on the selected volume has been gained, taking the markets spread and trading fees, aswell as market movements into account.
- 24h Sum Result can either show how much base currency has been earned in the past 24h in live mode or how many percent growth based on the selected volume has been gained, taking the markets spread and trading fees, aswell as market movements into account.
- Simulated Avg shows by how many percent points all open positions are in profit/loss when they would be closed immediately.
- Simulated Sum shows how much base currency would be earned if all open positions would be closed immediately.
- Simulated Winners counts the open positions in profit at the moment.
- Simulated Losers counts the open positions out of profit at the moment.
for monitoring the RScripts:
can be used.
sudo docker exec -i fibonacci-db /bin/bash -c "PGPASSWORD=password pg_dump --username postgres postgres" > dump.sql
The backup process can also be automated using the Ansible Role: cron-place.
sudo docker-compose up -d db
sudo docker exec -i fibonacci-db /bin/bash -c "PGPASSWORD=password psql --username postgres postgres" < dump.sql
sudo docker-compose up -d