Skip to content

UNSET_DOUBLE silently converted to 0.0 in CommissionReport fields #208

@msdavid

Description

@msdavid

Bug: UNSET_DOUBLE silently converted to 0.0 in CommissionReport fields

Version

ib_async 2.1.0

Description

In wrapper.py, the commissionReport handler converts IBKR's UNSET_DOUBLE sentinel value (1.7976931348623157e+308, meaning "not reported") to 0.0 for the realizedPNL and yield_ fields of CommissionReport.

This makes it impossible for consumers to distinguish between "IBKR did not report this value" and "the value is exactly zero" -- two semantically different states.

Related issues

Code reference

wrapper.py approximately lines 848-851 in version 2.1.0:

if report.realizedPNL >= UNSET_DOUBLE:
    report.realizedPNL = 0.0
if report.yield_ >= UNSET_DOUBLE:
    report.yield_ = 0.0

Expected behavior

UNSET_DOUBLE should be converted to math.nan (or None) rather than 0.0, preserving the semantic distinction between "not reported" and "zero."

Impact

Any system that tracks realized P&L or yield from commission reports cannot distinguish a genuine $0.00 realized P&L (e.g., a scratch trade) from a trade where IBKR simply has not yet reported the value. This can cause incorrect cost-basis calculations and misleading reporting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions