Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:AI4Finance Foundation FinGPT SciPy

From Leeroopedia
Knowledge Sources
Domains Scientific_Computing, Portfolio_Analytics
Last Updated 2026-10-18 00:00 GMT

Overview

SciPy scientific computing library used by the vendored pyfolio package's `timeseries` module for statistical significance tests, distribution functions, and numerical computations in risk metric calculation.

Description

This environment covers the `scipy` dependency used by pyfolio's `timeseries` module. The module uses `scipy.stats` for calculating p-values, t-tests, and probability distributions when computing risk metrics like Sharpe ratio significance, Value at Risk (VaR), and conditional VaR (CVaR). These statistical functions complement the basic pandas-based metric computations.

Usage

Use this environment for statistical analysis within portfolio performance evaluation. Required by the pyfolio timeseries module for risk metric computation.

System Requirements

Category Requirement Notes
OS Any Cross-platform
Python >= 3.8 3.10+ recommended
Hardware CPU sufficient No GPU needed

Dependencies

Python Packages

Credentials

No credentials required.

Quick Install

pip install "scipy>=1.10.0"

Code Evidence

Statistical tests from `pyfolio/timeseries.py`:

from scipy import stats

def sharpe_ratio(returns, risk_free=0, period='daily'):
    ...
    p_val = stats.t.sf(Sharpe_ratio, n - 1) * 2
    ...

Common Errors

Error Message Cause Solution
`ImportError: scipy.stats` SciPy not installed `pip install scipy`
`RuntimeWarning: invalid value` NaN in returns data Drop NaN values before computing metrics

Compatibility Notes

  • NumPy pin: Must use `numpy<2` for SciPy compatibility.
  • Stats module: All statistical functions are in `scipy.stats`.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment