Spaces:
Sleeping
Sleeping
File size: 4,815 Bytes
5dfb440 e8712f9 ebcbda5 cef78e9 a4deb7f cef78e9 d74f542 f789148 3c72aa3 cef78e9 a4deb7f d74f542 a4deb7f d74f542 a4deb7f d74f542 70d855c d74f542 70d855c d74f542 a4deb7f d74f542 a4deb7f d74f542 a4deb7f cef78e9 e8712f9 ebcbda5 ec2f725 e8712f9 663e322 85691dd 2aa88ae e8712f9 663e322 ebcbda5 663e322 e8712f9 70d855c 3c72aa3 e8712f9 d74f542 85691dd e8712f9 d74f542 e8712f9 d74f542 a4deb7f d74f542 a4deb7f 3c72aa3 a4deb7f 3c72aa3 e8712f9 d74f542 cef78e9 d74f542 cef78e9 d74f542 cef78e9 d74f542 ebcbda5 d74f542 ebcbda5 d74f542 cef78e9 d74f542 f789148 d74f542 a4deb7f d74f542 f789148 d74f542 f789148 d74f542 f789148 d74f542 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 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
@st.cache_data(show_spinner=False)
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') |