Quotex Demo To Real Code Review

import time import logging from quotexapi import Quotex ASSET = "EURUSD_otc" AMOUNT_PERCENT = 2 # % of balance per trade RSI_PERIOD = 14 RSI_OVERSOLD = 30 RSI_OVERBOUGHT = 70 MAX_DAILY_TRADES = 20 STOP_LOSS_DAILY = -5 # -5% stop ========= STATE ========= class TradingState: def init (self): self.daily_trades = 0 self.daily_pnl = 0.0 self.initial_balance = 0.0

state = TradingState() def calculate_rsi(prices, period=14): deltas = [prices[i] - prices[i-1] for i in range(1, len(prices))] gains = [d if d > 0 else 0 for d in deltas] losses = [-d if d < 0 else 0 for d in deltas]

if 9 <= current_hour < 17: rsi = calculate_rsi(prices, 14) if rsi < 30 and no_open_trade: place_trade("CALL", amount=2% of balance) elif rsi > 70 and no_open_trade: place_trade("PUT", amount=2% of balance) Use Python (pandas, numpy) to simulate 1000+ trades. Step 3 – Demo-forward with same code Run your bot on a demo account for identical logic . Step 4 – Real-money switchover Change one line: quotex demo to real code

# ---------- SWITCH THIS LINE ---------- client.account_type = "real" # ← "demo" or "real" # --------------------------------------

avg_gain = sum(gains[-period:]) / period avg_loss = sum(losses[-period:]) / period import time import logging from quotexapi import Quotex

Write it as pseudo-code first:

if consecutive_losses >= MAX_CONSECUTIVE_LOSSES: logging.warning("3 losses in a row. Switching to demo mode for 1 hour.") client.account_type = "demo" time.sleep(3600) client.account_type = "real" | Phase | Duration | Account | Goal | |-------|----------|---------|------| | 1 | 1 month | Demo | Perfect execution, no manual override | | 2 | 1 month | Demo | Introduce small errors (simulate slippage) | | 3 | 1 month | Demo | Run 24/7 without restart | | 4 | 2 weeks | Real (min $50) | Only 0.5% risk per trade | | 5 | 1 month | Real | Scale to 1–2% risk | Switching to demo mode for 1 hour

if avg_loss == 0: return 100 rs = avg_gain / avg_loss return 100 - (100 / (1 + rs)) def should_trade(rsi): if rsi < RSI_OVERSOLD: return "CALL" elif rsi > RSI_OVERBOUGHT: return "PUT" return None ========= MAIN LOOP (LIVE READY) ========= def run_live_bot(): client = Quotex(email="your@email.com", password="your_pass", lang="en")

client.connect() balance = client.get_balance() state.initial_balance = balance logging.info(f"Started with balance: $balance:.2f (client.account_type)")