当前位置: 首页>>代码示例>>C#>>正文


C# Order.Fill方法代码示例

本文整理汇总了C#中Order.Fill方法的典型用法代码示例。如果您正苦于以下问题:C# Order.Fill方法的具体用法?C# Order.Fill怎么用?C# Order.Fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Order的用法示例。


在下文中一共展示了Order.Fill方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixSentOnUnknown

        public void FixSentOnUnknown()
        {
            // reset everything
            id = 1;
            o = new OrderImpl();
            ot = new OrderTracker();
            ot.SendDebugEvent += new DebugDelegate(ot_SendDebugEvent);
            ot.VerboseDebugging = true;
            ot.FixSentSizeOnUnknown = true;

            // verify no size/pending/cancel
            Assert.AreEqual(0, ot.Sent(id), "sent but not sent");
            Assert.IsFalse(ot.isCompleted(id), "completed but not sent");
            Assert.IsFalse(ot.isCanceled(id), "wrongly canceled");
            Assert.IsFalse(ot.isPending(id), "wrongly pending");
            Assert.IsFalse(ot.isTracked(id), "wrongly tracked");
            // prepare a buy order
            o = new BuyLimit(sym, 100, 100, id++);
            // fill it
            Assert.IsTrue(o.Fill(TickImpl.NewTrade(sym, 100, 100)), "order did not fill");
            ot.GotFill((Trade)o);
            // order will be invalid since it was sent previously (or unknown)
            Assert.False(ot.SentOrder(id - 1).isValid, "valid order was found, none was sent though");
            // verify size/pending/cancel
            Assert.AreEqual(100, ot.Sent(id - 1), "not sent buy");
            Assert.AreEqual(100, ot.Filled(id - 1), "incorrect fill size buy");
            Assert.IsTrue(ot.isCompleted(id - 1), "wrongly not filled");
            Assert.IsFalse(ot.isCanceled(id - 1), "wrongly canceled");
            Assert.IsFalse(ot.isPending(id - 1), "wrongly pending");
            Assert.IsTrue(ot.isTracked(id - 1), "not tracked");

           
        }
开发者ID:bluejack2000,项目名称:core,代码行数:33,代码来源:TestOrderTracker.cs

示例2: FillingOrderRemovesWarehouseItemsWhenSufficientStockIsAvailable

        public void FillingOrderRemovesWarehouseItemsWhenSufficientStockIsAvailable()
        {
            Order order = new Order("milk", 20);
            IWarehouse warehouse = MockRepository.GenerateMock<IWarehouse>();
            warehouse.Stub(x => x.HasInventory("milk", 20)).Return(true);

            order.Fill(warehouse);

            warehouse.AssertWasCalled(x => x.Remove("milk", 20));
        }
开发者ID:dchetwynd,项目名称:Mocking-with-Microsoft-Fakes,代码行数:10,代码来源:OrderRhinoTest.cs

示例3: FillingOrderChecksTheWarehouseInventory

        public void FillingOrderChecksTheWarehouseInventory()
        {
            Order order = new Order("milk", 20);
            IWarehouse warehouse = MockRepository.GenerateMock<IWarehouse>();
            warehouse.Expect(x => x.HasInventory("milk", 20)).Return(false);

            order.Fill(warehouse);

            warehouse.VerifyAllExpectations();
        }
开发者ID:dchetwynd,项目名称:Mocking-with-Microsoft-Fakes,代码行数:10,代码来源:OrderRhinoTest.cs

示例4: WarehouseStockRemovedWhenSufficientStockAvailableForOrder

        public void WarehouseStockRemovedWhenSufficientStockAvailableForOrder()
        {
            Order order = new Order("milk", 20);
            Warehouse warehouse = new Warehouse();
            warehouse.Add("milk", 50);

            order.Fill(warehouse);

            Assert.That(warehouse.GetInventory("milk"), Is.EqualTo(30));
        }
开发者ID:dchetwynd,项目名称:Mocking-with-Microsoft-Fakes,代码行数:10,代码来源:OrderTest.cs

示例5: OrderIsNotFilledForInsufficientStockInWarehouse

        public void OrderIsNotFilledForInsufficientStockInWarehouse()
        {
            Order order = new Order("milk", 20);

            var warehouse = new StubIWarehouse()
            {
                HasInventoryStringInt32 = (itemName, quantity) =>
                {
                    return false;
                }
            };

            order.Fill(warehouse);

            Assert.False(order.IsFilled);
        }
开发者ID:dchetwynd,项目名称:Mocking-with-Microsoft-Fakes,代码行数:16,代码来源:OrderTest.cs

示例6: OrderIsFilledForSufficientStockInWarehouse

        public void OrderIsFilledForSufficientStockInWarehouse()
        {
            Order order = new Order("milk", 20);

            var warehouse = new StubIWarehouse()
            {
                HasInventoryStringInt32 = (itemName, quantity) =>
                {
                    return true;
                },

                RemoveStringInt32 = (itemName, quantity) =>
                {
                    return;
                }
            };

            order.Fill(warehouse);

            Assert.True(order.IsFilled);
        }
