コード例 #1
0
        public static List <MarketStatus> GetAllMarketStatus()
        {
            string connStr    = ConfigurationManager.AppSettings["connStr"];
            string sqlCommand = "Select * from MarketStatus order by MarketStatusId ASC";
            List <MarketStatus> marketStatuses = new List <MarketStatus>();
            SqlDataReader       sr             = null;

            using (SqlConnection sqlConnect = new SqlConnection(connStr))
            {
                using (SqlCommand sCommand = new SqlCommand(sqlCommand, sqlConnect))
                {
                    sqlConnect.Open();
                    sCommand.ExecuteNonQuery();
                    sr = sCommand.ExecuteReader();

                    while (sr.Read())
                    {
                        MarketStatus marketStatus = new MarketStatus();
                        marketStatus.MarketStatusId   = int.Parse(sr["MarketStatusId"].ToString());
                        marketStatus.MarketStatusText = sr["MarketStatusText"].ToString();
                        marketStatus.Volume           = int.Parse(sr["Volume"].ToString());
                        marketStatus.Price            = double.Parse(sr["Price"].ToString());
                        marketStatuses.Add(marketStatus);
                    }
                }
            }
            return(marketStatuses);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MarketWithOdds"/> class
        /// </summary>
        /// <param name="id">a <see cref="int"/> value specifying the market type</param>
        /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}"/> containing market specifiers.</param>
        /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}"/> containing additional market info.</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s) </param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapped ids of markets and outcomes</param>
        /// <param name="status">a <see cref="MarketStatus"/> enum member specifying the status of the market associated with the current <see cref="IMarketWithOdds"/> instance</param>
        /// <param name="cashoutStatus">A <see cref="CashoutStatus"/> to be set</param>
        /// <param name="isFavorite">Gets a value indicating whether the market associated with the current <see cref="IMarketWithOdds"/> instance is the most
        ///     balanced market.</param>
        /// <param name="outcomeOdds">a <see cref="IEnumerable{IOutcomeOdds}"/> where each <see cref="IOutcomeOdds"/> instance specifies the odds
        ///     for one outcome associated with the current <see cref="IMarketWithOdds"/> instance</param>
        /// <param name="marketMetadata">A <see cref="IMarketMetadata"/> to be set</param>
        /// <param name="marketDefinition">The associated market definition</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        internal MarketWithOdds(int id,
                                IReadOnlyDictionary <string, string> specifiers,
                                IReadOnlyDictionary <string, string> additionalInfo,
                                INameProvider nameProvider,
                                IMarketMappingProvider mappingProvider,
                                MarketStatus status,
                                CashoutStatus?cashoutStatus,
                                bool isFavorite,
                                IEnumerable <IOutcomeOdds> outcomeOdds,
                                IMarketMetadata marketMetadata,
                                IMarketDefinition marketDefinition,
                                IEnumerable <CultureInfo> cultures)
            : base(id, specifiers, additionalInfo, nameProvider, mappingProvider, marketDefinition, cultures)
        {
            Status        = status;
            CashoutStatus = cashoutStatus;

            if (outcomeOdds != null)
            {
                OutcomeOdds = outcomeOdds as ReadOnlyCollection <IOutcomeOdds> ?? new ReadOnlyCollection <IOutcomeOdds>(outcomeOdds.ToList());
            }
            IsFavorite = isFavorite;

            MarketMetadata = marketMetadata;
        }
コード例 #3
0
        public static O2GMarketStatus GetMarketStatus(MarketStatus value)
        {
            switch (value)
            {
            case MarketStatus.Closed:
                return(O2GMarketStatus.MarketStatusClosed);

            case MarketStatus.Open:
                return(O2GMarketStatus.MarketStatusOpen);
            }

            throw new ArgumentOutOfRangeException("value");
        }
