Skip to content

S&P 500 risk-reward optimized portfolios with data Post-covid ML model.

License

Notifications You must be signed in to change notification settings

StefanMqz/Optimized_Indexes_Forecasts

Repository files navigation

Optimized Indexes Forecasts

Creative Commons BY 3.0

Contact:
Jr. Data Scientist & QA Automation
(DA & BA | ML Eng. | DevOps)

Download Resume
Resume Resume

Business Inquiries 24/7
Business

Contact:

Repositories   Gists   gh-pages  

Repository Tools:
Actions: Repo-Visualization-Badge
Main Text-Editor: VSCode-Badge Jupyter-Badge
Language: Python-BadgeMarkdown-Badgeyaml-Badge
Libraries: Numpy-Badge Pandas-Badge Scipy-Badge Fitter-Badge Matplotlib-Badge Seaborn-Badge
Interface: React-Badge
Version Control: Git-Badge Git-Commands
Files Visualization:

Repository Jupyter

1.1 Table of Contents:

Sections and processes are illustrated:

1.2 Description:

Data has changed since Covid in most industries and the markets project the public's sentiment, financially speaking.
In this regard, from indexes OHLCVs, Volumes are standarized and compared dynamically in a web-app to show the big picture of indexes supported to the user, as well as to note important insights.

App-Markdown
Moreover, from $Adj_{Closes} \rightarrow P_t$ returns $r_t$ are obtained and manipulated as: $ln({P_{t+1}})-ln({P_{t}})$ because of their additive nature among other characteristics, which transforms the multiplicative nature of Compounded Returns (see 3.2): $$\prod_{t=1}^{n}(1+r_t) \implies \bigg[{\mathrm{e}^{\sum_{t=1}^{n} ln (1+r_t) }} \bigg]$$

From $ln(1+r_t)$ the following are calculated and interpreted (sections 3-7):

  • Estimators: $\mu_{j_d}, \mu_{j_{Yr}} \mu_{P_d}, \mu_{P_{Yr}}$.
  • Disperssion measures: $Q_n$, $IQR$, $\sigma_{j_d}, \sigma_{j_{Yr}} \sigma_{P_d}, \sigma_{P_{Yr}}$, Correlation $\rho_{i,j}$ and Covariance $\sigma_{i,j}$ matrices.
  • Optimizations: $R_{Sharpe}$, $R_{Sortino}$, $R_{Calmar}$, $R_{Burke}$, $R_{Kappa}$, $R_{\Omega}$, $R_{Traynor}$, $R_{Jensen}$.
  • Risk measures: $VaR_{\alpha}$, $ES_{\alpha}$, $MDD$.

Considering, the $SP500$ is generally used as benchmark because:

  1. It's the most commonly used index to determine the overall state of the economy.
  2. It has the most liquid derivatives markets (the same generally applies for $j$ components).
    Note: Market Risk exposure hedging won't be covered.
  3. Its components provide a broader scope to industries.

Out of the indexes supported, it will be modelled as an example (sections 4-7):
$\mathbb{R}^{500}$ = $x_j\in [x_1,x_{500}] \hookrightarrow SP500$.

Starting from its Optimizations $R^{n \times m}$:

$$R^{n \times m} = \sum_{t=1}^{n} \sum_{j=1}^{m} w_{j}\ ln(1+r_t)$$

  • $m$ = No° of components.
  • $j$ = Component
  • $n$ = No° of periods.
  • $t$ = Period.

And concluding with their Simulations and Forecasts.

2. Requirements:

Import files with .py extension in cwd callable as a list.

import glob
mod = [__import__(name[:-3]) for name in glob.glob('*.py')]

Generate requirements.txt file with latest versions of libraries used in project.

!pipreqs --encoding utf-8 "./" --force
mod[1].get_requirements(docstring)
with open(glob.glob('*.txt')[0], 'r') as file: print(file.read())

Install the packages in environment and import libraries (refer to 2.2).

%%capture
!pip install -r requirements.txt

3. Data Extraction and Exploration:

Data is extracted for indexes an saved in an html embed dataframe: OHCLV-web (see refs.).
Volumes are standarized and compared dynamically in an html embed plot: Plotly-web-app.

As an example of its usage, an image of its features is captured by selecting the NASDAQ and the SP500:

Nasdaq relative volume have sustained at much higher levels than the benchmark since Covid for example.

8. References

About

S&P 500 risk-reward optimized portfolios with data Post-covid ML model.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published