Python · IQ Option · Unofficial API

Python + IQ Option Unofficial API – Honest Guide

Penulis: Tim Editorial · Diperbarui: Mei 2026 · Waktu baca: 15 menit

📌 Yang Anda akan pelajari

  • Python + IQ Option API memungkinkan bot trading binary options
  • Library iqoptionapi (UNOFFICIAL – tidak supported by IQ Option)
  • Cara connect, get balance, dan execute trades programmatically
  • Build bot RSI lengkap dengan stop loss
  • ⚠️ Risk: API dapat di-block atau berubah tanpa notice

🚨 IMPORTANT WARNING

IQ Option tidak memiliki API resmi untuk trader retail. Library yang digunakan adalah reverse-engineered dari komunitas open source.

Implications:

  • Account dapat di-suspend jika IQ Option detect “automated trading”
  • Library dapat berhenti bekerja kapan saja jika IQ Option update internal API
  • Tidak ada support resmi untuk issues
  • Terms of Service IQ Option mungkin melarang penggunaan API tidak resmi

Use at your own risk. Selalu test di Practice account dahulu.

Apa itu IQ Option API unofficial?

IQ Option tidak menyediakan API publik untuk trader retail. Tetapi developer komunitas telah reverse-engineer WebSocket protocol mereka dan menciptakan Python library:

  • iqoptionapi (GitHub: Lu-Yi-Hsun/iqoptionapi)
  • Open source, maintained by community
  • Bekerja dengan stable API IQ Option internal
  • Support: binary options, digital options, forex, crypto

Status legal/ethical:

  • ⚠️ Tidak ada perjanjian resmi dengan IQ Option
  • ⚠️ Penggunaan automated trading mungkin melanggar T&C
  • ⚠️ Akun dapat di-banned tanpa notice

Untuk trading serius dengan API, pertimbangkan broker yang menyediakan API resmi seperti Deriv, OctaFX cTrader, atau IC Markets cTrader.

Setup dan install

Install library:

bash
pip install iqoptionapi

Verify installation:

python
from iqoptionapi.stable_api import IQ_Option
print("✓ Library installed correctly")

Jika error, library mungkin sudah deprecated. Cek GitHub repo untuk versi maintained terbaru.

Connect ke akun

python
from iqoptionapi.stable_api import IQ_Option
import time

# Login credentials
email = "your_email@example.com"
password = "your_password"

# Connect
iq = IQ_Option(email, password)
check, reason = iq.connect()

if check:
    print(f"✓ Connected to IQ Option")
    print(f"Balance: {iq.get_balance()} {iq.get_currency()}")
else:
    print(f"✗ Connection failed: {reason}")
    exit()

# Switch to demo account
iq.change_balance("PRACTICE")  # atau "REAL" untuk real money
print(f"Account type: {iq.get_balance_mode()}")

Yang penting:

  • Gunakan SELALU akun PRACTICE dahulu untuk testing
  • Tidak ada API token – login dengan email/password
  • Credentials harus di-store secure (gunakan .env file)

Buy contracts programmatically

python
# Buy Call (Higher) atau Put (Lower) binary option
asset = "EURUSD-OTC"  # atau "EURUSD" untuk regular hours
amount = 1.0  # USD
duration = 1  # menit
direction = "call"  # "call" untuk Higher, "put" untuk Lower

check, order_id = iq.buy(amount, asset, direction, duration)

if check:
    print(f"✓ Order placed: ID {order_id}")
    
    # Wait for result
    result = iq.check_win_v3(order_id)
    
    if result > 0:
        print(f"🟢 WIN: +${result:.2f}")
    elif result == 0:
        print(f"⚪ EQUAL/REFUND")
    else:
        print(f"🔴 LOSS: -${amount:.2f}")
else:
    print(f"✗ Order failed")

Asset names:

  • EURUSD: Regular hours forex
  • EURUSD-OTC: Over-the-counter (24/7)
  • GBPUSD, USDJPY, AUDUSD: Other major forex
  • BTCUSD-L: Bitcoin
  • ETHUSD-L: Ethereum

Directions:

  • “call”: Higher (Anda predict price akan naik)
  • “put”: Lower (Anda predict price akan turun)

Build RSI bot lengkap

python
from iqoptionapi.stable_api import IQ_Option
import numpy as np
import time

