Skip to content

Commit 341a2f6

Browse files
committed
feat: add Jupyter Notebook / IPython magic integration (#454)
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
1 parent 8298819 commit 341a2f6

5 files changed

Lines changed: 565 additions & 0 deletions

File tree

investing_algorithm_framework/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,13 @@
254254
"VolumeBasedFill",
255255
"FXRateProvider",
256256
"StaticFXRateProvider",
257+
"load_ipython_extension",
257258
]
259+
260+
261+
def load_ipython_extension(ipython):
262+
"""Allow ``%load_ext investing_algorithm_framework`` to register
263+
the ``%backtest`` / ``%%backtest`` magic commands."""
264+
from investing_algorithm_framework.notebook import load_ipython_extension \
265+
as _load
266+
_load(ipython)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .magic import load_ipython_extension
2+
3+
__all__ = ["load_ipython_extension"]

0 commit comments

Comments
 (0)