stock-analysis-terminal / data_fetcher.py
mobenta's picture
Upload 11 files
a5ca742 verified
raw
history blame contribute delete
528 Bytes
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