Commit 4d3b547
authored
Fix IB ineligibility reason serialization (#4380)
Newer IB Gateway versions may return ineligibilityReasonList populated
with ibapi.ineligibility_reason.IneligibilityReason objects in
contractDetails. _serialize_for_json() only handled Decimal/Enum and
passed other objects through unchanged, so persisting the instrument
to a cache database (Redis/msgpack) raised:
TypeError: Encoding objects of type
<class 'ibapi.ineligibility_reason.IneligibilityReason'>
is unsupported
_serialize_for_json() now checks primitive types first, then converts
arbitrary objects with __dict__ via vars() recursively (reusing the
existing dict branch), falling back to str() for anything else. Adds
a regression test that reproduces the original TypeError and verifies
the fix, and a RELEASES.md entry.1 parent fcc57d1 commit 4d3b547
3 files changed
Lines changed: 43 additions & 1 deletion
File tree
- nautilus_trader/adapters/interactive_brokers/parsing
- tests/integration_tests/adapters/interactive_brokers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1016 | 1016 | | |
1017 | 1017 | | |
1018 | 1018 | | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
1019 | 1025 | | |
1020 | 1026 | | |
1021 | 1027 | | |
1022 | 1028 | | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
1023 | 1032 | | |
1024 | 1033 | | |
1025 | 1034 | | |
| |||
1032 | 1041 | | |
1033 | 1042 | | |
1034 | 1043 | | |
1035 | | - | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
1036 | 1048 | | |
1037 | 1049 | | |
1038 | 1050 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| |||
643 | 648 | | |
644 | 649 | | |
645 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
0 commit comments