Finance professionals involved in data analytics and data science make use of R, Python and other programming languages to perform analysis on a variety of data sets. Python has been gathering a lot of interest and is becoming a language of choice for data analysis. Python also has a very active community which doesn’t shy from contributing to the growth of python libraries. If you search on Github, a popular code hosting platform, you will see that there is a python package to do almost anything you want.

This article provides a list of the best python packages and libraries used by finance professionals, quants, and financial data scientists.

Numerical, Statistical & Data Structures

  • numpy – NumPy is the fundamental package for scientific computing with Python. It is a first-rate library for numerical programming and is widely used in academia, finance, and industry. NumPy specializes in basic array operations.
  • scipy – SciPy supplements the popular Numeric module, Numpy. It is a Python-based ecosystem of open-source software for mathematics, science, and engineering. It is also used intensively for scientific and financial computation based on Python
  • pandas – The pandas library provides high-performance, easy-to-use data structures and data analysis tools for the Python programming language. Pandas focus is on the fundamental data types and their methods, leaving other packages to add more sophisticated statistical functionality
  • quantdsl – Quand DSL is domain specific language for quantitative analytics in finance and trading. Quant DSL is a functional programming language for modeling derivative instruments.
  • statistics – This is a built-in Python library for all basic statistical calculations

Financial Instruments

  • pyfin – Pyfin is a python library for performing basic options pricing in python
  • vollibvollib is a python library for calculating option prices, implied volatility and greeks using Black, Black-Scholes, and Black-Scholes-Merton. vollib implements both analytical and numerical greeks for each of the three pricing formulae.
  • QuantPy – A framework for quantitative finance In python. Some current capabilities: Portfolio class that can import daily returns from Yahoo, Calculation of optimal weights for Sharpe ratio and efficient frontier, and event profiler
  • ffn – A financial function library for Python. ffn is a library that contains many useful functions for those who work in quantitative finance. It stands on the shoulders of giants (Pandas, Numpy, Scipy, etc.) and provides a vast array of utilities, from performance measurement and evaluation to graphing and common data transformations.
  • pynance – PyNance is open-source software for retrieving, analyzing and visualizing data from stock and derivatives markets. It includes tools for generating features and labels for machine learning algorithms.
  • tia – TIA is a toolkit that provides Bloomberg data access, easier pdf generation, backtesting functionality, technical analysis functionality, return analysis and few windows utils.

Trading & Backtesting

  • TA-Lib – TA-Lib is widely used by trading software developers requiring to perform technical analysis of financial market data. It has an open-source API for python.
  • trade – trade is a Python framework for the development of financial applications. A trade app works like a service. The user informs the items he has in stock and a series of subsequent occurrences (purchases, sales, whatsoever) with those or other items. trade then calculates the effects of those occurrences and gives back the new amounts and costs of the items in stock.
  • zipline – Zipline is a Pythonic algorithmic trading library. It is an event-driven system that supports both backtesting and live trading.
  • QuantSoftware Toolkit – Python-based open source software framework designed to support portfolio construction and management. It is built the QSToolKit primarily for finance students, computing students, and quantitative analysts with programming experience.
  • quantitative – Quantitative finance, and backtesting library. Quantitative is an event driven and versatile backtesting library.
  • analyzer – Python framework for real-time financial and backtesting trading strategies
  • bt – bt is a flexible backtesting framework for Python used to test quantitative trading strategies.
  • backtrader – Python Backtesting library for trading strategies
  • pybacktest – Vectorized backtesting framework in Python / pandas, designed to make your backtesting easier. It allows users to specify trading strategies using full power of pandas, at the same time hiding all boring things like manually calculating trades, equity, performance statistics and creating visualizations. Resulting strategy code is usable both in research and production setting.
  • pyalgotrade – PyAlgoTrade is an event driven algorithmic trading Python library. Although the initial focus was on backtesting, paper trading is now possible
  • tradingWithPython – A collection of functions and classes for Quantitative trading
  • pandas_talib – A Python Pandas implementation of technical analysis indicators
  • algobroker – This is an execution engine for algo trading. The idea is that this python server gets requests from clients and then forwards them to the broker API.
  • finmarketpy – finmarketpy is a Python based library that enables you to analyze market data and also to backtest trading strategies using a simple to use API, which has prebuilt templates for you to define backtest.

Risk Analysis

  • pyfolio – pyfolio is a Python library for performance and risk analysis of financial portfolios. It works well with the Zipline open source backtesting library.
  • empyrical – Common financial risk and performance metrics. Used by zipline and pyfolio.
  • finance – Financial Risk Calculations. Optimized for ease of use through class construction and operator overload.
  • qfrm – Quantitative Financial Risk Management: awesome OOP tools for measuring, managing and visualizing risk of financial instruments and portfolios.
  • visualize-wealth – A library built in Python to construct, backtest, analyze, and evaluate portfolios and their benchmarks.
  • VisualPortfolio – This tool is used to visualize the performance of a portfolio

Time Series

  • ARCH – ARCH and other tools for financial econometrics in Python
  • statsmodels – Python module that allows users to explore data, estimate statistical models, and perform statistical tests.
  • dynts – A statistic package for python with emphasis on time series analysis. Built around numpy, it provides several back-end time series classes including R-based objects via rpy2.