FinQuant Documentation

repository·master·Indexed 23 days ago

https://github.com/fmilthaler/finquant

A financial analysis library for Python designed for portfolio management, return analysis, and mathematical optimisation. FinQuant enables users to create Portfolio objects from stock tickers, calculate technical indicators like Bollinger Bands and moving averages, and perform portfolio optimisation using the Efficient Frontier or Monte Carlo simulations. It supports data retrieval via yfinance and quandl, and provides tools for computing cumulative, percentage, and log returns.

Tokens
4.8K
Snippets
14
Records
39
Agent score
83%

What's inside FinQuant

  1. Overview of FinQuant

    master
    FinQuant is a Python library designed for financial portfolio management, analysis, and optimisation. It allows users to generate Portfolio objects from stock tickers, analyze returns, calculate moving averages (including Bollinger Bands), and perform portfolio optimisation using methods like the Efficient Frontier or Monte Carlo simulations.
  2. Overview of FinQuant capabilities

    master

    FinQuant is a library for financial portfolio management, analysis, and optimisation.

    Key features include:

    • Portfolio Management: Generates Portfolio objects that hold stock price data and automatically compute metrics like Expected annual Return, Volatility, and Sharpe Ratio.
    • Returns & Visualisation: A library for computing various types of Returns and visualising technical indicators like Moving Averages and Bollinger Bands.
    • Portfolio Optimisation: Tools to find optimised portfolios given a specific set of stocks.
  3. Use Monte Carlo simulations with finquant.monte_carlo

    master

    The Monte Carlo simulation functionality is located in the finquant.monte_carlo module. It provides two primary classes for performing simulations and optimizations:

    • MonteCarlo: Used for running Monte Carlo simulations.
    • MonteCarloOpt: Used for performing optimizations related to Monte Carlo methods.

    To use these, import them from the finquant.monte_carlo package.

  4. Use the finquant.returns module for daily and historical returns

    master
    The finquant.returns module provides implementations for calculating and analyzing daily and historical returns. This module is the primary entry point for return-based financial calculations within the library.
  5. Perform Monte Carlo portfolio optimisation

    master

    As an alternative to the Efficient Frontier approach, you can perform a Monte Carlo run of n trials to find optimal portfolios for:

    • Minimum volatility
    • Maximum Sharpe ratio

    Note: The Efficient Frontier approach is generally preferred for better computational efficiency and accuracy.

  6. Understand FinQuant custom data types

    master

    FinQuant uses custom data types defined in finquant.data_types as type hints throughout the library. When extending the library or implementing new functionality, you should use these types to ensure consistency with FinQuant's type validation system.

    Key categories of custom types include:

    • Array/List-Like Types: For handling collections, arrays, lists, DataFrames, or Series.
    • List of Dict keys: For specifying collections of dictionary keys.
    • Numeric Types: For specifying float, integer, or general numeric requirements.
  7. Understand the Portfolio object

    master
    The finquant.portfolio.Portfolio object is the central hub of the library. It holds all stock prices and automatically computes common financial quantities. It acts as a unified interface to the various modules in finquant/, combining data analysis, visualization, and optimization capabilities into a single object.
  8. Manage portfolios with finquant.portfolio.Portfolio

    master

    The finquant.portfolio.Portfolio class is the core abstraction of the library. It holds the prices of all stocks in a portfolio and automatically computes common financial quantities.

    Key features of the Portfolio object include:

    • Data Analysis: Interfaces to returns, moving averages, and risk metrics.
    • Visualisation: Methods to plot returns, moving averages, and Bollinger Bands.
    • Optimisation: Interfaces to the Efficient Frontier and Monte Carlo methods.

    To simplify creation, use the build_portfolio function to automatically generate a Portfolio instance.

  9. Install FinQuant

    master

    You can install FinQuant via PyPI or by cloning the GitHub repository.

    Via PyPI

    pip install FinQuant

    Via GitHub

    Clone the repository and run the setup script:

    git clone https://github.com/fmilthaler/FinQuant.git
    cd FinQuant
    python setup.py install

    Alternatively, you can clone the repository and add the directory to your PYTHONPATH without performing a formal installation.

    Dependencies

    FinQuant requires the following packages:

    • python>=3.10
    • numpy>=1.15
    • pandas>=2.0
    • matplotlib>=3.0
    • quandl>=3.4.5
    • yfinance>=0.1.43
    • scipy>=1.2.0
    • scikit-learn>=1.3.0
    pip install FinQuant
  10. Install FinQuant from GitHub

    master

    To install the latest development version from GitHub, clone the repository and run the setup script.

    Alternatively, you can clone the repository and add the directory to your PYTHONPATH if you prefer not to perform a formal installation.

    git clone https://github.com/fmilthaler/FinQuant.git
    cd FinQuant
    python setup.py install