public void SetUp() { _constantIndicator = new ConstantIndicator <Decimal>(Decimal.ValueOf(6)); _mockIndicator = new FixedIndicator <Decimal>(Decimal.ValueOf("-2.0"), Decimal.ValueOf("0.00"), Decimal.ValueOf("1.00"), Decimal.ValueOf("2.53"), Decimal.ValueOf("5.87"), Decimal.ValueOf("6.00"), Decimal.ValueOf("10.0")); _mockIndicator2 = new FixedIndicator <Decimal>(Decimal.Zero, Decimal.One, Decimal.Two, Decimal.Three, Decimal.Ten, Decimal.ValueOf("-42"), Decimal.ValueOf("-1337")); _sumIndicator = new SumIndicator(_constantIndicator, _mockIndicator, _mockIndicator2); }
public void ComputesCorrectly() { var cons = new ConstantIndicator<IndicatorDataPoint>("c", 1m); Assert.AreEqual(1m, cons.Current.Value); Assert.IsTrue(cons.IsReady); cons.Update(DateTime.Today, 3m); Assert.AreEqual(1m, cons.Current.Value); }
public void ComputesCorrectly() { var cons = new ConstantIndicator("c", 1d); Assert.AreEqual(1d, cons.Current.Value); Assert.IsTrue(cons.IsReady); cons.Update(DateTime.Today, 3d); Assert.AreEqual(1d, cons.Current.Value); }
public void ComputesCorrectly() { var cons = new ConstantIndicator <IndicatorDataPoint>("c", 1m); Assert.Equal(1m, cons.Current.Price); Assert.True(cons.IsReady); cons.Update(DateTime.Today, TimeZone.Utc, 3m); Assert.Equal(1m, cons.Current.Price); }
/// <summary> /// Initializes a new instance of the BollingerBands class /// </summary> /// <param name="name">The name of this indicator</param> /// <param name="period">The period of the standard deviation and moving average (middle band)</param> /// <param name="k">The number of standard deviations specifying the distance between the middle band and upper or lower bands</param> /// <param name="movingAverageType">The type of moving average to be used</param> public BollingerBands(String name, int period, decimal k, MovingAverageType movingAverageType = MovingAverageType.Simple) : base(name) { MovingAverageType = movingAverageType; StandardDeviation = new StandardDeviation(name + "_StandardDeviation", period); MiddleBand = movingAverageType.AsIndicator(name + "_MiddleBand", period); var kConstant = new ConstantIndicator<IndicatorDataPoint>(k.ToString(), k); LowerBand = MiddleBand.Minus(StandardDeviation.Times(kConstant), name + "_LowerBand"); UpperBand = MiddleBand.Plus(StandardDeviation.Times(kConstant), name + "_UpperBand"); }
public void ResetsProperly() { // constant reset should reset samples but the value should still be the same var cons = new ConstantIndicator<IndicatorDataPoint>("c", 1m); cons.Update(DateTime.Today, 3m); cons.Update(DateTime.Today.AddDays(1), 10m); cons.Reset(); Assert.AreEqual(1m, cons.Current.Value); Assert.AreEqual(DateTime.MinValue, cons.Current.Time); Assert.AreEqual(0, cons.Samples); }
public void ResetsProperly() { // constant reset should reset samples but the value should still be the same var cons = new ConstantIndicator("c", 1d); cons.Update(DateTime.Today, 3d); cons.Update(DateTime.Today.AddDays(1), 10d); cons.Reset(); Assert.AreEqual(1d, cons.Current.Value); Assert.AreEqual(0, cons.CurrentTime); Assert.AreEqual(0, cons.Samples); }
public void ResetsProperly() { // constant reset should reset samples but the value should still be the same var cons = new ConstantIndicator <IndicatorDataPoint>("c", 1m); cons.Update(DateTime.Today, TimeZone.Utc, 3m); cons.Update(DateTime.Today.AddDays(1), TimeZone.Utc, 10m); cons.Reset(); Assert.Equal(1m, cons.Current.Price); Assert.Equal(DateTime.MinValue, cons.Current.Occured); Assert.Equal(0, cons.Samples); }
public void GetValueWithNullTimeSeries() { var constant = new ConstantIndicator <Decimal>(Decimal.Ten); Assert.AreEqual(Decimal.Ten, constant.GetValue(0)); Assert.AreEqual(Decimal.Ten, constant.GetValue(100)); Assert.IsNull(constant.TimeSeries); var sma = new SmaIndicator(constant, 10); Assert.AreEqual(Decimal.Ten, sma.GetValue(0)); Assert.AreEqual(Decimal.Ten, sma.GetValue(100)); Assert.IsNull(sma.TimeSeries); }
public void getValueWithNullTimeSeries() { ConstantIndicator <decimal> constant = new ConstantIndicator <decimal>(Decimals.TEN); Assert.AreEqual(Decimals.TEN, constant.GetValue(0)); Assert.AreEqual(Decimals.TEN, constant.GetValue(100)); Assert.IsNull(constant.TimeSeries); SMAIndicator sma = new SMAIndicator(constant, 10); Assert.AreEqual(Decimals.TEN, sma.GetValue(0)); Assert.AreEqual(Decimals.TEN, sma.GetValue(100)); Assert.IsNull(sma.TimeSeries); }
public void setUp() { ConstantIndicator <decimal> constantIndicator = new ConstantIndicator <decimal>(6); FixedIndicator <decimal> mockIndicator = new FixedIndicator <decimal>( -2.0M, 0.00M, 1.00M, 2.53M, 5.87M, 6.00M, 10.0M ); differenceIndicator = new DifferenceIndicator(constantIndicator, mockIndicator); }
public void setUp() { ConstantIndicator <decimal> constantIndicator = new ConstantIndicator <decimal>(4); transPlus = new DecimalTransformIndicator(constantIndicator, Decimals.TEN, decimalTransformType.Plus); transMinus = new DecimalTransformIndicator(constantIndicator, Decimals.TEN, decimalTransformType.Minus); transMultiply = new DecimalTransformIndicator(constantIndicator, Decimals.TEN, decimalTransformType.multiply); transDivide = new DecimalTransformIndicator(constantIndicator, Decimals.TEN, decimalTransformType.divide); transMax = new DecimalTransformIndicator(constantIndicator, Decimals.TEN, decimalTransformType.Max); transMin = new DecimalTransformIndicator(constantIndicator, Decimals.TEN, decimalTransformType.Min); transAbs = new DecimalTransformIndicator(new ConstantIndicator <decimal>(-4), decimalTransformSimpleType.abs); transSqrt = new DecimalTransformIndicator(constantIndicator, decimalTransformSimpleType.sqrt); transLog = new DecimalTransformIndicator(constantIndicator, decimalTransformSimpleType.log); }
public void setUp() { ConstantIndicator <decimal> constantIndicator = new ConstantIndicator <decimal>(4); transEquals = new BooleanTransformIndicator(constantIndicator, 4, BooleanTransformType.equals); transIsGreaterThan = new BooleanTransformIndicator(constantIndicator, 3, BooleanTransformType.IsGreaterThan); transIsGreaterThanOrEqual = new BooleanTransformIndicator(constantIndicator, 4, BooleanTransformType.IsGreaterThanOrEqual); transIsLessThan = new BooleanTransformIndicator(constantIndicator, Decimals.TEN, BooleanTransformType.IsLessThan); transIsLessThanOrEqual = new BooleanTransformIndicator(constantIndicator, 4, BooleanTransformType.IsLessThanOrEqual); transIsNaN = new BooleanTransformIndicator(constantIndicator, BooleanTransformSimpleType.isNaN); transIsNegative = new BooleanTransformIndicator(new ConstantIndicator <decimal>(-4), BooleanTransformSimpleType.isNegative); transIsNegativeOrZero = new BooleanTransformIndicator(constantIndicator, BooleanTransformSimpleType.isNegativeOrZero); transIsPositive = new BooleanTransformIndicator(constantIndicator, BooleanTransformSimpleType.isPositive); transIsPositiveOrZero = new BooleanTransformIndicator(constantIndicator, BooleanTransformSimpleType.isPositiveOrZero); transIsZero = new BooleanTransformIndicator(new ConstantIndicator <decimal>(Decimals.ZERO), BooleanTransformSimpleType.isZero); }
public void setUp() { ConstantIndicator <decimal> constantIndicator = new ConstantIndicator <decimal>(6M); FixedIndicator <decimal> mockIndicator = new FixedIndicator <decimal>( -2.0M, 0.00M, 1.00M, 2.53M, 5.87M, 6.00M, 10.0M ); FixedIndicator <decimal> mockIndicator2 = new FixedIndicator <decimal>( Decimals.ZERO, Decimals.ONE, Decimals.TWO, Decimals.THREE, Decimals.TEN, -42M, -1337M ); sumIndicator = new SumIndicator(constantIndicator, mockIndicator, mockIndicator2); }
/// <summary> /// Create a new pair /// </summary> /// <param name="algorithm">The algorithm instance that experienced the change in securities</param> /// <param name="asset1">The first asset's symbol in the pair</param> /// <param name="asset2">The second asset's symbol in the pair</param> /// <param name="period">Period over which this insight is expected to come to fruition</param> /// <param name="threshold">The percent [0, 100] deviation of the ratio from the mean before emitting an insight</param> public PairData(QCAlgorithm algorithm, Symbol asset1, Symbol asset2, TimeSpan period, decimal threshold) { _asset1 = asset1; _asset2 = asset2; _asset1Price = algorithm.Identity(asset1); _asset2Price = algorithm.Identity(asset2); _ratio = _asset1Price.Over(_asset2Price); _mean = new ExponentialMovingAverage(500).Of(_ratio); var upper = new ConstantIndicator <IndicatorDataPoint>("ct", 1 + threshold / 100m); _upperThreshold = _mean.Times(upper, "UpperThreshold"); var lower = new ConstantIndicator <IndicatorDataPoint>("ct", 1 - threshold / 100m); _lowerThreshold = _mean.Times(lower, "LowerThreshold"); _predictionInterval = period; }
/// <summary> /// Event fired each time the we add/remove securities from the data feed /// </summary> /// <param name="algorithm">The algorithm instance that experienced the change in securities</param> /// <param name="changes">The security additions and removals from the algorithm</param> public override void OnSecuritiesChanged(QCAlgorithmFramework algorithm, SecurityChanges changes) { foreach (var added in changes.AddedSecurities) { // this model is limitted to looking at a single pair of assets if (added.Symbol != _asset1 && added.Symbol != _asset2) { continue; } if (added.Symbol == _asset1) { _asset1Price = algorithm.Identity(added.Symbol); } else { _asset2Price = algorithm.Identity(added.Symbol); } } if (_ratio == null) { // initialize indicators dependent on both assets if (_asset1Price != null && _asset2Price != null) { _ratio = _asset1Price.Over(_asset2Price); _mean = new ExponentialMovingAverage(500).Of(_ratio); var upper = new ConstantIndicator <IndicatorDataPoint>("ct", 1 + _threshold / 100m); _upperThreshold = _mean.Times(upper, "UpperThreshold"); var lower = new ConstantIndicator <IndicatorDataPoint>("ct", 1 - _threshold / 100m); _lowerThreshold = _mean.Times(lower, "LowerThreshold"); } } }
public void SetUp() { _constantIndicator = new ConstantIndicator <Decimal>(Decimal.ValueOf("30.33")); }
public void setUp() { constantIndicator = new ConstantIndicator <decimal>(30.33M); }
public void setUp() { ConstantIndicator <decimal> constantIndicator = new ConstantIndicator <decimal>(6); multiplierIndicator = new MultiplierIndicator(constantIndicator, 0.75M); }
public void SetUp() { _constantIndicator = new ConstantIndicator <Decimal>(Decimal.ValueOf(6)); _multiplierIndicator = new MultiplierIndicator(_constantIndicator, Decimal.ValueOf("0.75")); }
public void SetUp() { _constantIndicator = new ConstantIndicator <Decimal>(Decimal.ValueOf(6)); _mockIndicator = new FixedIndicator <Decimal>(Decimal.ValueOf("-2.0"), Decimal.ValueOf("0.00"), Decimal.ValueOf("1.00"), Decimal.ValueOf("2.53"), Decimal.ValueOf("5.87"), Decimal.ValueOf("6.00"), Decimal.ValueOf("10.0")); _differenceIndicator = new DifferenceIndicator(_constantIndicator, _mockIndicator); }