If you have already managed to log in to IQ Option with iqoptionapi and pull candles, the natural next step is the one that raises the most questions: how to send an order and then find out whether you won or lost. In this direct, honest 2026 guide you will see the buy() method (binary options) and buy_digital_spot() (digital options), how to capture the trade id and how to track the result with check_win_v4() — always on a demo account, which is where this kind of testing belongs.
Want to skip the tedious part of setting everything up by hand and see an automation flow already built for IQ Option?
See the IQ Option automation guide in Python →What iqoptionapi really is (and what it is not)
The iqoptionapi is an unofficial library maintained by the community that talks to IQ Option’s servers over WebSocket. It is not a product of the broker, it can break whenever the platform changes something internally, and it comes with no guarantee whatsoever. Use it as a tool for studying automation — not as a “money machine”.
pip install -U iqoptionapi, use a PRACTICE account and never run third-party code with your real account credentials without understanding every line.
Step 1 — Connect and select the demo account
Everything starts with the login and the switch to the practice account. Confirm the connection succeeded before sending any order:
from iqoptionapi.stable_api import IQ_Option
import time
api = IQ_Option("seu_email", "sua_senha")
status, reason = api.connect()
print("Conectado?", status, reason)
# SEMPRE em demo para testar
api.change_balance("PRACTICE")
print("Saldo demo:", api.get_balance())
Step 2 — Send a binary order with buy()
The buy() method is for classic binary options. The signature is buy(valor, ativo, direcao, expiracao), where direcao is "call" (up) or "put" (down) and expiracao is in minutes. valor is the stake of 1 in your account currency — most South African IQ Option accounts are denominated in US dollars, but the same logic applies to a rand balance. It returns a tuple (status, id):
valor = 1 # valor da entrada
ativo = "EURUSD" # par
direcao = "call" # "call" ou "put"
expiracao = 1 # minutos
ok, order_id = api.buy(valor, ativo, direcao, expiracao)
if ok:
print("Ordem enviada. ID:", order_id)
else:
print("Falha ao enviar a ordem")
order_id. Without it you cannot look up the result later. If ok comes back False, it is usually a closed asset, an unavailable payout or a stake below the minimum.
Step 3 — Track the result with check_win_v4()
After sending, you wait for the candle to close and query the outcome. check_win_v4() is the recommended method in current versions: it returns the trade’s status and the profit/loss. Only do this in a blocking way while studying:
resultado, lucro = api.check_win_v4(order_id)
if lucro > 0:
print(f"WIN — lucro de {lucro:.2f}")
elif lucro == 0:
print("EMPATE (devolucao)")
else:
print(f"LOSS — perda de {abs(lucro):.2f}")
The lucro return value is already net: positive is a win, zero is a tie (stake refunded) and negative is a loss — expressed in your account currency, whether dollars or rand. In real loops, prefer checking asynchronously instead of freezing the program while waiting for each candle.
What about digital options? Use buy_digital_spot()
Digitals have a separate flow. The entry is placed with buy_digital_spot(ativo, valor, direcao, expiracao) and the result is queried with check_win_digital_v2(id):
ok, order_id = api.buy_digital_spot("EURUSD", 1, "call", 1)
if ok:
# aguarda fechar e consulta
fechado = False
while not fechado:
fechado, lucro = api.check_win_digital_v2(order_id)
time.sleep(1)
print("Resultado digital:", lucro)
buy() + check_win_v4() for binaries; buy_digital_spot() + check_win_digital_v2() for digitals. Swapping one for the other is the number 1 cause of “id not found”.
Common errors when sending orders
The most frequent stumbles are: trying to buy with the session disconnected (check the status from connect()), using an asset that is closed at that hour (remember IQ Option schedules run on UTC — SAST is UTC+2), a stake below the allowed minimum, and forgetting to switch to PRACTICE — which would send the order to your real account. Always validate the boolean return before moving on.
FAQ
Is iqoptionapi official? No. It is a community project, unsupported by the broker, and it can stop working at any moment.
Can automation guarantee profit? No. Automation only executes rules; it does not change the fact that binary options carry a negative expected value for the trader in most scenarios.
Can I test without risking money? Yes, and you should. Use change_balance("PRACTICE") and keep everything on the demo account.
What is the difference between buy() and buy_digital_spot()? The first sends binary options; the second, digital options. Each one has its own result-checking method.
Disclaimer: binary and digital options are extremely high-risk products and most retail investors lose money. IQ Option is an offshore broker and is not authorised by the FSCA, so South African traders have no local regulatory recourse. This content is educational and technical, and does not constitute investment advice, an offer or a promise of returns. Unofficial libraries may breach the platform’s terms of use and stop working without notice. Always test on a demo account before any use with real money.
