forked from teddylee777/streamlit-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path07-stock-chart-2.py
43 lines (34 loc) · 980 Bytes
/
07-stock-chart-2.py
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
import streamlit as st
import FinanceDataReader as fdr
import datetime
import time
# Finance Data Reader
# https://github.com/financedata-org/FinanceDataReader
st.title('종목 차트 검색')
with st.sidebar:
date = st.date_input(
"조회 시작일을 선택해 주세요",
datetime.datetime(2022, 1, 1)
)
code = st.text_input(
'종목코드',
value='',
placeholder='종목코드를 입력해 주세요'
)
if code and date:
df = fdr.DataReader(code, date)
data = df.sort_index(ascending=True).loc[:, 'Close']
tab1, tab2 = st.tabs(['차트', '데이터'])
with tab1:
st.line_chart(data)
with tab2:
st.dataframe(df.sort_index(ascending=False))
with st.expander('컬럼 설명'):
st.markdown('''
- Open: 시가
- High: 고가
- Low: 저가
- Close: 종가
- Adj Close: 수정 종가
- Volumn: 거래량
''')