Repository navigation
Conversation
* This commit introduces support for cached builds across installation runs for each pushed update. It supports ccache, sccache and distcc. At this stage its only tested for remote installs, but it *should* cover all edge-cases either way as the compiled library is otherwise the same. * This commit closes #57 by implementing cached builds across installation runs.
* The README has been streamlined and now positions the {talib} relative to the upstream, and (implicitly) relative to the wider R ecosystem.
* The usage examples have been equally weighted between charting and indicators in general, with a generally higher emphasis on the candlestick pattern recognition which is the primary differentiator against {TTR}
* normalize one-column numeric indicator outputs back to double vectors * update the generated numeric templates so future wrappers keep the same behavior * tighten generated numeric tests to reject one-column matrix results while preserving multi-column matrix outputs Fixes #61 --------- Signed-off-by: nvphungdev <283886185+nvphungdev@users.noreply.github.com> Co-authored-by: nvphungdev <283886185+nvphungdev@users.noreply.github.com>
* The benchmarks now covers comparisions against
{TTR} across multiple indicators and presents them
in the README accordingly.
* The benchmarks now compares the .Call against the
dispatched methods more thoroughly than before.
The goal of the benchmarks is primarily micro-optimizations
on the R side.
* The README now includes a subtle reference to the benchmark where the claim of speed is made. * Added linebreak after dots (this is good standard)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## CRAN #65 +/- ##
==========================================
- Coverage 96.58% 96.06% -0.53%
==========================================
Files 280 162 -118
Lines 21012 21965 +953
==========================================
+ Hits 20294 21100 +806
- Misses 718 865 +147 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
* See issue #67 where remote installs fails on MacOS due to missing C header files. The error is related to gettext (source: https://stackoverflow.com/questions/11370684/what-is-libintl-h-and-where-can-i-get-it) The issue have not been addressed in the repository before now as it was assumed to be related to the workflow itself - the failed run coincided with the release of R4.6.0 which turned out to be a false-positive as it still an existing issue. * Since the issue is most likely an upstream issue, the R-devel runs have been removed for all OSes and replaced with oldrel-2. Backwards compatibility is more imporant than experimental releases - if you decide to throw a development version of R against a package that deals with (potentially) expensive implementations, you have bigger things to worry about.
* This PR introduces a lookback function that wraps indicator_lookack that returns <NA> for invalid indicator and data pairs, and always minimum 1 (Can't calculate any indicators without data). The implementation differs from upstream in the way that upstream returns -1 for invalid pairs, and 0 for indicators that in reality does not need a lookback periods (C is 0-indexed). * The implementation required significant backend changes that has no effect on the interface. One such example is using `dim(x) <- NULL` for 1D-arrays instead of `as.double()`; this introduces the following changes: (1) unit-testing has been made more flexible so it tests for `is.integer()` simultaneously as the new approach preserves the underlying storage mode. (2) parity-tests have, for lookback-calculation(s), been adapted to the new calculation of lookbacks. See PR #71 for more details.
* The indicators on C-side were generated using two separate templates for candlestick and non-candlestick. These have been consolidated to ease future changes from upstream and possible interface changes and additions. * The lookback-functions on C-side now ignores ununused arguments to avoid compiler-warnings. The arguments have been kept to streamline function signatures on the R-side.
* Instead of relying on nested if-else statments, the if-else statements are heavily dependent on conditionals to be met.
* This is common knowledge: '<-' is for assignments its unclear when '=' was used in the code. But let this commit be testament to the commitment of correct use of assignment operators. - All hail the assignment operator.
* Without this, the documentation entry does not render.
It appears that {roxygen2} looks for the top-level entry as
the title, unless strictly typed.
* The example in lookback() were breaking because
there was an additional non-existing argument passed
into the downstream function.
* The (possible) fix is to let lookback() be strictly
typed, for the lack of better words, such that it fails
if the lookback signature doesn't match the downstream function
entirely.
This is probably not the best idea, but the lookback function is
a function for 'developers' that seeks to wrap {talib} and it is therefore
expected that the developer is familiar with the function(s).
Even for non-developer use-cases this implementation has its justification
in the sense that if there is a need to pre-calculate the lookback period
it must be due to critical infrastructure implementations, which in return, again,
requires familiarity with the function(s).
Bumps [src/ta-lib](https://github.com/TA-Lib/ta-lib) from `c042ea3` to `bffd837`. - [Release notes](https://github.com/TA-Lib/ta-lib/releases) - [Commits](TA-Lib/ta-lib@c042ea3...bffd837) --- updated-dependencies: - dependency-name: src/ta-lib dependency-version: bffd83732f0ab022a272ae6cd79d1ba6b32cc2ce dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [src/ta-lib](https://github.com/TA-Lib/ta-lib) from `bffd837` to `2247d59`. - [Release notes](https://github.com/TA-Lib/ta-lib/releases) - [Commits](TA-Lib/ta-lib@bffd837...2247d59) --- updated-dependencies: - dependency-name: src/ta-lib dependency-version: 2247d599bddf37ed37e3a709371517e46efc66f6 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
* The code-generator currently only works for the TA-Lib (C-side) indicators and uses the TA-Lib functions list to identify all indicators with their respective signatures wrapped in X-Macros. The goal is to be independent from BASH and use an algorithmic approach so input arguments that has default values are not silently dropped. Furthermore it is expected that ALL TA-Lib indicators will be generated using X-Macros.
* The X-Macros will be using TA_* prefixes for readable preprocessing. So DBL --> TA_DOUBLE for doubles.
* The codegen/ now also parses the TA_<indicator>_Lookback signatures which is the optional inputs for all the functions. * The original C_MACRO has been renamed to BATCH to distinguish between streaming (Upcoming) and batch API for later TA-Lib versions.
* The identifiers follows a simple if-else statement for identifying candlesticks based on the indicator name 'CDL'. With this implementation it is now possible to implement candlestick-specific logic on the C preprocessing side without having to rewrite the logic downstream.
* All lookback related functions have been removed to accomodate the new codegen that uses the exact signature of the TA_<indicato>_lookback funtions.
## 📚 What? This PR is a rewrite of the source code that binds TA-Lib to R. The overall goal is to reduce the amount of code, and simplify the C-wrappers. It has been implemented incrementally, so much of the original functionality as been deleted but is to be reintroduced in a similar fashion. There has been no consideration for backwards compatibility which in this case means that a part of the R logic has to be re-written (This does not affect the signatures at all). All *_lookback functions, for example, now only accepts the relevant arguments in `.Call()` which breaks with the current R side logic. (This should be possible by only rewriting the templates, so the PR is mainly focused on the C-side)
* fmt target now also runs cargo fmt on the crate * gen-code target now includes cargo run * Deleted old script runners
* This commit mainly brings a new backend to the codegeneration on the R side - the old generation were handled by a mix of R and BASH which were harder to maintain than first expected. shQuote() or was it paste()? And how does BASH recieve these arguments? These were questions and debugging the code generation were riddled with. Using Rust unifies the headache in a uniform way, which seems to be easier maintainable.
* The code generation is mainly handled by mining the .xml file that TA-Lib constructs without any modifications to the input arguments. This means two things: (1) breaking changes in R signatures and (2) bug-fixes where MATypes were mixed with multiple indicators (See ta_APO.R) where the MAType's role were ambigious. {talib} is still in pre 1.0.0 and the download counts are so low that there should not be any breakage in dependencies downstream.
* The code generation on the R side is (at this stage) a brute attempt which means that some of the exported functions are either broken or incorrectly named. These will be fixed in the subsequent commits to avoid too many changes in a single commit. This squash commit contains 24 (ish) commits, which makes the development flow non-transparent, which is also why the bugs are kept as-is at this stage.
* The optional documentation is mined fromn the .xml file and manipulated so it emits proper R documentation for each documented parameter.
* This change reflects the new signature the exported functions follow.
* tests/testthat/helper-library.R attaches {xts} only when it is
installed, and every generated <xts> test block carries
skip_if_not_installed('xts') - the suite no longer hard-depends on a
Suggests package (verified against a library with xts/zoo hidden:
everything loads, the xts blocks skip cleanly, zero failures).
* Every generated test file gained a 'Value parity with <data.frame>
(<xts>)' block: the <xts> result must equal the lowercase
<data.frame> reference numerically, both on the GOOGL fixture and on
an alphabetically sorted copy that places 'Adjusted' before the OHLCV
columns - locking the column-resolution contract (formula order,
suffix matching, no substring collisions) for all 129 indicators.
* test-series.R gained unit tests for the <xts> resolution layer
itself: formula-order selection, quantmod-style suffix matches,
lowercase names, explicit 'cols =' order, and the error/warning
contracts (no match, ambiguity, short formula, unused 'subset');
plus a vanilla-session subprocess regression (skip_on_cran) proving
RSI(GOOGL) works without {xts} attached.
* series() gained a default method that defers any classed input to as.data.frame() before column resolution - a multivariate zoo (or any data.frame-coercible object) now computes on the coerced frame with the index as rownames, instead of dying with the internal "no applicable method for 'series'" error. Uncoercible inputs fail with base R's own coercion message naming the class. * The indicator documentation now states the actual per-class contract: xts in, xts out alongside data.frame/matrix; coercible inputs computed on the coerced data.frame; the xts column resolution (exact matches first, then quantmod-style suffix matches, consumed in formula order) documented under 'cols'; and '...' marked unused for xts input. * index_data_frame(), index_matrix() and index_xts() in src/names.c now return SEXP (R_NilValue) as Writing R Extensions requires for .Call routines - previously void, an undefined-behavior read of the return register. A registration sweep confirms no other void .Call routines remain.
* The chart dispatch no longer calls ...names() (R >= 4.1): the argument names are already captured by the substitute() call one line above, so names(dots_quoted) carries the identical information. * nullfile() (R >= 4.0) is replaced by an internal .nullfile() in the small base-R replacements section of utils.R, returning the platform null device; the three render-path call sites in chart_indicator.R now use it. Verified against the single-panel print, the multi-panel grob alignment and the print-guard paths. * The pattern-marker data.frames in chart_pattern.R set stringsAsFactors = FALSE explicitly - the default flipped in R 4.0, and the declared floor predates the flip. **NOTE:** This was captured during an adversial review by Fable.
* trading_volume() on a vector no longer errors on the default maType: the numeric splice converts the specifications like .default does.
* 'subset' is evaluated exactly once, by model.frame(), identically on every route (direct data.frame call, wrapper-on-chart, indicator()): data-context expressions like subset = close > 60000 now work everywhere, columns of the data win over caller objects, and the caller's frame is the fallback. The internal re-evaluations that crashed data-context expressions - and evaluated side-effecting expressions up to three times - are gone; the subset attribute now records the row positions model.frame() actually kept. * Arguments on the chart path resolve in the caller's frame: data =/subset = referencing function-local objects work from inside function bodies. indicator() keeps 'subset' quoted and evaluates the wrapper call in the caller's frame, so all routes share one semantic. * The ggplot2 backend aligns indicator positions by axis label, mirroring plotly - indicators computed with subset = are drawn at the subset's own candles instead of positions 1..n. * indicator(FUN, data = y) no longer silently stamps the chart's dates onto a mismatched override: a length mismatch warns and the trace is labelled with the override's own rownames. * chart() normalizes quantmod-style OHLCV names (TICKER.Close, Close) to the lowercase names the backends consume - exact matches first, then dot-suffix matches, mirroring series.xts() - and fails fast with the package's own missing-columns message instead of an opaque backend error at render time. Standalone indicator() with <xts> data keeps its time axis.
* Added <xts>-method mention, and removed the minimal dependency argument - even though xts and zoo are suggested it is still a departure from the minimal dependency framework. * Replaced BTC with GOOGL to demonstrate <xts> compatibility with class in and class out condtion.
* The .md file were not rendered or updated. This is what happens if you commit and rebase before bedtime.
* Moving averages now use foo(x, <series>, <options>, cols, na.bridge, ...). VWMA's volume is a formal of the generic with the ~close + volume column as fallback, fixing the 3-vs-4 parameter warning in checkFF(). Breaking: positional 'cols' as second argument in MA calls.
* This commit reverts the normalization of lookback periods so it follows upstream closer.
* All indicators have a deterministic number of leading
NAs which gets passed into the next indicator if passed as
foo(bar(x)) - the outer foo() will return all <NA> because of the
underlying algorithm.
- Before any calculation is done these leading <NA> should be stripped
and can be stripped in O(1) time given the existing attributes of the
underlying indicator.
Bumps [src/ta-lib](https://github.com/TA-Lib/ta-lib) from `a8272d0` to `5009422`. - [Release notes](https://github.com/TA-Lib/ta-lib/releases) - [Commits](TA-Lib/ta-lib@a8272d0...5009422) --- updated-dependencies: - dependency-name: src/ta-lib dependency-version: 500942220b9b42a0b4c272a99b7abfacb1fa0f7c dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
* This commit closes #84
serkor1
marked this pull request as ready for review
September 27, 2026 19:45
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?
This version brings many changes to the R package.
The entire code generating backend have been rewritten so it closely follows the upstream naming of parameters and it uses X-macros so it also installs way fastert than before - but it also means that there is alot of breaking changes.
The update is a big leap towards a stable release.
improvements
The function returns the required lookback for calculating the indicator. A lookback of 0 means the indicator is computable from the first observation (
talib::balance_of_power(), for example).Its use-case is customized control-flows for downstream wrappers and/or packages that declares dependency on {talib}.
lookbackattribute: the total number of leading rows that are not computed. The attribute is cumulative, so chaining indicators sums each stage's lookback, and it is used internally to chain indicators deterministically at full input length:The chain carries RSI (14), SMA (29) and BBANDS (19)—
attr(output, "lookback")is their sum, the leading-NA head of the final series. The per-indicator lookback remains available viatalib::lookback().The source code have been re-written so it generates the underlying TA-Lib wrappers using preprocessors and X-Macros, which compiles much faster than before.
<xts>-methods:—All indicators now supports <xts>-objects. These methods are considered the primary entry point for all indicators, and can be considered stable from v1.0.0, where changes—if any—will be implemented gradually after a deprecation period. The method uses the same signature as before, see the example below:
camelCasealias to introduce a form of consistency across R's finance ecosystem and oldschool coding schemes.The indicators below produces the same output:
Each
UPPERCASEandcamelCasefunction is an alias of its underlyingsnake_casefunction, so the functions behaves the same.breaking changes
This has the benefit of being transparent when comparing or reading the source code.
bollinger_bands()below:Prior to this update, the correct call was:
While the above function call is aestethically pleasing, it did introduce some ambigiuites in other calls. See, for example,
APO()(v0.9.2) below:In this specific case the function has three different
n- the underlying function were discardingn = 9while keeping the MAType.The new call is given as:
In this call the role of each argument is should be clearer than before.
This deviates from the generic
x+timePeriodsignature, and breaks thenumeric-method.One solution is to do the following:
To avoid breaking the S3 signature. However, given the importance of the
volume-argument and the fact thatcolsis rarely used, the signature has been changed to accommodate future additions of MAs which take additional series. The new signature is as follows:Additional series (the volume) lead directly after
x, while additional optional parameters keep their place aftertimePeriod. In the case of VWMA this becomes:And for the remaining MAs:
MAs with additional optional parameters retain them after
timePeriod, e.g.MAMA(x, timePeriod, fastLimit, slowLimit, cols, na.bridge, ...)andT3(x, timePeriod, volumeFactor, cols, na.bridge, ...).The
volume-argument is not required whenxcarries a volume column:VWMA(x)selects it via the default formula~close + volumeas before. An explicitly passed vector takes precedence, in which case only theclose-column is required:NOTE: passing
colspositionally as the second argument no longer works for the MAs—it has to be passed by name, ie.SMA(x, cols = ~open).bug-fixes
CCI: Incorrect charting—The indicator were incorrectly classified as a main chart indicator—
One-dimensional indicators: incorrect return <class>—Indicators that returns a one-dimensional indicator (MA, RSI, etc.) were returning a <matrix> or <data.frame> instead of <numeric>.
Merged indicators: overlapping last-values—On the plotly backend, merging indicators onto one panel stacked every last-value label on the panel's top-right corner. The labels are now collapsed into a single evenly spaced label, mirroring the merged subtitle of the ggplot2 backend.
Merged indicators: indistinguishable last-values—Merged last-value labels used the bare output column name, so merging the same indicator with different parameters displayed identical labels. The labels now carry the full indicator specification, including its parameters, as the ggplot2 backend already did.