{"id":17082285,"url":"https://github.com/ArturSepp/QuantInvestStrats","last_synced_at":"2025-02-22T05:30:49.189Z","repository":{"id":65445246,"uuid":"583712573","full_name":"ArturSepp/QuantInvestStrats","owner":"ArturSepp","description":"Quantitative Investment Strategies (QIS) package implements Python analytics for visualisation of financial data, performance reporting, analysis of quantitative strategies.","archived":false,"fork":false,"pushed_at":"2024-08-15T07:59:32.000Z","size":110047,"stargazers_count":122,"open_issues_count":0,"forks_count":21,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-16T09:18:56.283Z","etag":null,"topics":["asset-management","data-analysis","data-visualization","investment-analysis","performance-attribution","portfolio-optimization","portfolio-risk-management","python","quantitative-finance"],"latest_commit_sha":null,"homepage":"https://github.com/ArturSepp/QuantInvestStrats","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ArturSepp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-30T16:57:52.000Z","updated_at":"2024-08-18T07:40:39.196Z","dependencies_parsed_at":"2024-04-25T20:44:28.516Z","dependency_job_id":"1827a273-90c3-4ba9-ba00-7751515d4643","html_url":"https://github.com/ArturSepp/QuantInvestStrats","commit_stats":{"total_commits":26,"total_committers":3,"mean_commits":8.666666666666666,"dds":0.5769230769230769,"last_synced_commit":"b1e463b18a36ab9e8dfef223b5ddb868e33e74e4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturSepp%2FQuantInvestStrats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturSepp%2FQuantInvestStrats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturSepp%2FQuantInvestStrats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturSepp%2FQuantInvestStrats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArturSepp","download_url":"https://codeload.github.com/ArturSepp/QuantInvestStrats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240131743,"owners_count":19752725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asset-management","data-analysis","data-visualization","investment-analysis","performance-attribution","portfolio-optimization","portfolio-risk-management","python","quantitative-finance"],"created_at":"2024-10-14T13:00:24.380Z","updated_at":"2025-02-22T05:30:49.174Z","avatar_url":"https://github.com/ArturSepp.png","language":"Python","readme":"\n## **Quantitative Investment Strategies: QIS** \u003ca name=\"analytics\"\u003e\u003c/a\u003e\n\nqis package implements analytics for visualisation of financial data, performance\nreporting, analysis of quantitative strategies. \n\nqis package is split into 5 main modules with the \ndependency path increasing sequentially as follows.\n\n1. ```qis.utils``` is module containing low level utilities for operations with pandas, numpy, and datetimes.\n\n2. ```qis.perfstats``` is module for computing performance statistics and performance attribution including returns, volatilities, etc.\n\n3. ```qis.plots``` is module for plotting and visualization apis.\n\n4. ```qis.models``` is module containing statistical models including filtering and regressions.\n\n5. ```qis.portfolio``` is high level module for analysis, simulation, backtesting, and reporting of quant strategies.\nFunction ```backtest_model_portfolio()```  in ```qis.portfolio.backtester.py``` takes instrument prices \nand simulated weights from a generic strategy and compute the total return, performance attribution, and risk analysis\n\n```qis.examples``` contains scripts with illustrations of QIS analytics.\n\n```qis.examples.factheets``` contains scripts with examples of factsheets for simulated and actual strategies,\nand cross-sectional analysis of backtests.\n\n\n# Table of contents\n1. [Analytics](#analytics)\n2. [Installation](#installation)\n3. [Examples](#examples)\n   1. [Visualization of price data](#price)\n   2. [Multi assets factsheet](#multiassets)\n   3. [Strategy factsheet](#strategy)\n   4. [Strategy benchmark factsheet](#strategybenchmark)\n   5. [Multi strategy factsheet](#multistrategy)\n   6. [Notebooks](#notebooks)\n4. [Contributions](#contributions)\n5. [Updates](#updates)\n6. [ToDos](#todos)\n7. [Disclaimer](#disclaimer)\n\n\n## **Installation** \u003ca name=\"installation\"\u003e\u003c/a\u003e\nInstall using\n```python \npip install qis\n```\nUpgrade using\n```python \npip install --upgrade qis\n```\n\nClose using\n```python \ngit clone https://github.com/ArturSepp/QuantInvestStrats.git\n```\n\nCore dependencies:\n    python = \"\u003e=3.8\",\n    numba = \"\u003e=0.56.4\",\n    numpy = \"\u003e=1.22.4\",\n    scipy = \"\u003e=1.10\",\n    statsmodels = \"\u003e=0.13.5\",\n    pandas = \"\u003e=2.2.0\",\n    matplotlib = \"\u003e=3.2.2\",\n    seaborn = \"\u003e=0.12.2\"\n\nOptional dependencies:\n    yfinance \"\u003e=0.1.38\" (for getting test price data),\n    pybloqs \"\u003e=1.2.13\" (for producing html and pdf factsheets)\n\n\n## **Examples** \u003ca name=\"examples\"\u003e\u003c/a\u003e\n\n### 1. Visualization of price data \u003ca name=\"price\"\u003e\u003c/a\u003e\n\nThe script is located in ```qis.examples.performances``` (https://github.com/ArturSepp/QuantInvestStrats/blob/master/qis/examples/performances.py)\n\n```python \nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport yfinance as yf\nimport qis\n\n# define tickers and fetch price data\ntickers = ['SPY', 'QQQ', 'EEM', 'TLT', 'IEF', 'SHY', 'LQD', 'HYG', 'GLD']\nprices = yf.download(tickers, start=None, end=None)['Close'][tickers].dropna()\n\n# plotting price data with minimum usage\nwith sns.axes_style(\"darkgrid\"):\n    fig, ax = plt.subplots(1, 1, figsize=(10, 7))\n    qis.plot_prices(prices=prices, x_date_freq='YE', ax=ax)\n```\n![image info](qis/examples/figures/perf1.PNG)\n```python \n# 2-axis plot with drawdowns using sns styles\nwith sns.axes_style(\"darkgrid\"):\n    fig, axs = plt.subplots(2, 1, figsize=(10, 7), tight_layout=True)\n    qis.plot_prices_with_dd(prices=prices, x_date_freq='YE', axs=axs)\n```\n![image info](qis/examples/figures/perf2.PNG)\n\n```python \n# plot risk-adjusted performance table with excess Sharpe ratio\nust_3m_rate = yf.download('^IRX', start=None, end=None)['Close'].dropna() / 100.0\n# set parameters for computing performance stats including returns vols and regressions\nperf_params = qis.PerfParams(freq='ME', freq_reg='QE', alpha_an_factor=4.0, rates_data=ust_3m_rate)\n# perf_columns is list to display different perfomance metrics from enumeration PerfStat\nfig = qis.plot_ra_perf_table(prices=prices,\n                             perf_columns=[PerfStat.TOTAL_RETURN, PerfStat.PA_RETURN, PerfStat.PA_EXCESS_RETURN,\n                                           PerfStat.VOL, PerfStat.SHARPE_RF0,\n                                           PerfStat.SHARPE_EXCESS, PerfStat.SORTINO_RATIO, PerfStat.CALMAR_RATIO,\n                                           PerfStat.MAX_DD, PerfStat.MAX_DD_VOL,\n                                           PerfStat.SKEWNESS, PerfStat.KURTOSIS],\n                             title=f\"Risk-adjusted performance: {qis.get_time_period_label(prices, date_separator='-')}\",\n                             perf_params=perf_params)\n```\n![image info](qis/examples/figures/perf3.PNG)\n\n\n\n```python \n# add benchmark regression using excess returns for linear beta\n# regression frequency is specified using perf_params.freq_reg\n# regression alpha is multiplied using perf_params.alpha_an_factor\nfig, _ = qis.plot_ra_perf_table_benchmark(prices=prices,\n                                          benchmark='SPY',\n                                          perf_columns=[PerfStat.TOTAL_RETURN, PerfStat.PA_RETURN, PerfStat.PA_EXCESS_RETURN,\n                                                        PerfStat.VOL, PerfStat.SHARPE_RF0,\n                                                        PerfStat.SHARPE_EXCESS, PerfStat.SORTINO_RATIO, PerfStat.CALMAR_RATIO,\n                                                        PerfStat.MAX_DD, PerfStat.MAX_DD_VOL,\n                                                        PerfStat.SKEWNESS, PerfStat.KURTOSIS,\n                                                        PerfStat.ALPHA_AN, PerfStat.BETA, PerfStat.R2],\n                                          title=f\"Risk-adjusted performance: {qis.get_time_period_label(prices, date_separator='-')} benchmarked with SPY\",\n                                          perf_params=perf_params)\n```\n![image info](qis/examples/figures/perf4.PNG)\n\n\n\n### 2. Multi assets factsheet \u003ca name=\"multiassets\"\u003e\u003c/a\u003e\nThis report is adopted for reporting the risk-adjusted performance \nof several assets with the goal\nof cross-sectional comparision\n\nRun example in ```qis.examples.factsheets.multi_assets.py``` https://github.com/ArturSepp/QuantInvestStrats/blob/master/qis/examples/factsheets/multi_assets.py\n\n![image info](qis/examples/figures/multiassets.PNG)\n\n\n### 3. Strategy factsheet \u003ca name=\"strategy\"\u003e\u003c/a\u003e\nThis report is adopted for report performance, risk, and trading statistics\nfor either backtested or actual strategy\n    with strategy data passed as PortfolioData object\n\nRun example in ```qis.examples.factsheets.strategy.py``` https://github.com/ArturSepp/QuantInvestStrats/blob/master/qis/examples/factsheets/strategy.py\n\n![image info](qis/examples/figures/strategy1.PNG)\n![image info](qis/examples/figures/strategy2.PNG)\n![image info](qis/examples/figures/strategy3.PNG)\n\n### 4. Strategy benchmark factsheet \u003ca name=\"strategybenchmark\"\u003e\u003c/a\u003e\nThis report is adopted for report performance and marginal comparison\n  of strategy vs a benchmark strategy \n(data for both are passed using individual PortfolioData object)\n\nRun example in ```qis.examples.factsheets.strategy_benchmark.py``` https://github.com/ArturSepp/QuantInvestStrats/blob/master/qis/examples/factsheets/strategy_benchmark.py\n\n![image info](qis/examples/figures/strategy_benchmark.PNG)\n\nBrinson-Fachler performance attribution (https://en.wikipedia.org/wiki/Performance_attribution)\n![image info](qis/examples/figures/brinson_attribution.PNG)\n\n\n### 5. Multi strategy factsheet \u003ca name=\"multistrategy\"\u003e\u003c/a\u003e\nThis report is adopted to examine the sensitivity of \nbacktested strategy to a parameter or set of parameters:\n\nRun example in ```qis.examples.factsheets.multi_strategy.py``` https://github.com/ArturSepp/QuantInvestStrats/blob/master/qis/examples/factsheets/multi_strategy.py\n\n![image info](qis/examples/figures/multi_strategy.PNG)\n\n\n### 6. Notebooks \u003ca name=\"notebooks\"\u003e\u003c/a\u003e\n\nRecommended package to work with notebooks:  \n```python \npip install notebook\n```\nStarting local server\n```python \njupyter notebook\n```\n\nExamples of using qis analytics jupyter notebooks are located here\nhttps://github.com/ArturSepp/QuantInvestStrats/blob/master/qis/examples/notebooks\n\n\n## **Contributions** \u003ca name=\"contributions\"\u003e\u003c/a\u003e\nIf you are interested in extending and improving QIS analytics, \nplease consider contributing to the library.\n\nI 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 \nthe focus on developing high level commercial applications.\n\nThere are a number of requirements:\n\n- The code is [Pep 8 compliant](https://peps.python.org/pep-0008/)\n\n- Reliance on common Python data types including numpy arrays, pandas, and dataclasses.\n\n- Transparent naming of functions and data types with enough comments. Type annotations of functions and arguments is a must.\n\n- Each submodule has a unit test for core functions and a localised entry point to core functions.\n\n- Avoid \"super\" pythonic constructions. Readability is the priority.\n\n\n\n## **Updates** \u003ca name=\"updates\"\u003e\u003c/a\u003e\n\n#### 30 December 2022,  Version 1.0.1 released\n\n#### 08 July 2023, Version 2.0.1 released\n\nCore Changes\n\n1. Portfolio optimization (qis.portfolio.optimisation) layer is removed with core\nfunctionality moved to a stand-alone Python package: Backtesting Optimal Portfolio (bop)\n    \n* This allows to remove the dependency from cvxpy and sklearn packages and \nthus to simplify the dependency management for qis\n\n2.\tAdded factsheet reporting using pybloqs package https://github.com/man-group/PyBloqs\n* Pybloqs is a versatile tool to create customised reporting using Matplotlib figures and table\nand thus leveraging QIS visualisation analytics\n\n3. New factsheets are added\n* Examples are added for the four type of reports:\n    1. multi assets: report performance of several assets with goal of cross-sectional comparision:\n    see qis.examples.factsheets.multi_asset.py\n  2. strategy: report performance, risk, and trading statictics for either backtested or actual strategy\n    with strategy data passed as PortfolioData object: see qis.examples.factsheets.strategy.py\n  3. strategy vs benchmark: report performance and marginal comparison\n  of strategy vs a benchmark strategy (data for both are passed using individual PortfolioData object): \n  see qis.examples.factsheets.strategy_benchmark.py\n  4. multi_strategy: report for a list of strategies with individual PortfolioData. This report is \n  useful to examine the sensetivity of backtested strategy to a parameter or set of parameters: \n  see qis.examples.factsheets.multi_strategy\n\n\n## **ToDos** \u003ca name=\"todos\"\u003e\u003c/a\u003e\n\n1. Enhanced documentation and readme examples.\n\n2. Docstrings for key functions.\n\n3. Reporting analytics and factsheets generation enhancing to matplotlib.\n\n\n\n## **Disclaimer** \u003ca name=\"disclaimer\"\u003e\u003c/a\u003e\n\nQIS package is distributed FREE \u0026 WITHOUT ANY WARRANTY under the GNU GENERAL PUBLIC LICENSE.\n\nSee the [LICENSE.txt](https://github.com/ArturSepp/QuantInvestStrats/blob/master/LICENSE.txt) in the release for details.\n\nPlease report any bugs or suggestions by opening an [issue](https://github.com/ArturSepp/QuantInvestStrats/issues).\n\n","funding_links":[],"categories":["Recently Updated","Python"],"sub_categories":["[Oct 14, 2024](/content/2024/10/14/README.md)","Visualization","数据可视化"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FArturSepp%2FQuantInvestStrats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FArturSepp%2FQuantInvestStrats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FArturSepp%2FQuantInvestStrats/lists"}