demo_deploy_streamlit_app / src /streamlit_app.py
thinh-vu's picture
Upload 12 files
021d91d verified
Raw
History Blame Contribute Delete
2 kB
import streamlit as st
from src.components.header import set_page_config, set_custom_css, display_header, display_footer
from src.components.sidebar import display_sidebar
from src.components.technical_analysis import display_technical_analysis
from src.components.financial_analysis import display_financial_analysis
from src.utils.data_loader import get_stock_data, get_financial_data, get_default_dates
from src.utils.technical_indicators import add_technical_indicators
def main():
# Thiết lập cấu hình trang
set_page_config()
set_custom_css()
# Hiển thị header
display_header()
# Hiển thị sidebar và lấy tham số
symbol, source = display_sidebar()
# Tạo tabs
tab1, tab2 = st.tabs(["📊 Phân tích Kỹ thuật", "💰 Báo cáo Tài chính"])
# Lấy ngày mặc định
start_date, end_date = get_default_dates()
if symbol:
# Lấy dữ liệu giá
price_data = get_stock_data(symbol, source, start_date, end_date)
if price_data is not None and not price_data.empty:
# Thêm các chỉ báo kỹ thuật
price_data = add_technical_indicators(price_data)
# TAB 1: PHÂN TÍCH KỸ THUẬT
with tab1:
display_technical_analysis(price_data, symbol)
# TAB 2: BÁO CÁO TÀI CHÍNH
with tab2:
# Lấy dữ liệu tài chính
income, balance, cashflow, ratio = get_financial_data(symbol, source)
display_financial_analysis(income, balance, cashflow, ratio, symbol)
else:
st.error(f"Không thể lấy dữ liệu cho mã cổ phiếu {symbol}. Vui lòng kiểm tra lại mã cổ phiếu.")
else:
st.info("Vui lòng nhập mã cổ phiếu để bắt đầu phân tích.")
# Hiển thị footer
display_footer()
if __name__ == "__main__":
main()