-
-
Save cordmaur/2ed352268a1a193bc62d7e661f0cb81a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import yfinance as yf | |
# Load the forecasts | |
forecasts = pd.read_csv('sp500_forecasts_new.csv', header=None).rename(columns={0: 'Date', 1: 'Signal'}) | |
forecasts.set_index('Date', inplace=True) | |
forecasts.index = pd.to_datetime(forecasts.index) | |
# load the SP500 df | |
df = yf.Ticker('^GSPC').history(period='max') | |
df = df[(df.index > '1952-01-03') & (df.index < '2020-12-30')] | |
# save the strategy signal | |
df['Signal'] = forecasts['Signal'] | |
df.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment