public string OpenSellOrder(int volume) { string operationResultMessage; Position position = Position; if (position != null) { return(position.Submit(OrderTypeEnum.SELL_MARKET, volume, null, null, null, null, out operationResultMessage)); } else { TracerHelper.TraceOperationError(_tracer, "Failed to find corresponding position."); } //TracerHelper.Trace(_tracer, ""); //if (closeVolume <= 0) //{ // return null; //} //ActiveOrder order = new ActiveOrder(Manager, CurrentSession.OrderExecutionProvider); //if (order.LoadFromFile() == false) //{ // SystemMonitor.Error("Failed to initialize order."); // return null; //} //if (order.Submit(OrderTypeEnum.SELL_MARKET, closeVolume)) //{ // return order; //} return(null); }
public string OpenBuyOrder(int volume) { string operationResultMessage; Position position = Position; if (position != null) { return(position.Submit(OrderTypeEnum.BUY_MARKET, volume, null, null, null, null, out operationResultMessage)); } else { TracerHelper.TraceOperationError(_tracer, "Failed to find corresponding position."); } //if (closeVolume <= 0 || CurrentSession == null) //{ // return null; //} //ActiveOrder order = new ActiveOrder(base..Manager.GetOrderExecutionProvider(, CurrentSession.DataProvider.ExecutionSourceId, // CurrentSession.DataProvider.SessionInfo.Symbol, false); //if (order.LoadFromFile() == false) //{ // SystemMonitor.Error("Failed to initialize order."); // return null; //} //if (order.Submit(OrderTypeEnum.BUY_MARKET, closeVolume)) //{ // return order; //} return(null); }
public void ClosePosition() { string operationResultMessage; Position position = Position; if (position != null) { position.SubmitClose(null, out operationResultMessage); } else { TracerHelper.TraceOperationError(_tracer, "Failed to find corresponding position."); } }
public void ClosePosition() { string operationResultMessage; Position position = CurrentSession.OrderExecutionProvider.TradeEntities.ObtainPositionBySymbol(CurrentSession.Info.Symbol); if (position != null) { position.SubmitClose((int)position.Volume, out operationResultMessage); } else { TracerHelper.TraceOperationError(_tracer, "Failed to find corresponding position."); } }
protected ResponseMessage Receive(RequestMessage message) { TracerHelper.TraceEntry(message.GetType().Name); try { OperationInformation info = new OperationInformation(); info.Request = message; if (message.PerformSynchronous) { ResponseMessage result; if (_stub.PerformOperation <ResponseMessage>(info, null, true, out result)) {// Operation performed successfully. TracerHelper.Trace("Operation [" + message.GetType().Name + "] performed successfully."); return(result); } else { TracerHelper.TraceOperationError("Operation [" + message.GetType().Name + "] timed out."); } } else { _stub.PlaceOperation(info, true); if (message.RequestResponse) { return(new ResponseMessage(true)); } return(null); } } catch (Exception ex) {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the // entire package (MT4 included) down with a bad error. SystemMonitor.Error(ex.Message); } return(null); }
public string OpenBuyOrder(int volume) { string operationResultMessage; string orderId = null; Position position = Position; if (position != null) { orderId = position.Submit(OrderTypeEnum.BUY_MARKET, volume, null, null, null, null, out operationResultMessage); if (!string.IsNullOrEmpty(orderId)) { this.WorkingOrderIds.Add(orderId); } } else { TracerHelper.TraceOperationError(_tracer, "Failed to find corresponding position."); } return(orderId); }