Spaces:
Runtime error
Runtime error
import streamlit as st | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import yfinance as yf | |
yf.pdr_override() | |
from pandas_datareader import data as pdr | |
start = '2005-01-01' | |
end = '2022-12-31' | |
st.title("Stock Market Trend Predictor") | |
user_input = st.text_input("Enter the stock ticker", "TATAPOWER.NS") | |
df = pdr.get_data_yahoo(user_input, start, end) | |
st.subheader("Data from year 2005 to 2022:") | |
st.write(df.describe()) | |
st.subheader("Closing Price VS Time Chart:") | |
fig = plt.figure(figsize=(12,6)) | |
plt.plot(df.Close) | |
st.pyplot(fig) | |
moving_avg_100 = df.Close.rolling(100).mean() | |
st.subheader("Closing Price VS Time Chart With 100Moving Average:") | |
fig = plt.figure(figsize=(12,6)) | |
plt.plot(df.Close) | |
plt.plot(moving_avg_100,'red') | |
st.pyplot(fig) | |
moving_avg_200 = df.Close.rolling(200).mean() | |
st.subheader("Closing Price VS Time Chart With 100Moving Average and 200Moving Average:") | |
fig = plt.figure(figsize=(12,6)) | |
plt.plot(df.Close) | |
plt.plot(moving_avg_100,'red') | |
plt.plot(moving_avg_200,'green') | |
st.pyplot(fig) |