Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,53 +7,58 @@ import numpy as np
|
|
| 7 |
# 1. SAYFA AYARLARI VE ÖZEL TASARIM (CSS)
|
| 8 |
st.set_page_config(layout="wide", page_title="Gold Intelligence Dashboard")
|
| 9 |
|
| 10 |
-
#
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
| 13 |
-
/*
|
| 14 |
.stApp {
|
| 15 |
-
background-color: #
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
-
/*
|
| 19 |
-
h1, h2, h3, h4, p, span, div, li, label, .stMarkdown p {
|
| 20 |
-
color: #F8F9FA !important;
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
/* Ana Başlığı Altın Sarısı Yapalım */
|
| 24 |
h1.main-title {
|
| 25 |
-
color: #
|
| 26 |
-
text-shadow:
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
-
/* Metrik Değerlerini Kocaman ve Kalın Yapalım (
|
| 30 |
[data-testid="stMetricValue"] {
|
| 31 |
-
font-size: 60px !important; /* Değeri
|
| 32 |
font-weight: 900 !important; /* En kalın yazı */
|
| 33 |
-
color: #
|
| 34 |
-
letter-spacing: -2px; /* Harf aralarını daralt,
|
| 35 |
}
|
| 36 |
|
| 37 |
-
/* Metrik Etiketlerini (Label) de Netleştirelim */
|
| 38 |
[data-testid="stMetricLabel"] p {
|
| 39 |
font-size: 18px !important;
|
| 40 |
-
color: #
|
| 41 |
margin-bottom: -10px !important;
|
| 42 |
}
|
| 43 |
|
| 44 |
-
/*
|
| 45 |
.plot-container {
|
| 46 |
-
background-color: #
|
| 47 |
-
border-radius:
|
| 48 |
-
box-shadow: 0
|
| 49 |
-
padding:
|
| 50 |
-
border:
|
|
|
|
| 51 |
}
|
| 52 |
-
|
| 53 |
-
/* SideBar (Sol Panel)
|
| 54 |
.css-163utfM, .css-hxt7ib {
|
| 55 |
-
background-color: #
|
| 56 |
-
border-right: 1px solid #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
</style>
|
|
@@ -76,46 +81,46 @@ except Exception as e:
|
|
| 76 |
st.stop()
|
| 77 |
|
| 78 |
# 3. SIDEBAR
|
| 79 |
-
st.sidebar.markdown("<h2 style='color: #
|
| 80 |
years_list = sorted([y for y in df['YEAR'].unique() if y >= 2008])
|
| 81 |
year = st.sidebar.selectbox("Yıl Seçin / Select Year", options=years_list, index=0)
|
| 82 |
|
| 83 |
filtered_df = df[df['YEAR'] == year].copy()
|
| 84 |
|
| 85 |
# 4. ANA BAŞLIK
|
| 86 |
-
# Tam talep ettiğin başlık metni
|
| 87 |
st.markdown("<h1 class='main-title' style='text-align: center; font-size: 45px;'>💰 Gold Price Intelligence</h1>", unsafe_allow_html=True)
|
| 88 |
-
st.markdown("<p style='text-align: center; color: #
|
| 89 |
st.divider()
|
| 90 |
|
| 91 |
-
# 📈 METRİK KARTLARI (
|
| 92 |
m1, m2, m3 = st.columns(3)
|
| 93 |
with m1:
|
| 94 |
-
# Son Kapanış Fiyatı (Örnek: 86.52)
|
| 95 |
current_price = filtered_df['GLD'].iloc[-1]
|
| 96 |
st.metric(label="Son Kapanış Fiyatı (GLD)", value=f"{current_price:.2f}")
|
| 97 |
with m2:
|
| 98 |
-
st.metric(label=f"{year} Tepe Noktası
|
| 99 |
with m3:
|
| 100 |
-
st.metric(label=f"{year} Dip Noktası
|
| 101 |
|
| 102 |
st.divider()
|
| 103 |
|
| 104 |
-
# 5. YÖNETİCİ BİLGİ NOTU (
|
| 105 |
st.markdown("## 💼 Yönetici Bilgi Notu / Executive Summary")
|
| 106 |
info_col1, info_col2 = st.columns(2)
|
| 107 |
|
| 108 |
if year == 2008:
|
| 109 |
tr_text = "🇹🇷 2008'de altın güvenli limandır, alım faydalıdır."
|
| 110 |
us_text = "🇺🇸 Gold is a safe haven in 2008; buying is beneficial."
|
| 111 |
-
|
|
|
|
| 112 |
else:
|
| 113 |
tr_text = f"🇹🇷 {year} yılı verileri istikrarlı görünüyor. Teknik analiz önerilir."
|
| 114 |
us_text = f"🇺🇸 Data for {year} appears stable. Technical analysis recommended."
|
|
|
|
| 115 |
border_color = "#28A745" # Yeşil çizgi
|
| 116 |
|
| 117 |
-
tr_msg = f"<div style='background-color:
|
| 118 |
-
us_msg = f"<div style='background-color:
|
| 119 |
|
| 120 |
with info_col1:
|
| 121 |
st.markdown(tr_msg, unsafe_allow_html=True)
|
|
@@ -124,24 +129,24 @@ with info_col2:
|
|
| 124 |
|
| 125 |
st.divider()
|
| 126 |
|
| 127 |
-
# 6. GRAFİKLER (
|
| 128 |
st.markdown(f"## 📈 {year} Piyasa Hareketi / Market Action")
|
| 129 |
|
| 130 |
-
# Ana Grafik (
|
| 131 |
fig1 = go.Figure()
|
| 132 |
fig1.add_trace(go.Scatter(x=filtered_df['Date'], y=filtered_df['GLD'],
|
| 133 |
mode='lines',
|
| 134 |
-
line=dict(color='#FFD700', width=3), # Siyah
|
| 135 |
fill='tozeroy', fillcolor='rgba(255, 215, 0, 0.08)')) # Hafif dolgu
|
| 136 |
|
| 137 |
fig1.update_layout(template="plotly_dark", height=480, # Koyu şablon
|
| 138 |
-
paper_bgcolor='
|
| 139 |
title=f"{year} Altın Fiyat Hareketi | Alan Analizi",
|
| 140 |
xaxis_title="Tarih / Date", yaxis_title="GLD Fiyatı / Price",
|
| 141 |
-
margin=dict(l=
|
| 142 |
font=dict(color="#F8F9FA")) # Eksen yazıları beyaz
|
| 143 |
-
fig1.update_xaxes(showgrid=False)
|
| 144 |
-
fig1.update_yaxes(showgrid=True, gridcolor='#222222') #
|
| 145 |
|
| 146 |
st.plotly_chart(fig1, use_container_width=True)
|
| 147 |
|
|
@@ -155,9 +160,9 @@ with c1:
|
|
| 155 |
st.markdown("### 🎯 Dağılım / Distribution")
|
| 156 |
# Histogram (image_2.png Renkleri)
|
| 157 |
fig2 = px.histogram(filtered_df, x="GLD", nbins=25,
|
| 158 |
-
marginal="rug", color_discrete_sequence=['#FFD700'], # Siyah zemin üzerine sarı
|
| 159 |
template="plotly_dark")
|
| 160 |
-
fig2.update_layout(height=380, font=dict(color="#F8F9FA"), paper_bgcolor='
|
| 161 |
fig2.update_xaxes(title="GLD Fiyatı", showgrid=False)
|
| 162 |
st.plotly_chart(fig2, use_container_width=True)
|
| 163 |
|
|
@@ -167,14 +172,14 @@ with c2:
|
|
| 167 |
num_df = filtered_df.select_dtypes(include=['number']).corr()
|
| 168 |
fig3 = px.imshow(num_df, text_auto=True, color_continuous_scale='YlOrRd', # Sarı-Turuncu-Kırmızı
|
| 169 |
template="plotly_dark")
|
| 170 |
-
fig3.update_layout(height=380, font=dict(color="#F8F9FA"), paper_bgcolor='
|
| 171 |
st.plotly_chart(fig3, use_container_width=True)
|
| 172 |
|
| 173 |
st.divider()
|
| 174 |
|
| 175 |
# 7. VERİ TABLOSU (Her Zaman Açık, Temiz ve Net)
|
| 176 |
st.markdown("### 📋 Detaylı Veri Seti / Detailed Dataset")
|
| 177 |
-
#
|
| 178 |
st.dataframe(filtered_df.head(15), use_container_width=True)
|
| 179 |
|
| 180 |
csv = filtered_df.to_csv(index=False).encode('utf-8')
|
|
|
|
| 7 |
# 1. SAYFA AYARLARI VE ÖZEL TASARIM (CSS)
|
| 8 |
st.set_page_config(layout="wide", page_title="Gold Intelligence Dashboard")
|
| 9 |
|
| 10 |
+
# İstediğin "Aydınlık Arka Plan + Koyu Grafikler" Tasarımı için CSS
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
| 13 |
+
/* 1. Sayfa Arka Planını Aydınlık Yapalım (White) */
|
| 14 |
.stApp {
|
| 15 |
+
background-color: #FFFFFF;
|
| 16 |
+
color: #1A1A1A; /* Temel yazı rengi koyu */
|
| 17 |
}
|
| 18 |
|
| 19 |
+
/* 2. Aydınlık Fondaki Başlıkların Renkleri */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
h1.main-title {
|
| 21 |
+
color: #B28F2D !important; /* Premium Koyu Altın */
|
| 22 |
+
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
|
| 23 |
+
}
|
| 24 |
+
h2, h3, h4, p, span, div, li {
|
| 25 |
+
color: #1A1A1A !important;
|
| 26 |
}
|
| 27 |
|
| 28 |
+
/* 3. Metrik Değerlerini Kocaman ve Kalın Yapalım (Ferah Fondan Bağımsız) */
|
| 29 |
[data-testid="stMetricValue"] {
|
| 30 |
+
font-size: 60px !important; /* Değeri kocaman yap */
|
| 31 |
font-weight: 900 !important; /* En kalın yazı */
|
| 32 |
+
color: #B28F2D !important; /* Rakamlar koyu altın sarısı */
|
| 33 |
+
letter-spacing: -2px; /* Harf aralarını daralt, şık durur */
|
| 34 |
}
|
| 35 |
|
| 36 |
+
/* 4. Metrik Etiketlerini (Label) de Netleştirelim */
|
| 37 |
[data-testid="stMetricLabel"] p {
|
| 38 |
font-size: 18px !important;
|
| 39 |
+
color: #4A4A4A !important;
|
| 40 |
margin-bottom: -10px !important;
|
| 41 |
}
|
| 42 |
|
| 43 |
+
/* 5. GRAFİKLERİ ÇEVRELEYEN KOYU ALANLAR (Paylaştığın Örnekteki Gibi) */
|
| 44 |
.plot-container {
|
| 45 |
+
background-color: #000000; /* Grafik arka planı tam siyah */
|
| 46 |
+
border-radius: 12px;
|
| 47 |
+
box-shadow: 0 6px 10px rgba(0,0,0,0.2);
|
| 48 |
+
padding: 15px;
|
| 49 |
+
border: 2px solid #222222; /* Hafif bir çerçeve */
|
| 50 |
+
margin-bottom: 20px;
|
| 51 |
}
|
| 52 |
+
|
| 53 |
+
/* 6. SideBar (Sol Panel) Ferah Kalsın */
|
| 54 |
.css-163utfM, .css-hxt7ib {
|
| 55 |
+
background-color: #F8F9FA !important;
|
| 56 |
+
border-right: 1px solid #E0E0E0;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/* 7. Grafik İçindeki Yazıların Beyaz Kalmasını Garanti Altına Alalım */
|
| 60 |
+
.plot-container g.g-xtitle, .plot-container g.g-ytitle, .plot-container g.g-title {
|
| 61 |
+
fill: #F8F9FA !important;
|
| 62 |
}
|
| 63 |
|
| 64 |
</style>
|
|
|
|
| 81 |
st.stop()
|
| 82 |
|
| 83 |
# 3. SIDEBAR
|
| 84 |
+
st.sidebar.markdown("<h2 style='color: #B28F2D;'>📅 Filtreler</h2>", unsafe_allow_html=True)
|
| 85 |
years_list = sorted([y for y in df['YEAR'].unique() if y >= 2008])
|
| 86 |
year = st.sidebar.selectbox("Yıl Seçin / Select Year", options=years_list, index=0)
|
| 87 |
|
| 88 |
filtered_df = df[df['YEAR'] == year].copy()
|
| 89 |
|
| 90 |
# 4. ANA BAŞLIK
|
|
|
|
| 91 |
st.markdown("<h1 class='main-title' style='text-align: center; font-size: 45px;'>💰 Gold Price Intelligence</h1>", unsafe_allow_html=True)
|
| 92 |
+
st.markdown("<p style='text-align: center; color: #4A4A4A;'>Altın Fiyat Analizi ve Stratejik Öngörü Paneli</p>", unsafe_allow_html=True)
|
| 93 |
st.divider()
|
| 94 |
|
| 95 |
+
# 📈 METRİK KARTLARI (KOCAMAN VE KALIN - AYDINLIK FONDAN PARLAR)
|
| 96 |
m1, m2, m3 = st.columns(3)
|
| 97 |
with m1:
|
|
|
|
| 98 |
current_price = filtered_df['GLD'].iloc[-1]
|
| 99 |
st.metric(label="Son Kapanış Fiyatı (GLD)", value=f"{current_price:.2f}")
|
| 100 |
with m2:
|
| 101 |
+
st.metric(label=f"{year} Tepe Noktası", value=f"{filtered_df['GLD'].max():.2f}")
|
| 102 |
with m3:
|
| 103 |
+
st.metric(label=f"{year} Dip Noktası", value=f"{filtered_df['GLD'].min():.2f}")
|
| 104 |
|
| 105 |
st.divider()
|
| 106 |
|
| 107 |
+
# 5. YÖNETİCİ BİLGİ NOTU (FERAH FONDAN NET OKUNUR)
|
| 108 |
st.markdown("## 💼 Yönetici Bilgi Notu / Executive Summary")
|
| 109 |
info_col1, info_col2 = st.columns(2)
|
| 110 |
|
| 111 |
if year == 2008:
|
| 112 |
tr_text = "🇹🇷 2008'de altın güvenli limandır, alım faydalıdır."
|
| 113 |
us_text = "🇺🇸 Gold is a safe haven in 2008; buying is beneficial."
|
| 114 |
+
box_color = "#FFF8E1" # Çok açık altın sarısı kutu
|
| 115 |
+
border_color = "#B28F2D" # Koyu Altın sarısı çizgi
|
| 116 |
else:
|
| 117 |
tr_text = f"🇹🇷 {year} yılı verileri istikrarlı görünüyor. Teknik analiz önerilir."
|
| 118 |
us_text = f"🇺🇸 Data for {year} appears stable. Technical analysis recommended."
|
| 119 |
+
box_color = "#E8F5E9" # Çok açık yeşil kutu
|
| 120 |
border_color = "#28A745" # Yeşil çizgi
|
| 121 |
|
| 122 |
+
tr_msg = f"<div style='background-color: {box_color}; padding: 25px; border-left: 6px solid {border_color}; border-radius: 8px;'> <h3 style='margin:0; color: #1A1A1A;'>{tr_text}</h3> </div>"
|
| 123 |
+
us_msg = f"<div style='background-color: {box_color}; padding: 25px; border-left: 6px solid {border_color}; border-radius: 8px;'> <h3 style='margin:0; color: #1A1A1A;'>{us_text}</h3> </div>"
|
| 124 |
|
| 125 |
with info_col1:
|
| 126 |
st.markdown(tr_msg, unsafe_allow_html=True)
|
|
|
|
| 129 |
|
| 130 |
st.divider()
|
| 131 |
|
| 132 |
+
# 6. GRAFİKLER (PAYLAŞTIĞIN ÖRNEKLERDEKİ GİBİ SİYAH ÇERÇEVELİ)
|
| 133 |
st.markdown(f"## 📈 {year} Piyasa Hareketi / Market Action")
|
| 134 |
|
| 135 |
+
# Ana Grafik (Zaman Serisi - image_1.png Renkleri)
|
| 136 |
fig1 = go.Figure()
|
| 137 |
fig1.add_trace(go.Scatter(x=filtered_df['Date'], y=filtered_df['GLD'],
|
| 138 |
mode='lines',
|
| 139 |
+
line=dict(color='#FFD700', width=3), # Siyah çerçeve içinde net sarı
|
| 140 |
fill='tozeroy', fillcolor='rgba(255, 215, 0, 0.08)')) # Hafif dolgu
|
| 141 |
|
| 142 |
fig1.update_layout(template="plotly_dark", height=480, # Koyu şablon
|
| 143 |
+
paper_bgcolor='#000000', plot_bgcolor='#000000', # Grafik içi tam siyah
|
| 144 |
title=f"{year} Altın Fiyat Hareketi | Alan Analizi",
|
| 145 |
xaxis_title="Tarih / Date", yaxis_title="GLD Fiyatı / Price",
|
| 146 |
+
margin=dict(l=40, r=40, t=60, b=40),
|
| 147 |
font=dict(color="#F8F9FA")) # Eksen yazıları beyaz
|
| 148 |
+
fig1.update_xaxes(showgrid=False)
|
| 149 |
+
fig1.update_yaxes(showgrid=True, gridcolor='#222222') # Çok hafif ızgara
|
| 150 |
|
| 151 |
st.plotly_chart(fig1, use_container_width=True)
|
| 152 |
|
|
|
|
| 160 |
st.markdown("### 🎯 Dağılım / Distribution")
|
| 161 |
# Histogram (image_2.png Renkleri)
|
| 162 |
fig2 = px.histogram(filtered_df, x="GLD", nbins=25,
|
| 163 |
+
marginal="rug", color_discrete_sequence=['#FFD700'], # Siyah zemin üzerine sarı
|
| 164 |
template="plotly_dark")
|
| 165 |
+
fig2.update_layout(height=380, font=dict(color="#F8F9FA"), paper_bgcolor='#000000', plot_bgcolor='#000000')
|
| 166 |
fig2.update_xaxes(title="GLD Fiyatı", showgrid=False)
|
| 167 |
st.plotly_chart(fig2, use_container_width=True)
|
| 168 |
|
|
|
|
| 172 |
num_df = filtered_df.select_dtypes(include=['number']).corr()
|
| 173 |
fig3 = px.imshow(num_df, text_auto=True, color_continuous_scale='YlOrRd', # Sarı-Turuncu-Kırmızı
|
| 174 |
template="plotly_dark")
|
| 175 |
+
fig3.update_layout(height=380, font=dict(color="#F8F9FA"), paper_bgcolor='#000000', plot_bgcolor='#000000')
|
| 176 |
st.plotly_chart(fig3, use_container_width=True)
|
| 177 |
|
| 178 |
st.divider()
|
| 179 |
|
| 180 |
# 7. VERİ TABLOSU (Her Zaman Açık, Temiz ve Net)
|
| 181 |
st.markdown("### 📋 Detaylı Veri Seti / Detailed Dataset")
|
| 182 |
+
# Beyaz modda tablo verileri otomatik net ve okunur.
|
| 183 |
st.dataframe(filtered_df.head(15), use_container_width=True)
|
| 184 |
|
| 185 |
csv = filtered_df.to_csv(index=False).encode('utf-8')
|