Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 29, 2025

check_order_result was returning stale "active" status even after trades completed because it checked _active_orders before _order_results. This broke martingale strategies that need to know win/loss results.

Changes

  • pocketoptionapi_async/client.py: Reorder lookup in check_order_result to check _order_results first, matching the behavior of check_win
  • examples/get_active_orders.py: Fix attribute access on OrderResult objects (order.order_id not order['id'])

Before/After

# Before: Always returned "active" even after completion
result = await client.check_order_result(order_id)
print(result.status)  # "active" (wrong - trade already finished)
print(result.profit)  # None

# After: Returns completed order with final status
result = await client.check_order_result(order_id)
print(result.status)  # "win" or "lose"
print(result.profit)  # 0.92 (actual profit)
Original prompt

This section details on the original issue you should resolve

<issue_title>check order results, check win,get active orders are not doing what the docs are saying </issue_title>
<issue_description>Good day all.

I having trouble to get order results or to check win. i want to check if my order was a successfull win or not to intergrade a martingale strategy

basically checking results or get active order both show the same thing. the active status always shows active even thou the trade has finished and at profit it just shows the profit that is being obtained if trade is successfull and not actual trade winnings.

here is a traceback:

check_order_results:
Order Result: order_id='027965fb-c120-4947-968f-a40216957634' asset='EURUSD_otc' amount=1.0 direction=<OrderDirection.PUT: 'put'> duration=60 status=<OrderStatus.ACTIVE: 'active'> placed_at=datetime.datetime(2025, 7, 22, 16, 13, 28, 367905) expires_at=datetime.datetime(2025, 7, 22, 16, 14, 28, 367909) profit=0.92 payout=None error_message=None

get_active_orders:
Active Orders:
order_id='027965fb-c120-4947-968f-a40216957634' asset='EURUSD_otc' amount=1.0 direction=<OrderDirection.PUT: 'put'> duration=60 status=<OrderStatus.ACTIVE: 'active'> placed_at=datetime.datetime(2025, 7, 22, 16, 13, 28, 367905) expires_at=datetime.datetime(2025, 7, 22, 16, 14, 28, 367909) profit=0.92 payout=None error_message=None

check_win just hangs and i have to manually stop the script. but as you can see above that the active and get results show the same things. so i cant determine if the order was a win or not.

for now i will just use check balance to determine win or loss.

but please if anyone has a fix for this, it will be really helpfull.

thanks in advance
</issue_description>

Comments on the Issue (you are @copilot in this section)

@theshadow76 Try using our latest API, binaryoptionstoolsv2: https://github.com/ChipaDevTeam/BinaryOptionsTools-v2/

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

…ive_orders example

Co-authored-by: theshadow76 <59869868+theshadow76@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix order results and win checks functionality Fix check_order_result to prioritize completed orders over active orders Nov 29, 2025
Copilot AI requested a review from theshadow76 November 29, 2025 11:48
@theshadow76 theshadow76 marked this pull request as ready for review November 29, 2025 12:22
Copilot AI review requested due to automatic review settings November 29, 2025 12:22
@theshadow76 theshadow76 merged commit 8f87552 into main Nov 29, 2025
1 check passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug in order result retrieval where check_order_result was returning stale "active" status even after orders completed. The fix reorders the lookup logic to check completed orders (_order_results) before active orders (_active_orders), ensuring users receive accurate final trade results needed for strategies like martingale betting systems.

  • Reordered lookup priority in check_order_result to match check_win behavior
  • Fixed attribute access syntax in example code to properly access Pydantic model fields

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pocketoptionapi_async/client.py Reordered check_order_result to check _order_results before _active_orders, ensuring completed orders with final status/profit are returned instead of stale active data
examples/get_active_orders.py Fixed OrderResult attribute access from dictionary-style (order['id']) to object-style (order.order_id) to match Pydantic BaseModel interface

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check order results, check win,get active orders are not doing what the docs are saying

2 participants