Skip to content

🔨 Migrate codegen to {boilerplate.rs} #75

Description

@serkor1

📚 What?

TA-Lib, and therfore {talib}, is a huge library. It supports +150 (depending on how you count it) different indicators in separate files. The R wrappers were handwritten in the early development days, and as more more indicators were wrapped, even small additions/corrections triggered a full copy+paste, find-and-replace and other small makeshift BASH commands.
And then I finally opted for a full-scale BASH-templating approach first manually, and then with the assistance of AI (Thank you OpenAI and Anthropic).
While this approach did ease the development by alot, it also introduced a whole new branch of bugs, which shifted the focus from properly developing the TA-Lib wrapper, and a solution that were not portable to other projects; so each project were basically starting from scratch on the boilerplate generation.

Either way, there is now a tool called {boilerplate.rs} (which I have developed, with the help of AI) that abstracts the boilerplate generation, and is generally portable to other projects. {boilerplate.rs} will be implemented in the repository to reduce the size of this repository, reduce the exposure of bugs and generally test out and improve {boilerplate.rs}.

📋 TODO

The implementation will be done in two phases (c-wrappers, then R-wrappers (unit-tests included)), and the TODO list applies to both.

  • Map gen_code/indicators to config.toml
  • Recode splices to {boilerplate.rs} protected regions (Found in templates/)
  • Recode key-value pairs
  • Stage + commit
  • Check diffs (Rinse and repeat untill the diff is limited to key-value pairs)

📖 Notes and gotcha's

  • With the new release of TA-Lib the function signatures can be found in ta_codegen/input/<indicator>/<indicator>.c which are 1:1 mapable to R - which also implies that splices in .Call() are now redundant altogehter.

Note

These can be mined manually or through a simple BASH-script

  • Each ta_codegen/input/<indicator>/<indicator>.md contains a formula section which can be mapped to .Rd with some modifcation so formulas are rendered correctly.

💣 Plan of Attack

  • Make AI scan input/<input>/ twice to extract relevant parts of the C and R signatures by giving it a list of indicators, examples and formats. Remember to add formulas and indicator specific documentation.

  • Construct relevant key-value pairs manually (Do not forget multicolumn output, and shifted pointers)

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency fileenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions