[docs]@Float.register(["ceil"])defceil(s:"Stream[float]")->"Stream[float]":"""Computes the ceiling of a float stream. Parameters ---------- s : `Stream[float]` A float stream. Returns ------- `Stream[float]` The ceiling stream of `s`. """returns.apply(np.ceil).astype("float")
[docs]@Float.register(["floor"])deffloor(s:"Stream[float]")->"Stream[float]":"""Computes the floor of a float stream. Parameters ---------- s : `Stream[float]` A float stream. Returns ------- `Stream[float]` The floor stream of `s`. """returns.apply(np.floor).astype("float")
[docs]@Float.register(["sqrt"])defsqrt(s:"Stream[float]")->"Stream[float]":"""Computes the square root of a float stream. Parameters ---------- s : `Stream[float]` A float stream. Returns ------- `Stream[float]` The square root stream of `s`. """returns.apply(np.sqrt).astype("float")
[docs]@Float.register(["square"])defsquare(s:"Stream[float]")->"Stream[float]":"""Computes the square of a float stream. Parameters ---------- s : `Stream[float]` A float stream. Returns ------- `Stream[float]` The square stream of `s`. """returns.apply(np.square).astype("float")
[docs]@Float.register(["log"])deflog(s:"Stream[float]")->"Stream[float]":"""Computes the log of a float stream. Parameters ---------- s : `Stream[float]` A float stream. Returns ------- `Stream[float]` The log stream of `s`. """returns.apply(np.log).astype("float")
[docs]@Float.register(["pct_change"])defpct_change(s:"Stream[float]",periods:int=1,fill_method:str="pad")->"Stream[float]":"""Computes the percent change of a float stream. Parameters ---------- s : `Stream[float]` A float stream. periods : int, default 1 The number of periods to lag for until computing the percent change. fill_method : str, default "pad" The fill method to use for missing values. Returns ------- `Stream[float]` The percent change stream of `s`. """iffill_methodisnotNone:assertfill_methodin["pad","ffill"]iffill_method=="pad"orfill_method=="ffill":stream=s.ffill()else:stream=schange=(stream/stream.lag(periods))-1returnchange.astype("float")
[docs]@Float.register(["diff"])defdiff(s:"Stream[float]",periods:int=1)->"Stream[float]":"""Computes the difference of a float stream. Parameters ---------- s : `Stream[float]` A float stream. periods : int, default 1 The number of periods to lag for until computing the difference. Returns ------- `Stream[float]` The difference stream of `s`. """returnBinOp(np.subtract)(s,s.lag(periods)).astype("float")