Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +53 -0
- requirements.txt.txt +4 -0
app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import yfinance as yf
|
3 |
+
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 |
+
sembol = st.sidebar.text_input("Hisse Senedi Sembolü", value='ASELS.IS')
|
10 |
+
st.title(f"{sembol} Hisse Senedi Grafiği")
|
11 |
+
|
12 |
+
start_date = st.sidebar.date_input('Başlangıç Tarihi', value=date(2023, 1, 1))
|
13 |
+
end_date = st.sidebar.date_input('Bitiş Tarihi', value=date.today())
|
14 |
+
|
15 |
+
# Tarih kontrolü
|
16 |
+
if start_date > end_date:
|
17 |
+
st.error('Başlangıç tarihi bitiş tarihinden sonra olamaz.')
|
18 |
+
else:
|
19 |
+
# Veri çekme işlemi
|
20 |
+
df = yf.download(sembol, start=start_date, end=end_date)
|
21 |
+
|
22 |
+
if df.empty:
|
23 |
+
st.warning('Seçilen sembol ve tarih aralığı için veri bulunamadı.')
|
24 |
+
else:
|
25 |
+
# Zaman dilimi bilgisini kaldırma
|
26 |
+
df.index = df.index.tz_localize(None)
|
27 |
+
|
28 |
+
# Veri çerçevesini gösterme
|
29 |
+
st.subheader('Hisse Senedi Verileri')
|
30 |
+
st.write(df)
|
31 |
+
|
32 |
+
# Grafik çizme
|
33 |
+
st.subheader('Kapanış Fiyatı Grafiği')
|
34 |
+
st.line_chart(df['Close'])
|
35 |
+
|
36 |
+
# Excel dosyasını indirme
|
37 |
+
st.subheader('Hisse Senedi Verileri Excel Dosyası')
|
38 |
+
|
39 |
+
def to_excel(df):
|
40 |
+
output = BytesIO()
|
41 |
+
writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
42 |
+
df.to_excel(writer, index=True, sheet_name='Sheet1')
|
43 |
+
writer.close()
|
44 |
+
processed_data = output.getvalue()
|
45 |
+
return processed_data
|
46 |
+
|
47 |
+
excel_data = to_excel(df)
|
48 |
+
st.download_button(
|
49 |
+
label='Excel olarak indir',
|
50 |
+
data=excel_data,
|
51 |
+
file_name=f'{sembol}_data.xlsx',
|
52 |
+
mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
53 |
+
)
|
requirements.txt.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
yfinance
|
3 |
+
pandas
|
4 |
+
xlsxwriter
|