How to deploy your Jesse project into the production server

In this tutorial, I will show you step by step, how to deploy your Jesse project from your local into a VPS for production.

I highly recommend using a VPS for production instead of running the bot on your local machine. The reason being that your local machine is not as reliable as a server. It has a better Internet connection, and there’s less chance of accidents such as power outages.

Installation and configuration of a Linux VPS seem scary to some users. But don’t worry, because I have made a script that makes the installation super easy.

Recommended cloud provider

Here are a list of providers that I recommend based on my experience:

I’ll be using an Ubuntu 18.04 VPS which is offered by almost all cloud providers.

I’ve been using Hetzner for past years because not only it has the cheapest price, but also it has the highest quality among providers that I tried. Its starting plan which comes with 1 core CPU and 2GBs of RAM is what I’ve been using for running Jesse and it costs only €2.96 per month. You can use my referral link which gives you €20 free credits at the time of sign up. That is months of the server for free!

Creating a cloud VPS

After logging into your Hetzner account, choose the default project, or create a new one. Then click on the red “Add server” button. You can choose the location of the server as whatever you want it to be.

As for the “Image”, I’ll be choosing :

Leave the rest be. The beginning €2.96 is more than enough.

Next, you need to add/choose an SSH key and give your server a name. The name could be anything you want it to be. As for the SSH key, if you have one, just copy it from your local system and add it. If you haven’t created one already, go you Gitlab’s guide and follow the instruction to create one. It’ll only take a minute. And then, add it into the SSH key section:

Now go ahead and click on “CREATE & BUY NOW”.

Installing the server

Connect to the server we just created on Hezner, by opening a terminal and typing:

Now execute below command which is from my “ stack installer repository:

It’ll take a few minutes for the installation to go through. After that, your server has all that it needs to run Jesse.

Creating a Jesse project

Let’s create a new Jesse project on our local machine. I’m on a macOS machine. After going into your desired location, run:

And next I cd into it:

Creating a strategy

Let’s copy a strategy called “SMACrossover” from the “[example strategies](https://github.com/jesse-ai/example-strategies" repository which contains a few strategies submitted by the community members.

Next, I create a new strategy and name it by executing:

Next, I paste the contents of SMACrossover into in my project.

Getting the live trade plugin

If you are reading this, I assume you already have a valid license for the live trade plugin. If you don’t, please head over to Jesse’s website, register, and purchase a license.

Next, go to the “ releases” page and download the latest version for (in this case) :

Now move the download package into your project files.

Deploying everything to the server

I’ll be using Gitlab to host my project privately, and then of course to retrieve it from my server.

If you’re not familiar with Git, I highly recommend checking out this YouTube video to get started with it. Git is a very useful version manager and services such as Gitlab or Github are real-life savers for development.

First, I create a new private project on Gitlab and give it a name. In my case, I entered . Make sure that the "Visibility Level" is set to .

Now I need to push my project files into the repository. I do that by opening the terminal, and going into the project, and running:

Now I need to retrieve the files from the server. The first thing I need to do is to give my VPS access to this private repository. For that, I need to create an SSH key, and add it to my Gitlab account’s SSH:

It’ll ask for the location to store my keys, and I just choose the default one by pressing . Next, it'll ask for a passphrase, which I skip by pressing . And of course, one more time for confirmation.

After that, my keys are generated and I can see it by executing:

I now copy my SSH key and paste it into my Gitlab accounts SSH keys page:

And finally, click on “Add key”.

Now I open the terminal tab that has the VPS open in it, and clone this repository by typing:

Type for confirmation. Now open the project by typing . Notice that our project is missing the and files. That's because they are added into the files of projects created by Jesse. This is to make sure that your sensitive API keys and such, are not accidentally pushed to the repository.

So I create them back by just copying the content of each from my local, and paste it in the server:

Now I do the same for :

Here is the content of that I copied. You can modify it as you need:

Creating a database and user

Of course, we also need a database. PostgreSQL has already been installed using the script we just used. So let’s create one by below commands:

Installing the live trade plugin

Since I am already inside my project which has the live trade plugin’s package in it, I can easily install it with pip:

Now I should see the successful installation message:

Now I need to log in by typing:

This will ask for my email and password which I entered at the time of registration on Jesse’s website. If it goes well you should see:

Now let’s confirm that the live trade plugin is installed correctly by typing:

The output should have the and modes in it:

Exchange keys, notifications, and dashboard settings

In order for Jesse to be able to connect to the server, I have to enter my API keys, and for it to be able to send me notifications I have to enter my keys for either Telegram or Discord (or both!).

I can do that by modifying the file which contains this info:

Starting and monitoring the running bot

Now everything is in place. I can start a live session by typing:

Or a paper trading session by:

It is often useful to have the debug mode enabled. For that, enter the same commands but this time add the flag at the end.

Keeping the session alive after closing the terminal

But there’s a problem here. If I close my terminal, the live session will stop. But I want the bot to continue trading for days even if I shut down my computer. That was the whole point of running it on a VPS.

For that, I use a tool called “screen”. Screen creates a virtual terminal screen that I can attach and detach from whenever I need to. screen gets installed by that installer script that I just used. So I can go ahead and create my first screen:

Now inside this screen I can run the live session again, but this time it won’t be terminated if I close my terminal. Next time that I connect back to the server, I can reattach to that screen by:

Originally published at https://jesse.trade.

I write about algotrading. I do my best to publish practical tutorials.