pub enum Expr {
Show 69 variants
Data {
name: String,
},
Const {
value: f64,
},
Average {
of: Box<Expr>,
n: usize,
},
Ema {
of: Box<Expr>,
n: usize,
},
Std {
of: Box<Expr>,
n: usize,
},
Rsi {
of: Box<Expr>,
n: usize,
},
PctChange {
of: Box<Expr>,
n: usize,
},
Rise {
of: Box<Expr>,
n: usize,
},
Shift {
of: Box<Expr>,
n: usize,
},
RollingMax {
of: Box<Expr>,
n: usize,
},
RollingMin {
of: Box<Expr>,
n: usize,
},
BollingerMid {
of: Box<Expr>,
n: usize,
},
BollingerUpper {
of: Box<Expr>,
n: usize,
k: f64,
},
BollingerLower {
of: Box<Expr>,
n: usize,
k: f64,
},
Macd {
of: Box<Expr>,
fast: usize,
slow: usize,
},
MacdSignal {
of: Box<Expr>,
fast: usize,
slow: usize,
signal: usize,
},
MacdHist {
of: Box<Expr>,
fast: usize,
slow: usize,
signal: usize,
},
DonchianHigh {
of: Box<Expr>,
n: usize,
},
DonchianLow {
of: Box<Expr>,
n: usize,
},
DonchianMid {
of: Box<Expr>,
n: usize,
},
Atr {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
},
Natr {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
},
WillR {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
},
Cci {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
},
StochK {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
},
StochD {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
d: usize,
},
AroonUp {
high: Box<Expr>,
n: usize,
},
AroonDown {
low: Box<Expr>,
n: usize,
},
Adx {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
},
PlusDi {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
},
MinusDi {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
n: usize,
},
Obv {
close: Box<Expr>,
volume: Box<Expr>,
},
Mfi {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
volume: Box<Expr>,
n: usize,
},
Vwap {
high: Box<Expr>,
low: Box<Expr>,
close: Box<Expr>,
volume: Box<Expr>,
n: usize,
},
Fall {
of: Box<Expr>,
n: usize,
},
IsLargest {
of: Box<Expr>,
n: usize,
},
IsSmallest {
of: Box<Expr>,
n: usize,
},
Sustain {
of: Box<Expr>,
nwindow: usize,
nsatisfy: Option<usize>,
},
IsEntry {
of: Box<Expr>,
},
IsExit {
of: Box<Expr>,
},
ExitWhen {
entry: Box<Expr>,
exit: Box<Expr>,
},
QuantileRow {
of: Box<Expr>,
c: f64,
},
Winsorize {
of: Box<Expr>,
lower: f64,
upper: f64,
},
Zscore {
of: Box<Expr>,
},
Bucket {
of: Box<Expr>,
n: usize,
},
Demean {
of: Box<Expr>,
},
Gt {
l: Box<Expr>,
r: Box<Expr>,
},
Lt {
l: Box<Expr>,
r: Box<Expr>,
},
Ge {
l: Box<Expr>,
r: Box<Expr>,
},
Le {
l: Box<Expr>,
r: Box<Expr>,
},
And {
l: Box<Expr>,
r: Box<Expr>,
},
Or {
l: Box<Expr>,
r: Box<Expr>,
},
Not {
of: Box<Expr>,
},
Add {
l: Box<Expr>,
r: Box<Expr>,
},
Sub {
l: Box<Expr>,
r: Box<Expr>,
},
Mul {
l: Box<Expr>,
r: Box<Expr>,
},
Div {
l: Box<Expr>,
r: Box<Expr>,
},
Neg {
of: Box<Expr>,
},
Ceil {
of: Box<Expr>,
},
Rank {
of: Box<Expr>,
pct: bool,
ascending: bool,
},
Mask {
of: Box<Expr>,
by: Box<Expr>,
},
NormalizeRow {
of: Box<Expr>,
},
HoldUntil {
entry: Box<Expr>,
exit: Box<Expr>,
nstocks_limit: Option<usize>,
rank: Option<Box<Expr>>,
stop_loss: Option<f64>,
take_profit: Option<f64>,
trail_stop: Option<f64>,
trail_stop_activation: Option<f64>,
},
Rebalance {
of: Box<Expr>,
freq: Option<String>,
on: Option<Box<Expr>>,
},
Neutralize {
of: Box<Expr>,
by: Vec<Expr>,
add_const: bool,
},
NeutralizeIndustry {
of: Box<Expr>,
add_const: bool,
},
IndustryRank {
of: Box<Expr>,
categories: Option<Vec<String>>,
},
GroupbyCategory {
of: Box<Expr>,
agg: String,
},
InSector {
of: Box<Expr>,
name: String,
},
}Variants§
Data
A raw input series by name (e.g. close, pe, revenue_growth).
Const
A constant scalar value, broadcast across the panel.
Average
Simple moving average of of over n days.
Ema
Exponential moving average of of over n days.
Std
Rolling standard deviation of of over n days.
Rsi
Relative Strength Index of of over n days.
PctChange
Percentage change of of over n days.
Rise
1 where of rose for n consecutive days, else 0.
Shift
of lagged forward by n days.
RollingMax
Rolling maximum of of over n days.
RollingMin
Rolling minimum of of over n days.
BollingerMid
Bollinger mid band: the n-day simple moving average of of.
BollingerUpper
Bollinger upper band: sma(of, n) + k * std(of, n) (k defaults to 2).
BollingerLower
Bollinger lower band: sma(of, n) - k * std(of, n) (k defaults to 2).
Macd
MACD line: ema(of, fast) - ema(of, slow) (defaults 12/26).
MacdSignal
MACD signal line: signal-day EMA of the MACD line (defaults 12/26/9).
MacdHist
MACD histogram: MACD line minus its signal line (defaults 12/26/9).
DonchianHigh
Donchian channel upper band: rolling n-day high of of.
DonchianLow
Donchian channel lower band: rolling n-day low of of.
DonchianMid
Donchian channel mid-line: (rolling_max + rolling_min) / 2 over n days.
Atr
Average True Range over n days from high/low/close.
Natr
Normalized ATR (percent) over n days.
WillR
Williams %R over n days.
Cci
Commodity Channel Index over n days.
StochK
Stochastic %K over n days.
StochD
Stochastic %D: d-day average of %K over n days.
AroonUp
Aroon Up over n days from high.
AroonDown
Aroon Down over n days from low.
Adx
Average Directional Index over n days.
PlusDi
Plus Directional Indicator (+DI) over n days.
MinusDi
Minus Directional Indicator (−DI) over n days.
Obv
On-Balance Volume from close and volume.
Mfi
Money Flow Index over n days.
Vwap
Volume-Weighted Average Price over n days from high/low/close/volume.
Fall
1 where of fell for n consecutive days, else 0.
IsLargest
1 for the n highest values per row (cross-section), else 0.
IsSmallest
1 for the n lowest values per row (cross-section), else 0.
Sustain
1 where of held true at least nsatisfy times within the last nwindow rows.
IsEntry
1 on the row where of turns false→true (rising edge).
IsExit
1 on the row where of turns true→false (falling edge).
ExitWhen
Hold true from an entry edge until an exit edge (or the exit panel is true).
QuantileRow
Per-row quantile of of across symbols; collapses to one column (quantile).
Winsorize
Per-row winsorize: clip to empirical quantiles lower/upper in [0, 1].
Zscore
Per-row z-score (x − mean) / std (population std); constant rows → 0.
Bucket
Per-row quantile buckets labeled 1..=n (NaN preserved).
Demean
Per-row demean: subtract the cross-sectional mean of non-NaN cells.
Gt
1 where l is greater than r, else 0.
Lt
1 where l is less than r, else 0.
Ge
1 where l is greater than or equal to r, else 0.
Le
1 where l is less than or equal to r, else 0.
And
Logical AND of two boolean panels.
Or
Logical OR of two boolean panels.
Not
Logical NOT of a boolean panel (NaN is falsy, so not of NaN is 1).
Add
Element-wise l + r.
Sub
Element-wise l − r.
Mul
Element-wise l × r.
Div
Element-wise l ÷ r.
Neg
Negation (−of).
Ceil
Ceiling of of.
Rank
Cross-sectional rank of of per row; pct for 0..1 percentile, ascending sets direction.
Mask
of kept only where by is true; elsewhere dropped.
NormalizeRow
Scale each row so gross weight (Σ|w|) is 1; NaN preserved, zero rows unchanged.
HoldUntil
Stateful rotation: enter on entry, exit on exit, hold up to nstocks_limit (prioritised by rank), with optional stop_loss/take_profit/trail_stop/trail_stop_activation.
Fields
Rebalance
Hold of, refreshing on calendar freq (W/ME/QE) or on dates where on is true.
Neutralize
Cross-sectionally regress of against the by factors, optionally adding a constant.
NeutralizeIndustry
Neutralize of within each industry/sector.
IndustryRank
Rank of within each industry, optionally limited to categories.
GroupbyCategory
Aggregate of within each industry using agg (e.g. mean).
InSector
Boolean mask: 1 where the symbol’s industry equals name (exact, case-sensitive).
Shape follows of; symbols missing from the industry map are 0.