quantlab.factor.predefined.momentum#
N-bar price momentum, the reference factor for the Polars backend.
Most factors in this project are computed with KunQuant, a library that
compiles factor formulas to native code. Polars, a DataFrame library with a
lazy query engine, is a second, batch-only way to write a factor, for
formulas that are easier to express as table operations. Momentum shows
the whole FactorPolars contract in one class: a single
_get_factor_lazyframe override that returns a lazy frame with the
timestamp, symbol and factor columns, with the horizon read from the
config. Copy it as a starting point for a new Polars factor.
Classes
N-bar per-symbol price momentum, |