Esempio n. 1
0
        public OrderReply PostOrder(string account, Stock stock, Fill order, OrderType orderType)
        {
            PostOrder  request = new PostOrder(account, Name, stock, order, orderType);
            bool       success = request.Execute();
            OrderReply reply   = (request.Reply as OrderReply) ?? new OrderReply(false);

            if (success)
            {
                UpdateOrder(reply);
            }
            return(reply);
        }
Esempio n. 2
0
        public void PostOrderTest_Immediate()
        {
            Stock     stock   = new Stock("", Utils.TestStock);
            Fill      order   = new Fill(0, 100, Direction.Buy);
            PostOrder request = new PostOrder(Utils.TestAccount, Utils.TestVenue, stock, order, OrderType.ImmediateOrCancell);
            bool      actual  = request.Execute();

            Assert.IsTrue(actual);
            OrderReply reply = request.Reply as OrderReply;

            Assert.IsNotNull(reply);
            Assert.AreEqual(Utils.TestVenue, reply.Venue);
            Assert.AreEqual(Utils.TestStock, reply.Symbol);
        }
Esempio n. 3
0
        public void PostOrderTest_StockDoesNotExist()
        {
            Stock     stock   = new Stock("", "FALSEEX");
            Fill      order   = new Fill(0, 100, Direction.Buy);
            PostOrder request = new PostOrder(Utils.TestAccount, Utils.TestVenue, stock, order, OrderType.Market);
            bool      actual  = request.Execute();

            Assert.IsFalse(actual);
            OrderReply reply = request.Reply as OrderReply;

            Assert.IsNotNull(reply);
            Assert.IsNull(reply.Venue);
            Assert.IsNull(reply.Symbol);
            Assert.IsNull(reply.Fills);
        }
Esempio n. 4
0
        public void PostOrderTest_NoAccount()
        {
            Stock     stock   = new Stock("", Utils.TestStock);
            Fill      order   = new Fill(0, 0, Direction.Buy);
            PostOrder request = new PostOrder("", Utils.TestStock, stock, order, OrderType.Market);
            bool      actual  = request.Execute();

            Assert.IsFalse(actual);
            OrderReply reply = request.Reply as OrderReply;

            Assert.IsNull(reply);
            BaseReply baseReply = request.Reply as BaseReply;

            Assert.IsNotNull(baseReply);
            StringAssert.Contains("The remote server returned an error: (404) Not Found.", baseReply.Error);
        }