Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
8 |
+
sembol = st.sidebar.text_input("Hisse Senedi", value='ASELS.IS')
|
9 |
+
st.title(sembol + ' Hisse Senedi Grafiği')
|
10 |
+
|
11 |
+
start_date = st.sidebar.date_input('Başlangıç Tarihi', value=date(2023, 1, 1))
|
12 |
+
end_date = st.sidebar.date_input('Bitiş Tarihi', value=date.today())
|
13 |
+
|
14 |
+
df = yf.download(sembol, start=start_date, end=end_date)
|
15 |
+
|
16 |
+
# Zaman dilimi bilgisini kaldırıyoruz
|
17 |
+
df.index = df.index.tz_localize(None)
|
18 |
+
|
19 |
+
st.line_chart(df['Close'])
|
20 |
+
|
21 |
+
st.subheader('Hisse Senedi Verileri')
|
22 |
+
st.write(df)
|
23 |
+
|
24 |
+
st.subheader('Hisse Senedi Verileri Excel Dosyası')
|
25 |
+
|
26 |
+
def to_excel(df):
|
27 |
+
output = BytesIO()
|
28 |
+
writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
29 |
+
df.to_excel(writer, index=True, sheet_name='Sheet1')
|
30 |
+
writer.close()
|
31 |
+
processed_data = output.getvalue()
|
32 |
+
return processed_data
|
33 |
+
|
34 |
+
excel_data = to_excel(df)
|
35 |
+
st.download_button(
|
36 |
+
label='Excel olarak indir',
|
37 |
+
data=excel_data,
|
38 |
+
file_name=f'{sembol}_data.xlsx',
|
39 |
+
mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
40 |
+
)
|