Runnable Julia tutorials for RiskLabAI.jl,
the financial-machine-learning library based on López de Prado's Advances in
Financial Machine Learning and Machine Learning for Asset Managers. Each notebook
is exhaustive over its module, runs top-to-bottom against a pinned
environment, and mirrors the matching Python tutorial in
Notebooks.py.
New to this? This gets you from a fresh computer to running any tutorial. You only do Step 1 once.
1a. VS Code. Download and install Visual Studio Code (Windows or macOS) and open it once. Then install these extensions (left sidebar → Extensions icon → search → Install):
- Julia (publisher: julialang)
- Jupyter (publisher: Microsoft)
1c. Julia. Install Julia via the official installer
(juliaup):
- Windows:
winget install julia -s msstorein a terminal, or use the installer on that page. - macOS: paste
curl -fsSL https://install.julialang.org | shinto Terminal, orbrew install juliaup.
Confirm it works: open a new terminal and run julia --version.
- Add the Julia kernel for notebooks (once). In a terminal:
This lets VS Code / Jupyter run Julia notebooks.
julia -e "using Pkg; Pkg.add(\"IJulia\")" - Get the notebooks. Go to https://github.com/RiskLabAI/Notebooks.jl → green
Code button → Download ZIP → unzip somewhere easy. (Or, with git:
git clone https://github.com/RiskLabAI/Notebooks.jl.) - Open the folder in VS Code: File → Open Folder → choose the
Notebooks.jlfolder. - Install the packages. Open a terminal in VS Code (Terminal → New Terminal) and run:
This installs RiskLabAI plus the plotting/data packages pinned for the notebooks. (First time compiles for several minutes — normal for Julia.)
julia --project=. -e "using Pkg; Pkg.instantiate()" - Open a notebook (e.g.
Optimizing/01_portfolio_construction.ipynb), click Select Kernel (top-right) → Julia, then click Run All.
The fractional differentiation and triple-barrier labeling tutorials pull real data from FRED (the Federal Reserve's free database). To run them:
- Get a free API key (instant): https://fredaccount.stlouisfed.org/apikey
- Set it as an environment variable, then open a new terminal so it takes effect:
- Windows:
setx FRED_API_KEY "your_key_here" - macOS: add
export FRED_API_KEY="your_key_here"to~/.zshrc, thensource ~/.zshrc
- Windows:
- Verify in a new terminal:
echo %FRED_API_KEY%(Windows) orecho $FRED_API_KEY(macOS).
All other tutorials run fully offline and need no key.
The Deep-BSDE notebook (Pde/DeepBSDE.ipynb) uses the Lux/Zygote/Optimisers
deep-learning stack. It arrives automatically with RiskLabAI (no extra install) — just
run the notebook top-to-bottom.
| # | Notebook | Topic |
|---|---|---|
| 1 | Optimizing/01_portfolio_construction.ipynb |
Robust portfolio construction — covariance denoising (Marčenko–Pastur), HRP, and NCO vs naive Markowitz |
| 2 | Data/Structures/FinancialDataStructures.ipynb |
Financial data structures — time, tick, volume, dollar, imbalance & run bars (offline AAPL data) |
| 3 | Data/Diffrentation/FractionalDifferentiation.ipynb |
Fractional differentiation — the minimum d for stationarity via an ADF sweep (FRED S&P 500) |
| 4 | Data/Labelling/TripleBarrierLabeling.ipynb |
Triple-barrier labeling + meta-labeling + trend scanning (FRED S&P 500) |
| 5 | Validation/CrossValidationAndPBO.ipynb |
Cross-validation — purged K-Fold, CPCV, walk-forward, and the Probability of Backtest Overfitting (PBO) |
| 6 | Features/FeatureImportance.ipynb |
Feature importance — MDI, MDA, SFI, orthogonal (PCA) features, and weighted Kendall-τ |
| 7 | Pde/DeepBSDE.ipynb |
Deep-BSDE PDE solver (Han, Jentzen & E 2018) — four financial PDEs, checked vs Monte-Carlo / closed-form references |
Tutorials for the admitted library-extension methods, each framed baseline → where it breaks → admitted method → when to use / when NOT (the "when to use" takeaway is the method's regime tag from its admitting appraisal). All run offline (synthetic data
- the committed AAPL snapshot).
| Notebook | Topic |
|---|---|
Features/Microstructure_EDGE.ipynb |
EDGE bid-ask spread estimator (Ardia–Guidotti–Kroencke 2024) vs Roll / Corwin–Schultz |
Features/Structural Breaks/GSADF_MultipleBubbles.ipynb |
GSADF / BSADF multiple-bubble detection & date-stamping (Phillips–Shi–Yu 2015) vs single-window SADF |
Features/EntropyBiasCorrection.ipynb |
Bias-corrected entropy — Miller–Madow, Grassberger, NSB vs the plug-in under undersampling |
Features/DebiasedImportance_MDIplus_CPI.ipynb |
MDI+ (Agarwal 2023) & CPI (Watson–Wright 2021) vs MDI/MDA |
Data/Distance/KSG_DistanceCorrelation.ipynb |
KSG kNN mutual information & distance correlation vs binned MI |
Data/Diffrentation/AdaptiveFractionalDifferentiation.ipynb |
Adaptive Fractional Differencing vs de Prado's min-d-via-ADF |
Backtest/MultipleTesting_and_SharpeInference.ipynb |
Holm / BHY Sharpe haircuts (Harvey–Liu 2015) & LPLZ HAC Sharpe inference (2025) |
Backtest/RobustStatistics_CED_SharpeDiff.ipynb |
Conditional Expected Drawdown & the Ledoit–Wolf Sharpe-difference test |
Backtest/OUTradingRules.ipynb |
Closed-form OU trading rules (Lipton–López de Prado 2020) vs the Monte-Carlo PT/SL grid |
Validation/PathLevelCPCV.ipynb |
Path-level Bagged & Adaptive CPCV (Arian–Norouzi–Seco 2024) vs plain CPCV |
Validation/LeakageAwareHPO.ipynb |
Leakage-aware HPO through purged CV with a Deflated-Sharpe gate |
RiskLabAI is pulled from its public repository — no local clone of the library
needed. From this folder:
using Pkg
Pkg.activate(".")
Pkg.instantiate() # fetches RiskLabAI + deps and precompiles the envOnce
RiskLabAI.jlis published to the General registry, the[sources]entry inProject.tomlcan be dropped and the dep becomes a plainPkg.add("RiskLabAI").
Then open any notebook with IJulia, or run it headless:
jupyter nbconvert --to notebook --execute --inplace <path-to-notebook>The Deep-BSDE PDE notebook (Pde/DeepBSDE.ipynb) uses the Lux/Zygote/Optimisers
deep-learning stack; it arrives transitively with RiskLabAI, so no extra install
step is required — only that one notebook exercises it.
Tutorials 3–4 read the S&P 500 from FRED; set the FRED_API_KEY environment
variable (a free key from https://fred.stlouisfed.org). All other data is either
synthetic or the committed Data/AAPL_OHLCV_1m_Data.csv snapshot, so the notebooks
stay reproducible and offline.