コード例 #4
0
        public static MarketStatus GetOneMarketStatus(int marketStatusId)
        {
            List <MarketStatus> marketStatuses     = GetMarketStatus();
            MarketStatus        marketStatusResult = null;

            foreach (MarketStatus marketStatus in marketStatuses)
            {
                if (marketStatus.MarketStatusId == marketStatusId)
                {
                    marketStatusResult = marketStatus;
                    break;
                }
            }
            return(marketStatusResult);
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MarketWithProbabilities"/> class
        /// </summary>
        /// <param name="id">a <see cref="int"/> value specifying the market type</param>
        /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}"/> containing market specifiers.</param>
        /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}"/> containing additional market info.</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s) </param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapped ids of markets and outcomes</param>
        /// <param name="status">a <see cref="MarketStatus"/> enum member specifying the status of the market associated with the current <see cref="IMarketWithProbabilities"/> instance</param>
        /// <param name="outcomeProbabilities">a <see cref="IEnumerable{IOutcomeProbabilities}"/> where each <see cref="IOutcomeProbabilities"/> instance specifies the odds
        /// for one outcome associated with the current <see cref="IMarketWithProbabilities"/> instance</param>
        /// <param name="marketDefinition">The associated market definition</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        internal MarketWithProbabilities(int id,
                                         IReadOnlyDictionary <string, string> specifiers,
                                         IReadOnlyDictionary <string, string> additionalInfo,
                                         INameProvider nameProvider,
                                         IMarketMappingProvider mappingProvider,
                                         MarketStatus status,
                                         IEnumerable <IOutcomeProbabilities> outcomeProbabilities,
                                         IMarketDefinition marketDefinition,
                                         IEnumerable <CultureInfo> cultures)
            : base(id, specifiers, additionalInfo, nameProvider, mappingProvider, marketDefinition, cultures)
        {
            Status = status;

            if (outcomeProbabilities != null)
            {
                OutcomeProbabilities = outcomeProbabilities as ReadOnlyCollection <IOutcomeProbabilities> ?? new ReadOnlyCollection <IOutcomeProbabilities>(outcomeProbabilities.ToList());
            }
        }
コード例 #6
0
ファイル: Betfair.API.cs プロジェクト: gkvetenadze/lignite
 /// <summary>
 /// The API GetCompleteMarketPricesCompressed service allows you to
 /// retrieve all back and lay stakes for each price on the exchange
 /// for a given Market ID in a compressed format. The information
 /// returned is similar to the GetDetailAvailableMarketDepth,
 /// except it returns the data for an entire market, rather than
 /// just one selection.
 /// </summary>
 /// <param name="exchangeId">The exchange id.</param>
 /// <param name="marketId">The market id.</param>
 /// <param name="status">The status.</param>
 /// <returns></returns>
 public Market GetCompleteMarketPricesCompressedObject(int exchangeId, int marketId, MarketStatus status)
 {
     string result = GetCompleteMarketPricesCompressed(exchangeId, marketId, status);
     if (result != null)
     {
         return new GetCompleteMarketPricesCompressed().ConvertToObject(result, exchangeId, status, _currency,
                                                                        DateTime.Now);
     }
     return null;
 }
コード例 #7
0
ファイル: Betfair.API.cs プロジェクト: gkvetenadze/lignite
        /// <summary>
        /// The API GetCompleteMarketPricesCompressed service allows you to
        /// retrieve all back and lay stakes for each price on the exchange
        /// for a given Market ID in a compressed format. The information
        /// returned is similar to the GetDetailAvailableMarketDepth,
        /// except it returns the data for an entire market, rather than
        /// just one selection.
        /// </summary>
        /// <param name="exchangeId">The exchange id.</param>
        /// <param name="marketId">The market id.</param>
        /// <param name="status">The status.</param>
        /// <returns></returns>
        public string GetCompleteMarketPricesCompressed(int exchangeId, int marketId, MarketStatus status)
        {
            const string serviceName = "GetCompleteMarketPricesCompressed";
            Console.WriteLine("{0}$ API_SERVICE {1}", DateTime.Now, serviceName);

            var request = new GetCompleteMarketPricesCompressedReq
                              {
                                  currencyCode = _currency,
                                  marketId = marketId,
                                  header = ((BetfairExchangeAPI.APIRequestHeader) GetHeader(false))
                              };

            GetCompleteMarketPricesCompressedResp response =
                _bfExchangeService[exchangeId].getCompleteMarketPricesCompressed(request);
            ValidateAPIResponse(serviceName, Convert.ToString(response.header.errorCode),
                                Convert.ToString(response.errorCode), response.header.sessionToken);

            return response.completeMarketPrices;
        }
