import streamlit as st import websocket import json import threading import time from collections import deque, Counter import pandas as pd import plotly.express as px st.set_page_config(page_title="ProfitPlusPro Clone - Deriv AI Matches Predictor", layout="wide") st.title("­Ъџђ Profit Plus Pro Clone - Deriv AI Matches Predictor") st.markdown("**Real-time AI predictions for Deriv Digit Matches (last digit 0-9)** | Free & Open Source") # Sidebar with st.sidebar: st.header("Settings") app_id = st.text_input("Deriv App ID", value="12345", help="Get free App ID at https://developers.deriv.com/") symbol = st.selectbox("Symbol (Synthetic Index)", ["R_10", "R_25", "R_50", "R_75", "R_100"], index=4) history_length = st.slider("Analysis window (last ticks)", 50, 500, 200) st.info("No login/token needed for tick data.") # Global variables history = deque(maxlen=history_length) ws = None running = False def on_message(ws_app, message): try: data = json.loads(message) if "tick" in data and "quote" in data["tick"]: quote = float(data["tick"]["quote"]) # Last digit for Deriv Digits/Matches contracts (units digit) digit = int(quote) % 10 history.append(digit) except: pass def on_error(ws_app, error): st.error(f"WebSocket Error: {error}") def on_close(ws_app, close_status_code, close_msg): st.warning("Connection closed.") def on_open(ws_app): subscribe_msg = { "ticks": st.session_state.symbol, "subscribe": 1 } ws_app.send(json.dumps(subscribe_msg)) def start_websocket(): global ws, running if running: return running = True uri = f"wss://ws.derivws.com/websockets/v3?app_id={st.session_state.app_id}" ws = websocket.WebSocketApp( uri, on_open=on_open, on_message=on_message, on_error=on_error, on_close=on_close ) threading.Thread(target=ws.run_forever, daemon=True).start() # Session state if "app_id" not in st.session_state: st.session_state.app_id = app_id if "symbol" not in st.session_state: st.session_state.symbol = symbol col1, col2 = st.columns([1, 2]) with col1: st.subheader("Live Status") if st.button("РќХ№ИЈ Start Live Prediction", type="primary"): start_websocket() st.success("Connected to Deriv! Watching ticks...") if st.button("РЈ╣№ИЈ Stop"): if ws: ws.close() running = False st.warning("Stopped") st.metric("Ticks analyzed", len(history)) with col2: if len(history) > 0: last_digit = history[-1] st.success(f"**Latest Tick Digit: {last_digit}**") # AI Prediction Engine if len(history) >= 20: recent = list(history) counter = Counter(recent) # Simple AI: Frequency-based probability (like ProfitPlusPro uses) probs = {d: (count / len(recent)) * 100 for d, count in counter.items()} for d in range(10): if d not in probs: probs[d] = 0.0 df = pd.DataFrame({ "Digit": list(probs.keys()), "Probability (%)": list(probs.values()) }).sort_values("Probability (%)", ascending=False) st.subheader("­ЪДа AI Prediction for Next Matches") top_digit = df.iloc[0]["Digit"] st.markdown(f"**Recommended Matches Digit: {int(top_digit)}** (highest probability)") # Bar chart fig = px.bar(df, x="Digit", y="Probability (%)", text="Probability (%)", color="Probability (%)", color_continuous_scale="Blues") fig.update_layout(height=400) st.plotly_chart(fig, use_container_width=True) st.caption("This AI uses real-time frequency analysis on recent ticks. Hot digits have higher chance in short term (statistical pattern recognition).") # Live History st.subheader("Recent Digits History") if len(history) > 0: df_history = pd.DataFrame({"Digit": list(history)}) st.dataframe(df_history.tail(50), use_container_width=True) else: st.info("Waiting for ticks...") st.caption("Built by Grok as a free alternative to ProfitPlusPro.com | Trading involves risk of loss")