private void ShowSellDialog(string Symbol, int MaxQuantity) { using (var form = new SellDialog(m_oAh, m_oA, Symbol, MaxQuantity)) { var result = form.ShowDialog(); if (result == DialogResult.OK) { int SellQuantity = form.ReturnQuantity; //values preserved after close m_oA.SellHoldingFromAccount(SellQuantity, Symbol, m_oTradeHandler); RefreshData(); } else { form.Close(); } } }
public bool ExecuteOrder(IAccountHandlerInterface AccountHandler, ITradeHandlerInterface TradeHandler, out IOrder StopLossOrder) { StopLossOrder = this; if (EvaluateTriggerOnOrder()) { try { IAccountInterface oA = AccountHandler.GetAccount(m_oAccountIdentifier); switch (m_oOrderType) { case OrderType.Buy: oA.AddHoldingToAccount(m_oQuantity, m_oSymbol, TradeHandler); StopLossOrder = this; return(true); case OrderType.Sell: oA.SellHoldingFromAccount(m_oQuantity, m_oSymbol, TradeHandler); return(true); case OrderType.StopLoss: oA.AddHoldingToAccount(m_oQuantity, m_oSymbol, TradeHandler); StopLossOrder = CreateStopLossOrder(ImperaturGlobal.Quotes.Where(q => q.Symbol.Equals(m_oSymbol)).First().LastTradePrice.Amount); return(true); default: break; } } catch (Exception ex) { m_oLastErrorMessage = "OrderExecute error: " + ex.Message; return(false); } } return(false); }