According to PricewaterhouseCoopers, over $150 billion will be invested in FinTech companies over the next 3 to 5 years. FinTech has its reach in domains like insurance, lending, regulations, trading, e-banking and other payment services, and thus has a wide scope.
The rise in popularity of Python as a programming language can be verified with the increase in the number of FinTech startups employing Python and its frameworks. Investment banking and hedge fund industries are also using Python to solve quantitative problems for pricing, trade management, and risk management platforms.
“Everyone at JP Morgan now needs to know Python and there are around 5,000 developers using it at Bank of America. There are close to 10 million lines of Python code in Quartz and we got close to 3,000 commits a day,” Kirat Singh, former MD of Bank of America told a newsportal.
Citi group is also encouraging their analysts to pick up Python coding skills and the list continues. Python is even more popular with startups because of its simplicity and the ease with which the product can be taken to the market.
Choosing a language or a framework is important for a young company as factors like talent access, ease of validation and how quickly the product can be built has a greater impact on its life cycle.
Here are some of the top open-source Python libraries assisting the FinTech industry:
PyAlgoTrade
PyAlgoTrade is an event-driven algorithmic trading Python library which supports back-testing, live-feed paper trading and real-time trading on Bitstamp. PyAlgoTrade is developed and tested using Python 2.7/3.7 and dependencies include NumPy and SciPy, pytz, matplotlib for plotting support, tornado for Bitstamp support and tweepy for Twitter support.
How To Install: pip install pyalgotrade
Here we see how data series abstractions can be made using PyAlgoTrade:
class pyalgotrade.dataseries.SequenceDataSeries(maxLen=None)
Pyfolio
How To Install:pip install pyfolio import pyfolio as pf
It primarily deals with the risk analytics and performance related financial portfolios. This was developed and is maintained by Quantopian and was open-sourced in 2015. It works well with the Zipline open source backtesting library. Pyfolio library can be used to model tear sheets based on returns, Bayesian analysis and other transactions. Other features include plotting tear sheets with pyfolio.plotting and pyfolio.timeseries for calling individual statistical functions.
# THIS FETCHES APPLE STOCKS #
stock_rets = pf.utils.get_symbol_rets('AAPL')
Zipline
Zipline is an open-source algorithmic trading simulator written in Python. It is used to simulate realistic slippage, transaction costs and order delays. Process each event individually and avoids look-ahead bias. Zipline too is maintained by Quantopian which updates zipline round-the-clock.
How To Install:pip install zipline
quantecon
The quantecon python library consists of modules like game theory, Markov chains, random generation utilities (random), a collection of tools (tools), and other utilities (util) which are mainly used by developers internal to the package.
How To Install:pip install quantecon
Here we can see how Markov approximation is carried out with Rouwenhorst test,
quantecon.markov.approximation.rouwenhorst()
finmarketpy
finmarketpy is a Python-based library which enables you to analyze markets and backtest trading strategies using a simple to use API, which has inbuilt templates.
With this library, one can visualise the trading strategies over a certain period and investigate the seasonality surrounding these strategies. It also allows the users to conduct surveys around specific events corresponding the data under consideration. An in-built calculator can be used to assess how volatile the targets are. It depends on pandas and NumPy libraries.
ffn
The library has plenty to offer to those who belong to the field of quantitative finance. It provides a vast array of utilities, from performance measurement and evaluation to graphing and common data transformations.
How To Install:pip install ffn data = ffn.get()
The get function downloads data from an external service and packs that data into a pandas DataFrame.
SciPy
How To Install:pip install numpy scipy matplotlib
SciPy is a collection of mathematical algorithms and convenience functions built on the NumPy extension of Python. A typical user can access high-level data visualization and parallel programming with the database sub-routines and classes that SciPy has to offer. SciPy contains additional routines needed in scientific work: for example, routines for computing integrals numerically, solving differential equations, optimization, and sparse matrices.
Here are few functions in SciPy that makes financing feasible:
npv(rate, values) | Returns the NPV (Net Present Value) of a cash flow series. |
pmt(rate, nper, pv[, fv, when]) | Compute the payment against loan principal plus interest. |
ppmt(rate, per, nper, pv[, fv, when]) | Compute the payment against loan principal. |
ipmt(rate, per, nper, pv[, fv, when]) | Compute the interest portion of a payment. |
irr(values) | Return the Internal Rate of Return (IRR). |
scikit-learn
How To Install:pip install -U scikit-learn
The functionalities of this library are vast and beyond the scope of this article. It is well known and widely used for tasks like data preprocessing, dimensionality reduction, classification and clustering amongst other important jobs.
For example, scikit-learn can be used to perform discriminate analysis like LDA and QDA where the predictors are drawn from a multivariate Gaussian distribution.
import sklearn from sklearn.lda import LDA from sklearn.qda import QDA
Importing the modules from scikit-learn library will take care of the analysis. All we need is to provide test and train data for it to work on.
To Sum Up
Other well-known libraries like NumPy and Pandas offer wide range of data processing and visualization options and most of the aforementioned libraries are built on them.
Many successful startups that have made it big in FinTech industry had used python and its libraries in one way or other. For example, UK’s peer-to-peer lending company, Zopa uses Flask, Django, RabbitMQ, Pandas and Celery. This young company which leverages technology to cut-out the middle players between lenders and customers became the first company to lend more than 3 billion euros.
Modelling for market inefficiencies, tracking the price patterns or forecasting the returns is cumbersome and tricky and, these tools simplify the representation, improve the data interpretability and help devise strategies which predict and project outcomes closer to reality.