My First Trading Hive Dogecoin (part 1)

in #trade2 years ago (edited)

Hello Dear Dogecoin community and Hive Community !

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).


Technical stack

I also like PHP / MySQL so it is my duty to code this bot using those free, reliable and open sources technologies.


Prerequisite

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.


Principle

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

screen hiveengine - balance.png

It gets the last trade from the MySQL Table

SELECT * FROM trade ORDER BY id DESC LIMIT 1

screen mysql - table trade.png

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

coingecko - hive.png

curl -X GET https://api.coingecko.com/api/v3/coins/dogecoin

coingecko - dogecoin.png

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

screen hiveengine - sellbook.png

hiveengine buybook SWAP.DOGE

screen hiveengine - buybook.png

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

Next improvements

Here are my next ideas of improvements :


Et voilà !


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.

Please, feel free to express your ideas and recommendations.


dogecoin.gif

Sort:  

I now have a formidable and very motivating competitor.

Cheers mate, looks very good, but difficult to understand for me looks like Chinese for me 😅. But i like it.

!WINE
!PIZZA
!LOL


Hi @oceanwilley, This Post Is Older Than 3 Days Days.
Please Try Another Post.
(We Will Not Send This Error Message In Next 24 Hrs).

wine_logo


Contact Us : WINEX Token Discord Channel
WINEX Current Market Price : 0.360


Swap Your Hive <=> Swap.Hive With Industry Lowest Fee (0.1%) : Click This Link
Read Latest Updates Or Contact Us

What did the Buddhist say at the sandwich shop?
Make me one with everything.

Credit: reddit
@onlydoge, I sent you an $LOLZ on behalf of @oceanwilley
Use the !LOL or !LOLZ command to share a joke and an $LOLZ. (1/1)