Skip to content

Add continuous historical-to-realtime strategy streaming#85

Draft
luisleo526 wants to merge 2 commits into
mainfrom
codex/alert-webhooks
Draft

Add continuous historical-to-realtime strategy streaming#85
luisleo526 wants to merge 2 commits into
mainfrom
codex/alert-webhooks

Conversation

@luisleo526

@luisleo526 luisleo526 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a continuous historical OHLCV warmup → realtime raw-trade lifecycle
  • preserve positions, equity, pending orders, Pine/TA state, request.security() state, and partial timeframe aggregation across the handoff
  • evaluate resting broker orders on each exchange trade while retaining the default close-only strategy calculation cadence
  • expose the lifecycle through the stable C ABI and Python ctypes harness
  • add contiguous mmap corpus replay tooling that sends one whole-session tick span per strategy, without feed chunks
  • add a dedicated cdocs streaming guide and pf_streaming API group
  • add a runnable tutorial/run_stream.py example and keep it in the normal CTest lane
  • update ABI, lifecycle, FFI, coverage, and tutorial documentation to distinguish one-shot resets from continuous streams

Why

TradingView strategies load confirmed historical bars and then continue on realtime data without replacing the strategy instance. PineForge previously only exposed one-shot backtests, so switching data sources could not preserve the complete broker and script state. This change introduces an explicit streaming lifecycle that keeps the warmed instance alive.

It also establishes the realtime execution foundation needed for later alert(), order-fill alert, and JSON webhook work. Alert delivery itself is intentionally not part of this PR.

Validation

  • ctest --test-dir build --output-on-failure: 85/85 passed, including test_tutorial_stream
  • ./scripts/run_corpus.sh: 252/252 executed; 239 excellent, 12 strong, 1 existing anomaly
  • bash docs/build.sh: cdocs generated without warnings, including streaming.html and the pf_streaming group
  • python3 tutorial/run_stream.py: 672/672 bar continuity, 49 cumulative trades, exact tutorial P&L
  • ABI runtime checker and git diff --check: passed
  • long raw-tick corpus replay: 756/756 sessions completed
    • 756/756 input/script bar-count parity
    • 750/756 trade-count parity
    • 729/756 exact ordered trade structure
    • 99.866844% weighted ordered trade-structure parity across 4,463,189 compared trades

The long replay used three session starts (2025-03-29, 2025-03-30, and 2025-03-31), each ending exclusively at 2025-05-01. Each strategy/session received one contiguous strategy_stream_push_ticks(pointer, count) call.

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.

1 participant