protected OperationInformation GetOperationById(int id) { lock (this) { return(_stub.GetOperationById(id.ToString())); } }
/// <summary> /// Helper. /// </summary> void TryCompleteOrderOperation(string token, bool printWarning, OrderInfo?orderInfo) { PlaceOrderOperation operation; lock (this) { // Operations stored in stub by order token / Id. operation = (PlaceOrderOperation)_operationStub.GetOperationById(token); } if (operation == null) { if (printWarning) { SystemMonitor.Error("Operation with this ID [" + token + "] not found."); } return; } if (orderInfo.HasValue == false) { if (printWarning) { SystemMonitor.Warning("Failed to convert order for order [" + token + "]."); } operation.Complete("Failed to convert order type. Operation failed.", null); return; } operation.Complete(string.Empty, orderInfo.Value); }
/// <summary> /// /// </summary> void _historyClient_OnDataEvent(int lRequestId, object pHist, enumHistEventType evt) { List <DataBar> extractedBars = new List <DataBar>(); if (pHist is MbtHistDayBar) { MbtHistDayBar bars = (MbtHistDayBar)pHist; bars.First(); while (bars.Eof == false) { decimal open = (decimal)bars.Open; decimal close = (decimal)bars.Close; decimal high = (decimal)bars.High; decimal low = (decimal)bars.Low; extractedBars.Insert(0, new DataBar(bars.CloseDate, open, high, low, close, bars.TotalVolume)); bars.Next(); } } else if (pHist is MbtHistMinBar) { MbtHistMinBar bars = (MbtHistMinBar)pHist; bars.First(); while (bars.Eof == false) { decimal open = (decimal)bars.Open; decimal close = (decimal)bars.Close; decimal high = (decimal)bars.High; decimal low = (decimal)bars.Low; extractedBars.Insert(0, new DataBar(bars.UTCDateTime, open, high, low, close, bars.TotalVolume)); bars.Next(); } } DataHistoryOperation operation = (DataHistoryOperation)_operationStub.GetOperationById(lRequestId.ToString()); if (operation != null) { _operationStub.CompleteOperation(lRequestId.ToString(), new DataHistoryUpdate(operation.Request.Period, extractedBars)); } }