public BivariateOperator(Spud <T> a, Spud <T> b, BivariateOperatorFunction <T> op) : base(a.manager) { this.a = dependsOn(a); this.b = dependsOn(b); this.op = op; Bomb.unless(a.manager == b.manager, () => "a and b must have same manager"); }
public MakesLoop(SpudManager manager, int size) : base(manager) { Spud <double> last = this; zeroTo(size, i => { Spud <double> next = new RootSpud <double>(manager); next.dependsOn(last); last = next; }); dependsOn(last); }
// USE WITH CARE! This tremendously useful spud has one drawback. An IntervalSpud creates a new "time" definition, based on the BarSpud it is wrapped around. // So, 2 IntervalSpuds wrapped around different BarSpuds are not necessarily time-synchronized // (if one of the spuds has gotten a data point in the new interval, and the other hasn't, spud[0] will be different for each of them). // If you don't understand, go through your use case with Jeric and make sure it works. or pray. or sacrifice a chicken. public IntervalSpud(Spud <Bar> values, Interval interval) : base(new SpudManager()) { values.valueSet += newBar => { var newRange = interval.range(jDate(newBar.time)); if (currentRange == null || !currentRange.equals(newRange)) { manager.newBar(); currentRange = newRange; current = new ProtoBar(newBar.java()); } else { current.update(newBar.java()); } set(new Bar(current.asBar())); }; }
public Plus(Spud <double> a, Spud <double> b) : base(a, b, (x, y) => x + y) { }
public LogSpud(Spud <double> values) : base(values.manager) { this.values = dependsOn(values); }
public DiffSpud(Spud <double> values, int lag) : base(values.manager) { this.lag = lag; this.values = dependsOn(values); Bomb.unless(lag >= 1, () => "lag should be >= 1"); }
public LaggedSpud(Spud <T> values, int lag) : base(values.manager) { this.lag = lag; this.values = dependsOn(values); }
public CrossOverSpud(Spud <T> spud1, Spud <T> spud2) : base(spud1.manager) { this.spud1 = dependsOn(spud1); this.spud2 = dependsOn(spud2); }
public Divide(Spud <double> a, Spud <double> b) : base(a, b, (x, y) => y == 0 ? 0 : x / y) { }
public static ComparableSpud <T> comparable <T>(Spud <T> spud) where T : IComparable <T> { return(new ComparableSpudWrapper <T>(spud)); }
public ComparableSpudWrapper(Spud <T> spud) : base(spud.manager) { this.spud = dependsOn(spud); }
public DependsOnDependent(Spud <double> root) : base(root.manager) { parent = dependsOn(new DependentSpud(root)); }
public DependentSpud(Spud <double> parent) : base(parent.manager) { this.parent = dependsOn(parent); }
public Minus(Spud <double> a, Spud <double> b) : base(a, b, (x, y) => x - y) { }
public SpudTransformer(Spud <SOURCE> spud, Converter <SOURCE, TARGET> transform) : base(spud.manager) { this.spud = dependsOn(spud); transformer = transform; }
public Times(Spud <double> a, Spud <double> b) : base(a, b, (x, y) => x * y) { }
public WindowSpud(Spud <T> values, int window) : base(values.manager) { this.window = window; this.values = dependsOn(values); }
public MinMax(Spud <T> spud, int period, int direction) : base(spud.manager) { this.spud = dependsOn(spud); this.period = period; this.direction = direction; }
public CrossOverSpud(Spud <T> spud1, T t) : this(spud1, spud1.constant(t)) { }