ExecuteMarketOrderResponceMessage Receive(ExecuteMarketOrderMessage message) { IImplementation implementation = _implementation; if (implementation == null || OperationalState != OperationalStateEnum.Operational) { return(new ExecuteMarketOrderResponceMessage(message.AccountInfo, null, false)); } string operationResultMessage; if (message.PerformSynchronous == false) { return(new ExecuteMarketOrderResponceMessage(message.AccountInfo, null, true)); } OrderInfo?info; if (implementation.ExecuteMarketOrder(message.AccountInfo, message.Symbol, message.OrderType, message.Volume, message.Slippage, message.DesiredPrice, message.TakeProfit, message.StopLoss, message.Comment, out info, out operationResultMessage) == false) { return(new ExecuteMarketOrderResponceMessage(message.AccountInfo, null, false) { OperationResultMessage = operationResultMessage }); } return(new ExecuteMarketOrderResponceMessage(message.AccountInfo, info, true)); }
ExecuteMarketOrderResponseMessage Receive(ExecuteMarketOrderMessage message) { IImplementation implementation = _implementation; if (implementation == null || OperationalState != OperationalStateEnum.Operational) { return new ExecuteMarketOrderResponseMessage(message.AccountInfo, null, false); } string operationResultMessage; if (message.PerformSynchronous == false) { return new ExecuteMarketOrderResponseMessage(message.AccountInfo, null, true); } OrderInfo? info; if (implementation.ExecuteMarketOrder(message.AccountInfo, message.Symbol, message.OrderType, message.Volume, message.Slippage, message.DesiredPrice, message.TakeProfit, message.StopLoss, message.Comment, out info, out operationResultMessage) == false) { return new ExecuteMarketOrderResponseMessage(message.AccountInfo, null, false) { OperationResultMessage = operationResultMessage }; } return new ExecuteMarketOrderResponseMessage(message.AccountInfo, info, true); }
/// <summary> /// Main SynchronousExecute method. /// </summary> public bool SynchronousExecute(AccountInfo account, Order order, Symbol symbol, OrderTypeEnum orderType, int volume, decimal? allowedSlippage, decimal? desiredPrice, decimal? takeProfit, decimal? stopLoss, string comment, TimeSpan operationTimeOut, out OrderInfo? info, out string operationResultMessage) { TracerHelper.Trace(this.Name); info = null; operationResultMessage = string.Empty; if (OperationalState != OperationalStateEnum.Operational) { operationResultMessage = "Attempted operations on non operational order executioner."; SystemMonitor.Error(operationResultMessage); return false; } if (account.IsEmpty || string.IsNullOrEmpty(account.Id) || string.IsNullOrEmpty(account.Name)) { operationResultMessage = "Account info on order execution provider not properly assigned."; return false; } allowedSlippage = ProcessSlippage(allowedSlippage); ExecuteMarketOrderMessage request = new ExecuteMarketOrderMessage(account, symbol, orderType, volume, desiredPrice, allowedSlippage, takeProfit, stopLoss, comment); request.PerformSynchronous = true; ResponseMessage response = this.SendAndReceiveResponding<ResponseMessage> (SourceTransportInfo, request, operationTimeOut); if (response == null) {// Time out. operationResultMessage = "Failed receive result for order request. In this scenario inconsistency may occur!"; SystemMonitor.Error(operationResultMessage); return false; } if (response.OperationResult == false) { operationResultMessage = response.OperationResultMessage; return false; } //if (orderType == OrderTypeEnum.BUY_MARKET // || orderType == OrderTypeEnum.SELL_MARKET) //{// Immediate order. // resultState = OrderStateEnum.Executed; //} //else //{// Delayed pending order. // resultState = OrderStateEnum.Submitted; //} ExecuteMarketOrderResponseMessage responseMessage = (ExecuteMarketOrderResponseMessage)response; operationResultMessage = "Order opened."; info = responseMessage.Info; //RaiseOrderUpdateEvent(account, order.Info, ActiveOrder.UpdateTypeEnum.Submitted); return true; }
/// <summary> /// Main SynchronousExecute method. /// </summary> public bool SynchronousExecute(AccountInfo account, Order order, Symbol symbol, OrderTypeEnum orderType, int volume, decimal?allowedSlippage, decimal?desiredPrice, decimal?takeProfit, decimal?stopLoss, string comment, TimeSpan operationTimeOut, out OrderInfo?info, out string operationResultMessage) { TracerHelper.Trace(this.Name); info = null; operationResultMessage = string.Empty; if (OperationalState != OperationalStateEnum.Operational) { operationResultMessage = "Attempted operations on non operational order executioner."; SystemMonitor.Error(operationResultMessage); return(false); } if (account.IsEmpty || string.IsNullOrEmpty(account.Id) || string.IsNullOrEmpty(account.Name)) { operationResultMessage = "Account info on order execution provider not properly assigned."; return(false); } allowedSlippage = ProcessSlippage(allowedSlippage); ExecuteMarketOrderMessage request = new ExecuteMarketOrderMessage(account, symbol, orderType, volume, desiredPrice, allowedSlippage, takeProfit, stopLoss, comment); request.PerformSynchronous = true; ResponseMessage response = this.SendAndReceiveResponding <ResponseMessage> (SourceTransportInfo, request, operationTimeOut); if (response == null) {// Time out. operationResultMessage = "Failed receive result for order request. In this scenario inconsistency may occur!"; SystemMonitor.Error(operationResultMessage); return(false); } if (response.OperationResult == false) { operationResultMessage = response.OperationResultMessage; return(false); } //if (orderType == OrderTypeEnum.BUY_MARKET // || orderType == OrderTypeEnum.SELL_MARKET) //{// Immediate order. // resultState = OrderStateEnum.Executed; //} //else //{// Delayed pending order. // resultState = OrderStateEnum.Submitted; //} ExecuteMarketOrderResponseMessage responseMessage = (ExecuteMarketOrderResponseMessage)response; operationResultMessage = "Order opened."; info = responseMessage.Info; //RaiseOrderUpdateEvent(account, order.Info, ActiveOrder.UpdateTypeEnum.Submitted); return(true); }