File size: 1,306 Bytes
d1dac94 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# -*- coding: utf-8 -*-
"""therollercoasterstrategy.195
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1Pn8vxMsTuQGWNoH9Bqo7XTJ1stXjNDHx
"""
!pip install neuralprophet
from neuralprophet import NeuralProphet
import yfinance as yf
import pandas as pd
import matplotlib.pyplot as plt
stock_symbol = 'DAL'
start_date = '2020-11-01'
end_date = '2024-12-01'
stock_data = yf.download(stock_symbol, start = start_date, end=end_date)
print(stock_data.head())
stock_data.to_csv('stock_data.csv')
stocks = pd.read_csv('stock_data.csv')
stocks['Date'] = pd.to_datetime(stocks['Date'])
stocks = stocks[['Date', 'Close']]
stocks.columns = ['ds', 'y']
plt.plot(stocks['ds'], stocks['y'], label = 'actual', c = 'g')
plt.show()
model = NeuralProphet()
model.fit(stocks)
future = model.make_future_dataframe(stocks, periods = 300)
forecast = model.predict(future)
actual_prediction = model.predict(stocks)
plt.title(".159 Est. 1367")
plt.plot(actual_prediction['ds'], actual_prediction['yhat1'], label = "prediction_Actual", c = 'r')
plt.plot(forecast['ds'], forecast['yhat1'], label = 'future_predictions', c = 'b')
plt.plot(stocks['ds'], stocks['y'], label = 'actual', c = 'g')
plt.legend()
plt.show()
"""S&P 500"""
model.plot_components(forecast) |