transFreq#

swordfish.function.transFreq()#

For each element of X, conduct a transformation as specified with parameter rule. The result has the same length as X.

Parameters:
  • X (Constant) – A scalar/vector of temporal type.

  • rule (Constant) –

    A string that can take the following values:

    Values of parameter “rule”

    Corresponding DolphinDB function

    B

    businessDay

    W

    weekEnd

    WOM

    weekOfMonth

    LWOM

    lastWeekOfMonth

    M

    monthEnd

    MS

    monthBegin

    BM

    businessMonthEnd

    BMS

    businessMonthBegin

    SM

    semiMonthEnd

    SMS

    semiMonthBegin

    Q

    quarterEnd

    QS

    quarterBegin

    BQ

    businessQuarterEnd

    BQS

    businessQuarterBegin

    A

    yearEnd

    AS

    yearBegin

    BA

    businessYearEnd

    BAS

    businessYearBegin

    D

    date

    H

    hourOfDay

    min

    minuteOfHour

    S

    secondOfMinute

    L

    millisecond

    U

    microsecond

    N

    nanosecond

    SA

    semiannualEnd

    SAS

    semiannualBegin

    The strings above can also be used with positive integers for parameter rule. For example, “2M” means the end of every two months. In addition, rule can also be set as the identifier of the trading calendar, e.g., the Market Identifier Code of an exchange, or a user-defined calendar name. Positive integers can also be used with identifiers. For example, “2XNYS” means every two trading days of New York Stock Exchange.

  • closed (Constant, optional) –

    A string indicating which boundary of the interval is closed, by default DFLT.

    • The default value is ‘left’ for all values of rule except for ‘M’, ‘A’, ‘Q’, ‘BM’, ‘BA’, ‘BQ’, and ‘W’ which all have a default of ‘right’.

    • The default is ‘right’ if origin is ‘end’ or ‘end_day’.

  • label (Constant, optional) –

    A string indicating which boundary is used to label the interval, by default DFLT.

    • The default value is ‘left’ for all values of rule except for ‘M’, ‘A’, ‘Q’, ‘BM’, ‘BA’, ‘BQ’, and ‘W’ which all have a default of ‘right’.

    • The default is ‘right’ if origin is ‘end’ or ‘end_day’.

  • origin (Constant, optional) –

    A string or a scalar of the same data type as X, indicating the timestamp where the intervals start. It can be ‘epoch’, start’, ‘start_day’, ‘end’, ‘end_day’ or a user-defined time object, by default DFLT.

    • ’epoch’: origin is 1970-01-01

    • ’start’: origin is the first value of the timeseries

    • ’start_day’: origin is 00:00 of the first day of the timeseries

    • ’end’: origin is the last value of the timeseries

    • ’end_day’: origin is 24:00 of the last day of the timeseries