Exemple #1
0
        private COrderStateRecord ParseRecord(string stOneRecord)
        {
            string pat = @"\s*([\w\s]*)\s@\s([0-9\.]*)\(([0-9\.]*)\)";



            Regex reg = new Regex(pat);
            Match m   = reg.Match(stOneRecord);

            if (m.Groups.Count != 4)
            {
                throw new ApplicationException("COrderStatusTracker.ParseRecord");
            }

            string  status = m.Groups[1].ToString();
            decimal price  = Convert.ToDecimal(m.Groups[2].ToString().Replace('.', ','));
            decimal amount = Convert.ToDecimal(m.Groups[3].ToString().Replace('.', ','));



            COrderStateRecord ordStatusRec = new COrderStateRecord();

            ordStatusRec.Price       = price;
            ordStatusRec.Amount      = amount;
            ordStatusRec.OrderStatus = CBfxUtils.GetOrderStatus(status);
            ordStatusRec.Dir         = amount > 0 ? EnmDealDir.Buy : EnmDealDir.Sell;
            return(ordStatusRec);
        }
Exemple #2
0
        public CLstHistOrdStatus GetLstHistOrdStatus(string newStatus)
        {
            CLstHistOrdStatus lstHistOrdStatus = new CLstHistOrdStatus();

            string[] stArr = newStatus.Split(':');

            if (stArr == null || stArr.Count() == 0)
            {
                throw new ApplicationException("COrderStatusTracker.Update");
            }

            //first do process "was" - history deals (if exists)
            if (stArr.Count() == 2)
            {
                string hist = stArr[1].Remove(0, 4);                //remove " was "

                string[] histLst = hist.Split(',');

                foreach (var el in histLst)
                {
                    COrderStateRecord order = ParseRecord(el);
                    lstHistOrdStatus.Add(order);
                }
            }

            //then process "last" - current deal - put it to the end of history list
            lstHistOrdStatus.Add(ParseRecord(stArr[0]));

            return(lstHistOrdStatus);
        }