Exemple #1
0
        /// <summary>
        /// Get the riders data from the API and sort it to latest matched marketprice
        /// </summary>
        public static void get()
        {
            try
            {
                ApiGet.GetAllRiderInfo(ref runners, ref runnerDescription, ref marketPNL, ref orders);

                runners           = runners.FindAll(f => !discardedRiders.Contains(f.SelectionId)).OrderBy(f => f.SelectionId).ToList <Runner>();
                runnerDescription = runnerDescription.FindAll(f => !discardedRiders.Contains(f.SelectionId)).OrderBy(f => f.SelectionId).ToList <RunnerDescription>();
                var runnerPNL = marketPNL[0].ProfitAndLosses.FindAll(f => !discardedRiders.Contains(f.SelectionId)).OrderBy(f => f.SelectionId).ToList <RunnerProfitAndLoss>();

                Riders.riders = new Rider[Math.Min(Math.Min(runners.Count, runnerDescription.Count), runnerPNL.Count)];

                for (int i = 0; i < Math.Min(Math.Min(runners.Count, runnerDescription.Count), runnerPNL.Count); i++)
                {
                    Riders.riders[i] = new Rider(runners[i], orders, runnerDescription[i], runnerPNL[i],
                                                 (riders[i] == null) ? 0 : riders[i].minPrice, (riders[i] == null) ? 0 : riders[i].maxPrice);
                }

                riders = riders.OrderBy(f => f.latestMarketprice).ToArray <Rider>();

                for (int i = 0; i < riders.Count(); i++)
                {
                    riders[i].overround = riders.Take(i).Sum(f => 1 / f.latestMarketprice);
                }
            }
            catch { }
        }
Exemple #2
0
        private void ConnectButtonClick(object sender, System.EventArgs e)
        {
            BackEnd.sessionToken = ApiKeyTextBox.Text.ToString();
            if (ApiGet.getCyclingMarkets(ref cyclingMarkets))
            {
                BackEnd.connected2API = true;

                for (int i = 0; i < cyclingMarkets.Count; i++)
                {
                    DropDownMenu.Items.Add(cyclingMarkets[i].Event.Name);
                }

                ConnectionMessage.Text = "Connected to Betfair API";
                ChooseMarket.Text      = "Select market, click start!";
            }
            else
            {
                ConnectionMessage.Text      = "Failed to connect to Betfair API";
                ConnectionMessage.ForeColor = Color.Red;
            }
        }