Esempio n. 1
0
        private bool CloseOrder(IOrderInfo order)
        {
            try
            {
                TradeOperation orderType = order.GetTradeOperation();

                Console.WriteLine("Closing an order - order.closePrice: {0} market.bid: {1} market.ask: {2} order.OrderType: {3}", order.GetClosePrice(), Marketinfo(order.GetSymbol(), MarketInfo.MODE_BID), Marketinfo(order.GetSymbol(), MarketInfo.MODE_ASK), orderType);

                switch (orderType)
                {
                case TradeOperation.OP_BUY:
                case TradeOperation.OP_SELL:
                    RefreshRates();
                    if (order.GetTicket() > 0 && OrderClose(order.GetTicket(), order.GetLots(),
                                                            Marketinfo(order.GetSymbol(),
                                                                       orderType == TradeOperation.OP_BUY
                                                      ? MarketInfo.MODE_BID
                                                      : MarketInfo.MODE_ASK),
                                                            20, 0))
                    {
                        Info(String.Format("Order {0} has been closed", order));
                        return(true);
                    }
                    Info(String.Format("Order {0} to be closed; todo", order));
                    return(false);

                default:
                    if (OrderDelete(order.GetTicket(), Color.Black))
                    {
                        Info(String.Format("Order {0} has been deleted", order));
                        return(true);
                    }
                    else
                    {
                        Info(String.Format("Can not delete order {0}", order));
                        return(false);
                    }
                }
            }
            catch (ErrInvalidTicket)
            {
                Info(String.Format("Looks like order {0} has been deleted manually", order));
                return(true);
            }
            catch (ErrInvalidPrice)
            {
                Info(String.Format("## ErrInvalidPrice - Price slippage ## - order.closePrice: {0} market.bid: {1} market.ask: {2} order.OrderType: {3}", order.GetClosePrice(), Marketinfo(order.GetSymbol(), MarketInfo.MODE_BID), Marketinfo(order.GetSymbol(), MarketInfo.MODE_ASK), order.GetTradeOperation()));
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads current Copier account orders at creation.
        /// </summary>
        public override void Init()
        {
            int ordersTotal = OrdersTotal();

            for (int i = 0; i < ordersTotal; i++)
            {
                IOrderInfo order = OrderGet(i, SelectionType.SELECT_BY_POS, SelectionPool.MODE_TRADES);
                if (order != null)
                {
                    /*
                     * if (order.GetMagic() != 0)
                     * {
                     *  Console.WriteLine("Closing order: " + order);
                     *  CloseOrder(order);
                     * }
                     * continue;
                     */
                    if (order.GetMagic() != 0)
                    {
                        _ordersMap.Add(
                            order.GetMagic(), // Master's order ticket
                            order.GetTicket()
                            );
                        Info(String.Format("Master order {0} is mapped to {1}", order.GetMagic(), order));
                    }
                    else
                    {
                        Info(String.Format("Custom order {0} left unmanaged", order));

                        //lets try to close this
                        Info(String.Format("Closing orphaned order: {0}", order));
                    }
                }
            }
        }
Esempio n. 3
0
 internal void MasterOrderClosedOrDeleted(IOrderInfo masterOrder)
 {
     if (_ordersMap.Contains(masterOrder.GetTicket()))
     {
         var        orderTicket = (int)_ordersMap[masterOrder.GetTicket()];
         IOrderInfo order       = OrderGet(orderTicket, SelectionType.SELECT_BY_TICKET, SelectionPool.MODE_TRADES);
         if (order != null)
         {
             if (CloseOrder(order))
             {
                 _ordersMap.Remove(masterOrder.GetTicket());
             }
         }
         else
         {
             Info(String.Format("Order {0} not found", orderTicket));
             _ordersMap.Remove(masterOrder.GetTicket());
         }
     }
 }
Esempio n. 4
0
        internal void MasterOrderCreated(IOrderInfo masterOrder)
        {
            RefreshRates();
            double orderPrice = Marketinfo(masterOrder.GetSymbol(),
                                           (masterOrder.GetTradeOperation() == TradeOperation.OP_BUY)
                                                      ? MarketInfo.MODE_ASK
                                                      : MarketInfo.MODE_BID);
            TradeOperation orderType = masterOrder.GetTradeOperation();

            Console.WriteLine("Creating an order - order.closePrice: {0} market.bid: {1} market.ask: {2} order.OrderType: {3}", masterOrder.GetClosePrice(), Marketinfo(masterOrder.GetSymbol(), MarketInfo.MODE_BID), Marketinfo(masterOrder.GetSymbol(), MarketInfo.MODE_ASK), orderType);


            //Info(String.Format("Executing order for account {0}", _acc));

            try {
                int ticket = OrderSend(
                    masterOrder.GetSymbol(),
                    masterOrder.GetTradeOperation(),
                    masterOrder.GetLots(),
                    //masterOrder.GetOpenPrice(), // todo: adjust price to current Bid/Ask if OrderType==OP_BUY/SELL
                    orderPrice,
                    20,
                    masterOrder.GetStopLoss(),
                    masterOrder.GetTakeProfit(),
                    _master.Acc + "@" + _master.Broker + "-> _acc:" + _acc,
                    masterOrder.GetTicket(),
                    masterOrder.GetExpiration(),
                    0
                    );
                if (ticket != 0)
                {
                    _ordersMap.Add(masterOrder.GetTicket(), ticket);
                    Info(String.Format("Master order {0} is mapped to {1}", masterOrder, ticket));
                }
            }
            catch (ErrTradeDisabled)
            {
                Info(String.Format("Trade disabled for accoutn: {0}", _acc));
            }
            catch (ErrInvalidPrice)
            {
                Info(String.Format("## ErrInvalidPrice - Price slippage ## - order.closePrice: {0} market.bid: {1} market.ask: {2} order.OrderType: {3}", masterOrder.GetClosePrice(), Marketinfo(masterOrder.GetSymbol(), MarketInfo.MODE_BID), Marketinfo(masterOrder.GetSymbol(), MarketInfo.MODE_ASK), orderType));
            }

            /*
             * catch(ErrInvalidPrice)
             * {
             * Info(String.Format("Price invalid: {0} ", masterOrder.GetOpenPrice()));
             *
             * }
             * catch(ErrInvalidTradeVolume)
             * {
             * Info(String.Format("Trade volume invalid: {0} ", masterOrder.GetLots()));
             *
             * }
             * catch(ErrTradeDisabled)
             * {
             * Info(String.Format("Trade disabled!!"));
             *
             * }
             * catch(ErrOffQuotes)
             * {
             * Info(String.Format("This trade is off quotes!!"));
             *
             * }
             **/
        }
        public static void NewTerminal(object account)
        {
            MTAccount MetaAccount = (MTAccount)account;

            try
            {
                NJ4XServer server = MainController.m_listNJ4XServer.Find(x => x.id == MetaAccount.server_id);

                //---- NJ4X LOG -----
                string strLog = "The OutControl Server (" + server.name + ") Is Executing New Terminal.";
                Socket_Manager.Instance.SendNj4xServerLog(server.id, DateTime.Now, strLog);

                string AproveState     = MetaAccount.status;
                string AccountID       = MetaAccount.id;
                string ServerHost      = server.server_ip;
                int    ServerPort      = server.server_port;
                string BrokerAddress   = MetaAccount.broker.server_ip;
                string AccountNumber   = MetaAccount.account_number;
                string AccountPassword = MetaAccount.account_password;
                bool   IsMT5           = (MetaAccount.platform == "MT5");

                int magic   = 199589;
                int slipage = 50;

                double   min_lot             = MetaAccount.plan.min_lot;
                double   max_lot             = MetaAccount.plan.max_lot;
                double   max_daily_profit    = MetaAccount.plan.max_daily_profit;
                double   max_daily_loss      = MetaAccount.plan.max_daily_loss;
                bool     daily_loss_fix_flag = MetaAccount.plan.daily_loss_fix;
                double   max_total_profit    = MetaAccount.plan.max_total_profit;
                double   max_total_loss      = MetaAccount.plan.max_total_loss;
                bool     total_loss_fix_flag = MetaAccount.plan.total_loss_fix;
                int      max_orders          = MetaAccount.plan.max_orders;
                string[] currency_pair       = MetaAccount.plan.currency_pair;

                bool FLAG_MAX_DAILY_PROFIT = false;
                bool FLAG_MAX_DAILY_LOSS   = false;
                bool FLAG_MAX_TOTAL_PROFIT = false;
                bool FLAG_MAX_TOTAL_LOSS   = false;

                var mt4 = new nj4x.Strategy()
                {
                    IsReconnect = false
                };
                Console.WriteLine(String.Format("*** Connecting, {0}***", AccountNumber));
                mt4.SetPositionListener(
                    delegate(IPositionInfo initialPositionInfo)
                {
                    Console.WriteLine("initialPositionInfo=" + initialPositionInfo);
                    CoordinationDoneEvent.Set();
                },
                    delegate(IPositionInfo info, IPositionChangeInfo changes)
                {
                    //---------------------- INFO LOG ----------------------
                    foreach (IOrderInfo o in changes.GetNewOrders())
                    {
                        Console.WriteLine("NEW: " + o);
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now, "NEW: " + o);
                        if (AproveState != "Aprove")
                        {
                            Console.WriteLine("SORRY, YOUR ACCOUNT IS NOT APROVED! " + mt4.AccountName());
                            Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                                   "SORRY, YOUR ACCOUNT IS NOT APROVED! " + mt4.AccountName());
                            mt4.OrderCloseAll();
                            return(Task.FromResult(0));
                        }
                        //----------------------------- Check Symbols ------------------------------
                        bool allowed = false;
                        foreach (string strSymbol in currency_pair)
                        {
                            if (strSymbol == o.GetSymbol())
                            {
                                allowed = true;
                            }
                        }

                        if (allowed == false)
                        {
                            Console.WriteLine("SORRY, THIS SYMBOL IS NOT ALLOWED! " + mt4.AccountName());
                            Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                                   "SORRY, THIS SYMBOL IS NOT ALLOWED! " + mt4.AccountName());

                            mt4.OrderClose(o.GetTicket(), o.GetLots(), o.GetOpenPrice(), slipage, 0);
                            return(Task.FromResult(0));
                        }

                        //--------------------------------- Check Lots ------------------------------
                        if (o.GetLots() < min_lot || o.GetLots() > max_lot)
                        {
                            Console.WriteLine("SORRY, YOU VOLUMN IS OUT OF RANGE! " + mt4.AccountName());
                            Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                                   "SORRY, YOU VOLUMN IS OUT OF RANGE! " + mt4.AccountName());

                            mt4.OrderClose(o.GetTicket(), o.GetLots(), o.GetOpenPrice(), slipage, 0);
                            return(Task.FromResult(0));
                        }

                        double DailyLots = 0;
                        for (int v = 0; v < mt4.OrdersTotal(); ++v)
                        {
                            IOrderInfo orderInfo = mt4.OrderGet(v, SelectionType.SELECT_BY_POS, SelectionPool.MODE_TRADES);
                            if (orderInfo != null)
                            {
                                DailyLots += orderInfo.GetLots();
                            }
                        }

                        if (o.GetLots() < min_lot || o.GetLots() > max_lot)
                        {
                            Console.WriteLine("SORRY, YOU LOTS IS OUT OF MAX DAILY LOTS RANGE! " + mt4.AccountName());
                            Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                                   "SORRY, YOU LOTS IS OUT OF MAX DAILY LOTS RANGE! " + mt4.AccountName());

                            mt4.OrderClose(o.GetTicket(), o.GetLots(), o.GetOpenPrice(), slipage, 0);
                            return(Task.FromResult(0));
                        }
                    }
                    foreach (IOrderInfo o in changes.GetModifiedOrders())
                    {
                        Console.WriteLine("MODIFIED: " + o);
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                               "MODIFIED: " + o);
                        if (AproveState != "Aprove")
                        {
                            Console.WriteLine("SORRY, YOUR ACCOUNT IS NOT APROVED! " + mt4.AccountName());
                            Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                                   "SORRY, YOUR ACCOUNT IS NOT APROVED! " + mt4.AccountName());
                            mt4.OrderCloseAll();
                            return(Task.FromResult(0));
                        }
                        //--------------------------------- Check Lots ------------------------------
                        if (o.GetLots() < min_lot || o.GetLots() > max_lot)
                        {
                            Console.WriteLine("SORRY, YOU VOLUMN IS OUT OF RANGE! " + mt4.AccountName());
                            Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                                   "SORRY, YOU VOLUMN IS OUT OF RANGE! " + mt4.AccountName());

                            mt4.OrderClose(o.GetTicket(), o.GetLots(), o.GetOpenPrice(), slipage, 0);
                            return(Task.FromResult(0));
                        }

                        double DailyLots = 0;
                        for (int v = 0; v < mt4.OrdersTotal(); ++v)
                        {
                            IOrderInfo orderInfo = mt4.OrderGet(v, SelectionType.SELECT_BY_POS, SelectionPool.MODE_TRADES);
                            if (orderInfo != null)
                            {
                                DailyLots += orderInfo.GetLots();
                            }
                        }

                        if (o.GetLots() < min_lot || o.GetLots() > max_lot)
                        {
                            Console.WriteLine("SORRY, YOU LOTS IS OUT OF MAX DAILY LOTS RANGE! " + mt4.AccountName());
                            Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                                   "SORRY, YOU LOTS IS OUT OF MAX DAILY LOTS RANGE! " + mt4.AccountName());

                            mt4.OrderClose(o.GetTicket(), o.GetLots(), o.GetOpenPrice(), slipage, 0);
                            return(Task.FromResult(0));
                        }
                    }
                    foreach (IOrderInfo o in changes.GetClosedOrders())
                    {
                        Console.WriteLine("CLOSED: " + o);
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                               "CLOSED: " + o);
                    }
                    foreach (IOrderInfo o in changes.GetDeletedOrders())
                    {
                        Console.WriteLine("DELETED: " + o);
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                               "DELETED: " + o);
                    }

                    if (AproveState != "Aprove")
                    {
                        Console.WriteLine("SORRY, YOUR ACCOUNT IS NOT APROVED! " + mt4.AccountName());
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                               "SORRY, YOUR ACCOUNT IS NOT APROVED! " + mt4.AccountName());
                        mt4.OrderCloseAll();
                        return(Task.FromResult(0));
                    }

                    //------------------------------- Calculate Profit Information ----------------------------
                    double TotalMaxBalance = 0;
                    double DailyMaxBalance = 0;
                    double TotalProfit     = 0;
                    double DailyProfit     = 0;

                    double CurBalance = mt4.AccountBalance();
                    TotalMaxBalance   = CurBalance;
                    DailyMaxBalance   = CurBalance;

                    int total = mt4.OrdersHistoryTotal();
                    for (int v = 0; v < total; ++v)
                    {
                        IOrderInfo orderInfo = mt4.OrderGet(v, SelectionType.SELECT_BY_POS, SelectionPool.MODE_HISTORY);
                        if (orderInfo != null)
                        {
                            if (orderInfo.GetTradeOperation() == TradeOperation.OP_BUY || orderInfo.GetTradeOperation() == TradeOperation.OP_SELL)
                            {
                                if (CurBalance > TotalMaxBalance || TotalMaxBalance == 0)
                                {
                                    TotalMaxBalance = CurBalance;
                                }
                                CurBalance   = CurBalance - orderInfo.GetProfit();
                                TotalProfit += orderInfo.GetProfit();

                                if (orderInfo.GetCloseTime() >= mt4.iTime(orderInfo.GetSymbol(), Timeframe.PERIOD_D1, 0))
                                {
                                    if (CurBalance > DailyMaxBalance || DailyMaxBalance == 0)
                                    {
                                        DailyMaxBalance = CurBalance;
                                    }
                                    DailyProfit += orderInfo.GetProfit();
                                }
                            }
                        }
                    }

                    Console.WriteLine("TotalMaxBalance: " + TotalMaxBalance.ToString());
                    Console.WriteLine("DailyMaxBalance: " + DailyMaxBalance.ToString());
                    Console.WriteLine("TotalProfit: " + TotalProfit.ToString());
                    Console.WriteLine("DailyProfit: " + DailyProfit.ToString());
                    if (DailyProfit >= max_daily_profit)
                    {
                        mt4.OrderCloseAll();
                        Console.WriteLine("CONGRATS, YOU REACHED THE MAX PROFIT TODAY! " + mt4.AccountName());
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                               "CONGRATS, YOU REACHED THE MAX PROFIT TODAY! " + mt4.AccountName());

                        FLAG_MAX_DAILY_PROFIT = true;
                        return(Task.FromResult(0));
                    }
                    else
                    {
                        FLAG_MAX_DAILY_PROFIT = false;
                    }



                    //CheckTotalProfit
                    if (TotalProfit >= max_total_profit)
                    {
                        mt4.OrderCloseAll();
                        Console.WriteLine("CONGRATS, YOU REACHED THE MAX TOTAL PROFIT! " + mt4.AccountName());
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                               "CONGRATS, YOU REACHED THE MAX TOTAL PROFIT! " + mt4.AccountName());

                        FLAG_MAX_TOTAL_PROFIT = true;
                        return(Task.FromResult(0));
                    }
                    else
                    {
                        FLAG_MAX_TOTAL_PROFIT = false;
                    }


                    //Check Fix Flag
                    CurBalance = mt4.AccountBalance();
                    if (daily_loss_fix_flag == false)
                    {
                        DailyProfit = CurBalance - DailyMaxBalance;
                    }
                    if (total_loss_fix_flag == false)
                    {
                        TotalProfit = CurBalance - TotalMaxBalance;
                    }


                    if (DailyProfit <= max_daily_loss)
                    {
                        mt4.OrderCloseAll();
                        Console.WriteLine("SORRY, YOU REACHED THE MAX LOSS TODAY! " + mt4.AccountName());
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                               "SORRY, YOU REACHED THE MAX LOSS TODAY! " + mt4.AccountName());

                        FLAG_MAX_DAILY_LOSS = true;
                        return(Task.FromResult(0));
                    }
                    else
                    {
                        FLAG_MAX_DAILY_LOSS = false;
                    }


                    if (TotalProfit <= max_total_loss)
                    {
                        mt4.OrderCloseAll();
                        Console.WriteLine("SORRY, YOU REACHED THE MAX TOTAL LOSS! " + mt4.AccountName());
                        Socket_Manager.Instance.SendAccountLog(AccountID, DateTime.Now,
                                                               "SORRY, YOU REACHED THE MAX TOTAL LOSS! " + mt4.AccountName());

                        FLAG_MAX_TOTAL_LOSS = true;
                        return(Task.FromResult(0));
                    }
                    else
                    {
                        FLAG_MAX_TOTAL_LOSS = false;
                    }


                    return(Task.FromResult(0));
                }
                    );


                mt4.Connect(ServerHost, ServerPort,
                            new Broker(IsMT5 ? $"5*{BrokerAddress}" : BrokerAddress),
                            AccountNumber,
                            AccountPassword);

                _terminals.Add(mt4);

                //---- NJ4X LOG -----
                Console.WriteLine(String.Format("*** Connected, {0}***", mt4.GetVersion()));
                strLog = "The OutControl Server (" + server.name + ") Successed To Add New Terminal.";
                Socket_Manager.Instance.SendNj4xServerLog(server.id, DateTime.Now, strLog);

                using (mt4)
                {
                    int total = mt4.OrdersHistoryTotal();
                    for (int v = 0; v < Math.Min(10, total); ++v)
                    {
                        IOrderInfo orderInfo = mt4.OrderGet(v, SelectionType.SELECT_BY_POS, SelectionPool.MODE_HISTORY);
                        if (orderInfo != null)
                        {
                            Console.WriteLine(
                                String.Format("Historical order #{0}, P/L={1}, type={2}, symbol={3}, comments={4}",
                                              orderInfo.GetTicket(),
                                              orderInfo.GetProfit(),
                                              orderInfo.GetTradeOperation(),
                                              orderInfo.GetSymbol(),
                                              orderInfo.GetComment()
                                              ));
                        }
                    }
                    //
                    total = mt4.OrdersTotal();
                    for (int v = 0; v < Math.Min(10, total); ++v)
                    {
                        IOrderInfo orderInfo = mt4.OrderGet(v, SelectionType.SELECT_BY_POS, SelectionPool.MODE_TRADES);
                        if (orderInfo != null)
                        {
                            Console.WriteLine(
                                String.Format("LIVE order #{0}, P/L={1}, type={2}, symbol={3}, comments={4}",
                                              orderInfo.GetTicket(),
                                              orderInfo.GetProfit(),
                                              orderInfo.GetTradeOperation(),
                                              orderInfo.GetSymbol(),
                                              orderInfo.GetComment()
                                              ));
                        }
                    }
                    while (true)
                    {
                        Thread.Sleep(10);
                    }
                }
            }
            catch
            {
                Console.WriteLine("*** Server is not connected or Your Account is not assigned Server! *** " + MetaAccount.account_number);
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            // Create strategy
            var mt4 = new Strategy();

            // Connect to the Terminal Server
            mt4.Connect(
                ConfigurationManager.AppSettings["terminal_host"],
                int.Parse(ConfigurationManager.AppSettings["terminal_port"]),
                new Broker(ConfigurationManager.AppSettings["broker"]),
                ConfigurationManager.AppSettings["account"],
                ConfigurationManager.AppSettings["password"]
                );
            // Use API methods …

            Console.WriteLine($"Account {mt4.AccountNumber()}");
            Console.WriteLine($"Equity {mt4.AccountEquity()}");
            Thread.Sleep(3000);
            Console.Clear();
            var Total     = mt4.OrdersTotal();
            var Total_tmp = Total;
            //IOrderInfo Order_info = mt4.OrderGet(15328321, SelectionType.SELECT_BY_TICKET, SelectionPool.MODE_TRADES);
            IOrderInfo Order_info = mt4.OrderGet(6, SelectionType.SELECT_BY_POS, SelectionPool.MODE_TRADES);
            var        open_Price = Order_info.GetOpenPrice();

            Console.WriteLine($"Ticket ID :{Order_info.GetTicket()} . Open Price :{open_Price}");
            //while (true)
            //{
            //    //Console.WriteLine($"{Total}");
            //    if()
            //}

            //while (true)
            //{
            //    double bid = mt4.Marketinfo("AUDCAD-STD", MarketInfo.MODE_BID);
            //    Console.WriteLine($"AUDCAD-STD bid={bid}");
            //    Thread.Sleep(50);
            //    Console.Clear();
            //}
            //double bid = mt4.Marketinfo("AUDCAD-STD", MarketInfo.MODE_BID);
            //try
            //{
            //    var ticket = mt4.OrderSend("AUDCAD-STD",
            //        TradeOperation.OP_SELL,
            //        0.01, bid, 2, 0, 0,
            //        "Order_Sell_Demo", 0,
            //        MT4.NoExpiration
            //        );
            //    Console.WriteLine($"New Sell_Order ID: {ticket}");
            //}
            //catch (MT4Exception e)
            //{
            //    Console.WriteLine($"Order Placing Error #{e.ErrorCode}:{e.Message}");
            //}
            //try
            //{
            //    var ticket = mt4.OrderSend("AUDCAD-STD",
            //        TradeOperation.OP_BUY,
            //        0.01, bid, 2, 0, 0,
            //        "Order_Sell_Demo", 0,
            //        MT4.NoExpiration
            //        );
            //    Console.WriteLine($"New Buy_Order ID: {ticket}");
            //}
            //catch (MT4Exception e)
            //{
            //    Console.WriteLine($"Order Placing Error #{e.ErrorCode}:{e.Message}");
            //}


            //
            Console.ReadLine();
        }