private void OnEventReceived(Event data) { #if DEBUG Console.Out.Write("---- On Event Received ----"); Console.Out.Write(data.transaction); #endif if (data.transaction != null) { if (data.transaction.type == "ORDER_FILLED") { var qcOrder = _orderProvider.GetOrderByBrokerageId(data.transaction.orderId); const int orderFee = 0; var fill = new OrderEvent(qcOrder, DateTime.UtcNow, orderFee, "Oanda Fill Event") { Status = OrderStatus.Filled, FillPrice = (decimal)data.transaction.price, FillQuantity = data.transaction.units }; // flip the quantity on sell actions if (qcOrder.Direction == OrderDirection.Sell) { fill.FillQuantity *= -1; } OnOrderEvent(fill); } } }
/// <summary> /// Gets the order by its brokerage id /// </summary> /// <param name="orderProvider">The order provider to search</param> /// <param name="brokerageId">The brokerage id to fetch</param> /// <returns>The first order matching the brokerage id, or null if no match is found</returns> public static Order GetOrderByBrokerageId(this IOrderProvider orderProvider, long brokerageId) { return(orderProvider.GetOrderByBrokerageId(brokerageId.ToStringInvariant())); }
/// <summary> /// Gets the order by its brokerage id /// </summary> /// <param name="orderProvider">The order provider to search</param> /// <param name="brokerageId">The brokerage id to fetch</param> /// <returns>The first order matching the brokerage id, or null if no match is found</returns> public static Order GetOrderByBrokerageId(this IOrderProvider orderProvider, int brokerageId) { return(orderProvider.GetOrderByBrokerageId(brokerageId.ToString())); }