Features

Knowledge search

Search documentation, API, examples, and community answers with keyword and embedding ranking

How do you find the right answer among thousands of pages and messages? VBT's knowledge search searches its documentation, API reference, code examples, and community answers from Python. Look up an exact warning or ask a question in your own words, then open the original sources. You can also collect the best matches as context for your own LLM.

Search the knowledge base and see where the best matches come from
def source(link):
    if "discord.com" in link:
        return "community"
    if "/api/" in link:
        return "API"
    if "/tutorials/" in link or "/cookbook/" in link:
        return "tutorials and cookbook"
    return "documentation"

results = vbt.search("trailing stop after partial exit", display=False)  
len(results)
42434
top = results[:20]
pd.Series([source(d["link"]) for d in top]).value_counts()
community        17
documentation     2
API               1
Name: count, dtype: int64
docs = [d["link"].split(".pro")[1] for d in top if source(d["link"]) != "community"]
print("\n".join(dict.fromkeys(docs)))
/documentation/portfolio/from-signals/#types
/documentation/portfolio/from-signals/#creation-1
/api/signals/generators/stcx/#vectorbtpro.signals.generators.stcx.STCX.exit_place_func_nb

Searching the whole knowledge base took 2.7 seconds on an Apple M3 once its data was cached. The first search downloads the knowledge assets and their precomputed embeddings, which took about 15 minutes here. For a question about a specific situation, community answers dominated the top 20, alongside the documentation sections that explain how stop orders are created.

The knowledge base

The knowledge base is a set of assets: website pages, community messages, code examples, and concepts, each a list of records with a link, title, and content. vbt.find_docs, vbt.find_api, vbt.find_examples, and vbt.find_messages return the records about an object or a query, and the assets themselves can be filtered, queried, sorted, grouped, and merged like data, with methods such as select, query, find, and apply. Message threads and page sections can be combined into single documents before searching, and your own text can be wrapped in an asset and searched or chatted with the same way. See the Knowledge assets highlight below.

Search and ranking

Ranking runs in three steps:

  • Splitting: long documents are split into chunks, with code blocks and headings kept intact.
  • Retrieval: embeddings find documents with a similar meaning, BM25 finds documents with the same words, and the default hybrid mode merges both rankings with reciprocal rank fusion.
  • Reranking: an optional reranker from Cohere, Jina, Voyage, a local Hugging Face cross-encoder, or any LLM scores the top results again, as the Reranking highlight below shows.

Embeddings come from OpenAI, Gemini, Voyage, Cohere, Jina, Hugging Face, a local Sentence Transformers model, or Ollama, and are stored in memory, in files, or in LMDB. For the default models, precomputed embeddings of the knowledge base download with each release, so only your queries need to be embedded. Embeddings from different models cannot be mixed, so after switching the embeddings provider, clear the cached embeddings and let VBT build them again.

The website pages and community messages are not part of the package. They download from the release on GitHub with the same GITHUB_TOKEN used to install VBT, and an updated VBT fetches the matching assets on its first search. Machines without access can point the asset settings at a local copy of the files.

Search tools

ToolUse it forNeeds
vbt.searchQuestions in your own words, using meaning and keywords togetherAn embeddings provider
vbt.quick_searchExact warnings, function names, and other keywordsNothing beyond the downloaded assets
vbt.chat, vbt.quick_chatAn answer based on the retrieved sourcesA completions provider, plus embeddings for vbt.chat

Results open as an HTML page or return as an asset for your own code, as the SearchVBT and Quick search and chat highlights below show. The same ranking feeds the AI research assistant, and the member website has its own search bar for pages and API.

Find code or community answers

Looking for a working example? Limit a search to asset_names="examples". Debugging a warning or an unusual backtest setup? Use asset_names="messages" to search community discussions. This lets you choose the kind of answer you need without searching every source at once.

If you already know the VBT object, vbt.find_api and vbt.find_examples can find its API reference and examples directly. For custom signal logic, the Knowledge assets example below goes further and finds code containing a particular function definition.

Search your own research notes

Your knowledge base can include your own material too. Wrap notes or text extracted from your documents in a KnowledgeAsset, then filter, search, or chat with it. For example, keep execution assumptions and validation plans together and find the note you need:

Find an execution assumption in personal research notes
notes = vbt.KnowledgeAsset([
    dict(title="Execution assumptions", content="Compare slippage of 0.05% and 0.1%."),
    dict(title="Validation plan", content="Reserve the final year for out-of-sample testing."),
])
print(notes.find("slippage").get("title"))
['Execution assumptions']

