Creating and configuring a trading bot

 

Learn how to create a trading bot with the Cryptohopper API and edit the configuration of your trading bot(s). In 2 simple steps we will create a new trading bot and add configuration settings to the newly created trading bot.

To make API requests you will need to create an app and have an access token. If you haven't created an access token yet, please follow the tutorial Get an access token with Oauth2 first.

Step 1: Create a new trading bot

To create a new trading bot with the API you will need to make a POST call to the hopper endpoint. With the POST call you can immediately send configuration values, but in this example we will only send a few configuration examples and configure the trading bot in the next step. Underneath you will find the API endpoint and the JSON which you will need send with the POST request.

API endpoint:

https://api.cryptohopper.com/v1/hopper

JSON POST:

{
    "name": "The name of your newly created trading bot.",
    "enabled": 0
}

When the API request is successfull you will receive a JSON response with the value: id. This id is the unique identifier of your newly created trading bot. Save the id, because we will be needing it in the next step to adjust the config of the trading bot.

Step 2: Configure your trading bot

Now that we have created a new trading bot and you have the id of the newly created trading bot, it is time to configure the trading bot so that you can start trading automatically with it. All updates to your trading bot will be done by accessing the trading bot endpoints with your id, like /hopper/{id}. To update the configuration of your trading bot you will need to make a PATCH request to this endpoint. Underneath you will find the endpoint where you will need send your PATCH request to. Please replace {id} with the id you have received in step 1.

API endpoint:

https://api.cryptohopper.com/v1/hopper/{id}

You will need to send JSON data of the updates you want to make. If you want to change the name of your trading bot for example, you will need to send the name key again. If you do not want to change the name, you just simply omit this field. Underneath you will find an example of a JSON PATCH request.

Example JSON PATCH request:

{
    "name": "A new name of your newly created trading bot.",
    "enabled": 0,
    "api_config": {
    	"api_key": "The API key of your exchange account.",
    	"api_secret": "The API secret of your exchange account."
    },
    "config": {
    	"exchange": "binance",
        "collect_currency": "btc",
        .... And more configuration options
    }
}

Let's go over some of the possible configuration options in the JSON request.

api_config
api_key This is the API key which you created on your exchange.
api_secret This is the API secret which you created on your exchange.
config
exchange Enter the exchange key of the exchange you want to connect. To get a list of all exchanges and keys, go to: https://api.cryptohopper.com/v1/exchange
collect_currency This is the quote currency of your trading bot in lowercase characters, for example: btc, usd, eth.
allowed_coins An array list of coins (uppercase) which the trading bot may automatically buy. For example: ["BTC", "LTC", "ETH"].
perc_buy_amount The percentage of your total in assets which will be used to determine the buy amount.
min_buy_amount The minimum buy amount of automatic buys.
max_amount_allocated The max amount (in quote currency) allocated to your trading bot.
strategy The strategy you wish to configure. For example: no_strategy, multiple_ta. If you wish to configure a custom made strategy you will need to have the id of the strategy and configure it like: user_{id}, for example: user_1.
num_targets_per_buy The number of targets which will be bought if multiple targets are found by your strategy.
max_open_time_buy The number of minutes buy orders can stay open before they automatically are cancelled.
max_open_time The number of minutes sell orders can stay open before they automatically are cancelled.
set_percentage The take profit percentage you want configure, for example: 1.5.

Off course there are many other configuration options. Check out the API reference for more info about the config object.

When you have successfully updated the configuration of your trading bot, you will receive a 200 response with your complete config object returned. If the request failed, you will receive a 400 status with an error message explaining the error.

Hopefully you managed to create and configure your trading bot after reading this tutorial. You will now be able to adjust the configuration of your trading bot and add new trading bots to your account.