antitheft159 commited on
Commit
d1dac94
·
verified ·
1 Parent(s): d3b837b

Upload therollercoasterstrategy_195.py

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