Пример #1
0
        public PositionImpl(string positionEncoded, MT4 utils)
        {
            var bp = new DDParser(positionEncoded, MT4.ArgStartC, MT4.ArgEndC);
            var p  = new SDParser(bp.pop(), '|');

            _tCount = int.Parse(p.pop(), CultureInfo.InvariantCulture);
            _hCount = int.Parse(p.pop(), CultureInfo.InvariantCulture);
            _str    = AsString();
            //
            var sz = int.Parse(bp.pop(), CultureInfo.InvariantCulture);

            LiveOrders = new Dictionary <long, IOrderInfo>((int)(sz * 1.2));
            for (var i = 0; i < sz; i++)
            {
                var oi = new OrderImpl(bp.pop(), utils);
                LiveOrders.Add(oi.TicketNumber, oi);
            }
            sz = int.Parse(bp.pop(), CultureInfo.InvariantCulture);
            HistoricalOrders = new Dictionary <long, IOrderInfo>((int)(sz * 1.2));
            for (var i = 0; i < sz; i++)
            {
                var oi = new OrderImpl(bp.pop(), utils);
                HistoricalOrders.Add(oi.TicketNumber, oi);
            }
        }
Пример #2
0
        internal static List <Rate> Decode(string ratesEncoded, MT4 utils, out double bid, out double ask)
        {
            var bp    = new DDParser(ratesEncoded, MT4.ArgStartC, MT4.ArgEndC);
            var sz    = int.Parse(bp.pop(), CultureInfo.InvariantCulture);
            var rates = new List <Rate>(sz);

            for (var i = 0; i < sz; i++)
            {
                var oi = new Rate(bp.pop(), utils);
                rates.Add(oi);
            }
            var tail = bp.tail();

            if (string.IsNullOrEmpty(tail))
            {
                bid = ask = 0;
            }
            else
            {
                var p = new SDParser(tail, '|');
                bid = p.popDouble();
                ask = p.popDouble();
            }

            return(rates);
        }