Community written post: Collaborative strategy development using Jesse

Community written post: Collaborative strategy development using Jesse

2 years agoOpinion By qwpto

Our goal as a group of traders is to automate trading strategies in an agile way and to be able to optimize them in the shortest possible time using a reliable system that allows us to deploy them efficiently. The team consists of four people:

  • 1x Data Scientist / Quant Analyst
  • 1x Quant Developer
  • 2x Traders

Analyzing the miscellaneous competitors, Jesse presented itself as the most suitable solution for our purposes. Jesse trade is an open-source framework that allows retail traders to develop, optimize and deploy trading strategies on Crypto derivatives. The main reasons behind our choice of Jesse were:

  • Supports most of the major crypto exchanges
  • Allows you to trade futures derivatives
  • Subscription is made up of a one-time payment
  • Supports partial filings and leveraged trading
  • Written in Python
  • Multiple symbol trading and multiple timeframes simultaneously are supported
  • Self-hosted

So far we have been using Jesse trade for more than 6 months, developing TA-based strategies and implementing machine learning solutions, meanwhile, we have not encountered any critical issues. The dashboard made available is intuitive and the documentation is complete. In addition, when necessary we received quick support from the active community.

Over time we have structured the development into three stages.

  • Idea generation: The quant traders of our team develop trading ideas using their skillset. The strategies consist mainly of TA-based systematic strategies.
  • Development and Optimization: Once the idea is consolidated, it is developed using the Jesse framework. Thanks to the historical data available in Jesse, the strategy is back-tested on different timeframes and periods in order to stress it and highlight possible criticalities. Optimization is based on different techniques, ranging from classic risk management techniques to more complex Machine Learning solutions.
  • Deployment: the deployment is documented on Jesse's official website and allows you to connect it directly to your exchange or to receive trading signals through a webhook while paper trading. In the case of reinforcement learning, we export the data into CSV to iterate for the initial training independently.

Carrying out our development we have contributed to the improvement of Jesse by proposing and pushing on Github three solutions that helped us speed up the development phase.

Jesse Discord Reporting Library

This package allows us to post the results of backtests to a discord channel using a webhook. The backtests can take some time, so you want to be notified once they’re finished and to allow everyone to start reviewing the trades wherever they are.

discord-reporting-lib

The installation is pretty straightforward. To install and upgrade run the following lines:

pip install JesseReportDiscord

Once it's installed you just add the following lines to your Jesse strategy:

import JesseReportDiscord
      def terminate(self):
        JesseReportDiscord.sendJesseReportToDiscord('https://discordapp.com/api/webhooks/your/generated/webhook')

Where https://discordapp.com/api/webhooks/your/generated/webhook is the URL of the webhook you generate in the discord server's channel settings.

It publishes everything that you get after enabling all the options for your backtest (except debugging logs) and a little more:

  • Strategy Name,
  • Routes,
  • Hyperparameters,
  • Git Branch,
  • Git Commit Sha,
  • JSON Report,
  • CSV Report (Dates Updated To Human Readable),
  • Legacy Chart,
  • Quantstats Report,
  • Tradingview Pine Editor Script
  • Summary Metrics

Note that if the attachment files are too large for discord (8MB) they will be zipped into a zip archive. In case they are still too large the archive will be broken up into several uploads with the index _n for each file where n is incrementing. To recombine these for example in windows download all the parts and then run:

Downloads> COPY /B cb611e9b-458d-4450-a6c4-bfc19b194559_1.tvreport.html.zip +
cb611e9b-458d-4450-a6c4-bfc19b194559_2.tvreport.html.zip test.zip

The library will break the upload up into several consecutive posts in case it can't all fit into one. Users can add any number of additional reports with a second argument passed as a map for example:

JesseReportDiscord.sendJesseReportToDiscord('http://mydiscordgeneratedwebhook',
{'tvreport.html':'relative/path/to/custom/report.html'})

Don't use the inbuilt indexes which are 'JSON', 'HTML', 'Tradingview', and 'CSV' unless you want to overwrite those. It also allows them a single button press to start debugging the code. It will work for both Linux and Windows versions of docker and with the Jesse app natively on every OS.

Jesse Strategy Break Point Debugging In VSCode

Being able to pause the backtest at a specific point in time is key to resolving complex behavior within the strategies. It also helps those unfamiliar with python to be able to experiment and inspect the data. We are using Visual Studio Code to develop with Jesse. So we have forked the project template and updated it to work automatically with VSCode which means it will provide the user prompts to install docker, open in a container, and so on.

