Trading Bot

This page explains what is the trading bot and how it can be used in detail. It also includes example setups to help you explore the possibilities of the different trading strategies.

What is the trading bot?

The trading bot is a tool which is part of the Tokemon platform which allows for automating trading on your behalf. It allows you to configure trading configurations which contain trading strategies for various different tokens. The trading configurations are defined in terms of pairs (Token in and Token out). The pair denominator (Token out) for now is only ETH, but we're planning to allow more options for the pair denominator (such as different ERC20 tokens). The trades are executed against the Uniswap liquidity pool determined by the Token in and Token out parameters.

Currently the trading bot supports only trading on Uniswap V2, but we're working on enabling trading on Pancake Swap as well as supporting more exchanges and Uniswap V3 soon.

The high level overview of the trading bot is that it allows you to automate your AMM trading based on the trading configurations you define. The configurations can contain only simple buy/sell orders or more advanced strategies such as trailing stop/buy orders for more automated experience. In the following sections we will explore all of the mentioned features.

How does the trading bot work?

The trading bot follows the client <-> server architecture pattern. This pattern allows for maximal security and maximal trading precision, while requiring almost no computation costs on the client side (lightweight client). You're protected from exposing your private keys while at the same time high trading precision (signals) is achieved with almost no computation on your side.

The server constantly scans the blockchain for AMM transactions and creates an internal state of the AMM pools. It then compares your trading configurations with the internal state and if some of the trading strategy is satisfied then it prepares a trading transaction based on your input and sends a signal to the client. The server is https://app.tokemon.io.

The client is connected to the server via a secure WebSocket connection. It does not share any of your private keys with the server. The client waits for signals from the server (trading transactions) and executes them. Then it sends back a confirmation message to the server for a successful / failed transaction (transaction might fail if you use insufficient gas or slippage for example).

The client runs on your computer. It is open source (you can inspect the code to audit it). It can be downloaded from Github. For configuration instructions see Github. At this time only downloads for Windows 10 are available.

For trades to be executed, both of the following must be true:

  1. The trading client must be running on your computer

  2. Accounts connected with any trading strategies must have 'trading enabled'

If both of these conditions is true, you will see the following shown at the top of Tokemon

The status of both bots and configured accounts can be seen from the Trading > Accounts page on Tokemon.

The ability to disable trading on a per-account basis means that the bot client can be left running and you can temporarily disable trading for safety or in periods of volatility by simply adjusting the account configuration from https://app.tokemon.io/.

Trading bot features

The trading bot enables setting multiple trading configurations at once. For each trading configuration you can choose the account you want this strategies to be executed by (Account), the token you want to trade (Token in), the token you want to trade against - denominator token (Token out - only ETH for now) and the price in ETH that you bought the token at (Bought at price (ETH)). The Bought at price (ETH) parameter is only needed for the Stop at X trading strategy described below.

Each trading configuration contain multiple trading strategies:

Stop at X

The Stop at X strategy is used for selling your chosen token (Token in) at a multiplier from the price you bought it (Bought at price (ETH)). You can configure the following parameters for this strategy:

  • X value - the multiplier (e.g 1 means 1x, 1.5 means 1.5x, etc)

  • Max slippage - Maximum tolerable slippage (between 0 and 0.49, e.g. 0.10 = 10% slippage on Uniswap).

  • Gas price coefficient - A coefficient used for multiplying the fastest gas price (trader) at the time of the transaction being made (1 means no multiplying).

  • Amount of tokens to sell - Exact token amount in whole units (not wei) or 0 for selling the maximum available balance on the address

  • Strategy enabled - Wether this strategy should be enabled or not. You will get signals only for enabled strategies.

Sell at less than or equal to

