🤖 DEXBot simple VPS guide

This guide is aimed to be comprehensive and easy enough for the newbies to run a DEXbot in docker on their own server, with local config and its operation log.

This approach allows you to move those two folders to another server, and launch the bot there, without consulting the wiki to find out where the configs and data is stored.

It also allows skipping the configuration of the server and preserve dependencies, as well as avoid conflicts if other applications require different server configuration.

1. Server purchase and configuration

If you already have a server, then you can skip this step, but if not here is my ref link to Hetzner: https://hetzner.cloud/?ref=wsKdGpzXMlWr


This link gives you 10 Euro


Click add:

Here is the server config:


A config like this costing 4.19 euro/month will be enough:

Then click

Server will be created and you will receive an email like this:

If you are using Windows, you will require PuTTy, add your server’s IP address and use standard SSH port 22

Save the connection so you can connect quicker in the future.

Then launch the saved connection like this

You can enable auto login so you do not have to enter root username in the console

after you will have to go to the Session tab which is located top left, and save the current connection with updated configuration (please note, that first you have to connect to it so you can save it)

Then lets connect

if you made an autologin at the previous step, then you do not have to enter your credentials, alternatively if you clicked OPEN, then you will have to enter username in the console. Type root, then press ENTER, and use the password that you received in an email. Copy it with CTRL-C, and paste it into the console, after making sure that it has entry focus after switching from email. It is usual that a right click will paste the password, which will be hidden due to security considerations, afterwards press ENTER.

After changing the password you will have a clean ready Ubuntu 20 server.

2. Docker installation

sudo apt update

sudo apt install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

sudo apt update

apt-cache policy docker-ce

sudo apt install docker-ce

Do you want to continue? [Y/n] Y
If you see such prompt enter Y, to agree to continue.

sudo systemctl status docker

If you need a step by step guide, then follow this link: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04-ru

Here is the docker repository with assembled DEXbot: https://hub.docker.com/r/blckchnd/dexbot

Just use this line to download it to your local server:
docker pull blckchnd/dexbot

3. Account set up and key import

By default the local data is stored inside docker. To avoid losing configuration and data, it is recommended mounting user directories inside the container as shown below.

First of all, you need to create directories that will contain your configuration and data:

mkdir ~/dexbot-data ~/dexbot-config ~/dexbot-data/bitshares ~/dexbot-data/dexbot
touch ~/dexbot-data/dexbot/history.csv

Now set the access rights:
chmod -R 777 ~/dexbot-data/ ~/dexbot-config/

If you do not have a Graphene DEX account now would be the time to create it. You can follow my referral link below: https://market.rudex.org/?r=xnxt

Please make sure that you’ve created a backup of your wallet keys, and/or saved your password. Do not ignore the backup suggestion, it is very important.

It is impossible to restore keys and passwords later. After creating a user account you need to write down WIF active keys, to add them later. Here is the guide on how to export your WIF active key.

Follow the steps:

next

Here is your WIF active key, that you need for next steps, you have to write it down:

After creating local storage you can add your keys by executing the following script:
docker run -it --rm -v ~/dexbot-data:/home/dexbot/.local/share blckchnd/dexbot:latest uptick addkey

The console will ask to create a password (passphrase) for encrypting your keys in the local storage and then repeat it. Afterwards import your keys and press ENTER after each key if there are several keys. After you’ve entered all keys press ENTER instead of the key, and you will see something similar to the screenshot above, the accounts that had their keys imported will be detected.

4. Configuring DEXbot using CLI

After all your active trading keys have been imported (keys for all Graphene accounts that you plan to use for trading) you can continue setting up trading bots. Execute CONFIGURE as the next step:
docker run -it --rm -v ~/dexbot-config:/home/dexbot/.config/dexbot -v ~/dexbot-data:/home/dexbot/.local/share blckchnd/dexbot:latest dexbot-cli configure
And enter the passphrase to continue.

Here you enter the worker name (so you can easily distinguish them in the common list)

navigate around the buttons with TAB, press OK or ENTER

Here you can pick a strategy for the bot from 3 standard ones.
In this article we will look at the Relative (Relative order strategy)

Enter a Graphene account name

import an active key which begins with 5…. (you’ve saved it earlier when you were making backup)

You will see a message about successful key import

Here you enter the trading pair, that the current worker will operate on, press OK

Leave this part as is, it is the asset that the blockchain “order create” fees are paid with (don’t forget that orders in the blockchain aren’t free). I recommend having some GPH on all the bots for paying the blockchain fees, as it is cheaper than pay from the asset pool, which can also unexpectedly run out. Press OK

