I just finished the first version my first DIY trade bot on a Dogecoin Hive trade using Hiveengine API !
My objective is mainly to earn Dogecoins, because I like Dogecoin.
Let me share my rapid experience on the first version of the technical prototype (approx 200 code lines).
I also like PHP / MySQL so it is my duty to code this bot using those free, reliable and open sources technologies.
MySQL8 is used to store the trade bot bids history in a simple table :
https://dev.mysql.com/doc/refman/8.0/en/
Python3 is used to manage Hiveengine API :
https://hiveengine.readthedocs.io/en/latest/cli.html
PHP8 is used to query MySQL trade table, to call the CoinGecko API and to call Hiveengine API
https://www.php.net/manual/fr/langref.php
The script needs an internet access to call Hiveengine API and Coingecko API : https://www.coingecko.com/fr/api/documentation
The script needs a Hive Engine account, you can create it here : https://hive-engine.com/
You need to load it with few Dogecoin and Hive to fund first script executions.
The script needs some Hive Power available on the account, you can check your Hive Power here : https://hive.ausbit.dev/
Hive power of your account reloads itself naturaly each hour. If necessary you can load some more HIVE on your wallet to get enough ressource credits.
Each 5min the script is runing automaticaly (e.g: using crontab).
It calls the HiveEngine API to get the current Hive and Doge wallet balance :
hiveengine balance --account onlydoge
It gets the last trade from the MySQL Table
SELECT * FROM trade ORDER BY id DESC LIMIT 1
It calls the CoinGecko API to get current live quotes of HIVE and DOGE and then to calculate the appropriate Hive for Doge.
$currentDogePrice / $currentHivePrice = $currentDogeHivePrice
Note: the result is fat, but we only need the value of market_data.current_price.usd
curl -X GET https://api.coingecko.com/api/v3/coins/hive
curl -X GET https://api.coingecko.com/api/v3/coins/dogecoin
At each execution the bot is either proceeding to a Buy or to Sell order, depending on the last bid.
If it is a buy, it calculates recommendedDogeHivePrice by multiplying the currentDogeHivePrice by 0.98 to earn 2% for the exchange.
If it is a sell, it calculates recommendedDogeHivePrice by multiplying the currentDogeHivePrice by 1,02 to earn 2% for the exchange.
It calls the HiveEngine API to get the current list of bids in the sellbook or in the buybook (depending on our last bid).
hiveengine sellbook SWAP.DOGE
hiveengine buybook SWAP.DOGE
If one of our previous bid is still in the sellbook or buybook, it checks if the bid price is still appropriate, which means it is still in bounds (between currentDogeHivePrice and recommendedDogeHivePrice).
If we are not at the best bid, then we try to place 0,001 under the best one (and while staying inbound). So in case of necessary, it cancels our last bid.
hiveengine cancel -a onlydoge sell 8867981
And then place our Buy or Sell order :
hiveengine sell -a onlydoge 1 SWAP.DOGE 0.1638
or
hiveengine buy -a onlydoge 1 SWAP.DOGE 0.1638
Here are my next ideas of improvements :
The bot is still in test phase be sure I will provide feedbacks on its earning in coming days.
I hope you all enjoyed reading my explanations about my first Dogecoin Hive trading bot.