Implementation of visualisation and reporting analytics for Quantitative Investment Strategies
Project description
QIS: Quantitative Investment Strategies
The package implements analytics for visualisation of financial data, performance reporting, analysis of quantitative strategies.
Table of contents
Installation
pip install qis
pip install qis --upgrade
Core dependencies: Python >= 3.8+, pandas >=1.0.0, numpy >= 1.15.0, numba >= 1.2.0, matplotlib >= 3.0.0, seaborn >= 0.9.0, yfinance >= 0.1.38 (optional for getting test price data)
Analytics
The QIS package is split into 5 main modules with the dependecy path increasing sequentially as follows.
-
qis.utils
is module containing low level utilities for operations with pandas, numpy, and datetimes. -
qis.perfstats
is module for computing performance statistics and performance attribution including returns, volatilities, etc. -
qis.plots
is module for plotting and visualization apis. -
qis.models
is module containing statistical models including filtering and regressions. -
qis.portfolio
is high level module for analysis, simulation, backtesting, and reporting of quant strategies.
qis.examples
contains scripts with illustrations of QIS analytics.
Disclaimer
QIS package is distributed FREE & WITHOUT ANY WARRANTY under the GNU GENERAL PUBLIC LICENSE.
See the LICENSE.txt in the release for details.
Please report any bugs or suggestions by opening an issue.
Contributions
If you are interested in extending and improving QIS analytics, please consider contributing to the library.
I have found it is a good practice to isolate general purpose and low level analytics and visualizations, which can be outsourced and shared, while keeping the focus on developing high level commercial applications.
There are a number of requirements:
-
The code is Pep 8 compliant
-
Reliance on common Python data types including numpy arrays, pandas, and dataclasses.
-
Transparent naming of functions and data types with enough comments. Type annotations of functions and arguments is a must.
-
Each submodule has a unit test for core functions and a localised entry point to core functions.
-
Avoid "super" pythonic constructions. Readability is the priority.
Examples
Visualization of price data
The script is located in qis.examples.performances
import matplotlib.pyplot as plt
import seaborn as sns
import yfinance as yf
import qis
from qis import PerfStat
# define tickers and fetch price data
tickers = ['SPY', 'QQQ', 'EEM', 'TLT', 'IEF', 'LQD', 'HYG', 'GLD']
prices = yf.download(tickers, start=None, end=None)['Adj Close'][tickers].dropna()
# plotting price data with minimum usage
fig = qis.plot_prices(prices=prices)
# 2-axis plot with drawdowns using sns styles
with sns.axes_style("darkgrid"):
fig, axs = plt.subplots(2, 1, figsize=(10, 7))
qis.plot_prices_with_dd(prices=prices, axs=axs)
# plot risk-adjusted performance table with excess Sharpe ratio
ust_3m_rate = yf.download('^IRX', start=None, end=None)['Adj Close'].dropna() / 100.0
# set parameters for computing performance stats including returns vols and regressions
perf_params = qis.PerfParams(freq='M', freq_reg='Q', rates_data=ust_3m_rate)
fig = qis.plot_ra_perf_table(prices=prices,
perf_columns=[PerfStat.TOTAL_RETURN, PerfStat.PA_RETURN, PerfStat.VOL, PerfStat.SHARPE,
PerfStat.SHARPE_EXCESS, PerfStat.MAX_DD, PerfStat.MAX_DD_VOL,
PerfStat.SKEWNESS, PerfStat.KURTOSIS],
title=f"Risk-adjusted performance: {qis.get_time_period_label(prices, date_separator='-')}",
perf_params=perf_params)
ToDos and Contributions
-
Enhanced documentation and readme examples.
-
Docstrings for key functions.
-
Reporting analytics and factsheets generation enhancing to matplotlib.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.