An Exception was encountered at 'In [6]'.
This notebook contains the daily returns of the S&P500 sectors, VIX, 10-year Treasury Yield, 30-year Treasury Yield, and Crude Oil.
import yfinance as yf
import pandas as pd
import numpy as np
from wallstreet import get_moving_avg, get_dow_list, get_ytd_return, get_ytd_growth_percentage, get_spdr_sectors, get_daily_returns
from datetime import datetime
datetime.now()
datetime.datetime(2026, 3, 9, 17, 23, 5, 652559)
pd.options.display.float_format = '{:.2f}%'.format
my_list = get_spdr_sectors()
my_list.append('CL=F')
my_list.append('^TNX')
my_list.append('^TYX')
my_list.append('^VIX')
my_list.append('VOOG')
my_list.append('VOOV')
pd.options.display.float_format = '{:.2f}'.format
t = get_daily_returns(my_list)
- XLB: No data found for this date range, symbol may be delisted
Execution using papermill encountered an exception here and stopped:
t = t.sort_values(by='percent change',ascending=False)
t.set_index('ticker')
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) Cell In[6], line 1 ----> 1 t = t.sort_values(by='percent change',ascending=False) 2 t.set_index('ticker') File ~/.local/share/virtualenvs/reports-_ZceJivp/lib/python3.8/site-packages/pandas/util/_decorators.py:331, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs) 325 if len(args) > num_allow_args: 326 warnings.warn( 327 msg.format(arguments=_format_argument_list(allow_args)), 328 FutureWarning, 329 stacklevel=find_stack_level(), 330 ) --> 331 return func(*args, **kwargs) File ~/.local/share/virtualenvs/reports-_ZceJivp/lib/python3.8/site-packages/pandas/core/frame.py:6909, in DataFrame.sort_values(self, by, axis, ascending, inplace, kind, na_position, ignore_index, key) 6905 elif len(by): 6906 # len(by) == 1 6908 by = by[0] -> 6909 k = self._get_label_or_level_values(by, axis=axis) 6911 # need to rewrap column in Series to apply key function 6912 if key is not None: 6913 # error: Incompatible types in assignment (expression has type 6914 # "Series", variable has type "ndarray") File ~/.local/share/virtualenvs/reports-_ZceJivp/lib/python3.8/site-packages/pandas/core/generic.py:1850, in NDFrame._get_label_or_level_values(self, key, axis) 1844 values = ( 1845 self.axes[axis] 1846 .get_level_values(key) # type: ignore[assignment] 1847 ._values 1848 ) 1849 else: -> 1850 raise KeyError(key) 1852 # Check for duplicates 1853 if values.ndim > 1: KeyError: 'percent change'
spy_sectors = t[t['ticker'].str.startswith('X')]
spy_sectors.set_index('ticker')
Disclaimer: I am not a professional investment adviser and my opinions are based on my own technical analysis. Please consult an investment professional before making investment decisions.