ibapi 5.1.0

An unofficial Rust client for the Interactive Brokers TWS API. Async (Tokio) and blocking clients for TWS and IB Gateway.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
use super::*;
use crate::common::test_utils::helpers::assert_decimal_parse_error;
use crate::orders::{ExecutionSide, OrderStatusKind, TimeInForce, UnknownCondition};

// === parse_required ===

#[test]
fn parse_required_none_errors_with_label() {
    let err = parse_required::<OrderStatusKind>(None, "OrderStatus").unwrap_err();
    match err {
        Error::Parse(_, _, msg) => assert!(msg.contains("OrderStatus"), "expected label in message, got: {msg}"),
        other => panic!("expected Error::Parse, got {other:?}"),
    }
}

#[test]
fn parse_required_empty_errors_with_label() {
    let err = parse_required::<OrderStatusKind>(Some(""), "OrderStatus").unwrap_err();
    match err {
        Error::Parse(_, _, msg) => assert!(msg.contains("OrderStatus"), "expected label in message, got: {msg}"),
        other => panic!("expected Error::Parse, got {other:?}"),
    }
}

#[test]
fn parse_required_valid_round_trips() {
    let v: OrderStatusKind = parse_required(Some("Submitted"), "OrderStatus").unwrap();
    assert_eq!(v, OrderStatusKind::Submitted);
}

#[test]
fn parse_required_defers_unknown_to_fromstr() {
    // The helper adds no vocabulary policy of its own: a closed enum's
    // unknown value propagates as the FromStr error. (Open-enum fallback
    // behavior is owned by the enum and tested beside it — see
    // order_status_kind_preserves_unknown_wire_status.)
    assert!(matches!(
        parse_required::<ExecutionSide>(Some("Garbage"), "side"),
        Err(Error::Parse(_, _, _))
    ));
}

// === parse_optional ===

#[test]
fn parse_optional_none_is_ok_none() {
    let v: Option<OrderStatusKind> = parse_optional(None).unwrap();
    assert_eq!(v, None);
}

#[test]
fn parse_optional_empty_is_ok_none() {
    let v: Option<OrderStatusKind> = parse_optional(Some("")).unwrap();
    assert_eq!(v, None);
}

#[test]
fn parse_optional_valid_round_trips() {
    let v: Option<OrderStatusKind> = parse_optional(Some("Filled")).unwrap();
    assert_eq!(v, Some(OrderStatusKind::Filled));
}

#[test]
fn parse_optional_defers_unknown_to_fromstr() {
    // Mirrors parse_required_defers_unknown_to_fromstr.
    assert!(matches!(parse_optional::<ExecutionSide>(Some("Garbage")), Err(Error::Parse(_, _, _))));
}

// === parse_optional_decimal ===
//
// Tier 1: the helper's semantics, exhaustively, in one place. Decoder tests
// elsewhere assert only that each decoder is *wired* to this helper.

/// Every input class that must decode to "no value". The literal-sentinel rows are
/// derived from the constant under test rather than re-typed (docs/rules/testing/derive-from-constants.md).
fn unset_inputs() -> impl Iterator<Item = Option<&'static str>> {
    [
        None,     // field absent
        Some(""), // present but empty
        Some("inf"),
        Some("-inf"),
        Some("NaN"),
        Some("1e309"),                   // overflows to inf
        Some("1.7976931348623157E308"),  // f64::MAX, C# "R" spelling
        Some("1.7976931348623157e308"),  // ...lowercase
        Some("1.7976931348623157E+308"), // ...explicit sign
    ]
    .into_iter()
    .chain(UNSET_DECIMAL_WIRE.map(Some))
}

#[test]
fn parse_optional_decimal_unset_inputs_are_none() {
    for input in unset_inputs() {
        assert_eq!(parse_optional_decimal(input).unwrap(), None, "expected None for {input:?}");
    }
}

#[test]
fn parse_optional_decimal_preserves_fractional_values() {
    // The regression this whole change exists for: these all decoded to 0
    // through the old integer parse (issue #716).
    for (input, expected) in [("0.5", 0.5), ("0.001", 0.001), ("-0.25", -0.25), ("1.5", 1.5)] {
        assert_eq!(parse_optional_decimal(Some(input)).unwrap(), Some(expected), "input {input}");
    }
}

#[test]
fn parse_optional_decimal_zero_is_a_value_not_unset() {
    assert_eq!(parse_optional_decimal(Some("0")).unwrap(), Some(0.0));
    assert_eq!(parse_optional_decimal(Some("100")).unwrap(), Some(100.0));
}

