<jupyter_start><jupyter_text>Leveraged ETFsConsider the cumulative return of an asset:$$r_{0,T}^i \equiv (1+r^i_1)(1+r^i_2)(1+r_3^i)\cdot\cdot\cdot(1+r^i_T) - 1$$If we want to leverage this with traditionally leverage, we would borrow to invest $w^i>1$. Then our total cumulative return (before considering the borrowing cost) would be$$r_{0,T}^{i,\text{Levered}} \equiv w\cdot (1+r^i_1)(1+r^i_2)(1+r_3^i)\cdot\cdot\cdot(1+r^i_T) - w$$If we use a Levered ETF with leverage factor of $w$, then it leverages each individual return,$$r_{0,T}^{i,\text{LETF}} \equiv (1+wr^i_1)(1+wr^i_2)(1+wr_3^i)\cdot\cdot\cdot(1+wr^i_T) - 1$$ These expressions are not equal!Consider $w=3, T=2$$$r_{0,2}^{i,\text{Levered}} = 3(1+r^i_1+r^i_2+r^i_1r^i_2) - 3 = 3r^i_1 + 3r^i_2 + 3r^i_1r^i_2$$$$r_{0,2}^{i,\text{LETF}} = 1+3r^i_1+3r^i_2+9r^i_1r^i_2) - 1 = 3r^i_1 + 3r^i_2 + 9r^i_1r^i_2$$So they differ by $$-6r^i_1r^i_2$$ which could be positive or negative. Note:We have to subtract out the leveraged capital $w$ to get back the total return rate. The cumulative return formula would give a number like 1.10, which is the return factor. It says if we invest 1 we get back 1.10. We want the return rate, so we subtract the invested capital to get a number like 0.10 which says that if we invest 1 we make an extra return of 0.10.For a leveraged position, we must subtract out the total (levered) capital. Example:<jupyter_code>leverage = 3
r1 = .1
r2 = -.05
cumret = (1+r1)*(1+r2) - 1
leveraged_cumret = leverage * cumret
letf_cumret = (1+leverage*r1)*(1+leverage*r2) - 1
diff = -(leverage*(leverage-1)) * r1*r2

print(f'Unlevered cumulative return is {cumret:0.4f}\nLevered cumulative return is {leveraged_cumret:0.4f}\nLETF cumulative return is {letf_cumret:0.4f}\nDifference is {diff:0.4f}')<jupyter_output>Unlevered cumulative return is 0.0450
Levered cumulative return is 0.1350
LETF cumulative return is 0.1050
Difference is 0.0300<jupyter_text>Analysis of ProShares Levered SPX ETFs<jupyter_code>import numpy as np
import pandas as pd
pd.options.display.float_format = "{:,.4f}".format

import matplotlib.pyplot as plt
import seaborn as sns

import statsmodels.api as sm
from sklearn.linear_model import LinearRegression
import sys
sys.path.insert(0, '../cmds')
from portfolio import *
filepath_data = '../data/proshares_analysis_data.xlsx'
info = pd.read_excel(filepath_data,sheet_name='descriptions')
info.rename(columns={'Unnamed: 0':'Symbol'},inplace=True)
info.set_index('Symbol',inplace=True)

data = pd.read_excel(filepath_data,sheet_name='other_data')
data.set_index('date',inplace=True)

ml = pd.read_excel(filepath_data,sheet_name='merrill_factors')
ml.set_index('date',inplace=True)

spy = ml[['SPY US Equity']]
spy['SPY 3x'] = 3 * spy['SPY US Equity'].copy()
spy['SPY -3x'] = -3 * spy['SPY US Equity'].copy()
info.loc[list(data.columns)]
rets = spy.join(data[['SPXU US Equity','UPRO US Equity']],how='inner')
cumrets = (1+rets).cumprod()

cumrets_decay = pd.DataFrame((cumrets['UPRO US Equity'] / cumrets['SPY 3x']), columns=['+3x'])
cumrets_decay['-3x'] = (cumrets['SPXU US Equity'] / cumrets['SPY -3x'])

cumrets[['SPY 3x','UPRO US Equity']].plot(title='Positive Levered S&P')
cumrets[['SPY -3x','SPXU US Equity']].plot(title='Inverse Levered S&P')
cumrets_decay.plot(title='Value of LETF divided by Levered SPY')
performanceMetrics(rets,annualization=12)
maximumDrawdown(rets)
get_ols_metrics(rets['SPY US Equity'],rets,annualization=12)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1560426882030574, 'fraction_numerical': 0.04182290164407269, 'mean_word_length': 6.301052631578948, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '373200', 'license': 'MIT', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1357, 'n_words': 332, 'path': 'discussions/Case Topic - Leveraged ETFs.ipynb', 'repo_name': 'ychendm/finm-portfolio-2021', 'size': '3467'}