Skip to content

🔨 Lookback-functions#71

Open
serkor1 wants to merge 8 commits into
develfrom
70-lookback-function
Open

🔨 Lookback-functions#71
serkor1 wants to merge 8 commits into
develfrom
70-lookback-function

Conversation

@serkor1

@serkor1 serkor1 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

📚 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

  • Test the overhead of calculating lookback (should be O(1))
  • Implement unit-tests (attributes vs lookback)
  • Implement high-level wrapper talib::lookback(FUN, ...) similar to indicator()

⚠️ Caveats

When returning as as.double(x) the attributes gets stripped. So all numeric methods are broken - and all rolling-functions.

This PR closes #70

@serkor1 serkor1 added the enhancement New feature or request label Jun 8, 2026
@serkor1 serkor1 linked an issue Jun 8, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.96996% with 227 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.17%. Comparing base (a2d960c) to head (a34ce5a).

Files with missing lines Patch % Lines
src/ta_BETA.c 0.00% 9 Missing ⚠️
src/ta_CORREL.c 0.00% 9 Missing ⚠️
src/ta_STDDEV.c 0.00% 9 Missing ⚠️
src/ta_VAR.c 0.00% 9 Missing ⚠️
src/ta_MAX.c 0.00% 8 Missing ⚠️
src/ta_MIN.c 0.00% 8 Missing ⚠️
src/ta_SUM.c 0.00% 8 Missing ⚠️
R/lookback.R 65.00% 7 Missing ⚠️
R/ta_BETA.R 0.00% 6 Missing ⚠️
R/ta_CORREL.R 0.00% 6 Missing ⚠️
... and 126 more
Additional details and impacted files
@@            Coverage Diff             @@
##            devel      #71      +/-   ##
==========================================
- Coverage   96.67%   96.17%   -0.51%     
==========================================
  Files         280      281       +1     
  Lines       21012    24225    +3213     
==========================================
+ Hits        20314    23299    +2985     
- Misses        698      926     +228     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@serkor1 serkor1 force-pushed the 70-lookback-function branch from d012108 to c672e7d Compare June 8, 2026 16:02
@serkor1 serkor1 force-pushed the 70-lookback-function branch from c672e7d to 3764c17 Compare June 8, 2026 16:41
serkor1 added 4 commits June 20, 2026 21:36
* 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.
@serkor1

serkor1 commented Jun 20, 2026

Copy link
Copy Markdown
Owner Author

volume() is a pain. The lookback period depends on the MA-input. By construction it would need at minimum the maximum of (MA_1, MA_2, ..., MA_k).

serkor1 added 3 commits June 20, 2026 22:04
* 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.
@serkor1 serkor1 marked this pull request as ready for review June 20, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement loookback-function as development tools

1 participant