Пример #1
0
 public void insertPrice(UnpackMarketPrice price)
 {
     if (price.BackOrLay == 'L' || price.BackOrLay == 'l')
     {
         LayPrices.Add(price);
     }
     else
     {
         BackPrices.Add(price);
     }
 }
Пример #2
0
 private int priceCompareB(UnpackMarketPrice price1, UnpackMarketPrice price2)
 {
     if (price1.Price == price2.Price)
     {
         return(0);
     }
     if (price1.Price > price2.Price)
     {
         return(-1);
     }
     else
     {
         return(1);
     }
 }
Пример #3
0
        public MarketPrices(String InMarketPrices)
        {
            ToParse = InMarketPrices;

            MarketId          = Convert.ToInt32(GetNextField());
            CurencyCode       = GetNextField();
            MarketStatus      = GetNextField();
            InPlayDelay       = Convert.ToInt32(GetNextField());
            NoOfWinners       = Convert.ToInt32(GetNextField());
            MarketInformation = GetNextField();
            DiscountAllowed   = Convert.ToBoolean(GetNextField());
            MarketBaseRate    = GetNextField();
            RefreshTime       = Convert.ToInt64(GetNextField());

            String strRemovedRunners = GetNextField();

            if (strRemovedRunners != "")
            {
                ParseRemovedRunners(strRemovedRunners);
            }

            if (ToParse[begin + 1] == 'N' || ToParse[begin + 1] == 'n')
            {
                BSPMarket = false;
            }
            else
            {
                BSPMarket = true;
            }
            begin += 2;

            List <String> TempRunners = ToParse.Substring(begin).Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            if (Char.IsDigit(TempRunners[0][0]) == false)
            {
                TempRunners.RemoveAt(0);
            }

            foreach (String runner in TempRunners)
            {
                UnpackMarketRunnerInformation tempRunner = new UnpackMarketRunnerInformation();
                ToParse = runner;
                begin   = end = 0;

                tempRunner.SelectionId        = Convert.ToInt32(GetNextField());
                tempRunner.OrderIndex         = Convert.ToInt32(GetNextField());
                tempRunner.TotalAmountMatched = Convert.ToDouble(GetNextField());
                try
                {
                    tempRunner.LastPriceMatched = Convert.ToDouble(GetNextField());
                }
                catch
                {
                    tempRunner.LastPriceMatched = 0;
                }

                String RetValTemp;
                if ((RetValTemp = GetNextField()) != "")
                {
                    tempRunner.Handicap = Convert.ToDouble(RetValTemp);
                }
                if ((RetValTemp = GetNextField()) != "")
                {
                    tempRunner.ReductionFactor = Convert.ToDouble(RetValTemp);
                }
                if ((RetValTemp = GetNextField()) != "")
                {
                    tempRunner.Vacant = Convert.ToBoolean(RetValTemp);
                }
                if ((RetValTemp = GetNextField()) != "")
                {
                    tempRunner.FairSpPrice = Convert.ToDouble(RetValTemp);
                }
                if ((RetValTemp = GetNextField()) != "")
                {
                    tempRunner.NearSpPrice = Convert.ToDouble(RetValTemp);
                }
                if ((RetValTemp = GetNextField()) != "")
                {
                    tempRunner.ActualSpPrice = Convert.ToDouble(RetValTemp);
                }

                List <String> TempPrices = ToParse.Substring(begin + 1).Split(new char[] { '|', '~' }, StringSplitOptions.RemoveEmptyEntries).ToList();

                bool start0 = true;

                if (TempPrices.Count > 0)
                {
                    try
                    {
                        //CRO
                        //Convert.ToDouble(TempPrices[0].Replace('.',','));
                        //UK
                        Convert.ToDouble(TempPrices[0]);
                    }
                    catch
                    {
                        start0 = false;
                    }
                }

                for (int i = start0?0:1; i < TempPrices.Count;)
                {
                    //CRO

                    /*UnpackMarketPrice temp = new UnpackMarketPrice();
                     * temp.Price = Convert.ToDouble(TempPrices[i].Replace('.', ','));
                     * temp.AvaiableAmmount = Convert.ToDouble(TempPrices[i + 1].Replace('.', ','));
                     * if (TempPrices[i + 2][0] == 'L' || TempPrices[i + 2][0] == 'l')
                     *  temp.BackOrLay = 'B';
                     * else
                     *  temp.BackOrLay = 'L';
                     * temp.Depth = Convert.ToInt32(TempPrices[i + 3]);
                     * i += 4;
                     * tempRunner.insertPrice(temp);*/

                    //UK
                    UnpackMarketPrice temp = new UnpackMarketPrice();
                    temp.Price           = Convert.ToDouble(TempPrices[i]);
                    temp.AvaiableAmmount = Convert.ToDouble(TempPrices[i + 1]);
                    if (TempPrices[i + 2][0] == 'L' || TempPrices[i + 2][0] == 'l')
                    {
                        temp.BackOrLay = 'B';
                    }
                    else
                    {
                        temp.BackOrLay = 'L';
                    }
                    temp.Depth = Convert.ToInt32(TempPrices[i + 3]);
                    i         += 4;
                    tempRunner.insertPrice(temp);
                }
                tempRunner.sortPrice();
                RunnerInformation.Add(tempRunner);
            }
        }