#[test]
fn parse_optional_decimal_sentinel_near_misses_survive() {
    // Proves the literal/numeric split: sentinels are matched as strings, so a
    // real size that merely resembles one must not be swallowed.
    for (input, expected) in [
        ("2147483647.0", 2147483647.0),
        ("9223372036854775806", 9223372036854775806.0),
        ("21474836470", 21474836470.0),
        ("214748364", 214748364.0),
    ] {
        assert_eq!(parse_optional_decimal(Some(input)).unwrap(), Some(expected), "input {input}");
    }
}

#[test]
fn parse_optional_decimal_accepts_more_digits_than_f64_round_trips() {
    // f64 cannot hold these exactly. Accepted for now — this precision loss is
    // the motivation for the follow-up decimal quantity type; the contract here
    // is only that the value is not rejected and lands on the nearest f64.
    assert_eq!(parse_optional_decimal(Some("0.1234567890123456789")).unwrap(), Some(0.12345678901234568));
    assert_eq!(
        parse_optional_decimal(Some("123456789012345678901234567890")).unwrap(),
        Some(1.2345678901234568e29)
    );
}

#[test]
fn parse_optional_decimal_malformed_errors_with_offending_value() {
    for input in ["abc", " ", "1,000", "1.2.3", "--1", "0x10"] {
        assert_decimal_parse_error(parse_optional_decimal(Some(input)), input);
    }
}

// === parse_decimal_or_zero ===
//
// A composition of `parse_optional_decimal`, so it only needs to prove the
// delegation — re-running the full class table here would just test `unwrap_or`.

#[test]
fn parse_decimal_or_zero_collapses_unset_to_zero() {
    for input in unset_inputs() {
        assert_eq!(parse_decimal_or_zero(input).unwrap(), 0.0, "expected 0.0 for {input:?}");
    }
}

#[test]
fn parse_decimal_or_zero_passes_values_through() {
    assert_eq!(parse_decimal_or_zero(Some("0.5")).unwrap(), 0.5);
}

#[test]
fn parse_decimal_or_zero_propagates_parse_error() {
    assert!(matches!(parse_decimal_or_zero(Some("abc")), Err(Error::Parse(_, _, _))));
}

// === decode_combo_leg end-to-end (docs/rules/testing/exercise-production-code.md) ===

fn proto_leg(action: Option<&str>) -> proto::ComboLeg {
    proto::ComboLeg {
        con_id: Some(1),
        ratio: Some(1),
        action: action.map(str::to_string),
        ..Default::default()
    }
}

#[test]
fn decode_combo_leg_rejects_missing_action() {
    assert!(matches!(decode_combo_leg(&proto_leg(None)), Err(Error::Parse(_, _, _))));
}

#[test]
fn decode_combo_leg_rejects_empty_action() {
    assert!(matches!(decode_combo_leg(&proto_leg(Some(""))), Err(Error::Parse(_, _, _))));
}

#[test]
fn decode_combo_leg_rejects_unknown_action() {
    // SLONG is the variant LegAction deliberately excludes — guards against
    // a future "let's just reuse Action after all" regression.
    assert!(matches!(decode_combo_leg(&proto_leg(Some("SLONG"))), Err(Error::Parse(_, _, _))));
}

#[test]
fn decode_combo_leg_accepts_buy() {
    let leg = decode_combo_leg(&proto_leg(Some("BUY"))).unwrap();
    assert_eq!(leg.action, LegAction::Buy);
}

#[test]
fn decode_combo_leg_accepts_sell() {
    let leg = decode_combo_leg(&proto_leg(Some("SELL"))).unwrap();
    assert_eq!(leg.action, LegAction::Sell);
}

#[test]
fn decode_combo_leg_accepts_sshort() {
    let leg = decode_combo_leg(&proto_leg(Some("SSHORT"))).unwrap();
    assert_eq!(leg.action, LegAction::SellShort);
}

// === decode_contract surfaces combo-leg errors ===

#[test]
fn decode_contract_propagates_bad_combo_leg() {
    let proto_contract = proto::Contract {
        combo_legs: vec![proto_leg(Some("NOTAVARIANT"))],
        ..stk_contract()
    };
    assert!(matches!(decode_contract(&proto_contract), Err(Error::Parse(_, _, _))));
}

// === decode_contract sec_type ===

