-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathstockmarket.py
More file actions
56 lines (42 loc) · 1.73 KB
/
stockmarket.py
File metadata and controls
56 lines (42 loc) · 1.73 KB
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
52
53
54
55
56
import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
# Create a label for the stock ticker
self.ticker_label = QLabel("Stock ticker:")
# Create a text box for the stock ticker
self.ticker_edit = QLineEdit()
# Create a button to make a prediction
self.predict_button = QPushButton("Predict")
# Create a label for the predicted price
self.prediction_label = QLabel("Predicted price:")
# Create a text box for the predicted price
self.prediction_edit = QLineEdit()
# Set the layout of the main window
layout = QVBoxLayout()
layout.addWidget(self.ticker_label)
layout.addWidget(self.ticker_edit)
layout.addWidget(self.predict_button)
layout.addWidget(self.prediction_label)
layout.addWidget(self.prediction_edit)
self.setLayout(layout)
# Connect the predict button to the predict function
self.predict_button.clicked.connect(self.predict)
def predict(self):
# Get the stock ticker from the text box
ticker = self.ticker_edit.text()
# Train a Prophet model on the closing price of the stock
data = yf.download(ticker, period="1y")["Close"]
model = Prophet()
model.fit(data)
# Make a prediction for the closing price of the stock on the next day
future_price = model.predict(future_date="2023-10-31")
# Display the predicted price in the text box
self.prediction_edit.setText(str(future_price))
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())