Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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='
|
| 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("
|
| 19 |
sembol_kodu = stocks[sembol]
|
| 20 |
-
st.title(f"{sembol} ({sembol_kodu})
|
| 21 |
|
| 22 |
-
start_date = st.sidebar.date_input('
|
| 23 |
-
end_date = st.sidebar.date_input('
|
| 24 |
|
| 25 |
# Tarih kontrolü
|
| 26 |
if start_date > end_date:
|
| 27 |
-
st.error('
|
| 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('
|
| 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('
|
| 40 |
st.write(df)
|
| 41 |
|
| 42 |
# Grafik çizme
|
| 43 |
-
st.subheader('
|
| 44 |
st.line_chart(df['Close'])
|
| 45 |
|
| 46 |
-
st.subheader('
|
| 47 |
st.line_chart(df['Open'])
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
# Excel dosyasını indirme
|
| 50 |
-
st.subheader('
|
| 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='
|
| 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'
|