发布

  • 17933 153d0b7427

    Support Count and Python len() on user-facing lazy enumerables (#9631)

    frostbyte_neo 发布于 2026-07-21 21:24:37 +00:00 | 11 次提交 在此版本后已推送到 master

    • Memoize order and order ticket enumerables in SecurityTransactionManager

    Wrap the enumerables returned by GetOrders, GetOrderTickets and
    GetOpenOrderTickets in MemoizingEnumerable so they expose a Count
    property, which also enables len() on them in Python algorithms.

    • Memoize lazy enumerables in other user-facing APIs

    Wrap SubscriptionManager.Subscriptions, SecurityCache.GetAll,
    Cash.SecuritySymbols and ICurrencyConversion.ConversionRateSecurities
    in MemoizingEnumerable so they expose a Count property, which also
    enables len() on them in Python algorithms.

    • Add Count property to IObjectStore

    Exposes the count of stored objects without loading their content,
    which also enables len() on the object store in Python algorithms.

    • Revert "Add Count property to IObjectStore"

    This reverts commit 84c0a08c7c30f14a6986a7e11dc89ea426606d1e.

    • Avoid memoization overhead on engine hot paths
    • Revert SecurityCache.GetAll memoization: fill models enumerate it once
      per open order on every fill scan, so memoizing only adds allocations
      and per-item locking on a hot path.
    • SecurityTransactionManager.GetOpenOrdersRemainingQuantity and
      CancelOpenOrders go directly to the order processor since they
      enumerate a single time, keeping memoization only for the enumerables
      returned to the user.
    • Centralize order ticket memoization decision in private helpers

    Replace direct _orderProcessor calls with private GetOrderTickets/
    GetOpenOrderTickets overloads taking a required memoize flag, so every
    internal call site states whether the enumerable is single-pass (engine
    paths) or user-facing (memoized). Also drop the redundant x => true
    fallback: IOrderProvider documents null as match-all and every
    implementation handles it.

    • Coalesce null order ticket filters before reaching the order processor

    Preserves the previous behavior where IOrderProcessor implementations
    never received a null filter from the transaction manager.

    下载附件