ffn

github.com ↗

Calculate returns, portfolio statistics and allocation weights in Python

SI Score
80/100
Pricing
Open Source AI reading, not confirmed
Free plan
Yes AI reading, not confirmed
Sign-up required
Not required AI reading, not confirmed

Ask SI about ffn

Answers use saved listing facts and recorded sources.
Homepage screenshot
Screenshot of the ffn homepage

What it does

ffn adds financial-analysis functions to Python and pandas. It handles return transformations, performance statistics, charts, correlations and portfolio weights. The MIT-licensed library works with local data or a chosen provider and forms the analysis layer beneath the bt backtesting framework.

ffn is useful when prices are already in a notebook and you want to understand their behavior. Load a local CSV or request data through a provider, convert prices with to_returns or to_log_returns, and use calc_stats for a grouped performance report. Rebasing places several price series on a comparable starting scale; correlation tables and heatmaps show how their returns move together.

The quickstart supports explicit fields such as Open, High, Low and Close. Its Yahoo provider uses adjusted closing prices when a field is omitted. A CSV can be merged into the existing table, so the workflow can combine a downloaded series with your own data.

Install ffn locally for free. Yahoo examples need the separate ffn[yahoo] dependency; other providers can be callables or plugins. No ffn account is required for local files, although external providers have their own access conditions.

The library supplies calculations and plots, not a complete trading simulation. Use its companion bt when you need strategy rules and portfolio rebalancing. Importing ffn also adds methods to pandas objects, a detail to consider when integrating it into an existing Python project.

Strengths

  • Reads local CSV data as well as configurable providers
  • Brings return transformations, charts and performance summaries into pandas
  • Includes portfolio-weight calculations and correlation views

Watch out for

  • Full strategy backtesting requires an additional framework
  • Importing the package modifies pandas objects with extra methods

Best for

  • Python analysts exploring investment return series
  • Researchers building performance reports in pandas notebooks

Sources