How yatshunlee/caviar works
Project type and purpose
• This is a Python‐based research toolkit for value-at-risk (VaR) modeling and backtesting using the CAViaR approach.
• It consists of two core libraries—caviar (quantile regression VaR models) and var_tests (backtesting routines)—plus supporting modules, example notebooks, documentation, and demo dashboards.
File structure
• Top‐level modules:
• /caviar: Implements CAViaR models, Bayesian/frequentist quantile regression, utility functions, custom exceptions.
• /var_tests: VaR backtest functions (Kupiec, DQ tests, etc.).
• /backtesting: Higher-level backtest workflows and driver scripts.
• Demo applications:
• /dashboard_caviar: Streamlit dashboard for live demonstration.
• /dashboard_presentation: Sample Streamlit script, notebooks, and a localtunnel setup for sharing.
• Documentation and examples:
• /doc: Markdown docs for each component.
• /notebook-example, /notebook-experiment, /notebook-test: Jupyter notebooks illustrating usage, experiments, and tests.
• Config files: requirements.txt (root), dashboard_presentation/requirements.txt.
Extract additional insights from the README
• Two primary libraries (caviar, var_tests) form the backend computation layer.
• Dashboards are thin presentation layers that consume the libraries’ APIs.
• Notebooks serve both as user documentation and experimental pipelines.
• The system was designed to allow easy swapping of optimization constraints and initialization strategies.
a. Main components
• Data Source (CSV files, live market feed)
• Preprocessing Layer (data cleaning/transformation modules or notebooks)
• CAViaR Modeling Engine (caviar library)
• VaR Backtesting Engine (var_tests + /backtesting module)
• Demo Dashboards (dashboard_caviar, dashboard_presentation)
• Documentation & Notebooks (side-by-side experimental environment)
b. Component interactions
• Data Source → Preprocessing → CAViaR Engine → VaR Forecasts
• VaR Forecasts → Backtesting Engine → Backtest Reports
• Modeling & Backtesting APIs → Dashboards → End User (web UI)
• Notebooks invoke Modeling & Backtesting libraries for ad-hoc analysis
c. Key architectural patterns
• Layered architecture (data → computation → presentation)
• Clear separation of concerns: modeling vs. backtesting vs. presentation vs. docs
• Modular Python packaging for easy reuse and extension
d. Core technologies
• Python 3.x, NumPy, Pandas, SciPy, statsmodels
• Streamlit for interactive dashboards
• Jupyter Notebooks for examples and experiments
• localtunnel (for demo sharing)