feat: support TA-Lib C 0.8.1 (proposal, for after the 0.8.1 release) - #754
Open
mario4tier wants to merge 2 commits into
Open
feat: support TA-Lib C 0.8.1 (proposal, for after the 0.8.1 release)#754mario4tier wants to merge 2 commits into
mario4tier wants to merge 2 commits into
Conversation
_ta_func_unst_ids was built with enumerate() over the TA-Lib 0.4.0 names.
TA-Lib C 0.6.0 inserted TA_FUNC_UNST_IMI at slot 12, so every id from there
up mis-targets: set_unstable_period('RSI') sets PLUS_DM's unstable period,
'MAMA' sets KAMA's, and 'ALL' sets T3's alone. setup.py requires
ta-lib >= 0.6.1, so this affects every normal install.
Take the ids from lib.TA_FUNC_UNST_* instead. Cython reads the value of a
`cdef extern` const from the header at build time and ignores the literal
written in the .pxd, so one table is correct for every ta-lib release with
no version detection.
'ADXR', 'MFI' and 'STOCHRSI' remain accepted keys but are now no-ops that
emit a DeprecationWarning; TA-Lib C retired those slots. They are not
aliased to the inner ADX/RSI, which would turn a long-standing no-op into a
call with side effects on other functions.
In _ta_lib.pxd, fix the TA_FUNC_UNST_HD_PHASOR typo, drop the stale literal
values, and drop the enumerators that no longer exist.
The new test is behavioural on purpose: set and get look the id up in the
same table, so a wrong id round-trips perfectly.
Verified against ta-lib C 0.6.4, 0.7.1 and 0.8.1.
TA-Lib C 0.8.1 is now the minimum required version. - Bind the seven new functions: CMF, CMOU, HMA, NVI, PVI, PVO, VWMA (declarations in _ta_lib.pxd, regenerated _func.pxi/_stream.pxi, added to __function_groups__ and to both type stubs). - Add MA_Type.HMA and MA_Type.DISABLED. - abstract: __get_flags() raised KeyError on flag bits added after this wrapper was written. 0.8.1 sets TA_FUNC_FLG_STREAM, which made abstract.Function() unusable and left tests/test_abstract.py and tests/test_polars.py uncollectable. Unknown bits are now ignored, and the known new bits (streaming API, path-dependent, nullable output) are named. - tools/generate_func.py, tools/generate_stream.py: skip TA-Lib C's own streaming API (TA_<FUNC>_Open/_OpenAndFill/_Update/_Peek/_Close), which the header parser could not handle. - Building against an older ta-lib still links: a shared object may keep undefined symbols, so the failure only appears when the extension is loaded, as "undefined symbol: TA_CMF_Lookback". Catch that at import and say what is actually wrong. - Bump the pinned TALIB_C_VER in the wheel workflow and the three build scripts to 0.8.1. - Tests: APO/PPO now default matype to EMA and BBANDS timeperiod to 20 per TA-Lib C 0.8.1; version is 0.8.1 and the function count is 168. Added a smoke test per new function and an MA(HMA) == HMA check.
mario4tier
force-pushed
the
fix/752-unstable-period-ids
branch
from
September 5, 2026 20:17
282e50a to
5263446
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.
What breaks against 0.8.1 today
Two of them are hard failures, not just stale expectations:
abstractis unusable._abstract.pxi's__get_flags()doesflags_lookup_dict[2**i]for every set bit and raisesKeyError: 33554432on
TA_FUNC_FLG_STREAM, a flag added in 0.8.1. This takes outabstract.Function()entirely, sotests/test_abstract.pyandtests/test_polars.pycannot even be collected.TA_FUNC_FLG_PATH_DEPandTA_OUT_NULLABLEare also new. Fixed by ignoring unknown bits and namingthe new ones.
ta_func.hdeclares TA-Lib C's ownstreaming API (
TA_<FUNC>_Open/_OpenAndFill/_Update/_Peek/_Close), and theheader parser in
tools/generate_func.pyasserts onTA_ACCBANDS_Stream **stream. Both generators now skip those declarations.(talib's
stream_*wrappers are unrelated — they are generated from thebatch functions.)
What 0.8.1 adds
_ta_lib.pxd, regenerated_func.pxi/_stream.pxi, entries in__function_groups__, and both type stubs. Function count 161 → 168.MA_Type.HMA(9) andMA_Type.DISABLED(10).ta_abstractat runtime: APO/PPO default
matypeSMA → EMA, BBANDS defaulttimeperiod5 → 20. Only hardcoded test expectations and stubs moved.Older ta-lib now fails at import, with an explanation
Binding the new functions makes 0.8.1 a hard minimum. The failure mode is
nasty by default: linking a shared object against an older ta-lib succeeds
— a
.somay carry undefined symbols — sopip installlooks fine and thenimport talibdies withundefined symbol: TA_CMF_Lookback.talib/__init__.pynow catches that and chains a message onto it:The original linker error is preserved via
raise ... from error. This isdeliberately a runtime check rather than a
setup.pyprobe: a build-time probewould need a hardcoded symbol name that silently goes stale whenever the
minimum moves (the same failure mode as #752), and it could not catch a
prebuilt wheel meeting an older system library.
setup.pyis unchanged.Verification
ta-lib C built fresh from source, ta-lib-python built in place
(
setup.py build_ext --inplace, Cython 3.2.9, no wheels):All five test files collect on 0.8.1:
test_abstract.py17,test_func.py50,test_pandas.py2,test_polars.py4,test_stream.py5.For contrast, unmodified
masteragainst the same 0.8.1: 24 passed, 1 failed,2 collection errors.
Open items for you to decide
pyproject.tomlis untouched and the CHANGELOG heading0.8.0is a placeholder — release numbering is yours.TALIB_C_VERis bumped to 0.8.1 inwheels.ymland the three build scripts, and those downloadrefs/tags/v0.8.1.zip. Wheel jobs will 404 until TA-Lib C 0.8.1 is tagged.docs/func_groups/*.mdare hand-written and do not list the seven newfunctions. Nothing tests them; happy to add if you want it here.
talib/_ta_lib.cis left untouched, since it is only committed on Cythonversion bumps.