コード例 #8
0
ファイル: Betfair.API.cs プロジェクト: sjdweb/lignite
        /// <summary>
        /// The API GetCompleteMarketPricesCompressed service allows you to
        /// retrieve all back and lay stakes for each price on the exchange
        /// for a given Market ID in a compressed format. The information
        /// returned is similar to the GetDetailAvailableMarketDepth,
        /// except it returns the data for an entire market, rather than
        /// just one selection.
        /// </summary>
        /// <param name="exchangeId">The exchange id.</param>
        /// <param name="marketId">The market id.</param>
        /// <param name="status">The status.</param>
        /// <returns></returns>
        public string GetCompleteMarketPricesCompressed(int exchangeId, int marketId, MarketStatus status)
        {
            const string serviceName = "GetCompleteMarketPricesCompressed";

            Console.WriteLine("{0}$ API_SERVICE {1}", DateTime.Now, serviceName);

            var request = new GetCompleteMarketPricesCompressedReq
            {
                currencyCode = _currency,
                marketId     = marketId,
                header       = ((BetfairExchangeAPI.APIRequestHeader)GetHeader(false))
            };

            GetCompleteMarketPricesCompressedResp response =
                _bfExchangeService[exchangeId].getCompleteMarketPricesCompressed(request);

            ValidateAPIResponse(serviceName, Convert.ToString(response.header.errorCode),
                                Convert.ToString(response.errorCode), response.header.sessionToken);

            return(response.completeMarketPrices);
        }
コード例 #9
0
ファイル: Betfair.API.cs プロジェクト: sjdweb/lignite
        /// <summary>
        /// The API GetCompleteMarketPricesCompressed service allows you to
        /// retrieve all back and lay stakes for each price on the exchange
        /// for a given Market ID in a compressed format. The information
        /// returned is similar to the GetDetailAvailableMarketDepth,
        /// except it returns the data for an entire market, rather than
        /// just one selection.
        /// </summary>
        /// <param name="exchangeId">The exchange id.</param>
        /// <param name="marketId">The market id.</param>
        /// <param name="status">The status.</param>
        /// <returns></returns>
        public Market GetCompleteMarketPricesCompressedObject(int exchangeId, int marketId, MarketStatus status)
        {
            string result = GetCompleteMarketPricesCompressed(exchangeId, marketId, status);

            if (result != null)
            {
                return(new GetCompleteMarketPricesCompressed().ConvertToObject(result, exchangeId, status, _currency,
                                                                               DateTime.Now));
            }
            return(null);
        }
