difference_in_time {dispositionEffect} | R Documentation |
Difference in time
Description
Financial implementation of
base::difftime
, that takes into account
trading day horizons (including pre and after market hours.)
Usage
difftime_financial(
from,
to,
pre_market = 8,
after_market = 22,
units = "hours"
)
difftime_compare(from, to, time_threshold = "0 mins")
Arguments
from |
POSIXct for the initial date. |
to |
POSIXct for the final date. |
pre_market |
numeric or character representing the hour of the day at which the pre-market begins. |
after_market |
numeric or character representing the hour of the day at which the after-market ends. |
units |
Character string specifying a time unit.
(See |
time_threshold |
Character in the format "value units" indicating the
time threshold at which the computed financial difftime has to be evaluated
(for instance "05 mins" or "20 hours").
The allowed units are "secs", "mins", "hours", "days" and "weeks"
(See |
Value
difftime_financial
returns a numeric value in hours. To convert in a different time unit use
base::as.numeric
and specify theunits
argument (units = c("secs", "mins", "hours", "days", "weeks")).difftime_compare
returns a character string whose possible values are "greater" or "smaller", indicating whether the
difftime_financial
evaluated between the two dates is greater or smaller than the chosen threshold.
Functions
-
difftime_financial
: Extension of thebase::difftime
function to calculate the actual financial difftime taking into account pre and after market moments and financial markets closing days. -
difftime_compare
: Comparison of thedifftime_financial
with respect to a given time threshold.
See Also
base::difftime