Although my code is pinned below, I can't seem to filter to a tennis match (to differentiate from a horse example) and effectively find tennis players(or runners?). Can anyone point out something obvious? Thank you.
I'm not understanding yet, why the following call made, becomes an index out of range:
Calling: SportsAPING/v1.0/listMarketCatalogue With args: {"filter":{"eventTypeIds":["2"],"marketCountries":["AU","US","GB"],"marketTypeCodes":["WIN"],"marketStartTime":{"from":"2016-01-26T17:36:39.1951801+00:00","to":"2016-01-29T17:36:39.1951801+00:00"}},"marketProjection":["RUNNER_METADATA"],"sort":"FIRST_TO_START","maxResults":"2","locale" :null}
My Code Used:
Console.WriteLine("\nBeginning sample run!\n");
try
{
var marketFilter = new MarketFilter();
//if you want a population of eventypes....
var eventTypes = client.listEventTypes(marketFilter);
// forming an eventype id set for the eventype id extracted from the result
ISet<string> eventypeIds = new HashSet<string>();
foreach (EventTypeResult eventType in eventTypes)
{
if (eventType.EventType.Name.Equals("Tennis"))
{
Console.WriteLine("\nFound event type for Tennis: " + JsonConvert.SerializeObject(eventType));
//extracting eventype id, dab basically gets the eventtypeID from the text you supply i.e. tennis
eventypeIds.Add(eventType.EventType.Id);
}
}
//ListMarketCatalogue: Get next available event, parameters:
var time = new TimeRange();
time.From = DateTime.Now;
time.To = DateTime.Now.AddDays(3);
marketFilter = new MarketFilter();
marketFilter.EventTypeIds = eventypeIds;
marketFilter.MarketStartTime = time;
//market countries appears to be the location of the events (not legal betting territories)
marketFilter.MarketCountries = new HashSet<string>() { "AU", "US", "GB" };
marketFilter.MarketTypeCodes = new HashSet<String>() { "WIN" };
var marketSort = MarketSort.FIRST_TO_START;
var maxResults = "2";
//as an example we requested runner metadata
ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
marketProjections.Add(MarketProjection.RUNNER_META DATA);
//marketProjections.Add(MarketProjection.EVENT_TYPE) ;
Console.WriteLine("\nGetting the next available event selected markets");
var marketCatalogues = client.listMarketCatalogue(marketFilter, marketProjections, marketSort, maxResults);
//Test we can identify certain criteria
var description = new RunnerDescription();
description = marketCatalogues[0].Runners[0];
string myName = description.RunnerName;
string mySelectionID = "MySelectionID = " + description.SelectionId.ToString();
string markets = marketCatalogues.Count.ToString();
Console.WriteLine("The name of the selection is: " + myName + " " + mySelectionID + " " + " Number of Races in Pool = " + markets);
//extract the marketId of the next event
String marketId = marketCatalogues[0].MarketId;
// Console.WriteLine(marketCatalogues[0].Description.ToString());
IList<string> marketIds = new List<string>();
marketIds.Add(marketId);
ISet<PriceData> priceData = new HashSet<PriceData>();
//get all prices from the exchange
priceData.Add(PriceData.EX_BEST_OFFERS);
var priceProjection = new PriceProjection();
priceProjection.PriceData = priceData;
Console.WriteLine("\nGetting prices for market: " + marketId);
var marketBook = client.listMarketBook(marketIds, priceProjection);
// try to get the total participants selected book (tennis = 2)
string runners = marketBook[0].NumberOfActiveRunners.ToString();
if (marketBook.Count != 0)
{
Console.WriteLine("Total number of active runners in the race: " + runners);
Console.WriteLine("\nDONE!");
}
else
{
Console.Write("\nSorry the market has no runner to place a bet on, try again later");
}
}
catch (APINGException apiExcepion)
{
Console.WriteLine("Got an exception from Api-NG: " + apiExcepion.ErrorCode);
Environment.Exit(0);
}
catch (System.Exception e)
{
Console.WriteLine("Unknown exception from application: " + e.Message);
Environment.Exit(0);
}
}
}
}
I'm not understanding yet, why the following call made, becomes an index out of range:
Calling: SportsAPING/v1.0/listMarketCatalogue With args: {"filter":{"eventTypeIds":["2"],"marketCountries":["AU","US","GB"],"marketTypeCodes":["WIN"],"marketStartTime":{"from":"2016-01-26T17:36:39.1951801+00:00","to":"2016-01-29T17:36:39.1951801+00:00"}},"marketProjection":["RUNNER_METADATA"],"sort":"FIRST_TO_START","maxResults":"2","locale" :null}
My Code Used:
Console.WriteLine("\nBeginning sample run!\n");
try
{
var marketFilter = new MarketFilter();
//if you want a population of eventypes....
var eventTypes = client.listEventTypes(marketFilter);
// forming an eventype id set for the eventype id extracted from the result
ISet<string> eventypeIds = new HashSet<string>();
foreach (EventTypeResult eventType in eventTypes)
{
if (eventType.EventType.Name.Equals("Tennis"))
{
Console.WriteLine("\nFound event type for Tennis: " + JsonConvert.SerializeObject(eventType));
//extracting eventype id, dab basically gets the eventtypeID from the text you supply i.e. tennis
eventypeIds.Add(eventType.EventType.Id);
}
}
//ListMarketCatalogue: Get next available event, parameters:
var time = new TimeRange();
time.From = DateTime.Now;
time.To = DateTime.Now.AddDays(3);
marketFilter = new MarketFilter();
marketFilter.EventTypeIds = eventypeIds;
marketFilter.MarketStartTime = time;
//market countries appears to be the location of the events (not legal betting territories)
marketFilter.MarketCountries = new HashSet<string>() { "AU", "US", "GB" };
marketFilter.MarketTypeCodes = new HashSet<String>() { "WIN" };
var marketSort = MarketSort.FIRST_TO_START;
var maxResults = "2";
//as an example we requested runner metadata
ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
marketProjections.Add(MarketProjection.RUNNER_META DATA);
//marketProjections.Add(MarketProjection.EVENT_TYPE) ;
Console.WriteLine("\nGetting the next available event selected markets");
var marketCatalogues = client.listMarketCatalogue(marketFilter, marketProjections, marketSort, maxResults);
//Test we can identify certain criteria
var description = new RunnerDescription();
description = marketCatalogues[0].Runners[0];
string myName = description.RunnerName;
string mySelectionID = "MySelectionID = " + description.SelectionId.ToString();
string markets = marketCatalogues.Count.ToString();
Console.WriteLine("The name of the selection is: " + myName + " " + mySelectionID + " " + " Number of Races in Pool = " + markets);
//extract the marketId of the next event
String marketId = marketCatalogues[0].MarketId;
// Console.WriteLine(marketCatalogues[0].Description.ToString());
IList<string> marketIds = new List<string>();
marketIds.Add(marketId);
ISet<PriceData> priceData = new HashSet<PriceData>();
//get all prices from the exchange
priceData.Add(PriceData.EX_BEST_OFFERS);
var priceProjection = new PriceProjection();
priceProjection.PriceData = priceData;
Console.WriteLine("\nGetting prices for market: " + marketId);
var marketBook = client.listMarketBook(marketIds, priceProjection);
// try to get the total participants selected book (tennis = 2)
string runners = marketBook[0].NumberOfActiveRunners.ToString();
if (marketBook.Count != 0)
{
Console.WriteLine("Total number of active runners in the race: " + runners);
Console.WriteLine("\nDONE!");
}
else
{
Console.Write("\nSorry the market has no runner to place a bet on, try again later");
}
}
catch (APINGException apiExcepion)
{
Console.WriteLine("Got an exception from Api-NG: " + apiExcepion.ErrorCode);
Environment.Exit(0);
}
catch (System.Exception e)
{
Console.WriteLine("Unknown exception from application: " + e.Message);
Environment.Exit(0);
}
}
}
}


Comment