コード例 #10
0
        /// <summary>
        /// Extract the results of a Betfair GetMarketPricesCompressedresp.marketPrices string to a response object
        /// No prices get updated during suspend and closed market status state.
        /// The following values get updated during a normal update:
        /// </summary>
        /// <param name="completeMarketPrices">The complete market prices.</param>
        /// <param name="exchangeId">The exchange id.</param>
        /// <param name="status">The status.</param>
        /// <param name="currency">The currency.</param>
        /// <param name="pricesUpdateTime">The time to set the Market.lastRunnerPricesLoad value to</param>
        /// <returns></returns>
        public Market ConvertToObject(string completeMarketPrices, int exchangeId, MarketStatus status, string currency,
                                      DateTime pricesUpdateTime)
        {
            if (completeMarketPrices != null && status == MarketStatus.ACTIVE)
            {
                //Step 1 - Create the response object
                var market = new Market {status = status};

                //Step 2 - Clean up the break characters
                completeMarketPrices = HelperMethods.ProtectBreakChars(completeMarketPrices);

                //Step 3 - Split
                string[] marketData = completeMarketPrices.Split(":".ToCharArray());

                //Step 4 - Clean before split
                marketData[0] = HelperMethods.RemoveTrailingTilde(marketData[0]);

                //Step 5 - Get the market data segment
                string[] marketDataArray = marketData[0].Split("~".ToCharArray());

                //Step 6 - Populate the response object
                market.marketId = Convert.ToInt32(marketDataArray[0]);
                market.betDelay = Convert.ToInt32(marketDataArray[1]);
                market.currency = currency;
                market.lastRunnerPricesLoad = pricesUpdateTime;

                market.exchangeId = exchangeId;

                string removedRunners = "";
                if (marketDataArray.Length > 2)
                {
                    removedRunners = marketDataArray[2];
                }

                //Step 7 - Process the removed runner list
                if (removedRunners.Length > 0)
                {
                    if (removedRunners.Substring((removedRunners.Length - 1), 1) == ";")
                        removedRunners = removedRunners.Remove((removedRunners.Length - 1), 1);

                    string[] removedRunnersArray = removedRunners.Split(";".ToCharArray());
                    market.removedRunners = new RemovedRunner[removedRunnersArray.Length];

                    for (int x = 0; x < market.removedRunners.Length; x++)
                    {
                        string[] removedRunnerItems = removedRunnersArray[x].Split(",".ToCharArray());
                        var r = new RemovedRunner
                                    {
                                        name = removedRunnerItems[0],
                                        removedDate = removedRunnerItems[1],
                                        adjustmentFactor = Convert.ToDouble(removedRunnerItems[2])
                                    };
                        market.removedRunners[x] = r;
                    }
                }

                //Step 8 - Loop through the runners
                market.runners = new SelectionList();

                for (int x = 1; x < marketData.Length; x++)
                {
                    //Step 9 - Get the individual runners data from the string
                    string[] runnerDataArray = marketData[x].Split("|".ToCharArray());

                    //Step 10 - Create an data array for the 3 data objects
                    string[] runnerInfoArray =
                        HelperMethods.RemoveTrailingTilde(runnerDataArray[0]).Split("~".ToCharArray());
                    string[] runnerPricesArray =
                        HelperMethods.RemoveTrailingTilde(runnerDataArray[1]).Split("~".ToCharArray());

                    //Step 11 - Create the runner response object
                    var runner = new Selection
                                     {
                                         selectionId = Convert.ToInt32(runnerInfoArray[0])
                                     };

                    //Step 12 - Populate the data

                    if (runnerInfoArray[1].Length > 0)
                        runner.orderIndex = Convert.ToInt32(runnerInfoArray[1]);

                    if (runnerInfoArray[2].Length > 0)
                        runner.totalAmountMatched = Convert.ToDouble(runnerInfoArray[2]);

                    if (runnerInfoArray[3].Length > 0)
                        runner.lastPriceMatched = Convert.ToDouble(runnerInfoArray[3]);

                    if (runnerInfoArray[4].Length > 0)
                        runner.handiCap = Convert.ToDouble(runnerInfoArray[4]);

                    if (runnerInfoArray[5].Length > 0)
                        runner.reductionFactor = Convert.ToDouble(runnerInfoArray[5]);

                    if (runnerInfoArray[6].Length > 0)
                        runner.vacant = Convert.ToBoolean(runnerInfoArray[6]);

                    if (runnerInfoArray[7].Length > 0)
                        runner.asianLineId = Convert.ToInt32(runnerInfoArray[7]);

                    if (runnerInfoArray[8].Length > 0)
                        runner.farSPPrice = Convert.ToDouble(runnerInfoArray[8]);

                    if (runnerInfoArray[9].Length > 0)
                        runner.nearSPPrice = Convert.ToDouble(runnerInfoArray[9]);

                    if (runnerInfoArray[10].Length > 0)
                        runner.actualSPPrice = Convert.ToDouble(runnerInfoArray[10]);

                    //Step 13 - Add the prices
                    if (runnerPricesArray.Length > 1)
                    {
                        int countPrice = 0;
                        while (countPrice < (runnerPricesArray.Length))
                        {
                            if (runner.pricesToBack == null)
                                runner.pricesToBack = new PriceList();

                            if (Convert.ToDouble(runnerPricesArray[1 + countPrice]) > 0)
                            {
                                var backPrice = new Price
                                                    {
                                                        price = Convert.ToDouble(runnerPricesArray[0 + countPrice]),
                                                        amountAvailable =
                                                            Convert.ToDouble(runnerPricesArray[1 + countPrice]),
                                                        type = BetTypeOptions.L
                                                    };
                                runner.pricesToBack.Add(backPrice);
                            }

                            if (runner.pricesToLay == null)
                                runner.pricesToLay = new PriceList();

                            if (Convert.ToDouble(runnerPricesArray[2 + countPrice]) > 0)
                            {
                                var layPrice = new Price
                                                   {
                                                       price = Convert.ToDouble(runnerPricesArray[0 + countPrice]),
                                                       amountAvailable =
                                                           Convert.ToDouble(runnerPricesArray[2 + countPrice]),
                                                       type = BetTypeOptions.B
                                                   };
                                runner.pricesToLay.Add(layPrice);
                            }
                            countPrice += 5;
                        }

                        //Add the price depth and organize the data
                        runner.pricesToBack.Sort(new PriceDepthComparerReverse());
                        for (int depth = 0; depth < runner.pricesToBack.Count; depth++)
                            runner.pricesToBack[depth].depth = (depth + 1);

                        runner.pricesToLay.Sort(new PriceDepthComparer());
                        for (int depth = 0; depth < runner.pricesToLay.Count; depth++)
                            runner.pricesToLay[depth].depth = (depth + 1);
                    }
                    market.runners.Add(runner);
                }
                return market;
            }
            return null;
        }
