ESMATUGBA commited on
Commit
81562bc
·
verified ·
1 Parent(s): 32c16db

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +33 -20
src/streamlit_app.py CHANGED
@@ -31,37 +31,41 @@ def load_data():
31
 
32
  df = load_data()
33
 
 
 
 
 
34
  # 3. SIDEBAR
35
  st.sidebar.header("📅 Filtreler / Filters")
36
  year = st.sidebar.selectbox("Yıl Seçin / Select Year", options=sorted(df['YEAR'].unique(), reverse=True))
37
  filtered_df = df[df['YEAR'] == year].copy()
38
 
39
- # 4. ANA BAŞLIK
40
- st.markdown(f"<h1 style='text-align: center; color: #333;'>Gold Price Analysis / {year} Analizi</h1>", unsafe_allow_html=True)
41
  st.divider()
42
 
43
- # 5. YÖNETİCİ BİLGİ NOTU (Paylaştığın görseldeki gibi)
44
  st.markdown("### 💼 Yönetici Bilgi Notu / Executive Summary")
45
  col1, col2 = st.columns(2)
46
  with col1:
47
  if year == 2008:
48
- st.warning("**TR:** 2008'de altın güvenli limandır, alım faydalıdır.")
49
  else:
50
- st.success(f"**TR:** {year} yılı verileri istikrarlı görünüyor.")
51
  with col2:
52
  if year == 2008:
53
- st.warning("**US:** Gold is a safe haven in 2008; buying is beneficial.")
54
  else:
55
- st.success(f"**US:** Data for {year} appears stable.")
56
 
57
  st.divider()
58
 
59
- # 6. ANA GRAFİK (image_995583.png görselindeki gibi tek ince çizgi)
60
- st.markdown(f"#### 📈 {year} Altın Fiyat Hareketi")
61
  fig1 = go.Figure()
62
  fig1.add_trace(go.Scatter(x=filtered_df['Date'], y=filtered_df['GLD'],
63
  mode='lines',
64
- line=dict(color='gold', width=2))) # İnce ve net tek çizgi
65
  fig1.update_layout(
66
  template="plotly_dark", paper_bgcolor='black', plot_bgcolor='black',
67
  height=400, margin=dict(l=40, r=40, t=20, b=40),
@@ -70,26 +74,35 @@ fig1.update_layout(
70
  )
71
  st.plotly_chart(fig1, use_container_width=True)
72
 
73
- st.markdown(f"📝 *Not: Bu grafik {year} yılındaki günlük fiyat hareketlerini gösterir.*")
 
 
74
  st.divider()
75
 
76
- # 7. YAN YANA GRAFİKLER (image_98dcc5.png görselindeki gibi)
77
  c1, c2 = st.columns(2)
78
 
79
  with c1:
80
  st.markdown("#### 🎯 Dağılım / Distribution")
81
  fig2 = px.histogram(filtered_df, x="GLD", nbins=30, color_discrete_sequence=['gold'], template="plotly_dark")
82
- fig2.update_layout(paper_bgcolor='black', plot_bgcolor='black', height=350, margin=dict(l=20,r=20,t=20,b=20))
83
  st.plotly_chart(fig2, use_container_width=True)
 
84
 
85
  with c2:
86
  st.markdown("#### 🌡️ Korelasyon / Correlation")
87
- num_df = filtered_df.select_dtypes(include=['number']).drop(columns=['YEAR'], errors='ignore')
88
- fig3 = px.imshow(num_df.corr(), text_auto=".2f", color_continuous_scale='YlOrRd', template="plotly_dark")
89
- fig3.update_layout(paper_bgcolor='black', plot_bgcolor='black', height=350, margin=dict(l=20,r=20,t=20,b=20))
90
  st.plotly_chart(fig3, use_container_width=True)
 
 
 
 
 
 
 
91
 
92
- # 8. VERİ TABLOSU (image_995886.png görselindeki gibi)
93
- with st.expander("Verileri Gör / View Data"):
94
- st.dataframe(filtered_df.head(), use_container_width=True)
95
- st.download_button("📥 İndir / Download", data=filtered_df.to_csv(index=False), file_name=f'gold_{year}.csv')
 
31
 
32
  df = load_data()
33
 
34
+ if df is None:
35
+ st.error("Veri dosyası bulunamadı!")
36
+ st.stop()
37
+
38
  # 3. SIDEBAR
39
  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 (İstediğin Şekilde Güncellendi)
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 (Önerilerinle Güncellendi)
48
  st.markdown("### 💼 Yönetici Bilgi Notu / Executive Summary")
49
  col1, col2 = st.columns(2)
50
  with col1:
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 col2:
56
  if year == 2008:
57
+ st.warning("### 🇺🇸 Gold is a safe haven in 2008; buying is beneficial.")
58
  else:
59
+ st.success(f"### 🇺🇸 Data for {year} appears stable, monitor technical levels.")
60
 
61
  st.divider()
62
 
63
+ # 6. ANA GRAFİK (Tek İnce Çizgi ve Altında Yorum)
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'],
67
  mode='lines',
68
+ line=dict(color='gold', width=2)))
69
  fig1.update_layout(
70
  template="plotly_dark", paper_bgcolor='black', plot_bgcolor='black',
71
  height=400, margin=dict(l=40, r=40, t=20, b=40),
 
74
  )
75
  st.plotly_chart(fig1, use_container_width=True)
76
 
77
+ # Grafik Altı Yorumu
78
+ st.info(f"💡 **Analiz Yorumu:** {year} yılında altın fiyatları zaman serisi bazında incelendiğinde, piyasanın trend yönü ve volatilite aralığı net bir şekilde görülmektedir.")
79
+
80
  st.divider()
81
 
82
+ # 7. YAN YANA GRAFİKLER VE YORUMLARI
83
  c1, c2 = st.columns(2)
84
 
85
  with c1:
86
  st.markdown("#### 🎯 Dağılım / Distribution")
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.caption(f"📍 **Dağılım Notu:** Fiyatların {year} yılı içerisinde hangi seviyelerde yoğunlaştığını gösterir.")
91
 
92
  with c2:
93
  st.markdown("#### 🌡️ Korelasyon / Correlation")
94
+ numeric_df = filtered_df.select_dtypes(include=['number']).drop(columns=['YEAR'], errors='ignore')
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.caption("📍 **Korelasyon Notu:** Altın fiyatının diğer piyasa enstrümanları ile ilişkisini gösterir.")
99
+
100
+ st.divider()
101
+
102
+ # 8. VERİ TABLOSU (Tıklamadan Doğrudan Açık Kalacak Şekilde Düzenlendi)
103
+ st.markdown("### 📋 Verileri Gör / View Data")
104
+ st.dataframe(filtered_df, use_container_width=True)
105
 
106
+ # İndirme Butonu Tablonun Altında
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')