60 lines
2.6 KiB
Python
60 lines
2.6 KiB
Python
|
|
"""
|
||
|
|
Data collection page for the Streamlit Quant application.
|
||
|
|
"""
|
||
|
|
import streamlit as st
|
||
|
|
from data import financial, krx, prices
|
||
|
|
|
||
|
|
|
||
|
|
def render_data_page():
|
||
|
|
"""Render the data collection page interface."""
|
||
|
|
st.title("데이터 수집")
|
||
|
|
|
||
|
|
col1, col2 = st.columns(2)
|
||
|
|
|
||
|
|
with col1:
|
||
|
|
if st.button(label='주식 데이터 수집', help="KOSPI, KOSDAQ 주식 데이터 수집"):
|
||
|
|
with st.spinner('주식 데이터 수집중...'):
|
||
|
|
try:
|
||
|
|
# Call the krx data collection function
|
||
|
|
biz_day = krx.get_latest_biz_day()
|
||
|
|
krx.process_for_total_stock(biz_day)
|
||
|
|
krx.process_for_wics(biz_day)
|
||
|
|
# Show success message
|
||
|
|
st.success('종목 데이터 수집 완료')
|
||
|
|
except Exception as e:
|
||
|
|
st.error(f"데이터 수집 실패: {e}")
|
||
|
|
|
||
|
|
if st.button(label='가격 데이터 수집', help="주가 데이터 수집"):
|
||
|
|
with st.spinner('가격 데이터 수집중...'):
|
||
|
|
try:
|
||
|
|
# Call the price data collection function
|
||
|
|
prices.process_for_price()
|
||
|
|
# Show success message
|
||
|
|
st.success(f'가격 데이터 수집 완료')
|
||
|
|
except Exception as e:
|
||
|
|
st.error(f"데이터 수집 실패: {e}")
|
||
|
|
|
||
|
|
with col2:
|
||
|
|
if st.button(label='재무제표 데이터 수집', help="재무제표 데이터 수집"):
|
||
|
|
with st.spinner('재무제표 데이터 수집중...'):
|
||
|
|
try:
|
||
|
|
# Call the financial data collection function
|
||
|
|
financial.process_for_fs()
|
||
|
|
# Show success message
|
||
|
|
st.success(f'재무제표 데이터 수집 완료')
|
||
|
|
except Exception as e:
|
||
|
|
st.error(f"데이터 수집 실패: {e}")
|
||
|
|
|
||
|
|
if st.button(label='데이터 업데이트', help="모든 데이터 업데이트"):
|
||
|
|
with st.spinner('데이터 업데이트중...'):
|
||
|
|
try:
|
||
|
|
# Call all data collection functions
|
||
|
|
# biz_day = krx.get_latest_biz_day()
|
||
|
|
# stock_data = krx.get_stock_data(biz_day)
|
||
|
|
# sector_data = krx.get_sector_data(biz_day)
|
||
|
|
# price_data = prices.crawl_price()
|
||
|
|
# financial_data = financial.crawl_fs()
|
||
|
|
# Show success message
|
||
|
|
st.success('모든 데이터 업데이트 완료')
|
||
|
|
except Exception as e:
|
||
|
|
st.error(f"데이터 업데이트 실패: {e}")
|