Esempio n. 1
0
        public static string FormatDeal(this CIMTDeal deal, decimal balance, string serverName)
        {
            if (deal == null)
            {
                throw new ArgumentNullException(nameof(deal));
            }

            return($"Deal #{deal.Deal()}, Server '{serverName}', User '{deal.Login()}', Balance '{balance}', {FormatDealAction(deal)} {deal.Symbol()} {deal.Volume() / 10000.00} " +
                   $"lots at {DateTimeOffset.FromUnixTimeMilliseconds(deal.TimeMsc()).ToString("dd.MM.yyyy HH:mm:ss.fff")}");
        }
Esempio n. 2
0
        public void DealAdded(object control, CIMTDeal cimtDeal)
        {
            Deal deal = new Deal(cimtDeal, _mT5ApiRequests.Name);

            _deals.Add(deal);

            decimal balance = _mT5ApiRequests.GetUserBalance(cimtDeal.Login());

            _logger.Information(cimtDeal.FormatDeal(balance, _mT5ApiRequests.Name));

            RunChecks(deal, _deals.Where(x => x.Action == deal.Action && x.Timestamp <= deal.Timestamp).ToList());
        }
Esempio n. 3
0
        //get signal when new Deal is added to server
        public override void OnDealAdd(CIMTDeal ServerDeal)
        {
            var actDeal = new clsDealInfo();

            actDeal.Profit     = ServerDeal.Profit();
            actDeal.Volume     = ServerDeal.Volume();
            actDeal.Symbol     = ServerDeal.Symbol();
            actDeal.UserLogin  = ServerDeal.Login();
            actDeal.PositionID = ServerDeal.PositionID();
            actDeal.uOpenTime  = ServerDeal.Time();
            this.ExternalReport(actDeal);
        }
Esempio n. 4
0
        public static string FormatDealAction(this CIMTDeal deal)
        {
            switch (deal.Action())
            {
            case 0:
                return("Buy");

            case 1:
                return("Sell");

            default:
                return("Unknown");
            }
        }
Esempio n. 5
0
        private void DealEvents_DealAddEventHandler(object control, CIMTDeal deal)
        {
            var info = new RawTradeEvent()
            {
                Id          = deal.Deal(),
                Action      = deal.Action(),
                Symbol      = deal.Symbol(),
                Volume      = deal.Volume(),
                TimeMsc     = deal.TimeMsc(),
                Login       = deal.Login(),
                Description = deal.Print()
            };

            _rawTradeEvents.Enqueue(info);

            Console.WriteLine($"Deal event received ({_connection.Name}): {deal.Print()}");
            Console.WriteLine();
        }
Esempio n. 6
0
        public Deal(CIMTDeal cimtDeal, string serverName)
        {
            if (cimtDeal == null)
            {
                throw new ArgumentNullException(nameof(cimtDeal));
            }

            if (string.IsNullOrWhiteSpace(serverName))
            {
                throw new ArgumentException($"{nameof(serverName)} cannot be null or whitespace.");
            }

            DealId     = cimtDeal.Deal();
            UserId     = cimtDeal.Login();
            Volume     = cimtDeal.Volume();
            Action     = cimtDeal.Action() <= 1 ? (DealAction)cimtDeal.Action() : DealAction.Unknown;
            Symbol     = cimtDeal.Symbol();
            Timestamp  = cimtDeal.TimeMsc();
            ServerName = serverName;
        }
Esempio n. 7
0
 public override void OnDealAdd(CIMTDeal deal)
 {
     DealAddEventHandler?.Invoke(this, deal);
 }
Esempio n. 8
0
        //+------------------------------------------------------------------+
        //|                                                                  |
        //+------------------------------------------------------------------+
        private void OnBnClickedButtonGetdeals(object sender = null, EventArgs e = null)
        {
            CIMTDealArray deal_array = null;
            CIMTDeal      deal       = null;
            UInt64        login      = 0;
            DateTime      from       = m_From.Value;
            DateTime      to         = m_To.Value;
            string        stype      = string.Empty;

            //--- user login
            UInt64.TryParse(m_User.Text, out login);
            //--- get deal array
            if (!m_manager.GetUserDeal(out deal_array, login, from, to))
            {
                //--- clear list
                m_List.Items.Clear();
                //---
                MessageBox.Show("Get user deal fail", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //--- clear list
            m_List.Items.Clear();
            //--- for all deal in array
            for (uint i = 0; i < deal_array.Total(); i++)
            {
                //--- get deal
                deal = deal_array.Next(i);
                //--- check error
                if (deal == null)
                {
                    break;
                }
                //--- check action
                switch ((CIMTDeal.EnDealAction)deal.Action())
                {
                case CIMTDeal.EnDealAction.DEAL_BALANCE:
                    stype = "Balance";
                    break;

                case CIMTDeal.EnDealAction.DEAL_CREDIT:
                    stype = "Credit";
                    break;

                case CIMTDeal.EnDealAction.DEAL_CHARGE:
                    stype = "Charge";
                    break;

                case CIMTDeal.EnDealAction.DEAL_CORRECTION:
                    stype = "Correction";
                    break;

                case CIMTDeal.EnDealAction.DEAL_BONUS:
                    stype = "Bonus";
                    break;

                case CIMTDeal.EnDealAction.DEAL_COMMISSION:
                    stype = "Commission";
                    break;

                default:
                    //--- skip other actions
                    continue;
                }
                //---
                string stime = SMTTime.ToDateTime(deal.Time()).ToString("yyyy.MM.dd HH:mm:ss.fff");
                //--- insert item
                string[] row = { deal.Deal().ToString(), stype, deal.Profit().ToString() };
                var      it  = m_List.Items.Insert(0, stime);
                it.SubItems.AddRange(row);
                m_List.EnsureVisible(0);
                m_List.Update();
            }
        }
Esempio n. 9
0
 public override void OnDealAdd(CIMTDeal deal)
 {
     Console.WriteLine(deal.Order());
 }