Vectorbt Versions Save

Find your trading edge, using the fastest engine for backtesting, algorithmic trading, and research.

v0.21.0

2 years ago

Here's all the good stuff included in the v0.21.0 release!

Records

  • Records were further refactored to better bind NumPy structured data types. Instead of specifying the data type by passing it to the Records (or any subclass) constructor, it's now saved in the config of the class. The config also stores information on field titles, mappings, and other meta. Inheritance is achieved by using a class decorator that overrides the config of the base class with the config of the subclass. This allows seamless extending of records.
  • Implemented a new records class Ranges that allows analysis of any records that have a start time and an end time. For example, it can be used to analyze the distance between signals. It's inherited by both Drawdowns and Trades.

Signals

  • Removed a bunch of map-reduce methods on distances in signals and replaced them with methods that generate Ranges.
  • Added reverse flag to stop-signal generation based on OHLC data to control the direction (long/short).

Memory

  • Made storing call_seq in Portfolio and ts/close in Drawdowns, Orders, and Trades optional to save memory.
  • Made possible using flexible indexing on close and segment_mask arrays in Portfolio.from_order_func to save memory.

Portfolio

  • Implemented a flexible simulation mode (Portfolio.from_order_func with flexible=True) to lift the limit of one order per symbol and timestamp. Instead of following the call sequence provided by call_seq, the users can now issue as many orders as they want and in an arbitrary column order within a segment, and break out of the loop whenever they want. This mode is even faster than the strict one.
  • Refactored Portfolio.from_signals to work internally using a custom signal function and direction-aware arrays. Direction-aware arrays are 4 arrays: long entries, long exits, short entries, and short exits. They allow more signal combinations than the entries and exits arrays combined with the direction array. Additionally, the users can provide a custom signal function to generate signals dynamically. The same signal function by default is used to translate entries, exits, and direction to direction-aware arrays, for example.
  • Every class method in Portfolio that supports passing custom functions (such as from_order_func and from_signals) now supports templates such that the users have more power and convenience in broadcasting custom arrays and passing them as arguments.
  • Improved documentation around Portfolio.

Plotting

  • Apart from most classes having the stats method for computing common statistics, there is now also the plots method for plotting common plots (+ it's as easily extendible as stats).

License

  • Since this project draws more and more attention from startups, a Commons Clause was added to the Apache 2.0 license to prevent commercialization of the software by third parties (but still reserve the possibility of switching to AGPL in the future if the current license proves to be too weak). The license was changed without seeking approval from the contributors because each contribution to the codebase was relatively minor and has been overwritten more than once. Additionally, each future contribution will require signing a CLA to avoid any legal dispute.

Quantstats

  • Added quantstats adapter to the returns accessor and portfolio (see the qs attribute). This allows calling any quantstats function directly from the portfolio (+ vectorbt automatically passes all relevant arguments such as benchmark returns).

v0.20.0

2 years ago

Stats and plotting

  • Redesigned stats and plotting from the ground up.
  • Both now share a similar logic and have been put into separate mixin classes that can be subclassed by any wrapping class and extended easily. This way, not only portfolio but also accessors (generic, signals, returns), record classes (MappedArray, Records, Drawdowns, Orders, Trades/Positions, Logs), and IndicatorFactory now have tailored statistics implemented.

Signals

  • generate_ohlc_stop_exits now behaves similarly to Portfolio.from_signals.
  • Added grouping support for some functions to be used in stats.
  • Made ranking more flexible.
  • More integration with mapped arrays.
  • Renamed iteratively to chain and added more options to base generation functions.

Generic

  • Updates to Numba functions such as output data type not being necessary np.float64, but depending upon inputs.
  • Added mapping support for labeling any data (especially useful for integer data = enums).

Docs

  • Better UX on mobile devices and a clearer structure for DocSearch.
  • Improved representation and documentation of Config and Configured classes.

SignalFactory

  • Added support for generation of entries only.
  • Renamed signal generators according to a new naming schema.

Portfolio

  • Extended SL and TP stop adjustment functions by adding context.
  • Switched Portfolio.from_holding from signals to orders.

Accessors

  • Parent accessors now forward their config to child accessors (df.vbt(freq='d').signals is now the same as df.vbt.signals(freq='d')).
  • Removed caching from accessors, so each time calling an accessor on the same Series/DataFrame will re-initialize the accessor object. This is done to avoid side effects when the user changes index/columns in place. It brings some performance penalty of around 1-2ms pro initialization that has yet to be addressed.

Miscellaneous

  • Refactored most class decorators