public async static Task <BetfairServerResponse <List <EventResult> > > Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log, ExecutionContext context) { log.LogInformation("BFSearch BetFair API accessed, Date:" + new DateTime().ToString()); var searchString = req.Query["searchText"].ToString(); var marketFilter = new MarketFilter(); //marketFilter.EventTypeIds = new HashSet<string>() { "7" }; //marketFilter.MarketCountries = new HashSet<string>() { "AU" }; marketFilter.MarketStartTime = new TimeRange() { From = DateTime.Now, To = DateTime.Now.AddDays(15) }; marketFilter.TextQuery = searchString; //var events = client.ListEvents(marketFilter).Result; var apiConfig = new ApiConfig(context); log.LogInformation(""); return(await apiConfig.BetfairClient.ListEvents( marketFilter)); }
public static List <string> GetVenues(BetfairClient client, ILogger log) { var marketFilter = new MarketFilter(); marketFilter.EventTypeIds = new HashSet <string>() { "7" }; marketFilter.MarketCountries = new HashSet <string>() { "AU" }; marketFilter.MarketStartTime = new TimeRange() { From = DateTime.Now, To = DateTime.Now.AddDays(3) }; marketFilter.MarketTypeCodes = new HashSet <String>() { "WIN" }; //var events = client.ListEvents(marketFilter).Result; List <EventResult> events = client.ListEvents( marketFilter).Result.Response; VenueEngine venueEngine = new VenueEngine(); venueEngine.Execute(events.Select(e => e.Event).Distinct().ToList(), log); var venues = events.Select(mark => mark.Event.Venue + "|" + mark.Event.Name + "|" + mark.Event.Id).Distinct(); return(venues.ToList()); }
public IList<MarketTypeResult> listMarketTypes(MarketFilter marketFilter, string stringLocale) { var args = new Dictionary<string, object>(); args[FILTER] = marketFilter; args[LOCALE] = stringLocale; return Invoke<List<MarketTypeResult>>(LIST_MARKET_TYPES_METHOD, args); }
public static List <Tuple <DateTime, string> > GetRaces(BetfairClient client, string venueId) { var marketFilter = new MarketFilter(); marketFilter.EventIds = new HashSet <string>() { venueId }; marketFilter.MarketTypeCodes = new HashSet <String>() { "WIN" }; //var events = client.ListEvents(marketFilter).Result; List <MarketCatalogue> marketCatalogues = client.ListMarketCatalogue( marketFilter, BFHelpers.HorseRaceProjection(), MarketSort.FIRST_TO_START, 100).Result.Response; VenueEngine venueEngine = new VenueEngine(); var venue = venueEngine.GetFromApiId(venueId); RaceEngine raceEngine = new RaceEngine(); raceEngine.Execute(marketCatalogues, venue); var races = marketCatalogues.Select(race => new Tuple <DateTime, String> (race.Description.MarketTime, race.MarketName + "|" + "|" + race.MarketId) ); return(races.ToList()); }
/// <summary> /// Subscribe to the specified markets (matching your filter). (starting the client if needed). /// </summary> /// <param name="marketFilter"></param> public void SubscribeMarkets(MarketFilter marketFilter) { SubscribeMarkets(new MarketSubscriptionMessage() { MarketFilter = marketFilter, }); }
public Task <BetfairServerResponse <List <MarketTypeResult> > > ListMarketTypes(MarketFilter marketFilter) { var args = new Dictionary <string, object>(); args[FILTER] = marketFilter; return(networkClient.Invoke <List <MarketTypeResult> >(exchange, Endpoint.Betting, LIST_MARKET_TYPES, args)); }
public void FetchAndStoreMarkets(MarketFilter filter, ISet <string> trackedMarketIds) { AddMarketTypesToFilter(filter); IEnumerable <MarketCatalogue> markets; try { markets = _marketsReader.Read(filter); } catch (Exception e) { EventLog.WriteEntry("OddsFetchingTriggerer", "Error fetching markets: " + e.Message); markets = new HashSet <MarketCatalogue>(); } List <string> untrackedMarketIds = new List <string>(); foreach (MarketCatalogue market in markets) { if (!trackedMarketIds.Contains(market.MarketId)) { market.EventId = filter.EventIds.FirstOrDefault(); untrackedMarketIds.Add(market.MarketId); _marketsSaver.Save(market); } } }
public ISet <string> FetchAndStoreEvents(MarketFilter filter, ISet <string> trackedEventIds) { IEnumerable <Event> events = new List <Event>(); try { events = EventResultsConverter.ConvertEventResults(_eventsReader.Read(filter)); } catch (Exception e) { EventLog.WriteEntry("OddsFetchingTriggerer", "Error fetching events: " + e.Message); trackedEventIds = new HashSet <string>(); } List <string> untrackedEventIds = new List <string>(); HashSet <string> eventIds = new HashSet <string>(); foreach (Event ev in events) { ev.CompetitionId = filter.CompetitionIds.FirstOrDefault(); ev.Markets = new List <MarketCatalogue>(); eventIds.Add(ev.IdStr); if (!trackedEventIds.Contains(ev.IdStr)) { untrackedEventIds.Add(ev.IdStr); _eventsSaver.Save(ev); } } return(eventIds); }
public static bool getCyclingMarkets(ref List <MarketCatalogue> cyclingMarkets) { MarketFilter marketFilter = new MarketFilter(); ISet <string> set = new HashSet <string>(); set.Add("11"); marketFilter.EventTypeIds = set; ISet <MarketProjection> marketProjections = new HashSet <MarketProjection>(); marketProjections.Add(MarketProjection.EVENT); var marketSort = MarketSort.FIRST_TO_START; try { cyclingMarkets = apiClient.listMarketCatalogue(marketFilter, marketProjections, marketSort, "50").ToList(); return(true); } catch { return(false); } }
public Task <BetfairServerResponse <List <CountryCodeResult> > > ListCountries(MarketFilter marketFilter) { var args = new Dictionary <string, object>(); args[FILTER] = marketFilter; return(networkClient.Invoke <List <CountryCodeResult> >(Endpoint.Betting, LIST_COUNTRIES_METHOD, args)); }
public Task <BetfairServerResponse <List <CompetitionResult> > > ListCompetitions(MarketFilter marketFilter) { var args = new Dictionary <string, object>(); args[FILTER] = marketFilter; return(networkClient.Invoke <List <CompetitionResult> >(exchange, Endpoint.Betting, LIST_COMPETITIONS_METHOD, args)); }
public Task <BetfairServerResponse <List <EventTypeResult> > > ListEventTypes(MarketFilter marketFilter) { var args = new Dictionary <string, object>(); args[FILTER] = marketFilter; return(networkClient.Invoke <List <EventTypeResult> >(Endpoint.Betting, LIST_EVENT_TYPES_METHOD, args)); }
public IList<EventTypeResult> listEventTypes(MarketFilter marketFilter, string locale = null) { var args = new Dictionary<string, object>(); args[FILTER] = marketFilter; args[LOCALE] = locale; return Invoke<List<EventTypeResult>>(LIST_EVENT_TYPES_METHOD, args); }
public Task <BetfairServerResponse <List <VenueResult> > > ListVenues(MarketFilter marketFilter) { var args = new Dictionary <string, object>(); args[FILTER] = marketFilter; return(networkClient.Invoke <List <VenueResult> >(Endpoint.Betting, LIST_VENUES, args)); }
public static MarketFilter HorseRaceFilter(string country = null) { var marketFilter = new MarketFilter { EventTypeIds = new HashSet <string>() { "7" }, MarketStartTime = new TimeRange() { From = DateTime.Now, To = DateTime.Now.AddDays(1) } }; if (country != null) { marketFilter.MarketCountries = new HashSet <string>() { country } } ; marketFilter.MarketTypeCodes = new HashSet <string>() { "WIN" }; return(marketFilter); }
public async Task <Market> GetMarketForEventAndMarketType(string eventId, string marketType) { MarketFilter filter = new MarketFilter() { EventIds = new HashSet <string>() { eventId }, MarketTypeCodes = new HashSet <string>() { marketType } }; HashSet <MarketProjection> marketProjections = new HashSet <MarketProjection>() { MarketProjection.EVENT, MarketProjection.MARKET_DESCRIPTION, MarketProjection.RUNNER_DESCRIPTION, MarketProjection.RUNNER_METADATA }; var parameters = new BetfairRequestParameters() { Filter = filter, MarketProjections = marketProjections, MaxResults = _maxResults }; IEnumerable <Market> marketTypes = await _betfairBatchReader.Read(parameters); return(marketTypes?.FirstOrDefault(mt => mt.MarketType == marketType)); }
public LineDTO[] Convert(string response, string bookmaker) { var token = response.Split('|')[0]; var appKey = response.Split('|')[1]; var lines = new List <LineDTO>(); var aping = new SportsAPING(appKey, token); var marketProjection = new List <MarketProjection> { MarketProjection.EVENT, MarketProjection.EVENT_TYPE, MarketProjection.RUNNER_DESCRIPTION, }; var marketFilter = new MarketFilter { EventTypeIds = new[] { "1", //Footbal "7524" //Ice hockey //"7522", //"468328", //"998917" }, InPlayOnly = true, //TextQuery = "OVER_UNDER_*", MarketBettingTypes = new List <MarketBettingType> { MarketBettingType.ODDS, MarketBettingType.ASIAN_HANDICAP_DOUBLE_LINE } }; var resultList = aping.ListMarketCatalogue(marketFilter, marketProjection, null, 999); if (resultList == null || !resultList.Any()) { return(lines.ToArray()); } var listMarketCatalogue = resultList.ToList(); marketFilter.TextQuery = null; marketFilter.MarketTypeCodes = aping.ListMarketTypes(marketFilter) .Select(x => x.MarketType) .Where(x => Matches.Any(a => a == x)) .ToList(); listMarketCatalogue.AddRange(aping.ListMarketCatalogue(marketFilter, marketProjection, null, 999)); var marketCataloguesGroups = listMarketCatalogue .Where(x => x.Event.Name.Contains(" v ") || x.Event.Name.Contains(" @ ")) .GroupBy(x => new { EventTypeName = x.EventType.Name, EventName = x.Event.Name }); lines.AddRange(BetFairHelper.Convert(marketCataloguesGroups.SelectMany(m => m).ToList(), aping, bookmaker)); return(lines.ToArray()); }
public CatalogueFilter(MarketFilter baseMarketFilter, MarketCatalogueFilter filterId) { _startOffsetHours = baseMarketFilter.MarketStartTime.From.Subtract(DateTime.Now).TotalHours; _endOffsetHours = baseMarketFilter.MarketStartTime.To.Subtract(DateTime.Now).TotalHours; _baseMarketFilter = baseMarketFilter; FilterId = filterId; }
public Expression <Func <MarketCatalogue, bool> > Map(MarketFilter marketFilter) { if (marketFilter.IsFinished == true || marketFilter.IsFinished == false) { return(o => o.IsFinished == marketFilter.IsFinished); } return(o => true); }
public IList <VenueResult> listVenues(MarketFilter marketFilter, string locale = null) { Dictionary <string, object> args = new Dictionary <string, object>(); args[FILTER] = marketFilter; args[LOCALE] = locale; return(Invoke <List <VenueResult> >(LIST_VENUES_METHOD, args)); }
public async Task Subscribe(MarketFilter marketFilter, MarketDataFilter dataFilter) { Actions += "S"; MarketId = marketFilter?.MarketIds?.SingleOrDefault(); Fields = dataFilter?.Fields; LadderLevels = dataFilter?.LadderLevels; await Task.CompletedTask; }
public Task <BetfairServerResponse <List <TimeRangeResult> > > ListTimeRanges(MarketFilter marketFilter, TimeGranularity timeGranularity) { var args = new Dictionary <string, object>(); args[FILTER] = marketFilter; args[GRANULARITY] = timeGranularity; return(networkClient.Invoke <List <TimeRangeResult> >(Endpoint.Betting, LIST_TIME_RANGES, args)); }
public static void GetAllRiderInfo(ref List <Runner> runners, ref List <RunnerDescription> runnerDescription, ref List <MarketProfitAndLoss> runnerPNL, ref CurrentOrderSummaryReport orders) { PriceData pricedata1 = PriceData.EX_ALL_OFFERS; PriceData pricedata2 = PriceData.EX_TRADED; PriceData pricedata3 = PriceData.EX_BEST_OFFERS; HashSet <PriceData> prijsdata = new HashSet <PriceData>(); prijsdata.Add(pricedata1); prijsdata.Add(pricedata2); prijsdata.Add(pricedata3); PriceProjection priceprojection = new PriceProjection(); OrderProjection orderprojection = new OrderProjection(); MatchProjection matchprojection = new MatchProjection(); orderprojection = OrderProjection.ALL; matchprojection = MatchProjection.ROLLED_UP_BY_AVG_PRICE; priceprojection.PriceData = prijsdata; MarketFilter marketFilter = new MarketFilter(); ISet <string> set = new HashSet <string>(); set.Add(BackEnd.marketID); marketFilter.MarketIds = set; var marketSort = MarketSort.FIRST_TO_START; ISet <MarketProjection> marketProjections = new HashSet <MarketProjection>(); marketProjections.Add(MarketProjection.RUNNER_DESCRIPTION); List <string> marketIds = new List <string>(); marketIds.Add(BackEnd.marketID); try { runners = apiClient.listMarketBook(marketIds, priceprojection, orderprojection, matchprojection)[0].Runners; } catch { } try { runnerDescription = apiClient.listMarketCatalogue(marketFilter, marketProjections, marketSort)[0].Runners; } catch { } try { runnerPNL = apiClient.listMarketProfitAndLoss(marketIds, true, true, true).ToList <MarketProfitAndLoss>(); } catch { } try { orders = apiClient.listCurrentOrders(); } catch { } }
public IList <EventResult> listEventsRes(MarketFilter marketFilter, MarketSort marketSort, string locale = null) { var args = new Dictionary <string, object>(); args[FILTER] = marketFilter; args[SORT] = marketSort; args[LOCALE] = locale; return(Invoke <List <EventResult> >(LIST_EVENTS_METHOD, args)); }
private void AddMarketTypesToFilter(MarketFilter filter) { filter.MarketTypeCodes = new HashSet <string>(); var allowedCodes = Enum.GetValues(typeof(AllowedMarketTypeCodes)).Cast <AllowedMarketTypeCodes>(); foreach (var code in allowedCodes) { filter.MarketTypeCodes.Add(code.ToString()); } }
public IList<MarketCatalogue> listMarketCatalogue(MarketFilter marketFilter, ISet<MarketProjection> marketProjections, MarketSort marketSort, string maxResult = "1", string locale = null) { var args = new Dictionary<string, object>(); args[FILTER] = marketFilter; args[MARKET_PROJECTION] = marketProjections; args[SORT] = marketSort; args[MAX_RESULTS] = maxResult; args[LOCALE] = locale; return Invoke<List<MarketCatalogue>>(LIST_MARKET_CATALOGUE_METHOD, args); }
public async Task OnSubscribeSubscriptionMessageIsSent(string marketId) { var marketFilter = new MarketFilter().WithMarketId(marketId); var subscriptionMessage = new SubscriptionMessageStub("marketSubscription", 1) .WithMarketFilter(marketFilter) .ToJson(); await Subscription.Subscribe(marketFilter, null); Assert.Equal(subscriptionMessage, Writer.LastLineWritten); }
private async Task Subscribe(string marketId) { var marketFilter = new MarketFilter().WithMarketId(marketId); _subscription.Connect(); await _subscription.Authenticate(); await _subscription.Subscribe(marketFilter, GetMergedDataFilters()); await _subscription.SubscribeToOrders(); }
public void Test() { var marketFilter = new MarketFilter(); marketFilter.EventTypeIds = new HashSet <string>() { "7" }; marketFilter.MarketCountries = new HashSet <string>() { "AU" }; marketFilter.MarketStartTime = new TimeRange() { From = DateTime.Now, To = DateTime.Now.AddDays(2) }; marketFilter.MarketTypeCodes = new HashSet <String>() { "WIN" }; var events = _client.ListEvents(marketFilter).Result; var marketCatalogues = _client.ListMarketCatalogue( marketFilter, BFHelpers.HorseRaceProjection(), MarketSort.FIRST_TO_START, 100).Result.Response; var venues = marketCatalogues.Select(mark => mark.Event.Venue).Distinct(); foreach (MarketCatalogue mc in marketCatalogues) { Console.WriteLine(mc.Event.Venue); Console.WriteLine(mc.MarketName); var marketIds = new HashSet <String>() { mc.MarketId }; var marketBooks = _client.ListMarketBook(marketIds).Result.Response; List <Runner> runnersForMarket = marketBooks.First().Runners; Console.WriteLine("************RUNNERS**************"); foreach (Runner r in runnersForMarket) { var rc = mc.Runners.Find(runner => runner.SelectionId.Equals(r.SelectionId)); Console.WriteLine("Horse: " + rc.RunnerName + "|Last Price:" + r.LastPriceTraded + "|Status: " + r.Status); } } }
public BetfairServerResponse <List <MarketCatalogue> > ListMarketCatalogue( MarketFilter marketFilter, ISet <MarketProjection> marketProjections = null, MarketSort?sort = null, int maxResult = 1) { return(client.ListMarketCatalogue( marketFilter, marketProjections, sort, maxResult).Result); }
public IObservable<MarketSnap> SubscribeMarket(string marketId) { MarketFilter filter = new MarketFilter { MarketIds = new List<string>() { marketId } }; MarketSubscriptionMessage message = new MarketSubscriptionMessage() { MarketFilter = filter }; return SubscribeMarket(marketId, message); }