ffn: Financial Functions for Python

repository·master·Indexed 25 days ago

https://github.com/pmorissette/ffn

A Python library for quantitative finance built on Pandas, Numpy, and Scipy. ffn provides utilities for performance measurement, evaluation, graphing, and data transformation, including tools to fetch historical price data via ffn.get(), calculate returns, rebase prices for relative performance comparison, and compute comprehensive performance statistics using calc_stats().

Tokens
6.3K
Snippets
18
Records
59
Agent score
81%

What's inside ffn

  1. Overview of ffn - Financial Functions for Python

    master

    ffn is a Python library designed for quantitative finance. It provides a wide range of utilities including performance measurement, evaluation, graphing, and common data transformations. It is built on top of established scientific libraries like Pandas, Numpy, and Scipy.

    Note: If you require a full backtesting framework, use the bt library, which is built on top of ffn to facilitate fast backtesting of quantitative strategies.

  2. Overview of ffn

    master
    ffn is a library providing utilities for quantitative finance. It builds upon Pandas, Numpy, and Scipy to provide functions for performance measurement, evaluation, graphing, and common data transformations.
  3. Configure the klink theme in Sphinx

    master

    To use klink as your Sphinx theme, update your conf.py file with the following settings. You can customize the theme using html_theme_options.

    import klink
    
    html_theme = 'klink'
    html_theme_path = [klink.get_html_theme_path()]
    html_theme_options = {
        'github': 'yourname/yourrepo',
        'analytics_id': 'UA-your-number-here',
        'logo': 'logo.png'
    }
  4. Integrate IPython Notebooks into reST documentation

    master

    Use klink.convert_notebooks() in your conf.py to automatically convert IPython Notebooks into .rst files and copy their static assets (like images) to your _static directory.

    Important:

    • Place your notebooks in your documentation's source directory.
    • Do not name a notebook the same as an existing .rst file, as the conversion process will overwrite it.

    After conversion, use the standard Sphinx include command to insert the generated .rst files into your documentation.

    klink.convert_notebooks()
  5. Integrate IPython Notebooks into Sphinx docs using klink

    master

    You can automatically convert IPython Notebooks into .rst files (including images and output) for inclusion in your documentation using the klink.convert_notebooks() helper function.

    Setup Steps:

    1. Place your .ipynb files within your Sphinx source directory (the same directory containing conf.py).
    2. Call klink.convert_notebooks() inside your conf.py file.

    Usage Notes:

    • Cell Types: You can mix in Markdown cells or Raw NBConvert cells; these will also be converted to .rst.
    • Raw NBConvert Tip: If using Raw NBConvert cells containing .rst text, add a blank line at the start of the cell to avoid conversion bugs.
    • Naming Conflict Warning: Do not name a notebook with the same name as an existing .rst file in your source directory, as the notebook conversion will overwrite the existing file.
  6. Integrate IPython Notebooks with klink

    master

    Klink provides a helper function klink.convert_notebooks() that converts all .ipynb files in your source directory (the same directory as conf.py) into .rst files. This process includes all outputs, such as images.

    To use this:

    1. Place your notebooks in your docs' source directory.
    2. Add klink.convert_notebooks() to your conf.py.
    3. Once converted, use the Sphinx include command to insert the resulting .rst files into your documentation.

    Note on Raw NBConvert cells: If you use Raw NBConvert cells containing rst text, ensure you add a blank line at the start of the cell to avoid conversion issues.

    klink.convert_notebooks()
  7. Customize the klink theme locally

    master

    To customize the theme's appearance, clone the repository into a _themes folder within your documentation's source directory. To change the styles, edit the .less files directly (requires lessc to convert them to .css).

    Update your conf.py to point to the local theme directory:

    html_theme = 'klink'
    html_theme_path = ['_themes']
    html_theme_options = {
        'github': 'yourname/yourrepo',
        'analytics_id': 'UA-your-number-here',
        'logo': 'logo.png'
    }
  8. Use Raw NBConvert cells for reST in notebooks

    master
    In addition to standard markdown cells, you can use Raw NBConvert cells in your notebooks. This allows you to input reStructuredText (reST) directly. While the rendering might not look as polished within the notebook interface itself, it is highly effective for documentation generation as it supports special reST and Sphinx markup (such as links and code markup) when processed.
  9. Configure the klink Sphinx theme

    master

    To use the klink theme in your Sphinx documentation, update your conf.py file with the following settings. You can provide a GitHub repository path, a Google Analytics ID, and a path to your logo.

    import klink
    
    html_theme = 'klink'
    html_theme_path = [klink.get_html_theme_path()]
    html_theme_options = {
        'github': 'yourname/yourrepo',
        'analytics_id': 'UA-your-number-here',
        'logo': 'logo.png'
    }