void addBar(StatisticsCollector collector, IEnumerable <Position> positions, double close, double fxRate) { var weightedPositions = O.convert(positions, p => new WeightedPosition(p)); collector.addBar(weightedPositions, O.dictionaryOne(symbol(), new Bar(close, close, close, close, currentDate)), O.dictionaryOne(symbol(), fxRate)); currentDate = currentDate.AddDays(1); }
void bar(double?aValue, double?bValue) { var bars = new Dictionary <Symbol, Bar>(); if (aValue.HasValue) { bars.Add(A, new Bar(aValue.Value)); a.processBar(O.dictionaryOne(A, new Bar(aValue.Value))); } if (bValue.HasValue) { bars.Add(B, new Bar(bValue.Value)); b.processBar(O.dictionaryOne(B, new Bar(bValue.Value))); } combined.processBar(bars); var aCount = ewma(a, A).count(); var bCount = ewma(b, B).count(); AreEqual(ewma(combined, A).count(), aCount); AreEqual(ewma(combined, B).count(), bCount); if (aCount > 0) { AreEqual(ewma(combined, A)[0], ewma(a, A)[0]); } if (bCount > 0) { AreEqual(ewma(combined, B)[0], ewma(b, B)[0]); } }
[Test] public void testBombMissing() { var d = Objects.dictionaryOne(5, "hello"); AreEqual("hello", Bomb.missing(d, 5)); Bombs(() => Bomb.missing(d, 4), "no value for 4 in "); }
protected void processBar(Bar bar) { processBar(O.dictionaryOne(symbol(), bar)); }