#[test]
fn decode_contract_reads_missing_or_empty_sec_type_as_other_empty() {
    // Upstream sets SecType only `if (HasSecType)` and still delivers the
    // frame, so absence is an unset field, not a malformed frame. Requiring it
    // would end every stream carrying a contract (see #840).
    for sec_type in [None, Some(String::new())] {
        let proto_contract = proto::Contract {
            sec_type,
            ..Default::default()
        };
        let contract = decode_contract(&proto_contract).unwrap();
        assert_eq!(contract.security_type, crate::contracts::SecurityType::Other(String::new()));
    }
}

#[test]
fn decode_contract_preserves_unknown_sec_type() {
    let proto_contract = proto::Contract {
        sec_type: Some("NOTASECTYPE".into()),
        ..Default::default()
    };
    let contract = decode_contract(&proto_contract).unwrap();
    assert_eq!(contract.security_type, crate::contracts::SecurityType::Other("NOTASECTYPE".into()));
}

/// A `proto::Contract` carrying a `sec_type`, for tests that are not about the
/// `Other("")` fallback above.
fn stk_contract() -> proto::Contract {
    proto::Contract {
        sec_type: Some("STK".into()),
        ..Default::default()
    }
}

// === decode_order ===

/// The smallest `proto::Order` `decode_order` accepts: `action` is the one
/// required wire field.
fn proto_order() -> proto::Order {
    proto::Order {
        action: Some("BUY".into()),
        ..Default::default()
    }
}

#[test]
fn decode_order_maps_hedge_max_size() {
    let proto_order = proto::Order {
        hedge_max_size: Some(500),
        ..proto_order()
    };
    let order = decode_order(&proto_order).unwrap();
    assert_eq!(order.hedge_max_size, Some(500));
}

#[test]
fn decode_order_hedge_max_size_absent_is_none() {
    let order = decode_order(&proto_order()).unwrap();
    assert!(order.hedge_max_size.is_none());
}

#[test]
fn decode_order_keeps_the_up_to_mid_sentinel() {
    // PEG BEST "compete up to the midpoint" is sent as +inf; decoding must not drop it like the
    // f64::MAX unset sentinel.
    let proto_order = proto::Order {
        compete_against_best_offset: Some(f64::INFINITY),
        ..proto_order()
    };
    let order = decode_order(&proto_order).unwrap();
    assert_eq!(order.compete_against_best_offset, Some(f64::INFINITY));
}

// === decode_order deactivate ===

#[test]
fn decode_order_maps_deactivate() {
    let proto_order = proto::Order {
        deactivate: Some(true),
        ..proto_order()
    };
    let order = decode_order(&proto_order).unwrap();
    assert!(order.deactivate);
}

#[test]
fn decode_order_deactivate_absent_is_false() {
    let order = decode_order(&proto_order()).unwrap();
    assert!(!order.deactivate);
}

// === decode_order tif ===

#[test]
fn decode_order_preserves_unknown_tif() {
    // An unmodeled TIF keeps its raw value instead of decoding as DAY — the
    // bug GoodTillCrossing hit before it was a variant (#822).
    let proto_order = proto::Order {
        tif: Some("GTZ".to_string()),
        ..proto_order()
    };
    assert_eq!(decode_order(&proto_order).unwrap().tif, TimeInForce::Unknown("GTZ".to_string()));
}

#[test]
fn decode_order_maps_known_tif() {
    let proto_order = proto::Order {
        tif: Some("GTX".to_string()),
        ..proto_order()
    };
    assert_eq!(decode_order(&proto_order).unwrap().tif, TimeInForce::GoodTillCrossing);
}

#[test]
fn decode_order_tif_absent_or_empty_is_day() {
    // Upstream omits an empty Tif rather than sending one, so neither form is
    // an unknown value to preserve (unlike action, which is required).
    assert_eq!(decode_order(&proto_order()).unwrap().tif, TimeInForce::Day);

    let empty_tif = proto::Order {
        tif: Some(String::new()),
        ..proto_order()
    };
    assert_eq!(decode_order(&empty_tif).unwrap().tif, TimeInForce::Day);
}

// === decimal wire fields are routed through parse_optional_decimal (issue #716) ===

#[test]
fn decode_order_rejects_malformed_total_quantity() {
    let proto_order = proto::Order {
        total_quantity: Some("abc".into()),
        ..proto_order()
    };
    assert_decimal_parse_error(decode_order(&proto_order), "abc");
}

#[test]
fn decode_order_preserves_fractional_total_quantity() {
    let proto_order = proto::Order {
        total_quantity: Some("0.5".into()),
        ..proto_order()
    };
    assert_eq!(decode_order(&proto_order).unwrap().total_quantity, 0.5);
}

