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