Skip to content

@livefolio/sdk / IfNode

Type Alias: IfNode

IfNode = object

Defined in: tactical/types.ts:245

A branching node in a RuleNode tree. Evaluates cond and recurses into then when the condition is true, or into else otherwise. Nesting IfNode trees builds arbitrary decision logic over computed features.

Example

ts
import type { IfNode } from '@livefolio/sdk';

const node: IfNode = {
  op:   'if',
  cond: { op: 'gt', left: { ref: 'sma50' }, right: { ref: 'sma200' } },
  then: { op: 'allocate', weights: { SPY: 1 } },
  else: { op: 'allocate', weights: { SHY: 1 } },
};

Properties

cond

cond: Comparison

Defined in: tactical/types.ts:248

Condition to evaluate.


else

else: RuleNode

Defined in: tactical/types.ts:252

Sub-tree evaluated when cond is false.


op

op: "if"

Defined in: tactical/types.ts:246


then

then: RuleNode

Defined in: tactical/types.ts:250

Sub-tree evaluated when cond is true.

Released under the MIT License.