feat(stream): handles over TA-Lib C 0.8.1's streaming API (#757) - #759
Merged
Conversation
mario4tier
force-pushed
the
feat/streaming-handles
branch
from
September 6, 2026 18:23
66c7d42 to
1e58076
Compare
talib.stream.SMA(close) returns a handle, not a value: .value is the value at the last history bar, .update(bar) is O(1) and returns that bar's, .peek(bar) evaluates a forming bar without committing, .copy() forks it, and .open_and_fill() returns the handle plus the Function API's series in one pass. Multi-output functions answer with a named tuple; .out_range and .advance() carry the C contract's bar range. BREAKING: talib.stream_X and the old value-returning talib.stream.X are gone, along with the stream_* stubs in _ta_lib.pyi -- talib/stream.pyi types the handles instead. Migrating is stream.X(...) -> stream.X(...).value, and the compiler will not find the sites: `if stream.CDLDOJI(o, h, l, c):` used to test the pattern and now tests a handle, which is always true. Adds talib.InsufficientHistory, raised when an open gets too little history. talib/_stream.pxi and talib/stream.pyi are generated by tools/generate_stream.py (--stub for the second).
mario4tier
force-pushed
the
feat/streaming-handles
branch
from
September 6, 2026 18:32
1e58076 to
8185430
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #757:
talib.streambecomes handles over TA-Lib C 0.8.1's streamingAPI, replacing the last-value functions.
Multi-output functions answer with a named tuple whose fields are the output
names in the docstring; single-output ones with a bare
float(orint).out_rangeandadvance()carry the C contract's bar range. Newtalib.InsufficientHistoryfor an open with too little history.What to read
Two files:
tools/generate_stream.py(the generator) andtests/test_stream.py(the suite).talib/_stream.pxi,talib/stream.pyiand
talib/_ta_lib.care generated output —make generateplusmake cythonreproduces them byte for byte, so the 275k-line diff is 1000 lines of review.
Breaking change
talib.stream_Xand the value-returningtalib.stream.Xare gone, as are thestream_*stubs in_ta_lib.pyi(talib/stream.pyitypes the handlesinstead). Migrating is
stream.X(...)->stream.X(...).value, and thecompiler will not find the sites:
if stream.CDLDOJI(o, h, l, c):used to testthe pattern and now tests a handle, which is always true.
A few decisions worth a second opinion
check_begidxskips them, so
stream.X(h).value == talib.X(h)[-1]holds bitwise. The offsetis added back to
out_rangeand to theMAXINDEX/MININDEX/MINMAXINDEXoutputs, which the batch tier also rebases.
out_rangeandadvance()are exposed although refactor(streaming): replace with the v0.8.1 Core implementation #757 does not name them;they are part of the C streaming contract and the other backends have them.
open_and_fillreturns(handle, outputs), outputs being exactly what thebatch call returns, pandas/polars container included.
close()—__dealloc__frees, as GC suffices for a managed handle..github/workflows/tests.ymlgainsdevin both branch filters; ittriggered on
masteronly, so a PR intodevran no checks at all. If this PRshows none, that filter needs to land on
devfirst.Verification
TA_FUNC_FLG_STREAM: every streaming functioncompared bit-exactly against its batch series over three datasets (real prices,
prices mapped into [-1, 1], and one with zero-range and zero-volume bars), two
compatibility modes and two warm-up prefixes, plus a NaN-prefixed corpus.
test_the_data_discriminatesasserts only candlesticks are output-flat, so thecomparison cannot quietly go vacuous.
catches an argument-order slip in
MEDPRICE/ADD/MULT/WCLPRICE— those arebit-identical under a high/low swap.
dev, including the no-Cython sdist path thatcompiles the committed
_ta_lib.c, and a wheel that passes the release testcommand.