Пример #1
0
        public void MultipleBuys()
        {
            var a = new VAccount(10000, 4, 3);

            a.Buy("DIA", 10, 1.00);
            a.Buy("DIA", 10, 2.00);
            a.Sell("DIA", 20, 2.50);
            a.Equity.ShouldEqual(10011);
        }
Пример #2
0
        public void CannotSellMoreThanYouHave()
        {
            var a = new VAccount(10000, 4, 3);

            a.Buy("DIA", 4, 7.00);
            new Action(() => a.Sell("DIA", 5, 7.00)).ShouldThrow <Exception>(x => x.Message.ShouldContain("Can't sell"));
        }
Пример #3
0
        public void LongPosition()
        {
            var a = new VAccount(10000, 4, 3);

            a.Buy("DIA", 10, 1.50);
            a.Equity.ShouldEqual(9997);
            a.Invested.ShouldEqual(15);
            a.BuyingPower.ShouldEqual(39973);

            a.Sell("DIA", 10, 2.50);
            a.Equity.ShouldEqual(10004);
            a.Invested.ShouldEqual(0);
            a.BuyingPower.ShouldEqual(40016);
        }
Пример #4
0
        public void NotEnoughEquityToBuy()
        {
            var a = new VAccount(10, 4, 3);

            new Action(() => a.Buy("DIA", 4, 7.01)).ShouldThrow <Exception>(x => x.Message.ShouldEqual("Insufficient buying power"));
        }
Пример #5
0
        public void JustEnoughEquityToBuy()
        {
            var a = new VAccount(10, 4, 3);

            a.Buy("DIA", 4, 7.00);
        }