public void PriceScaleDoesNotUpdateForFillForwardBar() { var referenceTime = new DateTime(2020, 08, 06); var point = new Tick(referenceTime, Symbols.SPY, 1, 2); var point2 = point.Clone(true); point2.Time = referenceTime.AddDays(1); var point3 = point.Clone(false); point3.Time = referenceTime.AddDays(2); ; var enumerator = new List <BaseData> { point, point2, point3 }.GetEnumerator(); var factorFileProfider = new Mock <IFactorFileProvider>(); var factorFile = new FactorFile(_security.Symbol.Value, new[] { new FactorFileRow(referenceTime, 0.5m, 1), new FactorFileRow(referenceTime.AddDays(1), 1m, 1) }, referenceTime); factorFileProfider.Setup(s => s.Get(It.IsAny <Symbol>())).Returns(factorFile); var subscription = SubscriptionUtils.CreateAndScheduleWorker( new SubscriptionRequest( false, null, _security, _config, referenceTime, Time.EndOfTime ), enumerator, factorFileProfider.Object, true); Assert.IsTrue(subscription.MoveNext()); Assert.AreEqual(1, (subscription.Current.Data as Tick).AskPrice); Assert.IsFalse((subscription.Current.Data as Tick).IsFillForward); Assert.IsTrue(subscription.MoveNext()); Assert.AreEqual(1, (subscription.Current.Data as Tick).AskPrice); Assert.IsTrue((subscription.Current.Data as Tick).IsFillForward); Assert.IsTrue(subscription.MoveNext()); Assert.AreEqual(2, (subscription.Current.Data as Tick).AskPrice); Assert.IsFalse((subscription.Current.Data as Tick).IsFillForward); subscription.DisposeSafely(); }
public void AdjustTick() { var tick = new Tick { Time = new DateTime(2020, 5, 21, 8, 9, 0), Symbol = Symbols.SPY, Value = 100 }; var adjustedTick = tick.Clone(tick.IsFillForward).Adjust(_factor); Assert.AreEqual(tick.Value * _factor, (adjustedTick as Tick).Value); }
public void AdjustTickUsingConfig() { var tick = new Tick { Time = new DateTime(2020, 5, 21, 8, 9, 0), Symbol = Symbols.SPY, Value = 100, Quantity = 10 }; var adjustedTick = tick.Clone(tick.IsFillForward).Normalize(_config); Assert.AreEqual(tick.Value * _factor, (adjustedTick as Tick).Value); Assert.AreEqual(tick.Quantity / _factor, (adjustedTick as Tick).Quantity); }
public void AdjustQuoteTick() { var tick = new Tick { Time = new DateTime(2020, 5, 21, 8, 9, 0), Symbol = Symbols.SPY, TickType = TickType.Quote, AskPrice = 100, BidPrice = 99, AskSize = 100, BidSize = 10 }; var adjustedTick = tick.Clone(tick.IsFillForward).Adjust(_factor); Assert.AreEqual(tick.AskPrice * _factor, (adjustedTick as Tick).AskPrice); Assert.AreEqual(tick.BidPrice * _factor, (adjustedTick as Tick).BidPrice); Assert.AreEqual(tick.AskSize / _factor, (adjustedTick as Tick).AskSize); Assert.AreEqual(tick.BidSize / _factor, (adjustedTick as Tick).BidSize); }
public void AdjustQuoteTickUsingConfig() { var tick = new Tick { Time = new DateTime(2020, 5, 21, 8, 9, 0), Symbol = Symbols.SPY, TickType = TickType.Quote, AskPrice = 100, BidPrice = 99, AskSize = 100, BidSize = 10 }; var adjustedTick = tick.Clone(tick.IsFillForward).Normalize(_config.PriceScaleFactor, _config.DataNormalizationMode, _config.SumOfDividends); Assert.AreEqual(tick.AskPrice * _factor, (adjustedTick as Tick).AskPrice); Assert.AreEqual(tick.BidPrice * _factor, (adjustedTick as Tick).BidPrice); Assert.AreEqual(tick.AskSize / _factor, (adjustedTick as Tick).AskSize); Assert.AreEqual(tick.BidSize / _factor, (adjustedTick as Tick).BidSize); }
/// <summary> /// Change Tick Accorind to Permissions /// </summary> /// <param name="tick"></param> /// <param name="writeQuote"></param> /// <param name="writeTrade"></param> /// <returns></returns> private Tick ChangeTickAccordingToPermissions(Tick tick, bool writeQuote, bool writeTrade) { try { Tick newTick = (Tick)tick.Clone(); if (!writeQuote) { newTick.AskPrice = newTick.AskSize = newTick.BidPrice = newTick.BidSize = 0M; } if (!writeTrade) { newTick.LastPrice = newTick.LastSize = 0M; } return(newTick); } catch (Exception exception) { Logger.Error(exception, _oType.FullName, "ChangeTickAccordingToPermissions"); return(tick); } }
public void AcceptsTickDataWithSameTimestamps() { var reference = new DateTime(2015, 09, 23); var identity = new IdentityDataConsolidator <Tick>(); int count = 0; identity.DataConsolidated += (sender, data) => { count++; }; var tradeBar = new Tick { EndTime = reference }; identity.Update(tradeBar); tradeBar = (Tick)tradeBar.Clone(); identity.Update(tradeBar); Assert.AreEqual(2, count); }