本文整理汇总了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");
}
示例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));
}
示例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();
}
示例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));
}
示例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);
}
示例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);
}
示例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++;
}
示例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");
}