@@ -28,7 +28,7 @@ use binary_options_tools::pocketoption::{
2828 error:: PocketResult ,
2929 ssid:: { Demo , Ssid } ,
3030 state:: { State , StateBuilder } ,
31- types:: PendingOrder ,
31+ types:: { PendingOrder , OpenPendingOrder } ,
3232} ;
3333use binary_options_tools_core:: reimports:: Message ;
3434use binary_options_tools_core:: traits:: { ApiModule , RunnerCommand } ;
@@ -154,16 +154,16 @@ async fn example_basic_pending_order() -> PocketResult<()> {
154154 } ) ;
155155
156156 let result = client_handle
157- . open_pending_order (
158- 1 , // open_type: 1 = typical for binary options
159- Decimal :: from_f64_retain ( 100.0 ) . unwrap ( ) , // amount
160- "EURUSD_otc" . to_string ( ) , // asset (OTC EUR/USD)
161- "2026-04-07 22:50:00" . to_string ( ) , // open_time: specific trigger time (for openType 0) or expiration (for openType 1)
162- Decimal :: from_f64_retain ( 1.1950 ) . unwrap ( ) , // open_price: current market price
163- 60 , // timeframe: 60 seconds
164- 85 , // min_payout: 85% minimum payout
165- 0 , // command: 0 (typically for buy/call)
166- )
157+ . open_pending_order ( OpenPendingOrder {
158+ open_type : 1 , // open_type: 1 = typical for binary options
159+ amount : Decimal :: from_f64_retain ( 100.0 ) . unwrap ( ) , // amount
160+ asset : "EURUSD_otc" . to_string ( ) , // asset (OTC EUR/USD)
161+ open_time : "2026-04-07 22:50:00" . to_string ( ) , // open_time: specific trigger time (for openType 0) or expiration (for openType 1)
162+ open_price : Decimal :: from_f64_retain ( 1.1950 ) . unwrap ( ) , // open_price: current market price
163+ timeframe : 60 , // timeframe: 60 seconds
164+ min_payout : 85 , // min_payout: 85% minimum payout
165+ command : 0 , // command: 0 (typically for buy/call)
166+ } )
167167 . await ;
168168
169169 // 7. Handle the result
@@ -262,16 +262,16 @@ async fn example_concurrent_pending_orders() -> PocketResult<()> {
262262
263263 let order_fut = tokio:: spawn ( async move {
264264 handle_clone2
265- . open_pending_order (
266- 1 ,
267- amount2,
268- asset2,
269- "2026-04-07 22:50:00" . to_string ( ) ,
270- Decimal :: from_f64_retain ( 1.0 ) . unwrap ( ) ,
271- 60 ,
272- 85 ,
273- 0 ,
274- )
265+ . open_pending_order ( OpenPendingOrder {
266+ open_type : 1 ,
267+ amount : amount2,
268+ asset : asset2,
269+ open_time : "2026-04-07 22:50:00" . to_string ( ) ,
270+ open_price : Decimal :: from_f64_retain ( 1.0 ) . unwrap ( ) ,
271+ timeframe : 60 ,
272+ min_payout : 85 ,
273+ command : 0 ,
274+ } )
275275 . await
276276 } ) ;
277277
@@ -456,16 +456,16 @@ async fn example_integration_with_pocketclient() -> PocketResult<()> {
456456
457457 let order_result = timeout (
458458 Duration :: from_secs ( 30 ) ,
459- pending_trades_handle. open_pending_order (
460- 1 ,
461- Decimal :: from_f64_retain ( 250.0 ) . unwrap ( ) ,
462- "EURUSD_otc" . to_string ( ) ,
463- "2026-04-07 22:50:00" . to_string ( ) ,
464- Decimal :: from_f64_retain ( 1.1850 ) . unwrap ( ) ,
465- 60 ,
466- 90 ,
467- 0 ,
468- ) ,
459+ pending_trades_handle. open_pending_order ( OpenPendingOrder {
460+ open_type : 1 ,
461+ amount : Decimal :: from_f64_retain ( 250.0 ) . unwrap ( ) ,
462+ asset : "EURUSD_otc" . to_string ( ) ,
463+ open_time : "2026-04-07 22:50:00" . to_string ( ) ,
464+ open_price : Decimal :: from_f64_retain ( 1.1850 ) . unwrap ( ) ,
465+ timeframe : 60 ,
466+ min_payout : 90 ,
467+ command : 0 ,
468+ } ) ,
469469 )
470470 . await ;
471471
@@ -537,8 +537,16 @@ async fn scenario1_mismatched_responses() -> PocketResult<()> {
537537 } ) ;
538538
539539 println ! ( "Waiting for order (should handle mismatches)..." ) ;
540- // This might still fail if the module's matching logic is strict, but it demonstrates the retry loop
541- let _ = client_handle. open_pending_order ( 1 , dec ! ( 100 ) , "EURUSD_otc" . into ( ) , "2026-04-07 22:50:00" . into ( ) , dec ! ( 1.1950 ) , 60 , 85 , 0 ) . await ;
540+ let _ = client_handle. open_pending_order ( OpenPendingOrder {
541+ open_type : 1 ,
542+ amount : dec ! ( 100 ) ,
543+ asset : "EURUSD_otc" . into ( ) ,
544+ open_time : "2026-04-07 22:50:00" . into ( ) ,
545+ open_price : dec ! ( 1.1950 ) ,
546+ timeframe : 60 ,
547+ min_payout : 85 ,
548+ command : 0 ,
549+ } ) . await ;
542550
543551 module_task. abort ( ) ;
544552 Ok ( ( ) )
@@ -567,7 +575,16 @@ async fn scenario3_timeout() -> PocketResult<()> {
567575 let module_task = tokio:: spawn ( async move { module. run ( ) . await . ok ( ) } ) ;
568576
569577 println ! ( "Requesting order with no server response (expect timeout)..." ) ;
570- let result = timeout ( Duration :: from_secs ( 2 ) , client_handle. open_pending_order ( 1 , dec ! ( 100 ) , "EURUSD_otc" . into ( ) , "2026-04-07 22:50:00" . into ( ) , dec ! ( 1.1950 ) , 60 , 85 , 0 ) ) . await ;
578+ let result = timeout ( Duration :: from_secs ( 2 ) , client_handle. open_pending_order ( OpenPendingOrder {
579+ open_type : 1 ,
580+ amount : dec ! ( 100 ) ,
581+ asset : "EURUSD_otc" . into ( ) ,
582+ open_time : "2026-04-07 22:50:00" . into ( ) ,
583+ open_price : dec ! ( 1.1950 ) ,
584+ timeframe : 60 ,
585+ min_payout : 85 ,
586+ command : 0 ,
587+ } ) ) . await ;
571588
572589 match result {
573590 Err ( _) => println ! ( "✓ Correctly timed out!" ) ,
0 commit comments