コード例 #11
0
 /// <summary>
 /// Extract the results of a Betfair GetMarketPricesCompressedresp.marketPrices string to a response object
 /// No prices get updated during suspend and closed market status state.
 /// </summary>
 /// <param name="completeMarketPrices">The complete market prices.</param>
 /// <param name="exchangeId">The exchange id.</param>
 /// <param name="status">The status.</param>
 /// <param name="currency">The currency.</param>
 /// <returns></returns>
 public Market ConvertToObject(string completeMarketPrices, int exchangeId, MarketStatus status, string currency)
 {
     return ConvertToObject(completeMarketPrices, exchangeId, status, currency, DateTime.Now);
 }
コード例 #12
0
        private MarketStatusItemViewModel MapMarketStatusMostActive(MarketStatusModel source, MarketStatus status)
        {
            var item = Mapper.Map <MarketStatusItemViewModel>(source);

            item.Badge      = status.TopGainer.Any(a => a.StockCode == source.StockCode) ? "top-gainer" : string.Empty;
            item.BadgeClass = !string.IsNullOrEmpty(item.Badge) ? "success" : string.Empty;

            if (string.IsNullOrEmpty(item.Badge))
            {
                item.Badge      = status.TopLoser.Any(a => a.StockCode == source.StockCode) ? "top-loser" : string.Empty;
                item.BadgeClass = !string.IsNullOrEmpty(item.Badge) ? "danger" : string.Empty;
            }


            return(item);
        }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BetStop{T}" /> class
 /// </summary>
 /// <param name="timestamp">The value specifying timestamps related to the message (in the milliseconds since EPOCH UTC)</param>
 /// <param name="producer">The <see cref="IProducer" /> specifying the producer / service which dispatched the current <see cref="Message" /> message</param>
 /// <param name="event">An <see cref="ICompetition" /> derived instance representing the sport event associated with the current <see cref="EventMessage{T}" /></param>
 /// <param name="requestId">The id of the request which triggered the current <see cref="EventMessage{T}" /> message or a null reference</param>
 /// <param name="marketStatus">a <see cref="MarketStatus" /> specifying the new status of the associated markets</param>
 /// <param name="groups">a list of <see cref="string"/> specifying which market groups needs to be stopped</param>
 /// <param name="rawMessage">The raw message</param>
 public BetStop(IMessageTimestamp timestamp, IProducer producer, T @event, long?requestId, MarketStatus marketStatus, IEnumerable <string> groups, byte[] rawMessage)
     : base(timestamp, producer, @event, requestId, rawMessage)
 {
     MarketStatus = marketStatus;
     Groups       = groups;
 }