Here in % we set the amount of traded (QUOTE) asset, and the next screen an amount of base asset (BASE) that will be taken into the account by the bot for its operation.

As this example the trading pair is GPH/USDT and as GPH isn’t traded on external markets, I will not specify an external quote feed (NO).
This setting is needed so the bot would understand the current price from another source, which is very handy when you’re trading an illiquid market, and allows the bot to follow the market price, always making sure it keeps its orders above and below that feed price.

next screen will ask for an external quote feed address, which we in our case will leave as is, since from the last setting it is not used, but this step is part of the bot setup via CLI.

here we set the amount of QUOTE asset in the order, and can specify either absolute numbers, as well as %, if in % you will still have to write 10 here. On the next screen we will specify the relative marker for the order.

YES — is the relative size of the order, from the previous screen. It means that orders will be 10% from the total amount participating in the bot operation (in our case it is 100%),
If we set this to NO, then number 10 from the previous screen would mean 10 of the QUOTE asset, in our case GPH.

Spread is the % difference between buy and sell orders

We will not use dynamic spread, as it requires good understanding for effective use on the market (it is not advised to use for the newbies, and without a good understanding of specifics of the market that you’re setting up a bot for)

Market depth that will be used to change market spread. I am specifying 1000 GPH. In essence this is sensitivity for the dynamic spread. Which is not used in our case, as our spread is a constant.

Leave as is, our spread is constant, and this setting is for dynamic spread.
How many percent will the own spread be in comparison to the market spread. Press OK.

Here we’re specifying the central price, in this case I’ll set a price of 3 cents per GPH (price in BASE asset, USDT).

Measure the central price by market orders — the valuation is based on closest opposite orders or by depth, in this example we specify NO, let's say we want the central price to be fixed.

Depth change — total sum of QUOTE asset (in our case 1000 GPH) by order book depth, that will be measured in central price. In our case this parameter is not used, as in the previous step we’ve specified NO.

Last deal price will be the next central price, this will force the bot to move half a spread each time an order is filled.

Offset of the central price based on asset balances moves the calculated central price up or down, to try and keep the portfolio balanced, so as not to have only one asset on hand, as well as maximizing profits.

Manual center price adjustment allows you to manually correct the orders up or down. Works independently from other offsets and does not negate them. As far as my understanding goes it is an extra setting that allows to set a tolerance on certain markets not to move center price. A deviation during certain market conditions, to make the bot more effective.

Order recreation on partial fill, when a buy or sell order is partially filled.

An order fill threshold in percent, for activation of order recreation (see previous step). Press OK.

Reset orders when the central price changes by more than threshold value (set to False when using external quote sources)

Price change threshold — set central threshold price value, that requires action (from the previous step).

Activation of order expiration override to reset orders in set intervals

Order lifetime is expressed in seconds and allows resetting orders in desired intervals

Would you like to set up another worker? Reply No.

Should it run in the background as a daemon, reply No. We will run it explicitly in the docker.

After successfully completing configuration and saving it, you’ll see a New configuration saved message.

You can launch CONFIGURE again to check the list of configured workers and their parameters, or edit previously created worker if you have decided to change it.


Here is how you exit the menu:

5. Start. Stop. Checking the logs.

To start the bot use the following commands (passphrase here is the password that you set at step 3 for encrypting the keys):

docker run -d --name dexbot -e UNLOCK=passphrase -v pwd/dexbot-config:/home/dexbot/.config/dexbot -v pwd/dexbot-data:/home/dexbot/.local/share blckchnd/dexbot:latest dexbot-cli run

To check the logs:
docker logs -f dexbot

In the logs we can see what is happening, that the bot has canceled the orders if there were any on the market prior to starting it, as well as created bot BUY and SELL orders.

to exit the log viewing mode press CTRL+C

And this is how it looks in the Rudex trading GUI:

To stop the bot:

docker stop dexbot
docker rm dexbot

Now you’ve learned how to configure the bot to run in the docker, to launch it as well as to check the logs.

If you need to change the configuration or add a new worker on other markets, first you have to stop and delete the docker using the code above. Then add new workers or edit existing ones and launch them.

You can now disconnect from the server, the bot will operate in the docker on its own.

And going forward, only experience, observation and effectiveness comparison for the setups on different markets will allow you to deeply understand the settings and increase the profits that the bots operation can generate.

   
В ожидании ответов...
Станьте первым, кто начнёт обсуждение!