Skip to main content

Module interbar_cache

Module interbar_cache 

Source
Expand description

Inter-bar feature result caching for streaming optimization

GitHub Issue: https://github.com/terrylica/opendeviationbar-py/issues/96 GitHub Issue: https://github.com/terrylica/opendeviationbar-py/issues/59 Task #144 Phase 4: Result caching for deterministic sequences

Caches computed inter-bar features (OFI, VWAP, Kyle Lambda, Hurst, etc.) keyed by trade count and window hash to avoid redundant computation in streaming scenarios where similar lookback windows repeat.

§Benefits

  • Latency reduction: 20-40% for repeated window patterns (Task #144 target)
  • Memory efficient: LRU eviction, bounded capacity
  • Transparent: Optional, backward compatible

§Architecture

Cache key: (trade_count, window_hash)InterBarFeatures

Window hash captures:

  • Price movement pattern (OHLC bounds)
  • Volume distribution
  • Temporal characteristics (duration, trade frequency)

Structs§

InterBarCacheKey
Cache key for inter-bar feature results
InterBarFeatureCache
LRU cache for inter-bar feature computation results

Constants§

INTERBAR_FEATURE_CACHE_CAPACITY
Maximum capacity for inter-bar feature cache Trade-off: Larger → higher hit ratio; smaller → less memory