private void OrderBook_TradeCompleted(object sender, TradeCompletedEventArgs e) { LastTradedPrice = e.LastTradedPrice; TradeCompleted?.Invoke(this, e); System.Diagnostics.Debug.Print(LastTradedPrice.ToString()); }
public TradeCompletedRecord(TradeCompleted trade) { TradeId = trade.TradeId; OrderId = trade.OrderId; Created = trade.Created.Ticks; Updated = trade.Updated.Ticks; AmountIn = (double)(decimal)trade.AmountIn; AmountOut = (double)(decimal)trade.AmountOut; Commission = (double)(decimal)trade.Commission; CommissionCoin = trade.CommissionCoin.Symbol; }
/// <summary> /// Reads a <see cref="PeerTradeInfoServerMessage.Completed"/>. /// </summary> void ReadCompleted() { Debug.Assert(IsTradeOpen, "Why is the trade table not open...?"); // Raise events OnTradeCompleted(); if (TradeCompleted != null) { TradeCompleted.Raise(this, EventArgs.Empty); } }
public void ExecuteTrade(Order order, List <Order> matchingOrders) { Trade trade = new Trade(order.Symbol, order.Exchange); long quantityRequired = order.Quantity; //if (order.Transaction == TransactionType.Buy) { foreach (var sOrder in matchingOrders) { //Single seller has sufficient Quantity if (quantityRequired <= sOrder.Quantity) { trade.UpdateTrade(sOrder.Price, quantityRequired); } else { trade.UpdateTrade(sOrder.Price, sOrder.Quantity); } if (quantityRequired == trade.Quantity || sOrder.Quantity == trade.Quantity) { //Trade Finished TradeCompleted?.Invoke(this, new TradeCompletedEventArgs(trade)); if (order.Quantity == trade.Quantity) { sOrder.Quantity -= trade.Quantity; order.Status = OrderStatus.Completed; order.OrderSubmitted(OrderStatus.Completed); if (sOrder.Quantity == 0) { sOrder.Status = OrderStatus.Completed; } } else { order.Quantity -= trade.Quantity; sOrder.Status = OrderStatus.Completed; sOrder.OrderSubmitted(OrderStatus.Completed); } break; } } TradeList.Add(trade); } }
protected virtual void OnTradeCompleted(TradeResult result) { TradeCompleted?.Invoke(result); }