Skip to content

Commit

Permalink
removed delisted names from sp500ndx100 and timing example
Browse files Browse the repository at this point in the history
  • Loading branch information
enzbus committed Nov 22, 2023
1 parent a53d8fd commit d598987
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
16 changes: 11 additions & 5 deletions cvxportfolio/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,22 @@ def _get_data_yahoo(ticker, start='1900-01-01', end='2100-01-01'):
+ 'Json output:', str(res.json()))

if res.status_code != 200:
raise DataError('Yahoo finance data download failed. Json:',
raise DataError(f'Yahoo finance download of {ticker} failed. Json:',
str(res.json())) # pragma: no cover

data = res.json()['chart']['result'][0]

index = pd.DatetimeIndex(
[_timestamp_convert(el) for el in data['timestamp']])
try:
index = pd.DatetimeIndex(
[_timestamp_convert(el) for el in data['timestamp']])

df_result = pd.DataFrame(data['indicators']['quote'][0], index=index)
df_result['adjclose'] = data['indicators']['adjclose'][0]['adjclose']
df_result = pd.DataFrame(
data['indicators']['quote'][0], index=index)
df_result['adjclose'] = data[
'indicators']['adjclose'][0]['adjclose']
except KeyError:
raise DataError(f'Yahoo finance download of {ticker} failed.'
+ ' Json:', str(res.json())) # pragma: no cover

# last timestamp is probably broken (not timed to market open)
# we set its time to same as the day before, but this is wrong
Expand Down
6 changes: 3 additions & 3 deletions examples/sp500_ndx100.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
## with multi period optimization. It shows that all parts of the system scale
## to such usecases.

SP500 = ['MMM', 'AOS', 'ABT', 'ABBV', 'ACN', 'ATVI', 'ADM', 'ADBE', 'ADP',
SP500 = ['MMM', 'AOS', 'ABT', 'ABBV', 'ACN', 'ADM', 'ADBE', 'ADP',
'AAP', 'AES', 'AFL', 'A', 'APD', 'AKAM', 'ALK', 'ALB', 'ARE',
'ALGN', 'ALLE', 'LNT', 'ALL', 'GOOGL', 'GOOG', 'MO', 'AMZN',
'AMCR', 'AMD', 'AEE', 'AAL', 'AEP', 'AXP', 'AIG', 'AMT', 'AWK',
'AMP', 'ABC', 'AME', 'AMGN', 'APH', 'ADI', 'ANSS', 'AON', 'APA',
'AMP', 'AME', 'AMGN', 'APH', 'ADI', 'ANSS', 'AON', 'APA',
'AAPL', 'AMAT', 'APTV', 'ACGL', 'ANET', 'AJG', 'AIZ', 'T', 'ATO',
'ADSK', 'AZO', 'AVB', 'AVY', 'AXON', 'BKR', 'BALL', 'BAC', 'BBWI',
'BAX', 'BDX', 'WRB', 'BRK-B',
Expand Down Expand Up @@ -75,7 +75,7 @@
'IBM', 'MRK', 'MMM', 'VZ', 'WBA', 'INTC', 'PEP', 'AVGO',
'COST', 'TMUS', 'CMCSA', 'TXN', 'NFLX', 'SBUX', 'GILD', 'ISRG', 'MDLZ', 'BKNG', 'AMAT',
'ADI', 'ADP', 'VRTX', 'REGN', 'PYPL', 'LRCX', 'PYPL',
'MU', 'CSX', 'MELI', 'MNST', 'ATVI', 'PANW', 'ORLY', 'ASML', 'SNPS',
'MU', 'CSX', 'MELI', 'MNST', 'PANW', 'ORLY', 'ASML', 'SNPS',
'CDNS', 'MAR', 'KLAC', 'FTNT', 'CHTR', 'CHTR', 'MRNA',
'KHC', 'CTAS', 'AEP', 'DXCM', 'LULU', 'KDP',
'AZN', 'BIIB', 'ABNB', 'NXPI', 'ADSK', 'EXC', 'MCHP', 'IDXX', 'CPRT', 'PAYX',
Expand Down
6 changes: 3 additions & 3 deletions examples/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import time
import pandas as pd

SP500 = ['MMM', 'AOS', 'ABT', 'ABBV', 'ACN', 'ATVI', 'ADM', 'ADBE', 'ADP',
SP500 = ['MMM', 'AOS', 'ABT', 'ABBV', 'ACN', 'ADM', 'ADBE', 'ADP',
'AAP', 'AES', 'AFL', 'A', 'APD', 'AKAM', 'ALK', 'ALB', 'ARE',
'ALGN', 'ALLE', 'LNT', 'ALL', 'GOOGL', 'GOOG', 'MO', 'AMZN',
'AMCR', 'AMD', 'AEE', 'AAL', 'AEP', 'AXP', 'AIG', 'AMT', 'AWK',
'AMP', 'ABC', 'AME', 'AMGN', 'APH', 'ADI', 'ANSS', 'AON', 'APA',
'AMP', 'AME', 'AMGN', 'APH', 'ADI', 'ANSS', 'AON', 'APA',
'AAPL', 'AMAT', 'APTV', 'ACGL', 'ANET', 'AJG', 'AIZ', 'T', 'ATO',
'ADSK', 'AZO', 'AVB', 'AVY', 'AXON', 'BKR', 'BALL', 'BAC', 'BBWI',
'BAX', 'BDX', 'WRB', 'BRK-B',
Expand All @@ -25,7 +25,7 @@
'DISH', 'DIS', 'DG', 'DLTR', 'D', 'DPZ', 'DOV', 'DOW', 'DTE',
'DUK', 'DD', 'DXC', 'EMN', 'ETN', 'EBAY', 'ECL', 'EIX', 'EW', 'EA',
'ELV', 'LLY', 'EMR', 'ENPH', 'ETR', 'EOG', 'EPAM', 'EQT', 'EFX',
'EQIX', 'EQR', 'ESS', 'EL', 'ETSY', 'EVRG', 'ES', 'EXC',
'EQIX', 'EQR', 'ESS', 'EL', 'ETSY', 'EVRG', 'ES', 'EXC',
'EXPE', 'EXPD', 'EXR', 'XOM', 'FFIV', 'FDS', 'FICO', 'FAST', 'FRT',
'FDX', 'FITB', 'FSLR', 'FE', 'FIS', 'FLT', 'FMC', 'F',
'FTNT', 'FTV', 'FOXA', 'FOX', 'BEN', 'FCX', 'GRMN', 'IT', 'GEHC',
Expand Down

0 comments on commit d598987

Please sign in to comment.