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() (binary options) and buy_digital_spot() (digital options) methods, 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 configuring everything 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)
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 carries 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 switch to the demo account
Everything starts with logging in and switching to the practice account. Confirm the connection succeeded before sending any order:
from iqoptionapi.stable_api import IQ_Option
import time
api = IQ_Option("your_email", "your_password")
status, reason = api.connect()
print("Connected?", status, reason)
# ALWAYS in demo for testing
api.change_balance("PRACTICE")
print("Demo balance:", api.get_balance())
Step 2 — Send a binary order with buy()
The buy() method is used for classic binary options. The signature is buy(amount, asset, direction, expiry), where direction is "call" (up) or "put" (down) and expiry is in minutes. It returns a (status, id) tuple:
amount = 1 # stake amount
asset = "EURUSD" # pair
direction = "call" # "call" or "put"
expiry = 1 # minutes
ok, order_id = api.buy(amount, asset, direction, expiry)
if ok:
print("Order sent. ID:", order_id)
else:
print("Failed to send the order")
order_id. Without it you cannot look up the result afterwards. 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 check the outcome. check_win_v4() is the recommended method in current versions: it returns the trade status and the profit/loss. Only do this in a blocking way while studying:
result, profit = api.check_win_v4(order_id)
if profit > 0:
print(f"WIN — profit of {profit:.2f}")
elif profit == 0:
print("TIE (stake refunded)")
else:
print(f"LOSS — loss of {abs(profit):.2f}")
The profit value comes back net: positive is a win, zero is a tie (stake refunded) and negative is a loss. In real loops, prefer checking asynchronously instead of freezing the program while waiting for each candle.
What about digital options? Use buy_digital_spot()
Digital options have a separate flow. The entry is placed with buy_digital_spot(asset, amount, direction, expiry) and the result is checked with check_win_digital_v2(id):
ok, order_id = api.buy_digital_spot("EURUSD", 1, "call", 1)
if ok:
# wait for it to close, then check
closed = False
while not closed:
closed, profit = api.check_win_digital_v2(order_id)
time.sleep(1)
print("Digital result:", profit)
buy() + check_win_v4() for binaries; buy_digital_spot() + check_win_digital_v2() for digitals. Swapping one for the other is the number one 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 returned by connect()), using an asset that is closed at that hour, 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, with no support from 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 a demo account.
What is the difference between buy() and buy_digital_spot()? The first sends binary options; the second, digital options. Each has its own result-checking method.
Disclaimer: binary and digital options are extremely high-risk products and most retail investors lose money. This content is educational and technical; it does not constitute an investment recommendation, offer or promise of returns. Unofficial libraries may violate the platform’s terms of use and can stop working without notice. Always test on a demo account before any use with real money.