This text lookup runs locally without an embeddings or chat provider. The same asset can supply context for a model when you want to ask questions about the notes instead.

Context for your own LLM

to_context turns ranked results into one block of text within a token budget, with optional metadata such as links, ready to paste into any model or pass to your own pipeline. Choose how much source material to include with max_tokens. Local caching keeps downloaded assets and search results ready for reuse, and answers can stream into your notebook or be saved as text, Markdown, or HTML.

Reranking

✅ After the initial document retrieval, VBT can now rerank results using a dedicated reranking model to surface the most relevant documents. Five providers are supported out of the box: Cohere, Jina, Voyage, Hugging Face cross-encoders (local), and any LLM via completions-based scoring.

Rerank search results using Cohere
env["COHERE_API_KEY"] = "<YOUR_COHERE_API_KEY>"

vbt.search(  
    "How to rebalance weekly?",
    rerank=True,  
    reranker="cohere",  
    rerank_limit=20,  
)

Cookbook

Don't use OpenAI? Explore more configurations in the knowledge section of the Cookbook.

Quick search and chat

✅ In addition to embeddings, which require prior generation, VBT now supports BM25 for fast, fully offline lexical search. This is perfect for quickly finding something specific.

Search VBT knowledge for a warning
env["GITHUB_TOKEN"] = "<YOUR_GITHUB_TOKEN>"

vbt.quick_search("UserWarning: Symbols have mismatching index")

SearchVBT

✅ Want to find specific information using natural language on the website or Discord? SearchVBT accepts your question and generates an HTML page with ranked results and links to their sources. It searches by meaning as well as keywords, so you can describe what you want to do even when you do not know the VBT function name yet.

Search VBT knowledge for a warning
env["GITHUB_TOKEN"] = "<YOUR_GITHUB_TOKEN>"
env["OPENAI_API_KEY"] = "<YOUR_API_KEY>"

vbt.search("How to run indicator expressions?")

Knowledge assets

✅ Each release now includes valuable knowledge assets, JSON files containing private website content and the complete "vectorbt.pro" Discord history. These assets can be used with LLMs and services like Cursor. In addition, VBT offers a palette of classes for working with these assets, providing functions such as converting to Markdown and HTML files, browsing the website offline, performing targeted searches, interacting with LLMs, and much more!

Gather all pages and messages that define signal_func_nb
env["GITHUB_TOKEN"] = "<YOUR_GITHUB_TOKEN>"

pages_asset = vbt.PagesAsset.pull()  
messages_asset = vbt.MessagesAsset.pull()
vbt_asset = pages_asset + messages_asset
code = vbt_asset.find_code("def signal_func_nb", return_type="item")
code.print_sample(seed=42)  
link: https://discord.com/channels/x/918630948248125512/1251081573147742298
block: https://discord.com/channels/x/918630948248125512/1251081573147742298
thread: https://discord.com/channels/x/918630948248125512/1250844139952541837
reference: https://discord.com/channels/x/918630948248125512/1250844139952541837
replies:
- https://discord.com/channels/x/918630948248125512/1251083513336299610
channel: support
timestamp: '2024-06-14 07:51:31'
author: '@polakowo'
content: Something like this
mentions:
- '@fei'
attachments:
- file_name: Screenshot_2024-06-13_at_20.29.45-B4517.png
  content: |-
    Here's the text extracted from the image:

    ```python
    @njit
    def signal_func_nb(ctx, entries, exits, wait):
        is_entry = vbt.pf_nb.select_nb(ctx, entries)
        if is_entry:
            return True, False, False, False
        is_exit = vbt.pf_nb.select_nb(ctx, exits)
        if is_exit:
            if vbt.pf_nb.in_position_nb(ctx):
                last_order = vbt.pf_nb.get_last_order_nb(ctx)
                if ctx.index[ctx.i] - ctx.index[last_order["idx"]] >= wait:
                    return False, True, False, False
        return False, False, False, False

    pf = vbt.PF.from_random_signals(
        "BTC-USD",
        n=100,
        seed=42,
        signal_func_nb=signal_func_nb,
        signal_args=(
            vbt.Rep("entries"),
            vbt.Rep("exits"),
            vbt.dt.to_ns(vbt.timedelta("1000 days"))
        )
    )
    ```
reactions: 0

Copyright © 2021–2026 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.