Exemplo n.º 1
0
        public bool ExecuteTrades(LiveTrade trade, LiveTrade stopTrade)
        {
            if (!PendingApprovalCodes.Contains(trade.ApprovalCode) || (stopTrade != null && !PendingApprovalCodes.Contains(stopTrade.ApprovalCode)))
            {
                Log(new LogMessage("Trade Mgr", $"ERROR: Trades not approved: {trade} and {stopTrade}", LogMessageType.TradingError));
                return(false);
            }

            ActiveAccount.Portfolio.AddTrade(trade);
            if (stopTrade != null)
            {
                ActiveAccount.Portfolio.AddTrade(stopTrade);
            }

            TradingProvider.SubmitTrades(trade, stopTrade);

            CancelTrades(trade, stopTrade);

            return(true);
        }