Proposal
Add pending order cancellation functionality to the PocketOption API, including support for multiple concurrent pending orders and batch cancellation operations.
Problem Statement
The current pending order implementation in PendingTradesHandle only supports creating and retrieving pending orders, but lacks cancellation capabilities 1 . Additionally, the module is designed for single pending order workflows, stating "at most one OpenPendingOrder request is in-flight at any given time per client" 2 . This prevents implementation of complex trading strategies like martingale that require managing multiple pending orders simultaneously and canceling them when earlier levels succeed.
Suggested Implementation
- Add cancellation method to Rust core: Implement
cancel_pending_order(ticket: String) in PendingTradesHandle
- Add batch cancellation: Implement
cancel_pending_orders(tickets: Vec<String>) for multiple orders
- Update state management: Modify the
last_req_id tracking to support multiple concurrent pending orders
- Add Python bindings: Expose cancellation methods in both synchronous and asynchronous Python APIs
- Update
PendingOrder type: Ensure order status tracking for cancellation confirmation
Use Case
import asyncio
from BinaryOptionsToolsV2 import PocketOptionAsync
async def martingale_strategy():
client = PocketOptionAsync(ssid="your_ssid")
# Place initial pending order
order1 = await client.open_pending_order(
open_type=0, amount=10.0, asset="GBP/AUD_otc",
open_time=1642695900, open_price=1.8450,
timeframe=300, min_payout=80, command=0
)
# Place martingale level orders
order2 = await client.open_pending_order(
open_type=0, amount=20.0, asset="GBP/AUD_otc",
open_time=1642696200, open_price=1.8450,
timeframe=300, min_payout=80, command=0
)
order3 = await client.open_pending_order(
open_type=0, amount=40.0, asset="GBP/AUD_otc",
open_time=1642696500, open_price=1.8450,
timeframe=300, min_payout=80, command=0
)
# Monitor first order result
result = await client.check_win(order1["id"])
# If first order wins, cancel remaining martingale levels
if result["profit"] > 0:
await client.cancel_pending_order(order2["ticket"])
await client.cancel_pending_order(order3["ticket"])
print("Martingale levels cancelled - initial order won")
else:
print("Continuing with martingale strategy")
asyncio.run(martingale_strategy())
Benefits
- Enables complex trading strategies: Martingale, grid trading, and multi-level strategies require order cancellation capabilities
- Risk management: Allows traders to limit exposure by canceling unneeded orders
- API completeness: Cancellation is a standard feature in trading APIs and its absence limits the library's utility
- Competitive advantage: Other trading libraries support order cancellation, making this essential for adoption
- Resource efficiency: Prevents unnecessary order execution and reduces broker-side load
The pending order feature is currently marked as BETA 3 , making this an ideal time to enhance it with full CRUD operations before stable release.
Wiki pages you might want to explore:
Citations
File: README.md (L242-244)
- [x] **PocketOption**: Quick Trading
- [x] **PocketOption**: Pending Orders (BETA)
- [ ] **Platform**: Expert Options Integration
Proposal
Add pending order cancellation functionality to the PocketOption API, including support for multiple concurrent pending orders and batch cancellation operations.
Problem Statement
The current pending order implementation in
PendingTradesHandleonly supports creating and retrieving pending orders, but lacks cancellation capabilities 1 . Additionally, the module is designed for single pending order workflows, stating "at most oneOpenPendingOrderrequest is in-flight at any given time per client" 2 . This prevents implementation of complex trading strategies like martingale that require managing multiple pending orders simultaneously and canceling them when earlier levels succeed.Suggested Implementation
cancel_pending_order(ticket: String)inPendingTradesHandlecancel_pending_orders(tickets: Vec<String>)for multiple orderslast_req_idtracking to support multiple concurrent pending ordersPendingOrdertype: Ensure order status tracking for cancellation confirmationUse Case
Benefits
The pending order feature is currently marked as BETA 3 , making this an ideal time to enhance it with full CRUD operations before stable release.
Wiki pages you might want to explore:
Citations
File: README.md (L242-244)