-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finance use case - tenor conversions to time spans #459
Comments
Do I understand correctly that you want specialized parsers to get from
There is an internal unit parser since in lubridate: > lubridate:::parse_period_unit("1y")
$n
[1] 1
$unit
[1] "y" That's the closest it gets at the moment. |
You understand the concept The name I leave to you, period seems like a reasonable name for it. The I can take a stab at implementing. Were you thinking of adding another case here? |
Yes. But let's think of a proper and consistent API first. I would very much prefer to have a more generic string parser. Something like Also need to check what ISO standard has to say about it. Related #362 |
I certainly agree that parsing the ISO standards is an excellent goal to reach for. My question is, how about both? That is, have the ability to parse simple Of course, if you would rather this functionality be external to lubridate, just let me know and I will close this issue and related PR. |
Yes. This is the intention. I don't think it should be external to lubridate. I will give a stab at C parser for this and #362 when I have a bit of time. It will not happen by next release for sure (already next week). |
@waynenilsen what is the tenor abreviations for sub day units? 1H,1M,1S? If so that's compatible with strptime and would be very nice indeed. |
Unfortunately, in the case of tenors M is used for month, the tenors are always assumed to be a day or greater and generally interpreted in a case-insensitive way. H and S are fair game. A popular example is LIBOR 3M the three month London interbank offered rate. There is also LIBOR 6M and EURIBOR 6M for example. |
I have decided to fix this now. I need it to fix some misused of character comparison in a bunch of revdeps. As a by product you can now directly compare to strings: > duration("day") < "day 1sec"
[1] TRUE Arbitrary abreviation of units and repeated units is supported. > period("1sec 1second 1s 1 s")
[1] "4S" |
I thought I would add this as an issue, hoping that some functionality like this is already in lubridate. I have what we call tenors in finance, examples are
1w
5d
10y
etc. I think themonths
anddays
function serve this purpose however considering the ease-of-use nature of this library a convenience function would be great for converting these number-plus-span combinations into lubridate things. Let's call this functiontenor
for the sake of argument. The nature of this function would be such thatIs there already something like this?
The text was updated successfully, but these errors were encountered: