New releases, custom exchange drivers, WebSocket refactors, and more

Today I released 0.25.0 for the main framework and 0.0.8 of the live trade plugin.

One of Jesse’s outstanding features has always been its ability to execute backtests for multiple pairs at the same time. However, in the live mode, there have been some limits with how Binance sends the data over the WebSocket connection, hence causing issues such as missing candles after a period of connectivity.

Version 0.0.8 of the live trade plugin includes huge refactors which introduce solutions for these problems:

The WebSocket is now initiated before fetching initial candles via REST

There was an issue where if you were trading too many routes, importing initially required candles from the exchange (via the REST API) would have taken so long. And it was done one by one per each route.

For example, if you were trading 20 routes, assuming it would have taken 3 minutes to fetch the initial candles for routes 2-20, the data that you had imported for the first route has missed 3 1m candles.

But now the WebSocket would open first, hence keeping the data fresh and up to date.

One WebSocket connection is opened per each route

According to Binance’s documentation, there’s a limit of 5 messages per second for the WebSocket connection. So when you’re trading multiple routes, you will probably reach that limit. The worst part is you don’t even get an error, instead, the packages are just dropped.

To bypass this issue, I refactored how we connect to Binance. Instead of opening only one WebSocket connection for all the streams, Jesse now opens one per each route, and last but not least, a separate one for the user’s account data only. This solution has been tested with a few users in the past few days and has been reported to be effective.

Custom exchange drivers (plugins)

One of the most requested features of Jesse has always been (and will probably be) supporting more exchanges. And I very much intend to implement more myself. However, the truth is that there’s no way for me to add and maintain all the exchanges out there.

On the other hand, many numbers of our community members are developers, and in fact, have asked for help with new drivers. And we’re not really a framework unless we allow for customizations.

Thus, I thought about implementing a plugin-based API for others to add their own drivers. As always, I will make sure the API is as simple as it gets, only requiring the absolutely necessary part on your side. And of course, I have included examples and documentation.

I’m beginning with opening the plugins API for backtesting only. If the response I receive from you guys is good, I will do the same for the live trade.

What I wish to see is community members writing drivers and releasing them as PIP packages so others can use them too. This way, we’ll have a collection of new exchanges in no time.

Necessary update in existing projects

After upgrading to the 0.25.0 version you must have a plugins.py file present in your Jesse project to be able to import candles as before. If you don’t, create one and place below content in it to work as before:

from jesse.modes.import_candles_mode.drivers.binance import Binance
from jesse.modes.import_candles_mode.drivers.binance_futures import BinanceFutures
from jesse.modes.import_candles_mode.drivers.binance_inverse_futures import BinanceInverseFutures
from jesse.modes.import_candles_mode.drivers.bitfinex import Bitfinex
from jesse.modes.import_candles_mode.drivers.coinbase import Coinbase
from jesse.modes.import_candles_mode.drivers.testnet_binance_futures import TestnetBinanceFutures

import_candles_drivers = {
    'Binance': Binance,
    'Binance Futures': BinanceFutures,
    'Binance Inverse Futures': BinanceInverseFutures,
    'Testnet Binance Futures': TestnetBinanceFutures,
    'Bitfinex': Bitfinex,
    'Coinbase': Coinbase
}