🔨 Lookback-functions#71
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #71 +/- ##
==========================================
- Coverage 96.67% 96.56% -0.12%
==========================================
Files 280 281 +1
Lines 21012 24264 +3252
==========================================
+ Hits 20314 23431 +3117
- Misses 698 833 +135 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d012108 to
c672e7d
Compare
c672e7d to
3764c17
Compare
* The lookback function is a utility/helper function
for downstream packages that wants to implement their
own wrapper based on {talib} - the function gives a higher
degree of freedom in the way the indicators are called and can
be used in any custom control flows.
* The unit-test tests whether the lookback is equal between the lookback() and attribute. This is mainly to test the lookback() and not the the indicators. They are calculated the same way.
Owner
Author
|
|
* The function returns the max(MA1, MA2, ..., MAk) when passed - otherwise zero. * The ta_VOLUME.c has gotten some love and refactoring but the underlying logic is the same.
* as.double() strips all attributes which means that the lookback attribute gets lost in the meatgrinder - an alternative option is to set set the dim(x) <- NULL (which should be a safe alternative) * is.vector() only returns true if the input value if the only attribute is names; this implies (I guess, not tested) that all data containers would return TRUE in some form or the other. A separate test condition is to check whether the output has no dim()-value.
* TA-Lib returns -1 for invalid indicator and data pairs; if the lookback is invalid R will return it as <NA>. This behaviour has been documented internally and in the roxygen documentation. * lookback() will return max(lookback, 1) to avoid insensible return values like 0 (this is the case for volume without moving averages).
* In 82c5f88 the lookback values were set to minimum 1 for a valid indicator and data pair. This commit reflects this change such that the attributes behaves in a similar way - which also has to be reflected in the parity-tests so the comparision is apples-to-apples.
* When using `dim() <- NULL`, the storage.mode() is preserved and therefore indicators that returns one-dimensional indicators as vectors fails the as.double() test; it should be safe to test for is.double and is.integer at the same time - if there is any coercions these will be caught by the parity-tests either way.
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 PR introduces unexported lookback-functions for calculating lookback-periods independently of the indicator functions. The goal is to provide an input validation step for downstream wrappers like {ledgr}, and similar packages that may or may not use different control-flows.
📋 TODO
talib::lookback(FUN, ...)similar toindicator()When returning as
as.double(x)the attributes gets stripped. So all numeric methods are broken - and all rolling-functions.To solve this, strip the
dim()to retain the one-dimensional return values.This PR closes #70