class IQRSIBot:
    def __init__(self, email, password, asset="EURUSD-OTC"):
        self.iq = IQ_Option(email, password)
        self.iq.connect()
        self.iq.change_balance("PRACTICE")  # SELALU MULAI DEMO
        
        self.asset = asset
        self.amount = 1.0
        self.duration = 1  # menit
        self.rsi_period = 14
        self.total_pnl = 0
        self.max_loss = 20  # Stop di $20 loss
        self.trades = 0
        self.wins = 0
    
    def calculate_rsi(self, prices):
        """Calculate RSI dari list of closing prices."""
        if len(prices) < self.rsi_period + 1:
            return None
        
        deltas = np.diff(prices)
        gains = np.where(deltas > 0, deltas, 0)
        losses = np.where(deltas < 0, -deltas, 0)
        
        avg_gain = np.mean(gains[-self.rsi_period:])
        avg_loss = np.mean(losses[-self.rsi_period:])
        
        if avg_loss == 0:
            return 100
        
        rs = avg_gain / avg_loss
        return 100 - (100 / (1 + rs))
    
    def get_candles(self, count=50):
        """Get last N candles dari asset."""
        candles = self.iq.get_candles(self.asset, 60, count, time.time())
        return [c['close'] for c in candles]
    
    def execute_trade(self, direction):
        """Execute trade dan track hasil."""
        check, order_id = self.iq.buy(self.amount, self.asset, direction, self.duration)
        
        if not check:
            print(f"✗ Order failed")
            return
        
        self.trades += 1
        result = self.iq.check_win_v3(order_id)
        
        if result > 0:
            self.wins += 1
            self.total_pnl += result
            print(f"🟢 WIN #{self.wins}/{self.trades}: +${result:.2f}, Total: ${self.total_pnl:.2f}")
        else:
            self.total_pnl -= self.amount
            print(f"🔴 LOSS: -${self.amount:.2f}, Total: ${self.total_pnl:.2f}")
    
    def run(self, max_trades=10):
        """Main bot loop."""
        print(f"Starting bot. Asset: {self.asset}, Stake: ${self.amount}")
        
        while self.trades < max_trades:
            # Check loss limit
            if self.total_pnl <= -self.max_loss:
                print(f"⛔ Max loss reached. Stopping.")
                break
            
            # Get prices and calculate RSI
            prices = self.get_candles(30)
            rsi = self.calculate_rsi(prices)
            
            if rsi is None:
                print("Not enough data...")
                time.sleep(60)
                continue
            
            print(f"RSI: {rsi:.2f}")
            
            # Trade logic
            if rsi < 30:
                print(f"📈 Oversold → Buy Higher")
                self.execute_trade("call")
            elif rsi > 70:
                print(f"📉 Overbought → Buy Lower")
                self.execute_trade("put")
            else:
                print("⏳ Waiting for setup...")
                time.sleep(60)
                continue
            
            # Wait 2 menit before next analysis
            time.sleep(120)
        
        # Final stats
        win_rate = (self.wins / self.trades * 100) if self.trades > 0 else 0
        print(f"\n=== Final Stats ===")
        print(f"Trades: {self.trades}")
        print(f"Wins: {self.wins} ({win_rate:.1f}%)")
        print(f"Total P/L: ${self.total_pnl:.2f}")

# Run
if __name__ == "__main__":
    bot = IQRSIBot("your_email", "your_password")
    bot.run(max_trades=10)

Logic bot:

  1. Connect ke IQ Option (demo account)
  2. Get candles EUR/USD-OTC setiap 60 detik
  3. Calculate RSI(14)
  4. If RSI < 30 → Buy Higher (call)
  5. If RSI > 70 → Buy Lower (put)
  6. Track P/L
  7. Stop jika max loss $20 atau 10 trades

💡 Improvements

  • Add multiple indicators (RSI + MACD)
  • Implement reconnection logic untuk WebSocket disconnects
  • Save trade log ke CSV untuk analysis
  • Add Telegram notifications
  • Implement adaptive position sizing

Limitasi dan risks

Technical risks:

  • 🚨 Library deprecation: Jika IQ Option update internal API, library berhenti bekerja
  • 🚨 Account suspension: Automated trading bisa di-detect dan akun di-banned
  • 🚨 WebSocket instability: Connections drop frequently, butuh proper handling
  • 🚨 No official support: Bugs hanya di-fix oleh community

Trading risks (binary options):

  • 📉 Negative expected value: Payout 70-92% pada win, lose 100%. Butuh win rate >55% untuk break even.
  • 📉 Regulator concerns: Banyak yurisdiksi telah melarang binary options retail
  • 📉 Manipulation potential: Beberapa platform binary di-suspect manipulate

Untuk konteks regulator yang detail, lihat analisis kami tentang regulasi binary options 2026.

Alternatif yang lebih aman

1. Deriv (Official API)

API resmi dengan documentation lengkap. Synthetic indices unik (Volatility 75) yang tidak ada di broker lain. Lihat tutorial Python Deriv API kami.

2. MetaTrader 5 (Python integration)

MT5 memiliki Python integration resmi (MetaTrader5 library). Bekerja dengan broker seperti Exness, IC Markets, OctaFX. Untuk forex spot trading, bukan binary options.

3. cTrader Open API

cTrader (digunakan oleh IC Markets, Pepperstone, OctaFX) memiliki Open API resmi. Lebih sophisticated dari MT5 untuk algo trading.

4. CCXT (untuk crypto)

Library Python untuk 100+ crypto exchanges (Binance, Bybit, Kraken, dll). Trading crypto dengan API resmi, bukan binary.

FAQ

Apakah akun saya akan di-banned jika menggunakan API ini?

Possibly. IQ Option dapat detect automated patterns. Risk lebih rendah di Practice account. Untuk Real account, gunakan dengan low frequency dan natural patterns.

Library masih maintained?

Cek GitHub Lu-Yi-Hsun/iqoptionapi untuk last commit date. Jika lebih dari 6 bulan tidak update, library mungkin deprecated.

Bisakah Anda menjamin saya profit dengan bot ini?

Tidak. 70-89% trader retail kehilangan uang. Bot menambah convenience dan disiplin, tetapi tidak menghilangkan negative expected value binary options.

⚠️ Final disclaimer: IQ Option API ini unofficial. Risk teknis dan trading sangat tinggi. 70-89% trader retail kehilangan uang. Pertimbangkan alternatives dengan API resmi. Gunakan hanya dengan modal yang Anda dapat kehilangan 100%.

Similar Posts