Skip to content

Automatic Trading Program Operation Manual

Gabrielle Zhou edited this page Nov 30, 2018 · 1 revision

This article uses the cybex exchange as an example to illustrate the operation of the automated trading program we developed. By running this program, you can use the specified account to automatically place orders, cancel orders, and set related strategies as needed, including market acquisition, order placement, price setting, risk control rules, etc.

I. Environment

  1. Install Docker

The created Json configuration file can be run by using Docker on the terminal. You can download and install it from the official website at https://docs.docker.com/install/

  1. Get Image

Starting Docker then using the Docker pull command to pull the created image from Alibaba Cloud's public image library:

Docker pull registry.cn-hangzhou.aliyuncs.com/cybex/robot:0.1.20181128

II. Create Configuration File

Create your configuration files according to the config.json.examples document in the attached file. Detailed parameters:

  1. markets: //market module

When the transaction pair can get market information through cryptocompare, you can configure as follows:

{
  "name": "cryptocompare",   //market instance name
  "params": {
    "url": "https://min-api.cryptocompare.com/data/price?fsym={}&tsyms={}",
    "market_expiration": 60,  //market validity period, unit seconds
    "trading_pairs": [
      {"base": "USDT", "quote": "ETH"},
      {"base": "BTC", "quote": "ETH"}
  ]
}

When the transaction pair can not get market information through cryptocompare, you can configure as follows:

{
  "name": "cybex",     //market instance name
  "params": {
    "url": "https://shanghai.51nebula.com",  //cybex production environment address
    "market_expiration": 60,  //market validity period, unit seconds
    "trading_pairs": [
      {"base": "CYB", "quote": "JADE.KEY"}
  ]
}
  1. strategies: //strategies module
{
  "name": "robot_ETH_USDT",  //strategies instance name
  "type": "robot_strategy", //strategies module type
  "params": {
    "base": "USDT",
    "quote": "ETH",
    "price_positive_floating": 0.001,   //the price  floating ratio to the direction of the transaction
    "price_nagtive_floating": 0.01,      //he price  floating ratio to the direction of the transaction
    "amount": 0.05,                            //order quantity denominated by quote, this means order 0.5ETH
    "amount_floating": 0.5,    //floating ratio amount of order quantity, this means: 0.075ETH>=order quantity>=0,025ETH
    "expiration": 180             //order timeout, unit seconds. this means automatic withdrawal of orders over 180 seconds
  }
}
  1. risk: //risk module
{
  "name": "robot_position", //risk instance name
  "type": "max_position_risk", //risk module type
  "params": {
  "max_position": 0.05  //the ratio of positions that can be used to place orders, this means when more than 5 percent of the positions then stop ordering
  }
}
  1. stoplosses: //stop loss module
{
  "name": "simple_robot",  //stop loss instance name
  "type": "price_stoploss_cancel", //stop loss module type
  "params": {
    "order_cancel_ratio": 0.01  //price fluctuation ratio of automatic withdrawal,his means when more than 1 percent of the price then automatic withdrawal
  }
}
  1. account: //account module

When configuring accounts of the CYBEX exchange:

  "name": "pytest1",  //account instance name
  "type": "cybex",  //account module type
  "params": {
    "name": "rbt-test01",   //order account name
    "url": "https://shanghai .51nebula.com", //cybex production environment address
    "wif":"wif-priv-key-here"  //order account private key

When configuring accounts for other exchanges:

To be added
  1. instances: //Invoke the above configuration
{
  "strategy": "robot_ETH_USDT", //call the order policy instance named "robot_ETH_USDT"
  "account": "pytest1",    //call the account policy instance named "pytest1"
  "market": ["cryptocompare"],  //call all the market instances in [ ], multiple market instances can be configured here
  "risk": ["robot_position"],   //call all the market instances in [ ], multiple risk instances can be configured here
  "stoploss": "simple_robot",  //call the stoploss policy instance named "simple_robot"
  "gap_sec": 1        //order frequency, in seconds
},
{
  "strategy": "robot_KEY_CYB",
  "account": "pytest4",
  "market": ["cybex"],
  "risk": ["robot_position"],
  "stoploss": "simple_robot",
  "gap_sec": 3      
}

III. Run Configuration File

Run the script with the command:

Docker run -it -v ${ABSOLUTE_PATH_OF_YOUR_CFG_JSON}:/config.json egistry.cn-hangzhou.aliyuncs.com/cybex/robot:0.1.20181128

Notice: ABSOLUTE_PATH_OF_YOUR_CFG_JSON is the absolute path of your in your configuration file in your local computer, When you need to run it in the background, you can use: Docker run -itd -v ${ABSOLUTE_PATH_OF_YOUR_CFG_JSON}:/config.json egistry.cn-hangzhou.aliyuncs.com/cybex/robot:0.1.20181128

IV. Monitor Accounts

Log in to the exchange to verify the results of the script run, and check account balances in a timely.

开发者社区

了解CYBEX

文档中心

DEVELOPERS

GETTING STARTED

DOCUMENTATION

Clone this wiki locally