The workflow is:

  • (Optional) Follow The Desired Setup Instructions For Your Jesse Environment (You Can Skip This If You Just Want To Use Docker As Vscode Will Prompt You Through All The Setup)
  • Install VSCode
  • Create A New Strategy Project From This Template
  • Open This New Project In Vscode As A Folder
  • Vscode Will Then Prompt You Through The Remaining Steps (Eg Opening The Project In The Dev-Container, Installing Python, Etc)

Once you're ready to debug a strategy:

  • Open The File Of The Strategy In VSCode
  • Insert A Breakpoint By Clicking In The Left Margin (Near The Line Numbers)
  • Navigate To The Debugging Tab As Shown In The Image (1)
  • Choose Your Debugging Environment As Shown In The Image (2) Eg Jesse Docker Debug
  • Then Just Click Play To Start Debugging As Showing In The Image (3)

You can inspect the program flow, and variable values, and start experimenting with your strategy in the debug console against the candle data. oh and poke around at the internals of Jesse if that's what you're into.

https://jesse.trade/storage/images/qwpto/1.jpg

https://jesse.trade/storage/images/qwpto/2.jpg

https://jesse.trade/storage/images/qwpto/3.jpg

Jesse Tradingview Light Reporting Library

This addon will generate an HTML document containing all of the scripts and data to provide an offline Tradingview-like chart using lightweight charts where the data from the backtest of any timeframe and period is presented directly to review the results. It can also be called regularly within a strategy to review the progress.

The library is published to PyPI. So to install, from a command prompt where you would be running python:

pip install JesseTradingViewLightReport

In order to generate just the candlestick, volume, and order report, add the following to your strategy:

import JesseTradingViewLightReport

def terminate(self):
  JesseTradingViewLightReport.generateReport()

But you can also add custom data for example:

JesseTradingViewLightReport.generateReport(
      customData={
            "atr": {"data":self.atr, "options":{"pane":1, "colour":'rgba(251, 192, 45, 1)'}}, 
            'two':{"data":self.candles[:,1]-5, 
            "options":  {"pane":2}, 
            "type":"HistogramSeries"}, 
            'three':{"data":self.candles[:,1]+5, 
            "options":{"pane":2,"color":'purple'}
          }
      })

https://jesse.trade/storage/images/qwpto/example1.jpg

Available panels types are:

  • LineSeries
  • HistogramSeries
  • AreaSeries
  • BaselineSeries

You may be able to use:

  • BarSeries
  • CandlestickSeries

For more documentation on plot types and options see:

  • https://tradingview.github.io/lightweight-charts/docs/series-types
  • https://tradingview.github.io/lightweight-charts/docs/api
  • https://www.tradingview.com/lightweight-charts/

For the moment, the data will need to be the same length as the number of candles you would receive from self.candles. The different panels can be resized by dragging them with the cursor.

It is also possible to change the candle colors to PVSRA candles with the option:

JesseTradingViewLightReport.generateReport(chartConfig={'isPvsra':True})

However, at the moment it is not possible to use multiple panes with this option. This restriction will be removed in a future release.

https://jesse.trade/storage/images/qwpto/example2.jpg

The generateReport() function returns the relative location of the file. You can also find it inside where you're running the Jesse strategy from there will be a folder called storage, inside that this plugin creates a folder called JesseTradingViewLightReport. Then each time you run a strategy with different parameters it will create a unique file called something like 77cbda27-6eec-48b6-90fb-621656d9e9d8.html

So in this example, it will be:

c:/whereveryourunjesse/storage/JesseTradingViewLightReport/77cbda27-6eec-48b6-90fb-621656d9e9d8.html

Conclusions & Next Steps

The improvements shared by our team are aimed at creating agile processes and efficient communications between developers and traders in order to make operations as frictionless as possible.

We recommend using the vs code environment while developing strategies for Jesse, to generate HTML chart reports, and create a discord server. Even if you are working independently, this acts like a trade journal where you can create a channel per strategy and automatically upload the results into that channel to make notes in line with the results as you progress. We also link to the results in the git commits for traceability. We have noted that sometimes the results can overwhelm a conversation, in this case, create a separate channel for results from the conversation and link in the strategy’s conversation channel to the specific results, or paste important and annotated screenshots, etc to help the discussion.

In the coming months, our focus will be on the finalization of existing strategies and on the development of reliability systems to support the Live Plugin implemented by Jesse. In particular, we will focus on the development of systems that, together with Jesse, manage and cover the risks associated with system faults, which would inevitably lead to losses in trading operations.

❤️ Like Jesse?

If you like this project, please consider supporting me for free by using my referral links.

It's a win-win, you get free discounts and bonuses, and it helps me to develop more features and content:


Thank you 🙏