docs: add custom data loader guide#194
Merged
Merged
Conversation
Closed
Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
9124a39 to
21a48c1
Compare
Collaborator
|
Thanks @mvanhorn — really clean PR, and I appreciate you verifying every symbol against the source. One change on the way in: instead of a standalone
Merging now — thanks for closing the gap on #178! 🙏 |
Contributor
Author
|
Thanks for merging the loader guide too, @warren618. Custom data loaders are a lot more approachable documented. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
agent/backtest/loaders/README.md, a guide for registering a customhistorical OHLCV data loader, and a one-line pointer to it from
CONTRIBUTING.md. It documents the loader contract end to end: theDataLoaderProtocolshape, the@registerdecorator, the registry / configwiring, and how to select the loader via
source="<your loader>". This helpscontributors who want to feed a data source the project does not ship a
connector for into the backtest data layer.
Why
Issue #178 asks how to feed a custom data source into the backtest data layer.
The registration recipe currently lives only in a maintainer reply, not in the
repo — so a new contributor has no in-tree path to follow. This guide closes
that gap and also documents two steps that are easy to miss: adding the module
to the lazy import list so
@registerfires, and adding the source name to theconfig schema's allowlist so
config.jsonvalidation accepts it.Changes
agent/backtest/loaders/README.md:name/markets/requires_auth/is_available()/
fetch()returning{symbol: DataFrame}with atrade_dateindex andopen/high/low/close/volumecolumns)._loader_modulesinregistry.py, add the name to_VALID_SOURCESinrunner.py, optionallyadd to
FALLBACK_CHAINS, and select viasource=.connectors, plus a checklist.
CONTRIBUTING.md: a short "Adding a Custom Data Loader" sectionlinking to the new README.
Deliberately out of scope: real-time tick/depth ingestion. There is no
first-class interface for pushing a custom real-time stream today (real-time
flows through the broker connectors), so the guide documents the historical path
only and points readers there.
Test Plan
Documentation only — no code paths change. Every symbol, signature, and path in
the guide was verified against the current source:
agent/backtest/loaders/base.py—DataLoaderProtocoland thefetchsignature / OHLCV return contract;
check_budget,retry_with_budget,cached_loader_fetch,loader_cache_get/put,validate_date_range.agent/backtest/loaders/registry.py—register, the_loader_moduleslistin
_ensure_registered(),FALLBACK_CHAINS,get_loader_cls_with_fallback.agent/backtest/loaders/yfinance_loader.py,okx.py,akshare_loader.py—the concrete loader pattern the examples mirror.
agent/backtest/runner.py—BacktestConfigSchema._VALID_SOURCES/valid_source(the config-validation step) and_get_loader.No live, broker, MCP, network, secret, or deployment surface is touched.
Rollback: revert the single commit with
git revert.Checklist
git commit -s) per the DCO requirement.Fixes #178