File size: 3,775 Bytes
c143da8 a0b696b c143da8 a0b696b 43d7e82 09eacf2 c143da8 43d7e82 9454eb7 43d7e82 d50e982 9454eb7 c143da8 9454eb7 d50e982 45190ba 43d7e82 45190ba 55fde70 45190ba 43d7e82 d50e982 43d7e82 55fde70 45190ba 43d7e82 45190ba 09eacf2 45190ba c143da8 43d7e82 45190ba 9454eb7 45190ba 09eacf2 45190ba 43d7e82 09eacf2 43d7e82 09eacf2 43d7e82 09eacf2 43d7e82 09eacf2 43d7e82 | 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 | import streamlit as st
import requests
import pandas as pd
import matplotlib.pyplot as plt
# 1. Sayfa Ayarı
st.set_page_config(page_title="Fatih Han Pro", layout="wide")
# 2. CSS: Başlık ve Panel Sabitleme
st.markdown("""
<style>
.block-container { padding-top: 3.5rem !important; }
h1 { line-height: 1.8 !important; padding-bottom: 15px !important; }
[data-testid="column"]:nth-child(2) { flex: 0 0 360px !important; min-width: 360px !important; }
.stTabs [data-baseweb="tab-list"] { gap: 10px; }
.stTabs [data-baseweb="tab"] {
height: 40px;
background-color: #313244;
border-radius: 5px;
color: white;
padding: 0px 20px;
}
</style>
""", unsafe_allow_html=True)
@st.cache_data(ttl=600)
def verileri_cek():
url = "https://api.exchangerate-api.com/v4/latest/TRY"
try:
oranlar = requests.get(url).json()["rates"]
isimler = {
"USD": "Amerikan Doları", "EUR": "Euro", "GBP": "İngiliz Sterlini",
"KWD": "Kuveyt Dinarı", "BHD": "Bahreyn Dinarı", "OMR": "Umman Riyali",
"JOD": "Ürdün Dinarı", "CHF": "İsviçre Frangı", "CAD": "Kanada Doları",
"AUD": "Avustralya Doları", "SAR": "Suudi Riyali", "AED": "B.A.E Dirhemi",
"QAR": "Katar Riyali", "JPY": "Japon Yeni", "RUB": "Rus Rublesi",
"AZN": "Azerbaycan Manatı", "IQD": "Irak Dinarı", "NOK": "Norveç Kronu"
}
return pd.DataFrame([{"Kod": k, "Isim": isimler.get(k, f"{k} Birimi"), "Fiyat": round(1/v, 4)} for k, v in oranlar.items() if v != 0])
except: return pd.DataFrame(columns=["Kod", "Isim", "Fiyat"])
if 'filtre' not in st.session_state: st.session_state.filtre = "Hepsi"
df_ana = verileri_cek()
st.title("📊 PİYASA TERMİNALİ V9.3")
# --- Kontroller ---
c1, c2, c3, c_search = st.columns([1, 1, 1, 3])
if c1.button("🏠 Hepsi"): st.session_state.filtre = "Hepsi"
if c2.button("⭐ Popüler"): st.session_state.filtre = "Populer"
if c3.button("📈 Değerli"): st.session_state.filtre = "Pahali"
arama = c_search.text_input("", placeholder="🔍 Ara...", label_visibility="collapsed").upper()
df_goster = df_ana.copy()
if arama: df_goster = df_goster[df_goster['Kod'].str.contains(arama) | df_goster['Isim'].str.upper().contains(arama)]
if st.session_state.filtre == "Populer":
df_goster = df_goster[df_goster['Kod'].isin(["USD", "EUR", "GBP", "CHF", "KWD", "SAR", "AZN", "JPY"])]
elif st.session_state.filtre == "Pahali":
df_goster = df_goster.sort_values(by="Fiyat", ascending=False)
# --- Ana Gövde ---
sol, sag = st.columns([7, 3])
with sol:
st.dataframe(df_goster, use_container_width=True, height=580, hide_index=True)
with sag:
with st.container(border=True):
st.subheader("⚙️ İşlem Merkezi")
secili_kod = st.selectbox("Döviz Seç", df_goster['Kod'].tolist(), key="sb_v93")
secili_satir = df_goster[df_goster['Kod'] == secili_kod].iloc[0]
fiyat = secili_satir['Fiyat']
# --- SEKMELİ YAPI (TİTREMEYİ VE KARIŞIKLIĞI ÖNLER) ---
tab1, tab2 = st.tabs(["🧮 Hesapla", "📈 Grafik"])
with tab1:
st.write(f"**{secili_satir['Isim']}**")
miktar = st.number_input("Miktar (₺)", value=100.0)
st.success(f"{round(miktar/fiyat, 2)} {secili_kod}")
with tab2:
fig, ax = plt.subplots(figsize=(4, 3))
fig.patch.set_facecolor('#0e1117')
ax.set_facecolor('#1e1e2e')
y = [fiyat*0.99, fiyat*1.01, fiyat*0.98, fiyat*1.02, fiyat]
ax.plot(["-4", "-3", "-2", "-1", "Bugün"], y, color='#cba6f7', marker='o')
ax.tick_params(colors='white', labelsize=7)
plt.tight_layout()
st.pyplot(fig) |