public void testSpud() { var manager = new SpudManager(); var v = new RootSpud <double>(manager); v.set(7); Double foo = v; AreEqual(7.0, foo); v.set(6); AreEqual(6.0, (double)v); manager.newBar(); AreEqual(6.0, v[0]); AreEqual(6.0, v[1]); v.set(3); AreEqual(3.0, v[0]); AreEqual(6.0, v[1]); manager.newBar(); v.set(8); v.set(9); AreEqual(9.0, (double)v); AreEqual(9.0, v[0]); AreEqual(3.0, v[1]); AreEqual(6, v[2]); }
public void testSynchronicity() { var manager = new SpudManager(); var d = new RootSpud <double>(manager); Bombs(() => O.info("" + d[0]), "uninitialized"); d.set(7.5); var i = new RootSpud <int>(manager); i.set(4); var b = new RootSpud <bool>(manager); b.set(true); manager.newBar(); d.set(6.5); i.set(3); b.set(false); manager.newBar(); i.set(2); AreEqual(8.5, d[0] + i[0]); AreEqual(6.5, d[0]); AreEqual(6.5, d[1]); AreEqual(7.5, d[2]); AreEqual(2, i[0]); AreEqual(3, i[1]); AreEqual(4, i[2]); AreEqual(false, b[0]); AreEqual(false, b[1]); AreEqual(true, b[2]); }
public void testLogSpud() { var manager = new SpudManager(); var r = new RootSpud <double>(manager); var d = new LogSpud(r); r.set(-5); AreEqual(double.NaN, d[0]); r.set(1); AreEqual(0, d[0]); manager.newBar(); r.set(6.5); AlmostEqual(1.871802, d[0], 1e-6); manager.newBar(); r.set(10); AlmostEqual(2.302585, d[0], 1e-6); AlmostEqual(1.871802, d[1], 1e-6); manager.newBar(); r.set(0); AreEqual(double.NaN, d[0]); manager.newBar(); r.set(-1); AreEqual(double.NaN, d[0]); r.set(3); AlmostEqual(1.098612, d[0], 1e-6); AreEqual(double.NaN, d[1]); }
public void testHasNaNs() { var manager = new SpudManager(); var d = new RootSpud <double>(manager); IsFalse(d.hasNaN(10)); manager.newBar(); d.set(double.NaN); IsTrue(d.hasNaN(1)); manager.newBar(); d.set(0); IsFalse(d.hasNaN(1)); IsTrue(d.hasNaN(2)); IsTrue(d.hasNaN(10)); }
public void testDiffSpudLag1() { var manager = new SpudManager(); var r = new RootSpud <double>(manager); var d = new DiffSpud(r, 1); r.set(7.5); AreEqual(double.NaN, d[0]); manager.newBar(); r.set(6.5); AreEqual(-1, d[0]); manager.newBar(); r.set(10); AreEqual(3.5, d[0]); }
public void testChanged() { var manager = new SpudManager(); var v = new RootSpud <double>(manager); Bombs(() => v.changed(), "uninitialized"); v.set(4.0); IsTrue(v.changed()); manager.newBar(); IsFalse(v.changed()); v.set(5.0); IsTrue(v.changed()); manager.newBar(); v.set(5.0); IsFalse(v.changed()); }
public void testSymbolValueLive() { Log.setFile(@"C:\logs\jefftest"); SystemTimeSeriesTable.SYSTEM_TS.insert("testone", "ASCII", "ActiveMQ", "somedangtopic"); AsciiTable.SYSTEM_ASCII.insert("testone", @"\\nysrv37\share\Tools\RightEdge\TransitionTest\TY1C.full.csv", true, 1); var manager = new SpudManager(); var barSpud = new BarSpud(manager); var barSpud2 = new BarSpud(manager); var symbol = new Symbol("testone"); var spud = symbol.doubles(barSpud); var spud2 = new Symbol("RE.TEST.TY.1C").doubles(barSpud2); manager.newBar(); barSpud.set(new Bar(1, 3, 1, 2, O.date("2008/08/06"))); barSpud2.set(new Bar(1, 3, 1, 2, O.date("2008/08/06"))); manager.newTick(); spud.doSubscribe(); barSpud.lastTickedAt(O.date("2008/08/06 11:22:34")); spud2.doSubscribe(); IsTrue(spud2.isDirty()); symbol.javaSymbol().jmsLive().topic().send("value=97.1|timestamp=2008/08/06 11:22:33|MSTimestamp=2008/06/05 13:10:08"); Bombs(() => LogC.info("" + spud[0]), "stale"); symbol.javaSymbol().jmsLive().topic().send("value=97.2|timestamp=2008/08/06 11:22:34|MSTimestamp=2008/06/05 13:10:08"); O.wait(() => spud[0] == 97.2); barSpud.lastTickedAt(O.date("2008/08/06 11:22:35")); spud.allowStaleTicks(); AreEqual(97.2, spud[0]); AreEqual(116.140625, spud2[0]); }
public void testPlus() { var a = new RootSpud <double>(manager); var b = new RootSpud <double>(manager); var c = new RootSpud <double>(manager); var sum = new Plus(a, b); var sum2 = new Plus(sum, c); a.set(5); Bombs(() => O.info("" + sum[0]), "uninitialized"); b.set(3); AreEqual(8.0, sum[0]); a.set(8); AreEqual(11.0, sum[0]); b.set(9); AreEqual(17.0, sum[0]); manager.newBar(); AreEqual(17.0, sum[0]); Bombs(() => O.info("" + sum2[0]), "uninitialized"); c.set(3.0); AreEqual(20.0, sum2[0]); a.set(1.0); b.set(2.0); AreEqual(6.0, sum2[0]); AreEqual(3.0, sum[0]); a.set(4.0); b.set(5.0); c.set(6.0); AreEqual(15.0, sum2[0]); AreEqual(9.0, sum[0]); }
public void testPushDownOnNonRetrievedSpud() { var manager = new SpudManager(); var a = new RootSpud <double>(manager); var child = new DependentSpud(a); a.set(1.0); manager.newBar(); AreEqual(2.0, child[1]); }
public void testCrossOver() { var manager = new SpudManager(); var spud1 = new RootSpud <double>(manager); var spud2 = new RootSpud <double>(manager); var crossOver = new CrossOverSpud <double>(spud1, spud2); spud1.set(1); spud2.set(1); IsFalse(crossOver.crossedAbove()); IsFalse(crossOver.crossedBelow()); IsFalse(crossOver.crossed()); manager.newBar(); spud1.set(1); spud2.set(2); IsFalse(crossOver.crossedAbove()); IsFalse(crossOver.crossedBelow()); IsFalse(crossOver.crossed()); manager.newBar(); spud1.set(2); spud2.set(1); IsTrue(crossOver.crossedAbove()); IsFalse(crossOver.crossedBelow()); IsTrue(crossOver.crossed()); manager.newBar(); spud1.set(1); spud2.set(2); IsFalse(crossOver.crossedAbove()); IsTrue(crossOver.crossedBelow()); IsTrue(crossOver.crossed()); manager.newBar(); spud1.set(2); IsFalse(crossOver.crossedAbove()); IsFalse(crossOver.crossedBelow()); IsFalse(crossOver.crossed()); manager.newBar(); spud1.set(3); IsTrue(crossOver.crossedAbove()); IsFalse(crossOver.crossedBelow()); IsTrue(crossOver.crossed()); }
public void testSymbolValueSpud() { var manager = new SpudManager(); var barSpud = new BarSpud(manager); var spud = new Symbol("RE.TEST.TY.1C").doubles(barSpud); barSpud.set(new Bar(1, 3, 1, 2, O.date("2007/01/02"))); AreEqual(105.04687500, spud[0]); // test barSPud has date, but spud does not manager.newBar(); barSpud.set(new Bar(1, 3, 1, 2, O.date("2007/01/06"))); AreEqual(105.32812500, spud[0]); }
public void testObserver() { var manager = new SpudManager(); var observed = new RootSpud <double>(manager); observed.valueChanged += onChanged; observed.set(1.0); AreEqual(1, getAndReset()); manager.newBar(); AreEqual(0, getAndReset()); observed.set(1.0); AreEqual(0, getAndReset()); AreEqual(1.0, value); }
public void testTransform() { var manager = new SpudManager(); var d = new RootSpud <double>(manager); var i = d.transform(x => (int)Math.Round(x)); d.set(7.5); AreEqual(8, i[0]); d.set(6.5); AreEqual(6, i[0]); manager.newBar(); AreEqual(6, i[0]); d.set(5.4); AreEqual(5, i[0]); AreEqual(6, i[1]); }
public void testDependencies() { var manager = new SpudManager(); var root = new RootSpud <double>(manager); var otherRoot = new RootSpud <double>(manager); var plusOne = new DependentSpud(root); var plusTwo = new DependsOnDependent(root); var otherPlusOne = new DependentSpud(otherRoot); root.set(7); AreEqual(8, plusOne[0]); AreEqual(9, plusTwo[0]); IsTrue(plusOne.checkAndReset()); IsTrue(plusTwo.checkAndReset()); otherRoot.set(15); IsFalse(plusOne.checkAndReset()); IsFalse(plusTwo.checkAndReset()); IsFalse(otherPlusOne.checkAndReset()); AreEqual(16.0, otherPlusOne[0]); IsTrue(otherPlusOne.checkAndReset()); AreEqual(8, plusOne[0]); AreEqual(9, plusTwo[0]); root.set(11); manager.newBar(); AreEqual(12, plusOne[1]); AreEqual(13, plusTwo[1]); IsTrue(plusOne.checkAndReset()); IsTrue(plusTwo.checkAndReset()); IsFalse(plusOne.checkAndReset()); IsFalse(plusTwo.checkAndReset()); root.set(30); AreEqual(31, plusOne[0]); AreEqual(32, plusTwo[0]); IsTrue(plusOne.checkAndReset()); IsTrue(plusTwo.checkAndReset()); IsFalse(otherPlusOne.checkAndReset()); }
static void Last10Matches(SpudManager manager, string s, RootSpud <double> v, int i) { v.set(i); AreEqual(s, v.last10()); manager.newBar(); }