RIZAEFE commited on
Commit
d89e2f7
·
verified ·
1 Parent(s): fbec150

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -4,7 +4,7 @@ import pandas as pd
4
  from datetime import date
5
  from io import BytesIO
6
 
7
- st.set_page_config(page_title='Hisse Senedi Grafiği')
8
 
9
  # Hisse senetleri listesi
10
  stocks = {
@@ -15,39 +15,48 @@ stocks = {
15
  }
16
 
17
  # Kullanıcının hisse senedi seçmesi için selectbox
18
- sembol = st.sidebar.selectbox("Hisse Senedi Seçiniz", options=list(stocks.keys()))
19
  sembol_kodu = stocks[sembol]
20
- st.title(f"{sembol} ({sembol_kodu}) Hisse Senedi Grafiği")
21
 
22
- start_date = st.sidebar.date_input('Başlangıç Tarihi', value=date(2023, 1, 1))
23
- end_date = st.sidebar.date_input('Bitiş Tarihi', value=date.today())
24
 
25
  # Tarih kontrolü
26
  if start_date > end_date:
27
- st.error('Başlangıç tarihi bitiş tarihinden sonra olamaz.')
28
  else:
29
  # Veri çekme işlemi
30
  df = yf.download(sembol_kodu, start=start_date, end=end_date)
31
 
32
  if df.empty:
33
- st.warning('Seçilen sembol ve tarih aralığı için veri bulunamadı.')
34
  else:
35
  # Zaman dilimi bilgisini kaldırma
36
  df.index = df.index.tz_localize(None)
37
 
38
  # Veri çerçevesini gösterme
39
- st.subheader('Hisse Senedi Verileri')
40
  st.write(df)
41
 
42
  # Grafik çizme
43
- st.subheader('Kapanış Fiyatı Grafiği')
44
  st.line_chart(df['Close'])
45
 
46
- st.subheader('Kapanış Fiyatı Grafiği')
47
  st.line_chart(df['Open'])
48
 
 
 
 
 
 
 
 
 
 
49
  # Excel dosyasını indirme
50
- st.subheader('Hisse Senedi Verileri Excel Dosyası')
51
 
52
  def to_excel(df):
53
  output = BytesIO()
@@ -59,7 +68,7 @@ else:
59
 
60
  excel_data = to_excel(df)
61
  st.download_button(
62
- label='Excel olarak indir',
63
  data=excel_data,
64
  file_name=f'{sembol_kodu}_data.xlsx',
65
  mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
 
4
  from datetime import date
5
  from io import BytesIO
6
 
7
+ st.set_page_config(page_title='Stock Chart')
8
 
9
  # Hisse senetleri listesi
10
  stocks = {
 
15
  }
16
 
17
  # Kullanıcının hisse senedi seçmesi için selectbox
18
+ sembol = st.sidebar.selectbox("Select a Stock", options=list(stocks.keys()))
19
  sembol_kodu = stocks[sembol]
20
+ st.title(f"{sembol} ({sembol_kodu}) Stock Chart")
21
 
22
+ start_date = st.sidebar.date_input('Start Date', value=date(2023, 1, 1))
23
+ end_date = st.sidebar.date_input('End Date', value=date.today())
24
 
25
  # Tarih kontrolü
26
  if start_date > end_date:
27
+ st.error('Start date cannot be later than end date.')
28
  else:
29
  # Veri çekme işlemi
30
  df = yf.download(sembol_kodu, start=start_date, end=end_date)
31
 
32
  if df.empty:
33
+ st.warning('No data found for selected symbol and date range.')
34
  else:
35
  # Zaman dilimi bilgisini kaldırma
36
  df.index = df.index.tz_localize(None)
37
 
38
  # Veri çerçevesini gösterme
39
+ st.subheader('Stock Data')
40
  st.write(df)
41
 
42
  # Grafik çizme
43
+ st.subheader('Closing Price Chart')
44
  st.line_chart(df['Close'])
45
 
46
+ st.subheader('Opening Price Chart')
47
  st.line_chart(df['Open'])
48
 
49
+ st.subheader('High Price Chart')
50
+ st.plotly_chart(df['High'])
51
+
52
+ st.subheader('Low Price Chart')
53
+ st.plotly_chart(df['Low'])
54
+
55
+ st.subheader('Volume Price Chart')
56
+ st.plotly_chart(df['Volume'])
57
+
58
  # Excel dosyasını indirme
59
+ st.subheader('Stock Data Excel File')
60
 
61
  def to_excel(df):
62
  output = BytesIO()
 
68
 
69
  excel_data = to_excel(df)
70
  st.download_button(
71
+ label='Download as Excel',
72
  data=excel_data,
73
  file_name=f'{sembol_kodu}_data.xlsx',
74
  mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'