public void HandDuoLimitOrderUpdate(ILimitOrder limitOrder1, double limitOrder1NewPrice, int limitOrder1NewQuantity, ILimitOrder limitOrder2, double limitOrder2NewPrice, int limitOrder2NewQuantity) { if (!OrderBooks.ContainsKey(limitOrder1.Symbol)) return; OrderBooks[limitOrder1.Symbol].SetSuspendLimitOrderMatchingStatus(true); limitOrder1.Modify(limitOrder1NewQuantity, limitOrder1NewPrice); limitOrder2.Modify(limitOrder2NewQuantity, limitOrder2NewPrice); OrderBooks[limitOrder1.Symbol].SetSuspendLimitOrderMatchingStatus(false); OrderBooks[limitOrder1.Symbol].TryMatchLimitOrder(limitOrder1); OrderBooks[limitOrder1.Symbol].TryMatchLimitOrder(limitOrder2); }
public void HandDuoLimitOrderUpdate(ILimitOrder limitOrder1, double limitOrder1NewPrice, int limitOrder1NewQuantity, ILimitOrder limitOrder2, double limitOrder2NewPrice, int limitOrder2NewQuantity) { if (!OrderBooks.ContainsKey(limitOrder1.Symbol)) { return; } OrderBooks[limitOrder1.Symbol].SetSuspendLimitOrderMatchingStatus(true); limitOrder1.Modify(limitOrder1NewQuantity, limitOrder1NewPrice); limitOrder2.Modify(limitOrder2NewQuantity, limitOrder2NewPrice); OrderBooks[limitOrder1.Symbol].SetSuspendLimitOrderMatchingStatus(false); OrderBooks[limitOrder1.Symbol].TryMatchLimitOrder(limitOrder1); OrderBooks[limitOrder1.Symbol].TryMatchLimitOrder(limitOrder2); }
public void TryMatch(ILimitOrder buyLimitOrder, ILimitOrder sellLimitOrder) { /*if (buyLimitOrder.ClientId == sellLimitOrder.ClientId) * return;*/ if (buyLimitOrder.Symbol != sellLimitOrder.Symbol) { return; } if (buyLimitOrder.Price < sellLimitOrder.Price) { return; } if (buyLimitOrder.Quantity == 0 || sellLimitOrder.Quantity == 0) { return; } double matchPrice = FindMatchPrice(buyLimitOrder, sellLimitOrder); int matchQuantity = FindMatchQuantity(buyLimitOrder, sellLimitOrder); if (matchQuantity == 0) { return; } buyLimitOrder.Modify(buyLimitOrder.Quantity - matchQuantity); sellLimitOrder.Modify(sellLimitOrder.Quantity - matchQuantity); var execution = new NewExecution(buyLimitOrder, sellLimitOrder, matchQuantity, matchPrice, dateService.UtcNow()); for (int i = 0; i < executionHandlers.Count; i++) { executionHandlers[i].Invoke(execution); } }
public void TryMatch(IMarketOrder buyMarketOrder, ILimitOrder sellLimitOrder) { if (buyMarketOrder.Way != WayEnum.Buy || sellLimitOrder.Way != WayEnum.Sell) return; if (buyMarketOrder.Symbol != sellLimitOrder.Symbol) return; if (buyMarketOrder.Quantity == 0 || sellLimitOrder.Quantity == 0) return; int matchQuantity = FindMatchQuantity(buyMarketOrder, sellLimitOrder); if (matchQuantity == 0) return; double matchPrice = sellLimitOrder.Price; buyMarketOrder.Modify(buyMarketOrder.Quantity - matchQuantity); sellLimitOrder.Modify(sellLimitOrder.Quantity - matchQuantity); var execution = new NewExecution(buyMarketOrder, sellLimitOrder, matchQuantity, matchPrice, dateService.UtcNow()); for (int i = 0; i < executionHandlers.Count; i++) executionHandlers[i].Invoke(execution); }
public void TryMatch(ILimitOrder buyLimitOrder, IMarketOrder sellMarketOrder) { if (sellMarketOrder.Way != WayEnum.Sell || buyLimitOrder.Way != WayEnum.Buy) { return; } if (sellMarketOrder.Symbol != buyLimitOrder.Symbol) { return; } if (sellMarketOrder.Quantity == 0 || buyLimitOrder.Quantity == 0) { return; } int matchQuantity = FindMatchQuantity(sellMarketOrder, buyLimitOrder); if (matchQuantity == 0) { return; } double matchPrice = buyLimitOrder.Price; sellMarketOrder.Modify(sellMarketOrder.Quantity - matchQuantity); buyLimitOrder.Modify(buyLimitOrder.Quantity - matchQuantity); var execution = new NewExecution(buyLimitOrder, sellMarketOrder, matchQuantity, matchPrice, dateService.UtcNow()); for (int i = 0; i < executionHandlers.Count; i++) { executionHandlers[i].Invoke(execution); } }