The Sell at less than or equal to strategy is used for selling your chosen token (Token in) at at a set price less than or equal to the current token price. This is used to sell your token when it's price goes bellow or equal to specified price (stop loss). You can configure the following parameters for this strategy:

  • Price threshold (ETH) - The price at or below at which you want to sell your token (Token in), determined in ETH.

  • Max slippage - Maximum tolerable slippage (between 0 and 0.49, e.g. 0.10 = 10% slippage on Uniswap).

  • Gas price coefficient - A coefficient used for multiplying the fastest gas price (trader) at the time of the transaction being made (1 means no multiplying).

  • Amount of tokens to sell - Exact token amount in whole units (not wei) or 0 for selling the maximum available balance on the address

  • Strategy enabled - Whether this strategy should be enabled or not. You will get signals only for enabled strategies.

Sell at greater than or equal to

The Sell at greater than or equal to strategy is used for selling your chosen token (Token in) at at a set price greater than or equal to the current token price. This is used to sell your token when it's price goes above or equal to specified price. You can configure the following parameters for this strategy:

  • Price threshold (ETH) - The price at or greater at which you want to sell your token (Token in), determined in ETH.

  • Max slippage - Maximum tolerable slippage (between 0 and 0.49, e.g. 0.10 = 10% slippage on Uniswap).

  • Gas price coefficient - A coefficient used for multiplying the fastest gas price (trader) at the time of the transaction being made (1 means no multiplying).

  • Amount of tokens to sell - Exact token amount in whole units (not wei) or 0 for selling the maximum available balance on the address

  • Strategy enabled - Wether this strategy should be enabled or not. You will get signals only for enabled strategies.

Buy at less than or equal to

The Buy at less than or equal to strategy is used for buying your chosen token (Token in) at at a set price less than or equal to the current token price. This is used to buy your token when it's price goes below or equal to specified price. You can configure the following parameters for this strategy:

  • Price threshold (ETH) - The price at or less at which you want to buy your token (Token in), determined in ETH.

  • Max slippage - Maximum tolerable slippage (between 0 and 0.49, e.g. 0.10 = 10% slippage on Uniswap).

  • Gas price coefficient - A coefficient used for multiplying the fastest gas price (trader) at the time of the transaction being made (1 means no multiplying).

  • ETH amount to buy with - Exact ETH amount in whole units (not wei) or 0 for buying with the maximum available ETH on the address

  • Strategy enabled - Wether this strategy should be enabled or not. You will get signals only for enabled strategies.

Buy at greater than or equal to

The Buy at greater than or equal to strategy is used for buying your chosen token (Token in) at at a set price greater than or equal to the current token price. This is used to buy your token when it's price goes above or equal to specified price. You can configure the following parameters for this strategy:

  • Price threshold (ETH) - The price at or greater at which you want to buy your token (Token in), determined in ETH.

  • Max slippage - Maximum tolerable slippage (between 0 and 0.49, e.g. 0.10 = 10% slippage on Uniswap).

  • Gas price coefficient - A coefficient used for multiplying the fastest gas price (trader) at the time of the transaction being made (1 means no multiplying).

  • ETH amount to buy with - Exact ETH amount in whole units (not wei) or 0 for buying with the maximum available ETH on the address

  • Strategy enabled - Wether this strategy should be enabled or not. You will get signals only for enabled strategies.

Trailing stop loss

The trailing stop loss strategy is used for selling your token (Token in) when it goes a certain specified percent below the all current price of the token (at the time of setting this strategy). You can configure the following parameters for this strategy:

  • Percent - The percent below the current token price (the token price at the time of setting this strategy) that you want to sell at.

  • Max slippage - Maximum tolerable slippage (between 0 and 0.49, e.g. 0.10 = 10% slippage on Uniswap).

  • Gas price coefficient - A coefficient used for multiplying the fastest gas price (trader) at the time of the transaction being made (1 means no multiplying).

  • Amount of tokens to sell - Exact token amount in whole units (not wei) or 0 for selling the maximum available balance on the address

  • Strategy enabled - Wether this strategy should be enabled or not. You will get signals only for enabled strategies.

Trailing stop buy

