Skip to content

fix Timebars typo#197

Closed
gnzsnz wants to merge 1 commit intoib-api-reloaded:nextfrom
gnzsnz:fix-timebars
Closed

fix Timebars typo#197
gnzsnz wants to merge 1 commit intoib-api-reloaded:nextfrom
gnzsnz:fix-timebars

Conversation

@gnzsnz
Copy link
Contributor

@gnzsnz gnzsnz commented Dec 5, 2025

This typo is breaking timebars class. there is no isUnset method in timebars class. reverting change to isNan helper function.

This typo is breaking timebars class. there is no `isUnset` method in timebars class. reverting change to `isNan` helper function.
@mattsta
Copy link
Contributor

mattsta commented Dec 6, 2025

good catch, this is more correct in that it works, but if people do use the "don't use nan for unset" override system, these isNan checks would return bad results.

So the Op subclass usage is currently only valid if you don't overwrite NaN to None for updates, etc.

We don't have a clean way to thread/chain the defaults system down through these eventkit operation types here yet.

mattsta pushed a commit that referenced this pull request Dec 6, 2025
This typo is breaking timebars class. there is no `isUnset` method in timebars class. reverting change to `isNan` helper function.

Fixes #197
@gnzsnz
Copy link
Contributor Author

gnzsnz commented Dec 6, 2025

maybe if we define something like this

@dataclass
class IBDefaults:
    """A simple way to provide default values when populating API data."""

    # optionally replace IBKR using -1 price and 0 size when quotes don't exist
    
    emptyPrice: ClassVar[Final[Any]] = -1
    emptySize: ClassVar[Final[Any]] = 0

    # optionally replace ib_async default for all instance variable values before popualted from API updates
    unset: ClassVar[Final[Any]] = nan

    # optionally change the timezone used for log history events in objects (no impact on orders or data processing)
    timezone: ClassVar[Final[tzinfo]] = timezone.utc
    
    @classmethod
    def isUnset(cls, value) -> bool:
        # if default value is nan and value is nan, it is unset.
        # else, if value matches default value, it is unset.
        dev = cls.unset
        return (dev != dev and value != value) or (value == dev)

we can then use the IBDefaults instances, rather than instanciating it. this way there is no need to have an instance of IBDefaults and we hace have helper methods included.

what do you think?

for this "minor" release we can try it on Ticker. as we use IBDefaults in multiple places, we might not want to change everything now.

@mattsta mattsta closed this in 7edfe86 Dec 8, 2025
lkaino pushed a commit to lkaino/ib_async that referenced this pull request Feb 5, 2026
This typo is breaking timebars class. there is no `isUnset` method in timebars class. reverting change to `isNan` helper function.

Fixes ib-api-reloaded#197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants