ropensci / rb3

A bunch of downloaders and parsers for data delivered from B3
https://docs.ropensci.org/rb3/
Other
70 stars 28 forks source link

Use yc_mget for multiple dates and yc_get for a single date #26

Closed wilsonfreitas closed 2 years ago

wilsonfreitas commented 2 years ago

I rarely use yield curves for multiples dates. In instruments pricing the common use is to fetch the yield curve for one specific date and price the financial instruments with that curve.

So, my suggestion is: use yc_mget for multiple dates, following the same interface that is now used in yc_get. And yc_get should return one single curve for the given date.

yc_mget(first_date, last_date, by = 5, cachedir(), do_cache = FALSE)
yc_get(refdate, cachedir(), do_cache = FALSE)

The same can be applied to futures_get: futures_mget for multiple dates and futures_get for a single date.

get and mget names are commonly used in nosql databases to express the same behavior/idea.

@msperlin what do you think about that?

msperlin commented 2 years ago

@wilsonfreitas Im not sure I get it. Function yc_get already accepts a first and last date. If user wants just one date, use the same string in both inputs.. If user wants a particular vector of dates, just filter the output data from the whole period.

But, if you fell it is worth the work, do it. I'm not particularly picky about this stuff, as long as it works as intended.

wilsonfreitas commented 2 years ago

It's all about API design. I realy like to think of APIs that are inspiring and make the users happy to use them. From an API point of view, it is very important to express clearly its main objective. Being honest, I don't like the idea of having to declare two dates to get one date in return.

I will go on with this topic and keep you informed.

wilsonfreitas commented 2 years ago

Done