Closed goergen95 closed 4 months ago
I like this a lot, especially calculating multiple indicators in one go will be much cleaner with this.
One thing to consider. If a user wants to calculate a lot of indicators and one of them fails (e.g. because wrong parameter, resource missing, etc.) I think the rest of the indicators should still be calculated if possible.
Maybe we can have something like a fail_early
option. Say, you are working with a very large portfolio and request several indicators and some errors occur. You will just learn about that at the very end (at least if you use parallelization, because I think I have not figured out how to print errors directly in that mode) which might actually be after a considerable amount of time. Though I think that arguments should be checked in the outer function, so you get an error immediately when you supply e.g. a character instead of a numeric.
Oh, also I'd like to reconsider the return value of indicators if something does not match up. I think that NULL is a much more sensible value, but this is yet another issue. :smile:
This is currently WIP as announced in #240. Closing here, once the branch is ready for testing and issues arise it is better to put those in specific discussion threads.
I would like to propose to use closures for the definition of resource and indicator functions. Closures are function that return functions, thus they have two possible layers of arguments. We can use the first layer to expose the user-facing arguments to users of the package. The second layer than only requires package-internal arguments (that with this we could also check and emmit warnings if not matched.
I think the benefits for the users is a clearer UI: You have a single function for each resource/indicator that you can also look up in the help pages. Internally, there is the benefit that there are no ambiguties to which resource/indicator an arguemnt actually belongs. For developers, there is a little overhead introduced because the functions have to be wrapped in a second layer but it also gives much more freedom in the sense of user-facing arguement names etc.
If we started development on this I would suggest to do it on top of the
into-the-clouds
branch in order to cause less fricition once that one is merged.Below is a simple mock-up of the interface would look like:
Created on 2024-01-08 with reprex v2.0.2