Version 0.40.0 is released, bug fixes, improvements, new event handlers, and more

Version 0.40.0 is released, bug fixes, improvements, new event handlers, and more

2 years agoNews By Saleh

Today I released version 0.40.0 of the framework and the live plugin. This release mostly includes bug fixes and improvements. The previous release included a huge refactor which turned out to raise some issues. Based on the reports I received from you guys I fixed them and also did some other improvements. There's also a new feature that is helpful for those writing multiple strategies that are related to each other.

Here's the summary of what's new:

  • [BREAKING CHANGE] Removed the experimental plugin system used for defining custom exchange drivers for backtesting.
  • [BREAKING CHANGE] Implemented a new method called before_terminate which does exactly what the terminate() used to do. And slightly changed the terminate() method. To see their differences, check the updated documentation for before_terminate and terminate.
  • [NEW FEAWTURE] Implemented new event handler methods used for communicating among multiple strategies/routes: on_route_open_position, on_route_close_position, on_route_increased_position, on_route_reduced_position, on_route_canceled.
  • [IMPROVEMENT] Position entry price now displays all the digits after the decimal point.
  • [IMPROVEMENT] Added a warning if the open position is not in the list of trading symbols.
  • [IMPROVEMENT] Improved some error messages to include links to the related help center page.
  • [IMPROVEMENT] Improved authentication renewing of the WebSocket connection on Binance drivers.
  • [IMPROVEMENT] Changed "" endpoints to "" in hopes of a better network connectivity as it is mentioned on Bybit's docs.
  • [IMPROVEMENT] The "Reccuring position reports" feature of live sessions will now send reports even if the position is closed. This is to let you know that the bot is running (and not unexpectedly crashed for any reason).
  • [FIX] Fixed TypeError: Cannot parse single argument of type <class 'numpy.ndarray'>. for optimize mode
  • [FIX] Fixed TypeError: Cannot parse single argument of type <class 'numpy.ndarray'>. when using extra candles in live mode while "local candle generation" is enabled.
  • [FIX] Fixed the issue of exchanges not appearing in the live settings.
  • [FIX] Fixed the "Ratio Avg Win / Avg Loss" metric being always zero in backtest metrics.
  • [FIX] Fixed the store_candles() function from the research module. Also added validation for its inputs to prevent future issues.
  • [FIX] Fixed the TypeError: unsupported operand type(s) for *: 'NoneType' and 'float' error for a case after starting a session with the "persistency" feature enabled.

on_route_* event handlers

So far Jesse had bellow event handlers which you could use to hook into a specific event occurring for the route that you're trading:

  • on_open_position()
  • on_increased_position()
  • on_reduced_position()
  • on_close_position()
  • on_cancel()

But what if you needed to hook into an event occurring inside another route?

For example let's say I have two trading routes: BTC-USDT and ETH-USDT. Maybe I already have a long position in my BTC-USDT route and I want to close it immediately the moment I open a long position in my ETH-USDT route's strategy. To do that, inside my BTC-USDT's strategy I can say:

def on_route_open_position(self, strategy):
    if self.is_open and strategy.symbol == 'ETH-USDT':

Long story short, these new event handlers allow for communication between routes/strategies. Combine it with the shared_vars property and you can build some really cool stuff.

Here's the full list of the new event handlers:

New Tutorials

I also released two new episodes for the "algo trading from scratch" series on my Youtube channel. Make sure to check them out and like and comment to support me. Thank you!

That's it for this release. Catch you at the next one!

— 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 🙏