Example #1
0
        public void ReturnsMinimumOrderValueReason()
        {
            var algorithm = GetAlgorithm();
            var security  = InitAndGetSecurity(algorithm, 0);
            var model     = new SecurityMarginModel();
            var result    = model.GetMaximumOrderQuantityForTargetValue(algorithm.Portfolio, security, 0.00000001m);

            Assert.AreEqual(0m, result.Quantity);
            Assert.IsFalse(result.IsError);
            Assert.IsTrue(result.Reason.Contains("is less than the minimum"));
        }
Example #2
0
        public void ZeroTargetWithZeroHoldingsIsNotAnError()
        {
            var algorithm = GetAlgorithm();
            var security  = InitAndGetSecurity(algorithm, 0);

            var model  = new SecurityMarginModel();
            var result = model.GetMaximumOrderQuantityForTargetValue(algorithm.Portfolio, security, 0);

            Assert.AreEqual(0, result.Quantity);
            Assert.IsTrue(result.Reason.IsNullOrEmpty());
            Assert.IsFalse(result.IsError);
        }
        public void ZeroTargetWithZeroHoldingsIsNotAnError()
        {
            var algorithm = new QCAlgorithm();
            var security  = algorithm.AddEquity("SPY");

            var model  = new SecurityMarginModel();
            var result = model.GetMaximumOrderQuantityForTargetValue(algorithm.Portfolio, security, 0);

            Assert.AreEqual(0, result.Quantity);
            Assert.AreEqual(string.Empty, result.Reason);
            Assert.AreEqual(false, result.IsError);
        }
Example #4
0
        public void ZeroTargetWithNonZeroHoldingsReturnsNegativeOfQuantity()
        {
            var algorithm = GetAlgorithm();
            var security  = InitAndGetSecurity(algorithm, 0);

            security.Holdings.SetHoldings(200, 10);

            var model  = new SecurityMarginModel();
            var result = model.GetMaximumOrderQuantityForTargetValue(algorithm.Portfolio, security, 0);

            Assert.AreEqual(-10, result.Quantity);
            Assert.IsTrue(result.Reason.IsNullOrEmpty());
            Assert.IsFalse(result.IsError);
        }
        public void ZeroTargetWithNonZeroHoldingsReturnsNegativeOfQuantity()
        {
            var algorithm = new QCAlgorithm();
            var security  = algorithm.AddEquity("SPY");

            security.Holdings.SetHoldings(200, 10);

            var model  = new SecurityMarginModel();
            var result = model.GetMaximumOrderQuantityForTargetValue(algorithm.Portfolio, security, 0);

            Assert.AreEqual(-10, result.Quantity);
            Assert.AreEqual(string.Empty, result.Reason);
            Assert.AreEqual(false, result.IsError);
        }