Empyrial

Empyrial is a Python-based open-source quantitative investment library dedicated to financial institutions and retail investors, officially released in Mars 2021. Already used by thousands of people working in the finance industry, Empyrial aims to become an all-in-one platform for portfolio management, analysis, and optimization.

Empyrial empowers portfolio management by bringing different financial approaches such as risk analysis, quantitative analysis, fundamental analysis, factor analysis and prediction making.

With Empyrial, you can easily analyze security or a portfolio with these different approaches and get the best insights from it.

Installation

You can install Empyrial using pip:

pip install empyrial

For a better experience, we advise you to use Empyrial on a notebook (Jupyter, Google Colab...)

Here are the functions available with Empyrial:

  • empyrial : quantitative portfolio analytics | Quickstart | Documentation
  • oracle : prediction generation on your portfolio using several prediction models (Prophet, Auto-ARIMA, Fast Fourier Transform...) | Quickstart | Documentation
  • fundlens : fundamental analysis of each of the assets in your portfolio | Quickstart | Documentation
  • optimizer : optimize the asset's allocation in your portfolio | Quickstart

Usage

Empyrial

from empyrial import empyrial, Engine

portfolio = Engine(    
                  start_date= "2018-06-09", 
                  portfolio= ["BABA", "RELIANCE.NS", "KO", "^DJI","^IXIC"], 
                  weights = [0.2, 0.2, 0.2, 0.2, 0.2], #equal weighting by default
                  benchmark = ["SPY"] #SPY by default
)

empyrial(portfolio)

>> See the output

If you want to add rebalancing (calendar-based) to your strategy you can do that:

from empyrial import empyrial, Engine

portfolio = Engine(    
                  start_date= "2018-06-09", 
                  portfolio= ["BABA", "RELIANCE.NS", "KO", "^DJI","^IXIC"], 
                  benchmark = ["SPY"], #SPY by default
		  optimizer = "EF",
		  rebalance = "1y"
)

empyrial(portfolio)

Time periods available for rebalancing are 2y,1y,6mo,quarterly,monthly

Fundlens

from empyrial import fundlens, Engine

portfolio = Engine(    
                  start_date= "2020-06-09", 
                  portfolio= ["BABA", "RELIANCE.NS", "KO", "^DJI","^IXIC"], 
                  weights = [0.2, 0.2, 0.2, 0.2, 0.2], #optional
                  benchmark = ["SPY"] #optional
)

fundlens(portfolio)

>> See the output

Oracle

from empyrial import oracle, Engine

portfolio = Engine(    
                  start_date= "2020-06-09", 
                  portfolio= ["BABA", "RELIANCE.NS", "KO", "^DJI","^IXIC"], 
                  weights = [0.2, 0.2, 0.2, 0.2, 0.2], 
                  benchmark = ["SPY"] 
)

oracle(portfolio)

>> See the output

Optimizer

There are 3 optimizers available:

  • "EF": Global Efficient Frontier
  • "MEANVAR": Mean-Variance (in this case, you'll have to define a max volatility that you don't want to exceed)
  • "HRP": Hierarchical Risk Parity
  • "MINVAR": Minimum-Variance
  • "BL": Black Litterman

Note: the default optimizer is equal weighting

There is two ways to use the Empyrial's optimizer :

  1. Optimize allocation directly with Engine

    from empyrial import*

    portfolio = Engine(
    start_date = "2018-01-01",
    portfolio = ["BLK", "BAC", "AAPL", "TM", "JPM","JD", "INTU", "NVDA", "DIS", "TSLA"],
    optimizer = "EF"
    )

    portfolio.weights

Output:

[0.31409, 0.0, 0.03472, 0.00046, 0.0, 0.0, 0.069, 0.08831, 0.00854, 0.48489]
  1. See the performance of an optimizer

    from empyrial import*

    portfolio = Engine(
    start_date = "2018-01-01",
    portfolio = ["BLK", "BAC", "AAPL", "TM", "JPM","JD", "INTU", "NVDA", "DIS", "TSLA"]
    )

    for efficient frontier

    optimizer(portfolio, "EF")

    for hierarchical risk parity

    optimizer(portfolio, "HRP")

    for mean variance

    optimizer(portfolio, "MV", vol_max=0.15)

>> See the output

Download the Tearsheet

Want to download a tear sheet of the analysis as a PDF or HTML file? You can check out documentation to find out how to do this.

Stargazers over time

f656d70797269616c2e737667

GitHub

https://github.com/ssantoshp/Empyrial