Exemple #1
0
        public void TestShortBidOffer()
        {
            symbol = Factory.Symbol.LookupSymbol("EUR/USD");
            var inventory = new InventoryGroupDefault(symbol);

            inventory.Retrace        = .60;
            inventory.RoundLotSize   = 1000;
            inventory.MaximumLotSize = 1000;
            inventory.MinimumLotSize = 1000;
            inventory.Goal           = 5000;
            //Console.WriteLine("Price,Quantity,Cumulative,BreakEven,PandL");
            var first = true;
            var sb    = new StringBuilder();
            var price = 1.7000D;

            for (var i = 0; i < 3000; i++)
            {
                var amountToOffer = 0;
                inventory.CalculateBidOffer(price, price);
                amountToOffer = inventory.OfferSize;
                inventory.Change(price, -amountToOffer);
                var pandl = inventory.CurrentProfitLoss(price);
                sb.AppendLine(Round(price) + "," + amountToOffer + "," + inventory.Size + "," + Round(inventory.BreakEven) + "," + Round(pandl));
                price += symbol.MinimumTick * 10;
            }
            //Console.Write(sb.ToString());
        }
Exemple #2
0
        public void TestLongClose()
        {
            var inventory = new InventoryGroupDefault(symbol);

            inventory.Change(10, 1000);
            Assert.AreEqual(inventory.BreakEven, 10);
            inventory.Change(9, 666);
            Assert.AreEqual(9.6, Math.Round(inventory.BreakEven, 2), "break even 1");
            inventory.Change(8, 555);
            Assert.AreEqual(9.2, Math.Round(inventory.BreakEven, 2), "break even 2");
            var price = 6D;

            inventory.CalculateBidOffer(price, price);
            price = inventory.PriceToClose();
            int howManyToClose = inventory.Size;

            Assert.AreEqual(Math.Round(9.4, 2), Math.Round(price, 2), "close price");
            Assert.AreEqual(2221, howManyToClose, "close size");
        }
Exemple #3
0
        public void TestLongBidOffer()
        {
            symbol = Factory.Symbol.LookupSymbol("EUR/USD");
            var inventory = new InventoryGroupDefault(symbol);

            inventory.Retrace        = .60;
            inventory.RoundLotSize   = 1000;
            inventory.MaximumLotSize = 1000;
            inventory.MinimumLotSize = 1000;
            inventory.Goal           = 5000;
            //Console.WriteLine("Price,Quantity,Cumulative,BreakEven,PandL");
            var first = true;
            var sb    = new StringBuilder();

            for (var price = 1.7000D; price > 1.4000; price -= 10 * symbol.MinimumTick)
            {
                var amountToBid = 0;
                inventory.CalculateBidOffer(price, price);
                amountToBid = inventory.BidSize;
                inventory.Change(price, amountToBid);
                var pandl = inventory.CurrentProfitLoss(price);
                sb.AppendLine(Round(price) + "," + amountToBid + "," + inventory.Size + "," + Round(inventory.BreakEven) + "," + Round(pandl));
            }
        }