Conversation
- Replace hardcoded /tmp/ with tempfile.gettempdir() - Use Path.as_uri() instead of f"file://" for browser URLs - Normalize backslashes in sqlite:/// URIs
Add %%backtest cell magic and %backtest line magic for running backtests directly in Jupyter notebooks. - %%backtest: define a strategy inline and run a backtest in one cell - %backtest: run a backtest from an existing strategy file - Supports both event-driven and vectorized backtesting (--vectorized) - Parameters: --start, --end, --initial-amount, --market, --trading-symbol, -o (output variable), --show-report, --show-progress, --risk-free-rate - Extension loaded via %load_ext investing_algorithm_framework - Includes unit tests for parser, date parsing, strategy discovery, and extension registration Closes #454
Replace batch-level progress bar with strategy-level progress tracking when using parallel workers (n_workers). Workers now increment a shared counter after each individual strategy completes, and a monitoring thread updates a tqdm progress bar in real time (every 500ms). Changes: - Use multiprocessing.Manager().Value() as shared counter across workers - Add monitoring thread to poll counter and update tqdm bar - Show per-strategy throughput (strategies/s) and ETA instead of batch-level progress - Move multiprocessing, threading, concurrent.futures imports to top level - Order all imports per PEP 8 (stdlib, third-party, local) - Remove redundant inline combine_backtests import
Pass data_provider_service via ProcessPoolExecutor initializer instead of pickling it per task submission. On spawn-based systems (Windows/WSL) this avoids serializing the full data provider (with loaded dataframes) for every batch — now each worker pickles it only once at startup. - Add _init_worker() initializer and _worker_data_provider_service global - Copy data_provider_service once before pool starts - Worker falls back to module-level global when args value is None - No behavior change on fork-based systems (macOS/Linux)
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
Add
%%backtestcell magic and%backtestline magic for running backtests directly in Jupyter notebooks.Closes #454
Changes
New files
investing_algorithm_framework/notebook/__init__.py— Module entry pointinvesting_algorithm_framework/notebook/magic.py— IPython magic extensiontests/notebook/__init__.pytests/notebook/test_magic.py— 15 unit testsModified files
investing_algorithm_framework/__init__.py— Addedload_ipython_extensionfor%load_extsupportUsage
Supported parameters
--start--end--initial-amount--market--trading-symbol-o/--output--vectorized--show-report--show-progress--risk-free-rate--snapshot-interval--no-fill-missing-dataBacktesting modes
app.run_backtest()— strategy'srun_strategyis called at each time step--vectorized: callsapp.run_vector_backtest()— usesgenerate_buy_signals/generate_sell_signalsTests
All 15 tests passing: