Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +21 -14
src/streamlit_app.py
CHANGED
|
@@ -7,11 +7,12 @@ import os
|
|
| 7 |
# 1. SAYFA AYARLARI
|
| 8 |
st.set_page_config(layout="wide", page_title="Gold Price Analysis")
|
| 9 |
|
| 10 |
-
# CSS: Sade ve Net Tasarım
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
| 13 |
.stApp { background-color: #FFFFFF; }
|
| 14 |
-
[data-testid="stMetricValue"] { font-size:
|
|
|
|
| 15 |
.plot-container { border-radius: 10px; padding: 5px; }
|
| 16 |
</style>
|
| 17 |
""", unsafe_allow_html=True)
|
|
@@ -40,19 +41,19 @@ st.sidebar.header("📅 Filtreler / Filters")
|
|
| 40 |
year = st.sidebar.selectbox("Yıl Seçin / Select Year", options=sorted(df['YEAR'].unique(), reverse=True))
|
| 41 |
filtered_df = df[df['YEAR'] == year].copy()
|
| 42 |
|
| 43 |
-
# 4. ANA BAŞLIK
|
| 44 |
st.markdown("<h1 style='text-align: center; color: #333;'>Gold Price Analysis / Altın Fiyat Analizi</h1>", unsafe_allow_html=True)
|
| 45 |
st.divider()
|
| 46 |
|
| 47 |
-
# 5. YÖNETİCİ BİLGİ NOTU
|
| 48 |
st.markdown("### 💼 Yönetici Bilgi Notu / Executive Summary")
|
| 49 |
-
|
| 50 |
-
with
|
| 51 |
if year == 2008:
|
| 52 |
st.warning("### 🇹🇷 2008'de altın güvenli limandır, alım faydalıdır.")
|
| 53 |
else:
|
| 54 |
st.success(f"### 🇹🇷 {year} yılı verileri istikrarlı görünüyor, teknik seviyeler izlenmeli.")
|
| 55 |
-
with
|
| 56 |
if year == 2008:
|
| 57 |
st.warning("### 🇺🇸 Gold is a safe haven in 2008; buying is beneficial.")
|
| 58 |
else:
|
|
@@ -60,7 +61,13 @@ with col2:
|
|
| 60 |
|
| 61 |
st.divider()
|
| 62 |
|
| 63 |
-
# 6.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
st.markdown(f"#### 📈 {year} Altın Fiyat Trendi")
|
| 65 |
fig1 = go.Figure()
|
| 66 |
fig1.add_trace(go.Scatter(x=filtered_df['Date'], y=filtered_df['GLD'],
|
|
@@ -75,11 +82,11 @@ fig1.update_layout(
|
|
| 75 |
st.plotly_chart(fig1, use_container_width=True)
|
| 76 |
|
| 77 |
# Grafik Altı Yorumu
|
| 78 |
-
st.info(f"💡 **
|
| 79 |
|
| 80 |
st.divider()
|
| 81 |
|
| 82 |
-
#
|
| 83 |
c1, c2 = st.columns(2)
|
| 84 |
|
| 85 |
with c1:
|
|
@@ -87,7 +94,7 @@ with c1:
|
|
| 87 |
fig2 = px.histogram(filtered_df, x="GLD", nbins=30, color_discrete_sequence=['gold'], template="plotly_dark")
|
| 88 |
fig2.update_layout(paper_bgcolor='black', plot_bgcolor='black', height=350)
|
| 89 |
st.plotly_chart(fig2, use_container_width=True)
|
| 90 |
-
st.
|
| 91 |
|
| 92 |
with c2:
|
| 93 |
st.markdown("#### 🌡️ Korelasyon / Correlation")
|
|
@@ -95,14 +102,14 @@ with c2:
|
|
| 95 |
fig3 = px.imshow(numeric_df.corr(), text_auto=".2f", color_continuous_scale='YlOrRd', template="plotly_dark")
|
| 96 |
fig3.update_layout(paper_bgcolor='black', plot_bgcolor='black', height=350)
|
| 97 |
st.plotly_chart(fig3, use_container_width=True)
|
| 98 |
-
st.
|
| 99 |
|
| 100 |
st.divider()
|
| 101 |
|
| 102 |
-
#
|
| 103 |
st.markdown("### 📋 Verileri Gör / View Data")
|
| 104 |
st.dataframe(filtered_df, use_container_width=True)
|
| 105 |
|
| 106 |
-
# İndirme Butonu
|
| 107 |
csv = filtered_df.to_csv(index=False).encode('utf-8')
|
| 108 |
st.download_button("📥 Veriyi CSV Olarak İndir", data=csv, file_name=f'gold_data_{year}.csv')
|
|
|
|
| 7 |
# 1. SAYFA AYARLARI
|
| 8 |
st.set_page_config(layout="wide", page_title="Gold Price Analysis")
|
| 9 |
|
| 10 |
+
# CSS: Sade ve Net Tasarım + Metrik Stilini Koruma
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
| 13 |
.stApp { background-color: #FFFFFF; }
|
| 14 |
+
[data-testid="stMetricValue"] { font-size: 45px !important; font-weight: bold !important; color: #B28F2D !important; }
|
| 15 |
+
[data-testid="stMetricLabel"] { font-size: 18px !important; font-weight: bold !important; color: #333333 !important; }
|
| 16 |
.plot-container { border-radius: 10px; padding: 5px; }
|
| 17 |
</style>
|
| 18 |
""", unsafe_allow_html=True)
|
|
|
|
| 41 |
year = st.sidebar.selectbox("Yıl Seçin / Select Year", options=sorted(df['YEAR'].unique(), reverse=True))
|
| 42 |
filtered_df = df[df['YEAR'] == year].copy()
|
| 43 |
|
| 44 |
+
# 4. ANA BAŞLIK
|
| 45 |
st.markdown("<h1 style='text-align: center; color: #333;'>Gold Price Analysis / Altın Fiyat Analizi</h1>", unsafe_allow_html=True)
|
| 46 |
st.divider()
|
| 47 |
|
| 48 |
+
# 5. YÖNETİCİ BİLGİ NOTU
|
| 49 |
st.markdown("### 💼 Yönetici Bilgi Notu / Executive Summary")
|
| 50 |
+
col_tr, col_en = st.columns(2)
|
| 51 |
+
with col_tr:
|
| 52 |
if year == 2008:
|
| 53 |
st.warning("### 🇹🇷 2008'de altın güvenli limandır, alım faydalıdır.")
|
| 54 |
else:
|
| 55 |
st.success(f"### 🇹🇷 {year} yılı verileri istikrarlı görünüyor, teknik seviyeler izlenmeli.")
|
| 56 |
+
with col_en:
|
| 57 |
if year == 2008:
|
| 58 |
st.warning("### 🇺🇸 Gold is a safe haven in 2008; buying is beneficial.")
|
| 59 |
else:
|
|
|
|
| 61 |
|
| 62 |
st.divider()
|
| 63 |
|
| 64 |
+
# 6. ÖZEL METRİKLER (İstediğin: Son Kapanış, Zirve, Dip)
|
| 65 |
+
m1, m2, m3 = st.columns(3)
|
| 66 |
+
m1.metric("Son Kapanış", f"{filtered_df['GLD'].iloc[-1]:.2f}")
|
| 67 |
+
m2.metric(f"{year} Zirve", f"{filtered_df['GLD'].max():.2f}")
|
| 68 |
+
m3.metric(f"{year} Dip", f"{filtered_df['GLD'].min():.2f}")
|
| 69 |
+
|
| 70 |
+
# 7. ANA TREND GRAFİĞİ
|
| 71 |
st.markdown(f"#### 📈 {year} Altın Fiyat Trendi")
|
| 72 |
fig1 = go.Figure()
|
| 73 |
fig1.add_trace(go.Scatter(x=filtered_df['Date'], y=filtered_df['GLD'],
|
|
|
|
| 82 |
st.plotly_chart(fig1, use_container_width=True)
|
| 83 |
|
| 84 |
# Grafik Altı Yorumu
|
| 85 |
+
st.info(f"💡 **Fiyat Trendi Analizi:** {year} yılındaki fiyat hareketleri, piyasanın genel yönünü ve volatilite eşiklerini yansıtmaktadır. Trend çizgisi, destek ve direnç bölgelerinin belirlenmesi açısından kritik önem taşır.")
|
| 86 |
|
| 87 |
st.divider()
|
| 88 |
|
| 89 |
+
# 8. YAN YANA GRAFİKLER VE YORUMLARI
|
| 90 |
c1, c2 = st.columns(2)
|
| 91 |
|
| 92 |
with c1:
|
|
|
|
| 94 |
fig2 = px.histogram(filtered_df, x="GLD", nbins=30, color_discrete_sequence=['gold'], template="plotly_dark")
|
| 95 |
fig2.update_layout(paper_bgcolor='black', plot_bgcolor='black', height=350)
|
| 96 |
st.plotly_chart(fig2, use_container_width=True)
|
| 97 |
+
st.warning(f"📊 **Dağılım Notu:** Fiyatların bu yıl içinde en çok hangi bant aralığında konsolide olduğunu (sıkıştığını) gösterir. Yüksek barlar, piyasanın o fiyat seviyesini 'denge noktası' olarak kabul ettiğini kanıtlar.")
|
| 98 |
|
| 99 |
with c2:
|
| 100 |
st.markdown("#### 🌡️ Korelasyon / Correlation")
|
|
|
|
| 102 |
fig3 = px.imshow(numeric_df.corr(), text_auto=".2f", color_continuous_scale='YlOrRd', template="plotly_dark")
|
| 103 |
fig3.update_layout(paper_bgcolor='black', plot_bgcolor='black', height=350)
|
| 104 |
st.plotly_chart(fig3, use_container_width=True)
|
| 105 |
+
st.warning("🔗 **Korelasyon Notu:** Altının; petrol (USO), gümüş (SLV) ve borsa endeksleri (SPX) ile olan ilişkisini ölçer. +1'e yakın değerler beraber hareket ettiklerini, -1 ise zıt hareket ettiklerini gösterir.")
|
| 106 |
|
| 107 |
st.divider()
|
| 108 |
|
| 109 |
+
# 9. VERİ TABLOSU (Her zaman açık)
|
| 110 |
st.markdown("### 📋 Verileri Gör / View Data")
|
| 111 |
st.dataframe(filtered_df, use_container_width=True)
|
| 112 |
|
| 113 |
+
# İndirme Butonu
|
| 114 |
csv = filtered_df.to_csv(index=False).encode('utf-8')
|
| 115 |
st.download_button("📥 Veriyi CSV Olarak İndir", data=csv, file_name=f'gold_data_{year}.csv')
|