// === decode_order enum fields go through parse_required / parse_optional ===

#[test]
fn decode_order_rejects_missing_or_empty_action() {
    // Unlike tif, action has no unset state upstream: an order without a
    // side is a malformed frame, not a default.
    for proto_order in [
        proto::Order {
            action: None,
            ..proto_order()
        },
        proto::Order {
            action: Some(String::new()),
            ..proto_order()
        },
    ] {
        assert!(
            matches!(decode_order(&proto_order), Err(Error::Parse(_, _, _))),
            "expected Error::Parse for {proto_order:?}"
        );
    }
}

#[test]
fn decode_order_rejects_unknown_action() {
    // Action is closed: an unrecognized side fails the decode rather than
    // reading as Buy.
    let proto_order = proto::Order {
        action: Some("NOTASIDE".into()),
        ..proto_order()
    };
    assert!(matches!(decode_order(&proto_order), Err(Error::Parse(_, _, _))));
}

#[test]
fn decode_order_preserves_unknown_string_codes() {
    // rule80_a and open_close are open: an unrecognized value survives the
    // decode as Unknown(raw) instead of failing the order stream (tif is
    // covered by decode_order_preserves_unknown_tif above).
    let proto_order = proto::Order {
        rule80_a: Some("Z".into()),
        open_close: Some("X".into()),
        ..proto_order()
    };
    let order = decode_order(&proto_order).unwrap();
    assert_eq!(order.rule_80_a, Some(Rule80A::Unknown("Z".into())));
    assert_eq!(order.open_close, Some(OrderOpenClose::Unknown("X".into())));
}

#[test]
fn decode_order_empty_optional_strings_are_none() {
    let proto_order = proto::Order {
        rule80_a: Some(String::new()),
        open_close: Some(String::new()),
        ..proto_order()
    };
    let order = decode_order(&proto_order).unwrap();
    assert_eq!(order.rule_80_a, None);
    assert_eq!(order.open_close, None);
}

#[test]
fn decode_order_preserves_unknown_integer_codes() {
    let proto_order = proto::Order {
        oca_type: Some(9),
        trigger_method: Some(99),
        volatility_type: Some(9),
        reference_price_type: Some(9),
        origin: Some(9),
        short_sale_slot: Some(9),
        ..proto_order()
    };
    let order = decode_order(&proto_order).unwrap();
    assert_eq!(order.oca_type, OcaType::Unknown(9));
    assert_eq!(order.trigger_method, TriggerMethod::Unknown(99));
    assert_eq!(order.volatility_type, Some(VolatilityType::Unknown(9)));
    assert_eq!(order.reference_price_type, Some(ReferencePriceType::Unknown(9)));
    assert_eq!(order.origin, OrderOrigin::Unknown(9));
    assert_eq!(order.short_sale_slot, ShortSaleSlot::Unknown(9));
}

#[test]
fn decode_order_condition_preserves_unknown_trigger_method() {
    let proto_order = proto::Order {
        conditions: vec![proto::OrderCondition {
            r#type: Some(1),
            trigger_method: Some(99),
            ..Default::default()
        }],
        ..proto_order()
    };
    let order = decode_order(&proto_order).unwrap();
    match &order.conditions[..] {
        [OrderCondition::Price(price)] => assert_eq!(price.trigger_method, TriggerMethod::Unknown(99)),
        other => panic!("expected one price condition, got {other:?}"),
    }
}

fn populated_condition(condition_type: i32) -> proto::OrderCondition {
    proto::OrderCondition {
        r#type: Some(condition_type),
        is_conjunction_connection: Some(false),
        is_more: Some(true),
        con_id: Some(265598),
        exchange: Some("SMART".into()),
        symbol: Some("AAPL".into()),
        sec_type: Some("STK".into()),
        percent: Some(12),
        change_percent: Some(2.5),
        price: Some(150.0),
        trigger_method: Some(2),
        time: Some("20251230 14:30:00 US/Eastern".into()),
        volume: Some(1000),
    }
}

