Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,18 +3,17 @@ import pandas as pd
|
|
| 3 |
import plotly.express as px
|
| 4 |
import plotly.graph_objects as go
|
| 5 |
|
| 6 |
-
# 1. SAYFA AYARLARI
|
| 7 |
st.set_page_config(layout="wide", page_title="Gold Intelligence Dashboard")
|
| 8 |
|
| 9 |
-
# Streamlit Koyu
|
| 10 |
st.markdown("""
|
| 11 |
<style>
|
| 12 |
-
.
|
| 13 |
background-color: #0E1117;
|
| 14 |
-
color: #E0E0E0;
|
| 15 |
}
|
| 16 |
-
|
| 17 |
-
color: #F8F9FA !
|
| 18 |
}
|
| 19 |
</style>
|
| 20 |
""", unsafe_allow_html=True)
|
|
@@ -35,58 +34,88 @@ except Exception as e:
|
|
| 35 |
st.error(f"Veri yükleme hatası: {e}")
|
| 36 |
st.stop()
|
| 37 |
|
| 38 |
-
# 3. SIDEBAR
|
| 39 |
st.sidebar.markdown("<h2 style='color: #FFD700;'>📅 Filtreler</h2>", unsafe_allow_html=True)
|
| 40 |
years_list = sorted([y for y in df['YEAR'].unique() if y >= 2008])
|
| 41 |
year = st.sidebar.selectbox("Yıl Seçin / Select Year", options=years_list, index=0)
|
| 42 |
|
| 43 |
filtered_df = df[df['YEAR'] == year].copy()
|
| 44 |
|
| 45 |
-
# 4. ANA BAŞLIK
|
| 46 |
-
st.markdown("<h1 style='text-align: center; color: #FFD700;'>💰 Gold Price
|
|
|
|
| 47 |
st.divider()
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
st.markdown("### 📊 Temel Metrikler / Key Metrics")
|
| 51 |
k1, k2, k3 = st.columns(3)
|
| 52 |
with k1:
|
| 53 |
current_price = filtered_df['GLD'].iloc[-1]
|
| 54 |
-
st.metric(label=
|
| 55 |
with k2:
|
| 56 |
-
|
| 57 |
-
st.metric(label=f"{year} Tepe Fiyatı", value=f"{peak_price:.2f}", help="O yılın en yüksek fiyatı")
|
| 58 |
with k3:
|
| 59 |
-
|
| 60 |
-
st.metric(label=f"{year} Taban Fiyatı", value=f"{floor_price:.2f}", help="O yılın en düşük fiyatı")
|
| 61 |
|
| 62 |
st.divider()
|
| 63 |
|
| 64 |
-
# 5. YÖNETİCİ BİLGİ NOTU (
|
| 65 |
st.markdown("## 💼 Yönetici Bilgi Notu / Executive Summary")
|
| 66 |
info_col1, info_col2 = st.columns(2)
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
🇺🇸_msg = f"<div style='background-color: #2E3137; padding: 20px; border-left: 5px solid #28A745; border-radius: 5px;'> <h3 style='color: #F8F9FA;'>🇺🇸 Data for {year} appears stable. Price action warrants monitoring.</h3> </div>"
|
| 76 |
|
| 77 |
with info_col1:
|
| 78 |
-
st.markdown(
|
| 79 |
with info_col2:
|
| 80 |
-
st.markdown(
|
| 81 |
|
| 82 |
st.divider()
|
| 83 |
|
| 84 |
-
# 6. GRAFİKLER
|
| 85 |
-
st.markdown(f"## 📈 {year}
|
| 86 |
|
| 87 |
-
# Ana Grafik (Plotly Go ile daha detaylı alan grafiği)
|
| 88 |
fig1 = go.Figure()
|
| 89 |
fig1.add_trace(go.Scatter(x=filtered_df['Date'], y=filtered_df['GLD'],
|
| 90 |
mode='lines',
|
| 91 |
line=dict(color='#FFD700', width=3),
|
| 92 |
-
fill='tozeroy', fillcolor='rgba(255, 215, 0, 0.1)'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import plotly.express as px
|
| 4 |
import plotly.graph_objects as go
|
| 5 |
|
| 6 |
+
# 1. SAYFA AYARLARI
|
| 7 |
st.set_page_config(layout="wide", page_title="Gold Intelligence Dashboard")
|
| 8 |
|
| 9 |
+
# Streamlit Genel Koyu Tema ve Font Düzeltmeleri
|
| 10 |
st.markdown("""
|
| 11 |
<style>
|
| 12 |
+
.stApp {
|
| 13 |
background-color: #0E1117;
|
|
|
|
| 14 |
}
|
| 15 |
+
h1, h2, h3, p {
|
| 16 |
+
color: #F8F9FA !important;
|
| 17 |
}
|
| 18 |
</style>
|
| 19 |
""", unsafe_allow_html=True)
|
|
|
|
| 34 |
st.error(f"Veri yükleme hatası: {e}")
|
| 35 |
st.stop()
|
| 36 |
|
| 37 |
+
# 3. SIDEBAR
|
| 38 |
st.sidebar.markdown("<h2 style='color: #FFD700;'>📅 Filtreler</h2>", unsafe_allow_html=True)
|
| 39 |
years_list = sorted([y for y in df['YEAR'].unique() if y >= 2008])
|
| 40 |
year = st.sidebar.selectbox("Yıl Seçin / Select Year", options=years_list, index=0)
|
| 41 |
|
| 42 |
filtered_df = df[df['YEAR'] == year].copy()
|
| 43 |
|
| 44 |
+
# 4. ANA BAŞLIK
|
| 45 |
+
st.markdown("<h1 style='text-align: center; color: #FFD700; font-size: 45px;'>💰 Gold Price Intelligence</h1>", unsafe_allow_html=True)
|
| 46 |
+
st.markdown("<p style='text-align: center; color: #E0E0E0;'>Altın Fiyat Analizi ve Stratejik Öngörü Paneli</p>", unsafe_allow_html=True)
|
| 47 |
st.divider()
|
| 48 |
|
| 49 |
+
# METRİK KARTLARI
|
|
|
|
| 50 |
k1, k2, k3 = st.columns(3)
|
| 51 |
with k1:
|
| 52 |
current_price = filtered_df['GLD'].iloc[-1]
|
| 53 |
+
st.metric(label="Son Kapanış Fiyatı", value=f"{current_price:.2f}")
|
| 54 |
with k2:
|
| 55 |
+
st.metric(label=f"{year} Tepe Noktası", value=f"{filtered_df['GLD'].max():.2f}")
|
|
|
|
| 56 |
with k3:
|
| 57 |
+
st.metric(label=f"{year} Dip Noktası", value=f"{filtered_df['GLD'].min():.2f}")
|
|
|
|
| 58 |
|
| 59 |
st.divider()
|
| 60 |
|
| 61 |
+
# 5. YÖNETİCİ BİLGİ NOTU (Değişken isimleri TR_msg ve US_msg olarak düzeltildi)
|
| 62 |
st.markdown("## 💼 Yönetici Bilgi Notu / Executive Summary")
|
| 63 |
info_col1, info_col2 = st.columns(2)
|
| 64 |
|
| 65 |
+
# Değişken isimlerinde emoji kullanmıyoruz, sadece metin içinde kullanıyoruz
|
| 66 |
+
if year == 2008:
|
| 67 |
+
tr_text = "🇹🇷 2008'de altın güvenli limandır, alım faydalıdır."
|
| 68 |
+
us_text = "🇺🇸 Gold is a safe haven in 2008; buying is beneficial."
|
| 69 |
+
border_color = "#FFD700" # Altın sarısı
|
| 70 |
+
else:
|
| 71 |
+
tr_text = f"🇹🇷 {year} yılı verileri istikrarlı görünüyor. Teknik analiz önerilir."
|
| 72 |
+
us_text = f"🇺🇸 Data for {year} appears stable. Technical analysis recommended."
|
| 73 |
+
border_color = "#28A745" # Yeşil
|
| 74 |
|
| 75 |
+
tr_msg = f"<div style='background-color: #1E2127; padding: 20px; border-left: 5px solid {border_color}; border-radius: 5px;'> <h3 style='margin:0; color: #F8F9FA;'>{tr_text}</h3> </div>"
|
| 76 |
+
us_msg = f"<div style='background-color: #1E2127; padding: 20px; border-left: 5px solid {border_color}; border-radius: 5px;'> <h3 style='margin:0; color: #F8F9FA;'>{us_text}</h3> </div>"
|
|
|
|
| 77 |
|
| 78 |
with info_col1:
|
| 79 |
+
st.markdown(tr_msg, unsafe_allow_html=True)
|
| 80 |
with info_col2:
|
| 81 |
+
st.markdown(us_msg, unsafe_allow_html=True)
|
| 82 |
|
| 83 |
st.divider()
|
| 84 |
|
| 85 |
+
# 6. GRAFİKLER
|
| 86 |
+
st.markdown(f"## 📈 {year} Piyasa Hareketi / Market Action")
|
| 87 |
|
|
|
|
| 88 |
fig1 = go.Figure()
|
| 89 |
fig1.add_trace(go.Scatter(x=filtered_df['Date'], y=filtered_df['GLD'],
|
| 90 |
mode='lines',
|
| 91 |
line=dict(color='#FFD700', width=3),
|
| 92 |
+
fill='tozeroy', fillcolor='rgba(255, 215, 0, 0.1)'))
|
| 93 |
+
|
| 94 |
+
fig1.update_layout(template="plotly_dark", height=450,
|
| 95 |
+
paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)',
|
| 96 |
+
margin=dict(l=20, r=20, t=20, b=20))
|
| 97 |
+
st.plotly_chart(fig1, use_container_width=True)
|
| 98 |
+
|
| 99 |
+
# ALT GRAFİKLER
|
| 100 |
+
c1, c2 = st.columns(2)
|
| 101 |
+
with c1:
|
| 102 |
+
st.markdown("### 🎯 Dağılım / Distribution")
|
| 103 |
+
fig2 = px.histogram(filtered_df, x="GLD", color_discrete_sequence=['#FFD700'], template="plotly_dark")
|
| 104 |
+
fig2.update_layout(paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)')
|
| 105 |
+
st.plotly_chart(fig2, use_container_width=True)
|
| 106 |
+
|
| 107 |
+
with c2:
|
| 108 |
+
st.markdown("### 🌡️ Korelasyon / Correlation")
|
| 109 |
+
num_df = filtered_df.select_dtypes(include=['number']).corr()
|
| 110 |
+
fig3 = px.imshow(num_df, text_auto=True, color_continuous_scale='YlOrRd', template="plotly_dark")
|
| 111 |
+
fig3.update_layout(paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)')
|
| 112 |
+
st.plotly_chart(fig3, use_container_width=True)
|
| 113 |
+
|
| 114 |
+
st.divider()
|
| 115 |
+
|
| 116 |
+
# 7. VERİ TABLOSU
|
| 117 |
+
st.markdown("### 📋 Detaylı Veri Seti / Detailed Dataset")
|
| 118 |
+
st.dataframe(filtered_df.head(15), use_container_width=True)
|
| 119 |
+
|
| 120 |
+
csv = filtered_df.to_csv(index=False).encode('utf-8')
|
| 121 |
+
st.download_button("📥 Raporu İndir (CSV)", data=csv, file_name=f'gold_report_{year}.csv')
|