开发者ID:dchetwynd,项目名称:Mocking-with-Microsoft-Fakes,代码行数:21,代码来源:OrderTest.cs

示例7: AddOrder

        protected void AddOrder(Order o,Account a) 
        {
            if (!a.isValid) throw new Exception("Invalid account provided"); // account must be good
            if ((FillMode== FillMode.OwnBook) && a.Execute)
            {
                // get best bid or offer from opposite side,
                // see if we can match against this BBO and cross locally
                Order match = BestBidOrOffer(o.symbol, !o.side);

                // first we need to make sure the book we're matching to allows executions
                Account ma = new Account();
                if (acctlist.TryGetValue(match.Account,out ma) && ma.Execute) 
                {
                    // if it's allowed, try to match it
                    bool filled = o.Fill(match);
                    int avail = o.UnsignedSize;
                    // if it matched 
                    if (filled)
                    {
                        // record trade
                        Trade t = (Trade)o;
                        MasterTrades[a.ID].Add(t); 
                        // notify the trade occured
                        if (GotFill != null) 
                            GotFill(t);

                        // update the order's size (in case it was a partial fill)
                        o.size = (avail - Math.Abs(t.xsize)) * (o.side ? 1 : -1);

                        // if it was a full fill, no need to add order to the book
                        if (Math.Abs(t.xsize) == avail) return;
                    }
                }
            }
            // add any remaining order to book as new liquidity route
            List<Order> tmp;
            // see if we have a book for this account
            if (!MasterOrders.TryGetValue(a, out tmp))
            {
                tmp = new List<Order>();
                MasterOrders.Add(a, tmp); // if not, create one
            }
            o.Account = a.ID; // make sure order knows his account
            tmp.Add(o); // record the order
            // increment pending count
            _pendorders++; 
        }
开发者ID:antonywu,项目名称:tradelink,代码行数:47,代码来源:Broker.cs

示例8: PartialFill

        public void PartialFill()
        {
            // reset everything
            id = 1;
            o = new OrderImpl();
            ot = new OrderTracker();
            ot.SendDebugEvent += new DebugDelegate(ot_SendDebugEvent);
            ot.VerboseDebugging = true;

            // verify no size/pending/cancel
            Assert.AreEqual(0, ot.Sent(id), "sent but not sent");
            Assert.IsFalse(ot.isCompleted(id), "completed but not sent");
            Assert.IsFalse(ot.isCanceled(id), "wrongly canceled");
            Assert.IsFalse(ot.isPending(id), "wrongly pending");
            Assert.IsFalse(ot.isTracked(id), "wrongly tracked");
            // send a buy order
            o = new BuyLimit(sym, 200, 100, id++);
            ot.GotOrder(o);
            // fill it
            Assert.IsTrue(o.Fill(TickImpl.NewTrade(sym, 100, 100)), "order did not fill");
            ot.GotFill((Trade)o);
            // verify order is there
            Assert.IsTrue(ot.SentOrder(id - 1).isValid, "no valid order");
            // verify size/pending/cancel
            Assert.AreEqual(200, ot.Sent(id - 1), "not sent buy");
            Assert.AreEqual(100, ot.Filled(id - 1), "incorrect fill size buy");
            Assert.IsFalse(ot.isCompleted(id - 1), "wrongly completed");
            Assert.IsFalse(ot.isCanceled(id - 1), "wrongly canceled");
            Assert.IsTrue(ot.isPending(id - 1), "wrongly pending");
            Assert.IsTrue(ot.isTracked(id - 1), "not tracked");

            // do sell order

            // verify no size/pending/cancel
            Assert.AreEqual(0, ot.Sent(id), "sent but not sent");
            Assert.IsFalse(ot.isCompleted(id), "completed but not sent");
            Assert.IsFalse(ot.isCanceled(id), "wrongly canceled");
            Assert.IsFalse(ot.isPending(id), "wrongly pending");
            Assert.IsFalse(ot.isTracked(id), "wrongly tracked");
            // send sell order
            o = new SellLimit(sym, 200, 100, id++);
            ot.GotOrder(o);
            // fill it
            Assert.IsTrue(o.Fill(TickImpl.NewTrade(sym, 100, 100)), "order did not fill");
            ot.GotFill((Trade)o);
            // verify order is there
            Assert.IsTrue(ot.SentOrder(id - 1).isValid, "no valid order");
            // verify size/pending/cancel
            Assert.AreEqual(-100, ot.Filled(id - 1), "incorrect fill size sell");
            Assert.AreEqual(-200, ot.Sent(id - 1), "not sent sell");
            Assert.IsFalse(ot.isCompleted(id - 1), "wrongly completed");
            Assert.IsFalse(ot.isCanceled(id - 1), "wrongly canceled");
            Assert.IsTrue(ot.isPending(id - 1), "wrongly pending");
            Assert.IsTrue(ot.isTracked(id - 1), "not tracked");
        }
开发者ID:bluejack2000,项目名称:core,代码行数:55,代码来源:TestOrderTracker.cs


注:本文中的Order.Fill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。