Пример #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")}");
        }
Пример #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());
        }
Пример #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);
        }
Пример #4
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();
        }
Пример #5
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;
        }