Spaces:
Running
Running
File size: 528 Bytes
a5ca742 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import streamlit as st
import yfinance as yf
import pandas as pd
from datetime import datetime, timedelta
@st.cache_data(ttl=3600)
def get_stock_data(symbol):
"""Fetch stock data from Yahoo Finance"""
end_date = datetime.now()
start_date = end_date - timedelta(days=365)
stock = yf.Ticker(symbol)
df = stock.history(start=start_date, end=end_date)
return df
@st.cache_data(ttl=3600)
def get_company_info(symbol):
"""Fetch company information"""
stock = yf.Ticker(symbol)
return stock.info |