コード例 #14
0
        /// <summary>
        /// Extract the results of a Betfair GetMarketPricesCompressedresp.marketPrices string to a response object
        /// No prices get updated during suspend and closed market status state.
        /// The following values get updated during a normal update:
        /// </summary>
        /// <param name="completeMarketPrices">The complete market prices.</param>
        /// <param name="exchangeId">The exchange id.</param>
        /// <param name="status">The status.</param>
        /// <param name="currency">The currency.</param>
        /// <param name="pricesUpdateTime">The time to set the Market.lastRunnerPricesLoad value to</param>
        /// <returns></returns>
        public Market ConvertToObject(string completeMarketPrices, int exchangeId, MarketStatus status, string currency,
                                      DateTime pricesUpdateTime)
        {
            if (completeMarketPrices != null && status == MarketStatus.ACTIVE)
            {
                //Step 1 - Create the response object
                var market = new Market {
                    status = status
                };

                //Step 2 - Clean up the break characters
                completeMarketPrices = HelperMethods.ProtectBreakChars(completeMarketPrices);

                //Step 3 - Split
                string[] marketData = completeMarketPrices.Split(":".ToCharArray());

                //Step 4 - Clean before split
                marketData[0] = HelperMethods.RemoveTrailingTilde(marketData[0]);

                //Step 5 - Get the market data segment
                string[] marketDataArray = marketData[0].Split("~".ToCharArray());

                //Step 6 - Populate the response object
                market.marketId             = Convert.ToInt32(marketDataArray[0]);
                market.betDelay             = Convert.ToInt32(marketDataArray[1]);
                market.currency             = currency;
                market.lastRunnerPricesLoad = pricesUpdateTime;

                market.exchangeId = exchangeId;

                string removedRunners = "";
                if (marketDataArray.Length > 2)
                {
                    removedRunners = marketDataArray[2];
                }

                //Step 7 - Process the removed runner list
                if (removedRunners.Length > 0)
                {
                    if (removedRunners.Substring((removedRunners.Length - 1), 1) == ";")
                    {
                        removedRunners = removedRunners.Remove((removedRunners.Length - 1), 1);
                    }

                    string[] removedRunnersArray = removedRunners.Split(";".ToCharArray());
                    market.removedRunners = new RemovedRunner[removedRunnersArray.Length];

                    for (int x = 0; x < market.removedRunners.Length; x++)
                    {
                        string[] removedRunnerItems = removedRunnersArray[x].Split(",".ToCharArray());
                        var      r = new RemovedRunner
                        {
                            name             = removedRunnerItems[0],
                            removedDate      = removedRunnerItems[1],
                            adjustmentFactor = Convert.ToDouble(removedRunnerItems[2])
                        };
                        market.removedRunners[x] = r;
                    }
                }

                //Step 8 - Loop through the runners
                market.runners = new SelectionList();

                for (int x = 1; x < marketData.Length; x++)
                {
                    //Step 9 - Get the individual runners data from the string
                    string[] runnerDataArray = marketData[x].Split("|".ToCharArray());

                    //Step 10 - Create an data array for the 3 data objects
                    string[] runnerInfoArray =
                        HelperMethods.RemoveTrailingTilde(runnerDataArray[0]).Split("~".ToCharArray());
                    string[] runnerPricesArray =
                        HelperMethods.RemoveTrailingTilde(runnerDataArray[1]).Split("~".ToCharArray());

                    //Step 11 - Create the runner response object
                    var runner = new Selection
                    {
                        selectionId = Convert.ToInt32(runnerInfoArray[0])
                    };

                    //Step 12 - Populate the data

                    if (runnerInfoArray[1].Length > 0)
                    {
                        runner.orderIndex = Convert.ToInt32(runnerInfoArray[1]);
                    }

                    if (runnerInfoArray[2].Length > 0)
                    {
                        runner.totalAmountMatched = Convert.ToDouble(runnerInfoArray[2]);
                    }

                    if (runnerInfoArray[3].Length > 0)
                    {
                        runner.lastPriceMatched = Convert.ToDouble(runnerInfoArray[3]);
                    }

                    if (runnerInfoArray[4].Length > 0)
                    {
                        runner.handiCap = Convert.ToDouble(runnerInfoArray[4]);
                    }

                    if (runnerInfoArray[5].Length > 0)
                    {
                        runner.reductionFactor = Convert.ToDouble(runnerInfoArray[5]);
                    }

                    if (runnerInfoArray[6].Length > 0)
                    {
                        runner.vacant = Convert.ToBoolean(runnerInfoArray[6]);
                    }

                    if (runnerInfoArray[7].Length > 0)
                    {
                        runner.asianLineId = Convert.ToInt32(runnerInfoArray[7]);
                    }

                    if (runnerInfoArray[8].Length > 0)
                    {
                        runner.farSPPrice = Convert.ToDouble(runnerInfoArray[8]);
                    }

                    if (runnerInfoArray[9].Length > 0)
                    {
                        runner.nearSPPrice = Convert.ToDouble(runnerInfoArray[9]);
                    }

                    if (runnerInfoArray[10].Length > 0)
                    {
                        runner.actualSPPrice = Convert.ToDouble(runnerInfoArray[10]);
                    }

                    //Step 13 - Add the prices
                    if (runnerPricesArray.Length > 1)
                    {
                        int countPrice = 0;
                        while (countPrice < (runnerPricesArray.Length))
                        {
                            if (runner.pricesToBack == null)
                            {
                                runner.pricesToBack = new PriceList();
                            }

                            if (Convert.ToDouble(runnerPricesArray[1 + countPrice]) > 0)
                            {
                                var backPrice = new Price
                                {
                                    price           = Convert.ToDouble(runnerPricesArray[0 + countPrice]),
                                    amountAvailable =
                                        Convert.ToDouble(runnerPricesArray[1 + countPrice]),
                                    type = BetTypeOptions.L
                                };
                                runner.pricesToBack.Add(backPrice);
                            }

                            if (runner.pricesToLay == null)
                            {
                                runner.pricesToLay = new PriceList();
                            }

                            if (Convert.ToDouble(runnerPricesArray[2 + countPrice]) > 0)
                            {
                                var layPrice = new Price
                                {
                                    price           = Convert.ToDouble(runnerPricesArray[0 + countPrice]),
                                    amountAvailable =
                                        Convert.ToDouble(runnerPricesArray[2 + countPrice]),
                                    type = BetTypeOptions.B
                                };
                                runner.pricesToLay.Add(layPrice);
                            }
                            countPrice += 5;
                        }


                        //Add the price depth and organize the data
                        runner.pricesToBack.Sort(new PriceDepthComparerReverse());
                        for (int depth = 0; depth < runner.pricesToBack.Count; depth++)
                        {
                            runner.pricesToBack[depth].depth = (depth + 1);
                        }

                        runner.pricesToLay.Sort(new PriceDepthComparer());
                        for (int depth = 0; depth < runner.pricesToLay.Count; depth++)
                        {
                            runner.pricesToLay[depth].depth = (depth + 1);
                        }
                    }
                    market.runners.Add(runner);
                }
                return(market);
            }
            return(null);
        }
コード例 #15
0
 /// <summary>
 /// Extract the results of a Betfair GetMarketPricesCompressedresp.marketPrices string to a response object
 /// No prices get updated during suspend and closed market status state.
 /// </summary>
 /// <param name="completeMarketPrices">The complete market prices.</param>
 /// <param name="exchangeId">The exchange id.</param>
 /// <param name="status">The status.</param>
 /// <param name="currency">The currency.</param>
 /// <returns></returns>
 public Market ConvertToObject(string completeMarketPrices, int exchangeId, MarketStatus status, string currency)
 {
     return(ConvertToObject(completeMarketPrices, exchangeId, status, currency, DateTime.Now));
 }