@livefolio/sdk / Comparison
Type Alias: Comparison
Comparison =
object
Defined in: tactical/types.ts:186
A binary comparison between two operands. Each operand is either a literal number or a FeatureRef resolved at evaluation time. The result is true when left op right holds.
When tolerance is provided the comparison implements hysteresis — the result is sticky and only changes when the left operand exits the band. A stable id is required in that case so RuleTreeState can track the last outcome.
Example
import type { Comparison } from '@livefolio/sdk';
// Feature "sma200" > feature "sma50"
const cond: Comparison = {
op: 'gt',
left: { ref: 'sma200' },
right: { ref: 'sma50' },
};Properties
id?
optionalid?:string
Defined in: tactical/types.ts:202
Stable identifier used to persist comparison state across steps when tolerance is set. Must be unique within the rule tree.
left
left:
FeatureRef|number
Defined in: tactical/types.ts:190
Left-hand operand — a feature reference or a literal number.
op
op:
ComparisonOp
Defined in: tactical/types.ts:188
Which binary operator to apply.
right
right:
FeatureRef|number
Defined in: tactical/types.ts:192
Right-hand operand — a feature reference or a literal number.
tolerance?
optionaltolerance?:Tolerance
Defined in: tactical/types.ts:197
Optional hysteresis band. Requires op to be 'gt' or 'lt' and requires id to be set.