foundryts.functions.derivative

foundryts.functions.derivative()

Returns a function that calculates the per-second value change for a single time series.

For every point in the time series, starting from the second point, output a tick with the derivative of the value of the previous point in time. Each value is scaled to a per-second rate irrespective of the original frequency at which the ticks are stored.

  • Returns: A function that accepts a single time series as input and returns a time series with per-second derative values.
  • Return type: (FunctionNode) -> FunctionNode

Dataframe schema

Column nameTypeDescription
timestamppandas.TimestampTimestamp of the point
valuefloatValue of the point
Note

This function is only applicable to numeric series.

See Also

integral()

Examples

Copied!
1 2 3 4 5 6 7 8 9 10 >>> series = F.points( ... (100, 100.0), (120, 200.0), (130, 230.0), (166, 266.0), (167, 366.0), name="series" ... ) >>> series.to_pandas() timestamp value 0 1970-01-01 00:00:00.000000100 100.0 1 1970-01-01 00:00:00.000000120 200.0 2 1970-01-01 00:00:00.000000130 230.0 3 1970-01-01 00:00:00.000000166 266.0 4 1970-01-01 00:00:00.000000167 366.0
Copied!
1 2 3 4 5 6 7 >>> derivative_series = F.derivative()(series) >>> derivative_series.to_pandas() timestamp value 0 1970-01-01 00:00:00.000000120 5.000000e+09 1 1970-01-01 00:00:00.000000130 3.000000e+09 2 1970-01-01 00:00:00.000000166 1.000000e+09 3 1970-01-01 00:00:00.000000167 1.000000e+11