Tradingfather / src /streamlit_app.py
Usman303's picture
Update src/streamlit_app.py
9f4a6bb verified
Raw
History Blame Contribute Delete
3.02 kB
import streamlit as st
import pandas as pd
import numpy as np
import yfinance as yf
import ta
import time
from sklearn.ensemble import GradientBoostingClassifier
st.set_page_config(page_title="Trading Father Empire", page_icon="πŸ‘‘", layout="wide")
st.markdown("<h1 style='text-align: center; color: #FFD700;'>πŸ‘‘ TRADING FATHER: ALGORITHM BREAKER</h1>", unsafe_html=True)
st.markdown("<h3 style='text-align: center; color: #FFFFFF;'>Global Market Maker Matrix & Live Signal Feed</h3>", unsafe_html=True)
WATCH_LIST = {
"Bitcoin (Crypto)": "BTC-USD",
"Ethereum (Crypto)": "ETH-USD",
"Gold (Commodity)": "GC=F",
"NVIDIA (Stock)": "NVDA",
"EUR/USD (Forex)": "EURUSD=X"
}
st.sidebar.header("πŸ‘‘ Trading Father Control Panel")
selected_market = st.sidebar.selectbox("Select Market to Inspect", list(WATCH_LIST.keys()))
ticker = WATCH_LIST[selected_market]
st.subheader(f"πŸ“Š Live Market State: {selected_market} ({ticker})")
try:
df = yf.download(tickers=ticker, period="1d", interval="1m", progress=False)
if not df.empty:
current_price = df['Close'].iloc[-1]
high_price = df['High'].max()
low_price = df['Low'].min()
col1, col2, col3 = st.columns(3)
col1.metric(label="Current Live Price", value=f"${current_price:,.4f}")
col2.metric(label="Today's Highest Point", value=f"${high_price:,.4f}")
col3.metric(label="Today's Lowest Point", value=f"${low_price:,.4f}")
st.line_chart(df['Close'].tail(30))
df['BB_Width'] = (ta.volatility.BollingerBands(df['Close']).bollinger_hband() - ta.volatility.BollingerBands(df['Close']).bollinger_lband()) / df['Close']
df['CMF'] = ta.volume.chaikin_money_flow(df['High'], df['Low'], df['Close'], df['Volume'])
df['ROC'] = ta.momentum.roc(df['Close'], window=5)
df['Target'] = np.where(df['Close'].shift(-1) > df['Close'], 1, 0)
df.dropna(inplace=True)
X = df[['BB_Width', 'CMF', 'ROC']]
y = df['Target']
ai_brain = GradientBoostingClassifier(n_estimators=300, learning_rate=0.05, max_depth=6, random_state=42)
ai_brain.fit(X[:-1], y[:-1])
prediction = ai_brain.predict(X.tail(1))
probability = ai_brain.predict_proba(X.tail(1))[prediction] * 100
st.write("---")
st.subheader("πŸ•΅οΈβ€β™‚οΈ Trading Father Intelligence Feed (Updated Every 60s)")
if probability >= 95.00:
if prediction == 1:
st.success(f"🟒 UP SIGNAL (BUY) DETECTED! Institutional Confidence: {probability:.2f}%")
else:
st.error(f"πŸ”΄ DOWN SIGNAL (SELL) DETECTED! Institutional Confidence: {probability:.2f}%")
else:
st.info(f"⏳ HOLDING - Market Maker Algorithm is in Squeeze Range (AI Confidence: {probability:.2f}%). Waiting for Sniper entry.")
except Exception as e:
st.error(f"Connecting to market data stream... {e}")
time.sleep(60)
st.rerun()