#[test]
fn decode_order_preserves_unknown_condition_type() {
    // #827: an unmodeled type (2 is unassigned) must not read as a zeroed price condition.
    let proto_order = proto::Order {
        conditions: vec![
            populated_condition(2),
            proto::OrderCondition {
                r#type: Some(99),
                ..Default::default()
            },
        ],
        ..proto_order()
    };
    let order = decode_order(&proto_order).unwrap();
    assert_eq!(
        order.conditions,
        vec![
            OrderCondition::Unknown(UnknownCondition {
                condition_type: 2,
                is_conjunction: false,
                is_more: Some(true),
                contract_id: Some(265598),
                exchange: Some("SMART".into()),
                symbol: Some("AAPL".into()),
                security_type: Some("STK".into()),
                percent: Some(12),
                change_percent: Some(2.5),
                price: Some(150.0),
                trigger_method: Some(2),
                time: Some("20251230 14:30:00 US/Eastern".into()),
                volume: Some(1000),
            }),
            OrderCondition::Unknown(UnknownCondition {
                condition_type: 99,
                is_conjunction: true,
                ..Default::default()
            }),
        ]
    );
}

#[test]
fn decode_order_condition_missing_type_is_parse_error() {
    let proto_order = proto::Order {
        conditions: vec![proto::OrderCondition::default()],
        ..proto_order()
    };
    match decode_order(&proto_order).unwrap_err() {
        Error::Parse(_, _, msg) => assert!(msg.contains("OrderCondition type"), "got: {msg}"),
        other => panic!("expected Error::Parse, got {other:?}"),
    }
}

#[test]
fn decode_order_condition_maps_every_type_code() {
    // Probes the same range as check_wire_code_round_trip: a type added to the
    // decoder without a row here fails.
    const MODELED: [i32; 6] = [1, 3, 4, 5, 6, 7];
    for code in -8..=64 {
        let condition = decode_order_condition(&proto::OrderCondition {
            r#type: Some(code),
            ..Default::default()
        })
        .unwrap();
        assert_eq!(condition.condition_type(), code, "code {code}");
        assert_eq!(
            matches!(condition, OrderCondition::Unknown(_)),
            !MODELED.contains(&code),
            "code {code} decoded as {condition:?}"
        );
    }
}

#[test]
fn decode_execution_rejects_malformed_shares() {
    let proto_exec = proto::Execution {
        side: Some("BOT".into()),
        shares: Some("abc".into()),
        ..Default::default()
    };
    assert_decimal_parse_error(decode_execution(&proto_exec), "abc");
}

#[test]
fn decode_execution_rejects_malformed_cumulative_quantity() {
    let proto_exec = proto::Execution {
        side: Some("BOT".into()),
        shares: Some("10".into()),
        cum_qty: Some("abc".into()),
        ..Default::default()
    };
    assert_decimal_parse_error(decode_execution(&proto_exec), "abc");
}

#[test]
fn decode_contract_details_rejects_malformed_min_size() {
    let details = proto::ContractDetails {
        min_size: Some("abc".into()),
        ..Default::default()
    };
    assert_decimal_parse_error(decode_contract_details(&stk_contract(), &details), "abc");
}

#[test]
fn decode_contract_details_rejects_malformed_min_tick() {
    let details = proto::ContractDetails {
        min_tick: Some("abc".into()),
        ..Default::default()
    };
    assert_decimal_parse_error(decode_contract_details(&stk_contract(), &details), "abc");
}

#[test]
fn decode_order_state_sentinel_suggested_size_is_none() {
    // Regression guard: `optional_string_f64`'s unset semantics had to survive
    // the swap to `parse_optional_decimal`.
    let state = proto::OrderState {
        status: Some("Submitted".into()),
        suggested_size: Some("2147483647".into()),
        ..Default::default()
    };
    assert_eq!(decode_order_state(&state).unwrap().suggested_size, None);
}

#[test]
fn decode_order_state_rejects_malformed_allocation_position() {
    let state = proto::OrderState {
        status: Some("Submitted".into()),
        order_allocations: vec![proto::OrderAllocation {
            account: Some("DU1234".into()),
            position: Some("abc".into()),
            ..Default::default()
        }],
        ..Default::default()
    };
    assert_decimal_parse_error(decode_order_state(&state), "abc");
}

// === ContractDetails size rules are optional (issue #716) ===

#[test]
fn decode_contract_details_absent_size_rules_are_none() {
    // Contracts without size rules omit these entirely; `0.0` would have been a
    // nonsense size increment.
    let details = decode_contract_details(&stk_contract(), &proto::ContractDetails::default()).unwrap();

    assert_eq!(details.min_size, None);
    assert_eq!(details.size_increment, None);
    assert_eq!(details.suggested_size_increment, None);
}

#[test]
fn decode_contract_details_preserves_fractional_size_increment() {
    let details = proto::ContractDetails {
        size_increment: Some("0.0001".into()),
        ..Default::default()
    };
    let decoded = decode_contract_details(&stk_contract(), &details).unwrap();

    assert_eq!(decoded.size_increment, Some(0.0001));
}