Beispiel #1
0
        public void VolumeShareSlippageModelInitializationTests()
        {
            // These are low volume tests, since the order quantity and the volume are the same

            // These are the default values for the VolumeShareSlippageModel
            var priceImpact = 0.1m;
            var volumeLimit = 0.025m;
            var model       = new VolumeShareSlippageModel();

            var expected = _equity.Price * priceImpact * volumeLimit * volumeLimit;
            var actual   = model.GetSlippageApproximation(_equity, _equityBuyOrder);

            Assert.AreEqual(expected, actual);

            // Double the values
            priceImpact *= 2;
            volumeLimit *= 2;
            model        = new VolumeShareSlippageModel(volumeLimit, priceImpact);

            expected = _equity.Price * priceImpact * volumeLimit * volumeLimit;
            actual   = model.GetSlippageApproximation(_equity, _equityBuyOrder);
            Assert.AreEqual(expected, actual);

            // Half the values
            priceImpact /= 4;
            volumeLimit /= 4;
            model        = new VolumeShareSlippageModel(volumeLimit, priceImpact);

            expected = _equity.Price * priceImpact * volumeLimit * volumeLimit;
            actual   = model.GetSlippageApproximation(_equity, _equityBuyOrder);
            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void VolumeShareSlippageModel_ForexTest()
        {
            var model = new VolumeShareSlippageModel();

            // Since FX/CFD often have zero volume, the model returns zero slippage
            var expected = 0;
            var actual = model.GetSlippageApproximation(_forex, _forexBuyOrder);
            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void VolumeShareSlippageModel_HighVolumeTest()
        {
            // These are the default values for the VolumeShareSlippageModel
            var priceImpact = 0.1m;
            var volumeLimit = 0.025m;
            var model = new VolumeShareSlippageModel();

            // High volume: volume > volumeLimit x order.Quantity
            var volume = 100;
            var volumeShare = _equityBuyOrder.Quantity / (decimal)volume;
            Assert.Greater(volume, volumeLimit * _equityBuyOrder.Quantity);
            _equity.SetMarketPrice(new TradeBar(DateTime.Now, Symbols.SPY, 100m, 100m, 100m, 100m, volume));

            var expected = _equity.Price * priceImpact * volumeShare * volumeShare;
            var actual = model.GetSlippageApproximation(_equity, _equityBuyOrder);
            Assert.AreEqual(expected, actual);
        }