Java application to fetch details from Bitvavo trading system
This project involves two types
- Displaying BTC in real time
- Step 1 and notifying the change in BTC price using Telegram Bot
Please follow the respective types for the instructions
Java
Docker
Maven
Python3
Telegram account <Optional>. Needed for type 2 project
If you have docker installed then just build docker image and run the container
./mvnw spring-boot:build-image -DskipTests
Start the container
docker run -it -d -p 8080:8080 -p 8026:8026 --rm --name bitvavo-trading bitvavo-trading:0.0.1
Navigate to
http://localhost:8080
If you dont have docker installed but want to run the java jar then follow below steps.
If you want to make source code changes then follow the below prerequisites
- Git clone the bitvavo java library from https://github.com/bitvavo/java-bitvavo-api
- cd
java-bitvavo-api
- Run
mvn clean install
so that jars are pushed to local mvn repo - Signup with bitvavo and get api/secret key
- Add the bitvavo api key, secret key in
application.properties
file - Start the project using
mvn spring:boot-run
or build jar file usingmvn clean packages -DskipTests
- Run the jar using
java -jar target/bitvavo-trading-0.0.1.jar
- Hit the end points
localhost:8080/api/assets
orlocalhost:8080/api/ticker/BTC-EUR
To see the bitcoin price in real time, navigate to
http://localhost:8080
You can change the source code to monitor for other cryptocurrencies as well
This involves some extra steps. So if you are running the docker or jar file already then stop it.
The aim of type 2 is to send alerts when BTC prices go up or below the configured prices.
You configure the prices using the below format
bitvavo:
trades:
- action: sell
price: 41000
crypto: BTC
tradeprice: 41000
notify: true
- action: buy
price: 38200
crypto: BTC
tradeprice: 35000
notify: true
This states that you want to notified when the BTC prices goes above €41000 or below €35000
Create a new git repository and create a new file in it called bitvavo-client.yml
with the above contents.
It is important that the file name is same as above mentioned
Enter the above created repository name in the file bitvavo-config/src/main/resources/application.yml
.
If its a private repo then enter your username and password as well.
- Now start the config server
cd bitvavo-config
mvn clean package -DskipTests
java -jar target/bitvavo-config-server-0.0.1.jar
Let it run in the backend
Make sure you have a telegram bot. If you dont have you can skip step and continue with step 3.
Install the below packages in your machine
apt install python3-pip
pip3 install telegram
pip3 install python-telegram-bot
**Create a bot **
Search for the user @BotFather in Telegram.
Use the command /newbot
to create a newbot. Enter the username and other required details.
Once everything is done, it will display the token. Store it in a safe place.
Lets store this as TOKEN
For the bot to send messages to you, first you need to get your chat id. This can be done by
sending a /start
message to https://telegram.me/getidsbot
. Lets store this as CHAT_ID
Configure telegram bot program
You need to enter the CHAT_ID
and TOKEN
in src/main/resources/telegram_bot.py
You can test to see if telegram is sending message to you by running
python3 src/main/resources/telegram_bot.py "hello world"
Copy the above mentioned telegram_bot.py
file to any suitable location in your machine. If not copied
then messaging wont work. Enter the full path of the script in src/main/resources/application.properties
telegram.bot.path=<your path>
Also enter the location of python3 executable under
python.path=
Once all these steps are configured, build the packages
mvn clean package -DskipTests
and start the application using
java -jar target/bitvavo-trading-0.0.1.jar
Navigate to
http://localhost:8080
You should receive a telegram notification whenever the BTC value goes below or above the configured value.\
If you want to be notified at a different price, then change the values in bitvavo-client.properties
and commit the file.
Push the changes to the repository and run the below command
curl -X POST http://localhost:8080/actuator/refresh
This will refresh the configured values and will notifiy on new values.
Whenever you change the values, dont forget to commit and push the chanes. After that issue the post command.