Features

Patterns and event studies

Detect time-series patterns, build price projections, and analyze portfolios across selected date ranges

Simulation ranges

✅ Each simulation starts and ends at specific points, usually matching the first and last rows of your data. You can set a different simulation range beforehand, and now, you can also adjust this range during the simulation. This flexibility lets you stop the simulation when further processing is unnecessary. Additionally, the date range is saved in the portfolio object, so all metrics and subplots recognize it. Processing only the relevant dates speeds up execution and adds a new dimension to your analysis: isolated time windows 🔬

Simulate a quick liquidation scenario
@njit
def post_segment_func_nb(ctx):
    value = vbt.pf_nb.get_group_value_nb(ctx, ctx.group)
    if value <= 0:
        vbt.pf_nb.stop_group_sim_nb(ctx, ctx.group)  

pf = vbt.PF.from_random_signals(
    "BTC-USD",
    n=10,
    seed=42,
    sim_start="auto",  
    post_segment_func_nb=post_segment_func_nb,
    leverage=10,
)
pf.plot_value()  
Seeded leveraged BTC-USD portfolio value through liquidation Figure data (JSON)

Patterns

✅ Patterns are distinctive formations created by price movements on a chart and are central to technical analysis. There are now new dedicated functions and classes for detecting patterns of any complexity in any type of time series data. The idea is simple: fit a pattern to align with the scale and period of your selected data window, then compute the element-wise distance between them to get a single similarity score. You can adjust the threshold for this score to decide above which value a data window should be marked as "matched." Thanks to Numba, this operation can be performed hundreds of thousands of times per second! 🔎

Find and plot a descending triangle pattern
data = vbt.YFData.pull("BTC-USD")
data.hlc3.vbt.find_pattern(
    pattern=[5, 1, 3, 1, 2, 1],
    window=100,
    max_window=700,
).loc["2017":"2019"].plot().show()
Descending triangle pattern matches in BTC-USD from 2017 through 2019 Figure data (JSON)

Tutorial

Learn more in the Patterns and projections tutorial.

Projections

✅ There are cleaner ways to analyze events and their impact on price than conventional backtesting. Meet projections! 👋 Not only can they help you assess event performance visually and quantitatively, but they can also project events into the future to support trading. This is done by extracting the price range after each event, collecting all these price ranges into a multidimensional array, and then deriving confidence intervals and other useful statistics from that array. When combined with patterns, these tools are a quantitative analyst's dream! 🌟

Find occurrences of the price moving similarly to the last week and project them
data = vbt.YFData.pull("ETH-USD")
pattern_ranges = data.hlc3.vbt.find_pattern(
    pattern=data.close.iloc[-7:],
    rescale_mode="rebase"
)
delta_ranges = pattern_ranges.with_delta(7)
fig = data.iloc[-7:].plot(plot_volume=False)
delta_ranges.plot_projections(fig=fig)
fig.show()
ETH-USD last-week pattern matches with projected confidence bands Figure data (JSON)

Tutorial

Learn more in the Patterns and projections tutorial.

✅ Previously, OHLC data was used for simulation, but only the close price was analyzed. Now, most classes let you track all OHLC data for more accurate quantitative and qualitative analysis.

Plot trades of a random portfolio
data = vbt.YFData.pull("BTC-USD", start="2020-01", end="2020-03")
pf = vbt.PF.from_random_signals(
    open=data.open,
    high=data.high,
    low=data.low,
    close=data.close,
    n=10,
    seed=42
)
pf.trades.plot().show()
BTC-USD OHLC with random portfolio trade entries and exits Figure data (JSON)

Copyright © 20212026 Oleg Polakow. All rights reserved.

Site content and documentation are provided for using and evaluating VectorBT PRO and for educational purposes. Any other use, including building or supporting competing products or services, requires prior written consent.