Spaces:
Runtime error
Runtime error
File size: 2,541 Bytes
2dd7bee 99561e6 f2f8150 7d98092 78198ac 99561e6 f20226d 99561e6 f20226d 99561e6 fee1685 9ca4b78 99561e6 f20226d c953136 99561e6 f20226d 3eac012 c953136 f20226d 99561e6 c953136 5e200ff f20226d 5e200ff 7d98092 f6dcfb4 f45cc22 ab9e7de ece7fec 9ca4b78 4ae28a7 ece7fec 67fdabf 0759c1f f45cc22 7195026 40e2563 7195026 40e2563 7195026 7d98092 9ddf64a f20226d ed60e56 |
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
import streamlit as st
import yfinance as yf
import pandas as pd
import cufflinks as cf
import datetime
import plotly.graph_objects as go
# App title
st.markdown('''
# Sovrenn Market Sentiment Indicator App
Shown are the stock price data for the selected company!
**Credits**
- App built by SRL
''')
st.write('---')
# Sidebar
st.sidebar.subheader('Query parameters')
start_date = st.sidebar.date_input("Start date", datetime.date(2023,9, 20))
#start_date = start_date - datetime.timedelta(days=1)
end_date = start_date + datetime.timedelta(days=14)
# User input for the stock ticker symbol
tickerSymbol = st.sidebar.text_input('Enter Stock Ticker Symbol')
if tickerSymbol:
tickerData = yf.Ticker(tickerSymbol) # Get ticker data
tickerDf = tickerData.history(period='1d', start=start_date, end=end_date) # Get the historical prices for this ticker
string_name = tickerData.info.get('longName', 'Company Name Not Available')
st.header('**%s**' % string_name)
# Try to get the business summary, handle KeyError if not available
try:
string_summary = tickerData.info['longBusinessSummary']
st.info(string_summary)
except KeyError:
st.warning("Business summary not available for this company.")
# Ticker data
st.header('**Ticker data**')
st.write(tickerDf)
# Create a candlestick chart and volume bar chart
fig_candlestick = go.Figure(data=[go.Candlestick(x=tickerDf.index,
open=tickerDf['Open'],
high=tickerDf['High'],
low=tickerDf['Low'],
close=tickerDf['Close'])])
fig_volume = go.Figure(data=[go.Bar(x=tickerDf.index, y=tickerDf['Volume'])])
st.header('**Candlestick Chart**')
st.plotly_chart(fig_candlestick)
st.header('**Volume Bar Chart**')
st.plotly_chart(fig_volume)
st.write(start_date)
tickerDf = pd.DataFrame(tickerDf).reset_index()
# st.write(tickerDf)
#date = datetime.date(start_date)
date_str = start_date.strftime("%Y-%m-%d")
st.write(date_str)
df = tickerDf[tickerDf["Date"]==date_str]
st.write(df)
if (Df["Close"][0] > Df["Open"][0] ):
st.write("NSE has uptrend on " +date_str )
if (Df["Close"][0] < Df["Open"][0] ):
st.write(" NSE has downdtrend on " +date_str )
else:
st.warning("Please enter a valid Stock Ticker Symbol.")
|