Skip to content

v6.4.0 — request.security()

Choose a tag to compare

@wallneradam wallneradam released this 28 Mar 16:37
· 27 commits to main since this release

request.security() — Multi-Symbol and Multi-Timeframe Support

This release adds full request.security() support, enabling multi-symbol and multi-timeframe analysis in PyneCore scripts. Each security context runs as a separate OS process with its own Series history, providing true parallel execution on multi-core systems.

New Features

request.security()

  • Higher-timeframe (HTF) data access with lookahead_off semantics (confirmed previous period)
  • Multi-symbol support — access data from any symbol with available OHLCV data
  • Multiple security calls per script, each running in its own process
  • Conditional and nested security calls supported
  • barmerge.gaps_off (forward-fill) and barmerge.gaps_on (na between periods)
  • ignore_invalid_symbol parameter — returns na for missing symbols instead of raising an error
  • currency parameter — automatic currency conversion using CurrencyRateProvider
  • --security CLI flag for pyne run to provide OHLCV data for each security context
  • Same-symbol, same-timeframe optimization — no separate process spawned, values read directly from chart
  • Lazy process startup — security processes spawn on first signal, not at script initialization
  • Configurable security context limit (default 64)

request.security_lower_tf()

  • Lower-timeframe (LTF) data access returning array<type> (list of intrabar values per chart bar)
  • Accumulation buffer with flush-on-signal protocol

request.currency_rate()

  • TOML metadata scan for automatic FX pair detection
  • Lazy OHLCV loading with binary search for nearest-prior timestamp
  • Chart OHLCV as rate source when chart is a currency pair
  • Inverse pair fallback (1.0 / close)

Architecture

  • AST Transformer (SecurityTransformer): rewrites request.security() calls into signal/write/read/wait protocol functions
  • Shared Memory IPC (security_shm.py): SyncBlock + ResultBlock with version-tracking readers for near-zero-overhead inter-process communication
  • Process Loop (security_process.py): independent OHLCV loading, bar-by-bar synchronization with advance/done events
  • Protocol (security.py): HTF period confirmation via Resampler, session gap handling

Documentation

  • docs/lib/request-security.md — usage guide with examples
  • docs/lib/request-data.md — overview of all request.* functions
  • docs/advanced/request-security-internals.md — technical implementation details
  • docs/overview/compatibility.md — TradingView compatibility matrix
  • Updated docs/cli/run.md with --security flag documentation
  • Updated docs/programmatic/script-runner.md with security data API

Tests

  • 13 AST transformation tests
  • 20 shared memory and runtime protocol tests
  • 10 currency rate tests
  • 3 end-to-end integration tests (advance/decline ratio, same context, ignore invalid symbol)

Known Limitations

  • lookahead_on is deliberately not supported — it leaks future data into backtesting decisions
  • Standalone mode (python script.py data.csv) does not support --security yet