Version 0.38.0 is released with support for spot trading, new drivers, and many improvements and bug fixes

Version 0.38.0 is released with support for spot trading, new drivers, and many improvements and bug fixes

2 years agoNews By Saleh Mir

Today I'm releasing version 0.38.0 of both the framework and the live plugin which brings the long-awaited support for spot trading.

I have a confession to make. It may sound weird, but I started my trading career by trading futures; and NOT the spot market! Here's why:

Spot trading is a bit tricky. In better words, it's too simple and sometimes too limiting. For example, I like being able to submit both take-profit and stop-loss at the same time for my open positions.

Speaking of positions, I like monitoring my open positions in realtime rather than estimating the metrics in my mind. Because as you know in spot trading, when you buy an asset, you don't get to see metrics such as PNL, entry-price, etc.

It also sucks that when you sell an asset in the spot mode, usually, a small amount of it remains in your account. Maybe that doesn't bother you when trading manually; but when trading with a bot, it's a real pain as your bot assumes the position is still open (as qty != 0).

But on the bright side, you don't have to pay funding fees in spot trading which is nice if you intend to hold a position for weeks. Also, futures trading is prohibited in many countries, so their citizens have no other choice but to trade in spot markets only.

I want Jesse to be so good that I personally enjoy using it every day. So instead of merely implementing support for spot trading like any other trading bot out there which merely supports submitting buy and sell orders, I went the extra step of making it simple. As simple as futures trading. Well, almost.

I'll explain how I did it, but first things first; here's the changelog for this release:

What's new?

  • [NEW FEATURE] Added support for live spot trading on Binance.com, FTX.com, and FTX.us
  • [IMPROVEMENT] Improved handling of queued orders when trading multiple routes in the live mode.
  • [IMPROVEMENT] Loaded DNA values are now logged at the beginning of the live mode if the debugging mode is enabled.
  • [IMPROVEMENT] Added validation for timeframe of passed candles to research.backtest() to prevent confusions.
  • [IMPROVEMENT] Queued orders' price points are now displayed on the real-time chart in the live mode.
  • [IMPROVEMENT] Increased the font size of logs in live trading.
  • [IMPROVEMENT] Improved behavior of the download links for backtest results so you won't face the exit popup question when you click on them.
  • [IMPROVEMENT] Added proper handling of {'code': -2011, 'msg': 'Unknown order sent.'} errors on Binance Perpetual Futures which were occurring after a "reduced position" event.
  • [FIX] Fixes a bug where the dna() was not being loaded in the live mode.
  • [FIX] Fixed the issue with the detection of liquidation orders on BinanceFutures
  • [FIX] Fixed the ImportError: numpy.core.multiarray failed to import error related to numpy in new installations on Ubuntu.
  • [FIX] Fixed an issue causing KeyError: 'futures_leverage' error in new installations.
  • [FIX] Fixed an issue where there are duplicate exchange names in the routes exchange list.

Update guide

If you are not using the live plugin, just follow the typical steps for installing updates.

In case of using the live plugin, you also need to open your project's .env file, and add the below values:

# Binance Spot (https://www.binance.com/en/trade/BTC_USDT?type=spot)
BINANCE_SPOT_API_KEY=
BINANCE_SPOT_API_SECRET=

# FTX Spot (https://ftx.com/markets/spot)
FTX_SPOT_API_KEY=
FTX_SPOT_API_SECRET=
FTX_SPOT_SUBACCOUNT_NAME=

# FTX US Spot (https://ftx.us/markets/spot)
FTX_US_SPOT_API_KEY=
FTX_US_SPOT_API_SECRET=
FTX_US_SPOT_SUBACCOUNT_NAME=

How spot trading on Jesse works (that doesn't suck)

Remember the issues I mentioned earlier? Well, here's how Jesse solves them so you don't have to worry about them:

  • Positions are tracked on Jesse just like it is on our paper-trading mode. So you'll get to see your open positions, their PNL, etc, even though it's not visible on the exchange.
  • If the open positions' size (qty) is less than a certain amount (the amount is dictated by the exchange) Jesse considers it closed. For example, if you only have 0.00000001ETH left in your account, Jesse will consider it zero. So you don't have to worry about this issue at all.
  • You can submit both take-profit and stop-loss orders at the same time. Depending on the exchange you're trading on and its requirements, Jesse will submit the order(s) that is accepted at the moment, and queue the other(s). Once the live price gets closer to the other (queued) order, Jesse will cancel the previously submitted one, queue it, and submit the previously queued one. Confused? Don't worry, you don't have to worry about this at all. It'll all be handled by Jesse. But it's good to know what a queued order status is; because you will see it in the logs.

Limitations

But not everything is perfect. I wrote a post explaining the limitations of Jesse's spot trading support at this time. Please read it if you intend to trade on the spot market.

I need your help for Binance.us

The API of binance.com (spot) and binance.us seem to be identical just as it is the case on ftx.com and ftx.us. However, unlike ftx.us, binance.us does not allow registration for non-US accounts.

So since I already have implemented binance.com, my code for binance.us should work fine. But as always, I need to run some tests to make sure.

If you have an account on binance.us and are willing to help me test it, please contact me. All I need for testing is a pair of API keys, and $25 in the account. As a thank you, I will give you a free license for the live plugin.

[update]: I finished the implementation thanks to a member of the community providing me with an account. What warms my heart even more is that there was even more users offerting help with this. I will release version 0.38.2 containing the driver for binance.us tomorrow.

What's next?

At the moment Jesse fetches 1m candles from the exchange and calculates the other timeframes from it.

This approach works fine for backtests. However, in live trading, there are cases like Bybit Spot where the exchange doesn't provide historical candles for more than a limited number.

For that reason, I need to implement an alternative way of fetching the data so that such exchanges could be supported. Also, doing so will probably cause the near-instant startup of live sessions which in case you're using multiple routes, could be beneficial to you.

I also intend to add more exchanges. So if you have recommendations for other exchanges, please let me know.

Happy algo-trading,

— Saleh

❤️ 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 🙏