← About me & projects
Shared library

func_lib.py

One library, so every project is built and judged the same way.

About 1,500 lines of Python shared by all seven notebooks: data handling, date-safe splits, backtests, performance statistics, the DQN agent and environments, option pricing, volatility models and the dark Plotly theme.

1,523lines of Python
7notebooks use it
7sections
0look-ahead shortcuts

How it works

  1. Plotly theme. The shared dark template and palette behind every chart.
  2. Cross-sectional tools. Prices, momentum features, chronological splits, train-only scaling, date-ordered CV folds, benchmark and strategy backtests.
  3. Time-series tools. Downloads, indicators (moving averages, Bollinger Bands, Wilder RSI) and chart builders.
  4. RL core. The DQN agent with replay, target network and action masking; the episode runner; trade reports and statistics.
  5. Options and volatility. Black-Scholes and Greeks, implied volatility, GBM paths, Monte Carlo pricing, GARCH and HAR-RV forecasters, risk parity weights.
  6. Options RL. The options environment with bid/ask pricing, margin, margin calls and per-position trade statistics.

Results

CheckResult
Monte Carlo vs Black-Scholeswithin the confidence interval
Greeks vs finite differencesmatch to 1e-6
Put-call parity, implied-vol round tripexact
GARCH parameter recoveryrecovered on simulated data
RSI vs the ta libraryidentical
Options account equity vs trade P&Lequal to the cent

Verified, not just written

Each numerical routine was checked against an independent answer before it was used in a notebook.

Takeaways

  • Comparable results. Every strategy is split, scaled, backtested and charted the same way.
  • Fewer bugs. One tested implementation replaces copies spread across notebooks.