Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import plotly.express as px | |
| import plotly.graph_objects as go | |
| # 1. SAYFA AYARLARI VE ÖZEL TASARIM (CSS) | |
| st.set_page_config(layout="wide", page_title="Gold Intelligence Dashboard") | |
| st.markdown(""" | |
| <style> | |
| /* 1. Aydınlık Arka Plan */ | |
| .stApp { | |
| background-color: #FFFFFF; | |
| } | |
| /* 2. Metrik Değerlerini Kocaman ve Kalın Yap (İsteğin Üzerine) */ | |
| [data-testid="stMetricValue"] { | |
| font-size: 70px !important; | |
| font-weight: 900 !important; | |
| color: #B28F2D !important; | |
| line-height: 1.2; | |
| } | |
| /* 3. Metrik Etiketleri */ | |
| [data-testid="stMetricLabel"] p { | |
| font-size: 20px !important; | |
| color: #333333 !important; | |
| font-weight: bold !important; | |
| } | |
| /* 4. GRAFİK KUTULARI (Siyah Çerçeve ve Gölge) */ | |
| .plot-container { | |
| background-color: #000000; | |
| border-radius: 15px; | |
| padding: 20px; | |
| box-shadow: 0 8px 16px rgba(0,0,0,0.2); | |
| border: 1px solid #333333; | |
| } | |
| /* 5. Yazı Renklerini Sabitle */ | |
| h1, h2, h3, h4, p, span { | |
| color: #1A1A1A !important; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # 2. VERİ YÜKLEME | |
| def load_data(): | |
| df = pd.read_csv("gold_feature_engineered.csv") | |
| date_col = next((col for col in df.columns if col.lower() == 'date'), df.columns[0]) | |
| df[date_col] = pd.to_datetime(df[date_col]) | |
| df['YEAR'] = df[date_col].dt.year | |
| df = df.rename(columns={date_col: 'Date'}) | |
| return df | |
| try: | |
| df = load_data() | |
| except Exception as e: | |
| st.error(f"Veri yükleme hatası: {e}") | |
| st.stop() | |
| # 3. SIDEBAR | |
| st.sidebar.markdown("<h2 style='color: #B28F2D;'>📅 Filtreler</h2>", unsafe_allow_html=True) | |
| years_list = sorted([y for y in df['YEAR'].unique() if y >= 2008]) | |
| year = st.sidebar.selectbox("Yıl Seçin", options=years_list, index=0) | |
| filtered_df = df[df['YEAR'] == year].copy() | |
| # 4. ANA BAŞLIK (Tam İstediğin Şekilde) | |
| st.markdown("<h1 style='text-align: center; color: #B28F2D; font-size: 42px;'>💰 Gold Price Intelligence / Altın Fiyat Analizi ve Stratejik Öngörü Paneli</h1>", unsafe_allow_html=True) | |
| st.divider() | |
| # 📈 METRİK KARTLARI (DEVASA BOYUT) | |
| m1, m2, m3 = st.columns(3) | |
| with m1: | |
| st.metric(label="Son Kapanış Fiyatı (GLD)", value=f"{filtered_df['GLD'].iloc[-1]:.2f}") | |
| with m2: | |
| st.metric(label=f"{year} Tepe Noktası", value=f"{filtered_df['GLD'].max():.2f}") | |
| with m3: | |
| st.metric(label=f"{year} Dip Noktası", value=f"{filtered_df['GLD'].min():.2f}") | |
| st.divider() | |
| # 5. YÖNETİCİ BİLGİ NOTU | |
| st.markdown("## 💼 Yönetici Bilgi Notu / Executive Summary") | |
| info_col1, info_col2 = st.columns(2) | |
| box_style = "padding: 20px; border-left: 8px solid #B28F2D; background-color: #F9F9F9; border-radius: 10px;" | |
| with info_col1: | |
| st.markdown(f"<div style='{box_style}'><h3>🇹🇷 {year} yılı verileri teknik analiz için uygundur.</h3></div>", unsafe_allow_html=True) | |
| with info_col2: | |
| st.markdown(f"<div style='{box_style}'><h3>🇺🇸 Data for {year} is suitable for technical analysis.</h3></div>", unsafe_allow_html=True) | |
| st.divider() | |
| # 6. GRAFİKLER (GENİŞ VE KOYU KUTULU) | |
| st.markdown(f"## 📈 {year} Piyasa Analizi") | |
| # ANA GRAFİK (TAM GENİŞLİK) | |
| fig1 = go.Figure() | |
| fig1.add_trace(go.Scatter(x=filtered_df['Date'], y=filtered_df['GLD'], | |
| line=dict(color='#FFD700', width=3), | |
| fill='tozeroy', fillcolor='rgba(255, 215, 0, 0.1)')) | |
| fig1.update_layout(template="plotly_dark", paper_bgcolor='black', plot_bgcolor='black', height=500, margin=dict(l=20,r=20,t=20,b=20)) | |
| st.plotly_chart(fig1, use_container_width=True) | |
| st.write("") # Boşluk | |
| # YAN YANA GRAFİKLER (GENİŞLETİLMİŞ) | |
| c1, c2 = st.columns(2) | |
| with c1: | |
| st.markdown("### 🎯 Dağılım / Distribution") | |
| fig2 = px.histogram(filtered_df, x="GLD", nbins=30, color_discrete_sequence=['#FFD700'], template="plotly_dark") | |
| fig2.update_layout(paper_bgcolor='black', plot_bgcolor='black', height=450) | |
| st.plotly_chart(fig2, use_container_width=True) | |
| with c2: | |
| st.markdown("### 🌡️ Korelasyon / Correlation") | |
| num_df = filtered_df.select_dtypes(include=['number']).corr() | |
| fig3 = px.imshow(num_df, text_auto=True, color_continuous_scale='YlOrRd', template="plotly_dark") | |
| fig3.update_layout(paper_bgcolor='black', plot_bgcolor='black', height=450) | |
| st.plotly_chart(fig3, use_container_width=True) | |
| st.divider() | |
| # 7. DETAYLI VERİ SETİ (KAPALI - TIKLAYINCA AÇILIR) | |
| with st.expander("📋 Detaylı Veri Seti / Detailed Dataset"): | |
| st.dataframe(filtered_df, use_container_width=True) | |
| csv = filtered_df.to_csv(index=False).encode('utf-8') | |
| st.download_button("📥 Veriyi İndir (CSV)", data=csv, file_name=f'altin_verisi_{year}.csv') |