The trailing stop buy strategy is used for buying your token (Token in) when it goes a certain specified percent above the current price of the token (at the time of setting this strategy). You can configure the following parameters for this strategy:

  • Percent - The percent above the current token price (the token price at the time of setting this strategy) that you want to buy at.

  • Max slippage - Maximum tolerable slippage (between 0 and 0.49, e.g. 0.10 = 10% slippage on Uniswap).

  • Gas price coefficient - A coefficient used for multiplying the fastest gas price (trader) at the time of the transaction being made (1 means no multiplying).

  • Amount of tokens to sell - Exact token amount in whole units (not wei) or 0 for selling the maximum available balance on the address

  • Strategy enabled - Wether this strategy should be enabled or not. You will get signals only for enabled strategies.

What is important to note is that for the buy strategies your ETH is used, so your account has to be funded with enough ETH. If you choose the option for buying with the maximum available amount on the address (ETH amount to buy with is set to 0) then the gas costs will be deducted from your account balance and the rest will be used for buying. However when selecting an exact amount you need to make sure that you have at least that amount of ETH + ETH for the gas costs (depending on the gas price coefficient you've chosen and the current trader gas price), the gas costs are not deducted for exact amounts.

For the sell strategies you only need to ensure that you have enough ETH for the gas costs (depending on the gas price coefficient you've chosen and the current trader gas price). Obviously you will need to hold the tokens you want to sell.

The logic behind the trading strategies

After a trading strategy is executed it is inactivated. To activate it again you need to edit the trading configuration and check the Strategy enabled checkbox.

The sell trading strategies are prioritised before the buy trading strategies. This means if you have sell and buy strategies setup for a configuration, the sell strategies will be executed first. When all of the trading strategies get executed the status of the whole configuration is switched to buy if there are buy strategies enabled or stopped if there are no more strategies enabled.

Also it is important to note that for the trailing strategies (Trailing stop loss and Trailing stop buy) the trading status of the whole configuration is changed when one of this strategies is executed. For example if you have activated Trailing stop loss and Trailing stop buy, when trailing stop loss executes then the status of the trading configuration is changed to buy and the Trailing stop buy is prioritised.

Usage guide

To create a trading configuration:

  1. Download the trading client from: https://github.com/tokemon-hq/client and set it up according to the README.md file.

  2. Go to https://app.tokemon.io and login with your credentials.

  3. From the menu on the left side choose Trading -> Trading Bots

  4. Fill in the Account, Token in, Token out and Bought at price (ETH) params. The account should be one of the accounts configured in the trading client.

  5. Fill in the parameters for your desired trading strategy/strategies and mark the Strategy enabled button for each strategy to enable them.

  6. Click the Save button at the bottom of the page.

  7. You should be able to view the trading configuration on the right side of the screen.

To edit a trading configuration:

  1. On the Trading bots page, on the right side of the page find and choose the configuration you want to edit (click on the wrench icon for the configuration).

  2. Change the desired parameters for the trading configuration.

  3. Click the save button at the bottom of the page.

Indicators

For each configured trading configuration there are various indicators to help you determine the status of the trading configuration.

  • On the right of the page (on the Existing trading configurations pane) for each configuration there is an indicator that shows the connection status of the trading bot.

  • For each configuration there is an indicator on the header of the pane that shows the status of the trading configuration:

    • Sell (the configuration is in sell mode) - activated when there are sell strategies active

    • Buy (the configuration is in buy mode) - activated when there are buy strategies active

    • Stopped (no active trading strategy)

  • For each trading strategy there is an indicator on the header of the strategy pane that shows the status of the trading strategy:

    • Active (the trading strategy is active)

    • Inactive (the trading strategy is inactive)

Example strategies

The following images show some example setups along with descriptions, to give you a better idea on how to use the bot.

Notifications

When some of the trading strategy gets executed, you will be notified via our trading telegram bot for the transaction. For this you will need to have the telegram bot connected. You can find the details about the telegram bot in the Settings page, under the Trading bots pane.

Below are some images on how the received telegram notifications look like:

Last updated