--- title: 'Getting Started with Leverj-mm' --- Getting Started with Leverj-mm === :::warning ⚠️ **Disclaimer:** This is not advice of any kind. Interacting with decentralised protocols has an element of risk. You can loose money, proceed with caution. ::: :::info ℹ️ This document assumes a reasonable knowledge of containers, key management, DevOps and trading systems. You should familiarise yourself with these topics beforehand. ::: ## Table of Contents [TOC] ## You will need To get started you will need the following: 1. A registered account on leverj.io (*Kovan is recommended for testing*) 2. Downloaded copy of the Gluon API json file 3. Cloned copy of the [https://github.com/leverj/leverj-mm](leverj-mm) repo 4. Docker & Node installed Basic config --- For the pupose of getting started, this config uses the Collar strategy with a small quantity and a large spread. ```yaml { "strats": { "COLLAR": true, "RANDOM": false, "EMA": false}, "futures": { "strategy": "COLLAR", "instrumentId": "4", "quantity": 0.025, "depth": 3, "step": 2.5, "spread": 15, "premium": 0.1, "startSide": "buy", "multiplyQty": false, "apiPath": "/futures/api/v1", "socketPath": "/futures/socket.io" } } ``` Take note of the key parameters: `"instrumentId": "4"` This is the ETHUSDT instrument `"quantity": 0.025` Order quantity of the instrument `"depth": 3` Depth of orders to place on each side `"step": 2.5` Step increment in price between orders `"spread": 15` Spread from the index price `"premium": 0.1` Premium to adjust order position above the index price Save this config file in `/packages/bot/config` as `default.json` Walk then run --- Navigate to `/packages/bot/` and create a directory called `privateKey` to store a copy of your Gluon API json file. **First, you can run a local instance of the Node app with the command:** ```shell! BASE_URL=https://kovan.leverj.io NODE_ENV=kovan BOT_APP=futures node src/mm.js privateKey/{secretFile}.json ``` This can be understood as: `BASE_URL=https://kovan.leverj.io` Base URL for connecting to Leverj (Kovan) `NODE_ENV=kovan` Environment config to use (Kovan) `BOT_APP=futures` Connection to Futures or Spot `node src/mm.js privateKey/{secretFile}.json` Run the mm.js app with the provided credentials *All other parameters are read from the `default.json` config created in the previous step* :::success ✅ You should see the log output of the app including connection and order creation. ::: **Next, try running a local instance of the Docker container with the command:** ```shell! docker run -d --name mm -v privateKey:/privateKey -e BASE_URL=https://kovan.leverj.io -e NODE_ENV=kovan -e BOT_APP=futures leverj/leverj-mm:develop node src/mm.js /privateKey/{secretFile}.json ``` This can be understood as: `docker run -d --name mm` Docker run command with a name for the container `-v privateKey:/privateKey` Create a volume using the `privateKey` folder as the source `-e BASE_URL=https://kovan.leverj.io` Base URL for connecting to Leverj (Kovan) `-e NODE_ENV=kovan` Environment config to use (Kovan) `-e BOT_APP=futures` Connection to Futures or Spot `leverj/leverj-mm:develop` Container image source (DockerHub) `node src/mm.js /privateKey/{secretFile}.json` Run the mm.js app with the provided credentials :::info ℹ️ The result should be similar to running the Node app, **except** it won't have used the default config because that doesn't exist within the container image from DockerHub ::: Let's look at all of the environment variables that can be passed into our docker image :eyes: ```yaml "STRATEGY" COLLAR, RANDOM, or EMA "BASE_URL" Base URL for connecting to Leverj "INST_ID" ID of the instrument to trade "QUANTITY" Order quantity of the instrument "DEPTH" Depth of orders to place on each side "STEP" Step increment in price between orders "SPREAD" Spread from the index price "PREMIUM" Premium to adjust order position above the index price "LEVERAGE" Leverage factor to apply on margin trading "COLLAR_REFRESH_RATE" Frequency for refreshing orders "MULTIPLY_QTY" True|False whether to multiply the quantity based on order depth ``` Each of the above env vars (in CAPS) can be passed to your container and will be read by the app allowing for config changes on-the-fly without redeploying. Common Errors --- :::danger ⚠️ **Insuffient funds** ::: :::spoiler Self explanatory, deposit more DAI/USDT into your Gluon Futures wallet. ::: ___ :::danger ⚠️ **Set positive quantity to trade** ::: :::spoiler This error can occur when trying to place an order for a quantity that is smaller than the minimum quantity for that instrument. ::: ___ :::danger ⚠️ **Invalid signature** ::: :::spoiler The signed order includes a timestamp based nonce. Leverj has a very small tolerance on timestamps due to the high frequency nature of the platform. The most common cause of an `Invalid signature` error is that the container's clock is not perfectly synced. ::: ___ Next steps --- 1. Continue testing your container on testnet for a suitable period of time to understand the operational requirements and market dynamics 2. Identify a provider with strong security to host the container 3. Ensure appropriate firewalls are in place and no ports are open to the container 4. Deploy the container in a region with good connectivity and low latency to Leverj - EU west 5. Only deposit funds to this Gluon account when you are 100% confident in your configuration choices, security, and assessment of the risks invovled