Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get Market Information of each Race. #25

Open
abdulbarik opened this issue Aug 20, 2016 · 10 comments
Open

Unable to get Market Information of each Race. #25

abdulbarik opened this issue Aug 20, 2016 · 10 comments

Comments

@abdulbarik
Copy link

I am using REST API to get market info of each Race.
I have "marketID" "WIN" also have all the details of each race, I didn't get any proper call to get market info of each race.
I have tried with end point "listMarketCatalogue" and "listMarketBook" but didn't get any luck.

@mgwalm
Copy link

mgwalm commented Aug 20, 2016

This is a sample from my code which works. however why it isn't working could be more complex than this.
` private async Task LoadFullCatalogue()
{
var marketFilter = new MarketFilter();

  ISet<string> ids = new HashSet<string>();
  ids.Add(_marketId); // the market i want
  marketFilter.MarketIds = ids;

  ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
  marketProjections.Add(MarketProjection.RUNNER_METADATA);
  marketProjections.Add(MarketProjection.EVENT);
  marketProjections.Add(MarketProjection.MARKET_DESCRIPTION);
  marketProjections.Add(MarketProjection.COMPETITION);
  marketProjections.Add(MarketProjection.EVENT_TYPE);
  const string MaxResults = "1";
  const MarketSort MarketSort = MarketSort.FIRST_TO_START;

  try
  {
    var marketCatalogues = await JsonRpcClient.Instance.ListMarketCatalogue(marketFilter, marketProjections, MarketSort, MaxResults);

    // add marked id to each runner
    if (marketCatalogues.Count > 0)
    {
      MarketCatalogue = marketCatalogues[0];
      foreach (var runner in MarketCatalogue.Runners)
      {
        runner.MarketId = MarketCatalogue.MarketId;
        runner.EventDescription = MarketCatalogue.FullDescription;
      }
    }
  }
  catch (Exception ex)
  {
    DialogHelpers.DisplayMessage(ex.Message);
  }
}

`

@mgwalm
Copy link

mgwalm commented Aug 20, 2016

Also the marketProjections specify what data you want. so what exactly do you want?

@mgwalm
Copy link

mgwalm commented Aug 20, 2016

An example of listMarketBook
` // get the market book
var ids = new List
{
MarketCatalogue?.MarketId
};
var priceProj = new PriceProjection
{
Virtualise = true, //??
PriceData = new HashSet()
};
priceProj.PriceData.Add(PriceData.EX_BEST_OFFERS);

  try
  {
    StatusMessage = $"Refreshing {MarketCatalogue?.FullDescription}...";
    _cancellationTokenSource = new CancellationTokenSource();

    var books = await JsonRpcClient.Instance.ListMarketBook(ids, priceProj, OrderProjection.EXECUTABLE, MatchProjection.ROLLED_UP_BY_AVG_PRICE, _cancellationTokenSource);
    if (books.Count > 0)
    {
      MarketBook = books[0];

      Runners = new ObservableCollection<Runner>(MarketBook.Runners);

`

@abdulbarik
Copy link
Author

abdulbarik commented Aug 20, 2016

I have all events of eventType "7" in my DB, I just want a cronJob in every 15 mins. to get market information of each event of "WIN" type.
Here what I tried yet:
URL: "https://api-au.betfair.com/exchange/betting/rest/v1.0/listMarketCatalogue/"
JSON value: {"filter": {
"eventIds": ["26420387"],
"marketIds": ["WIN"]
},
"sort": "FIRST_TO_START",
"maxResults": "100"
}

But I am getting empty array every time.

Maybe I am doing something wrong to get this stuff. Please suggest me what I should do to get my task.

Thanks,

@mgwalm
Copy link

mgwalm commented Aug 20, 2016

"marketIds": ["WIN"] is not correct, it should contain the id of a market.

I think it should be
"marketTypeCodes": [ "WIN", "PLACE" ],

@mgwalm
Copy link

mgwalm commented Aug 20, 2016

For example
` var marketFilter = new MarketFilter();
var time = new TimeRange();
time.From = DateTime.Now;
time.To = DateTime.Now.AddDays(1);

  ISet<string> eventypeIds = new HashSet<string>();
  eventypeIds.Add(eventType.Id);

  marketFilter.EventTypeIds = eventypeIds;
  marketFilter.MarketStartTime = time;
  //marketFilter.MarketCountries = new HashSet<string>
  //                                   {
  //                                     "UK"
  //                                   };
  marketFilter.MarketTypeCodes = new HashSet<string>
                                   {
                                     "WIN"
                                   };

  var marketSort = MarketSort.FIRST_TO_START;
  var maxResults = "550";

  ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
  marketProjections.Add(MarketProjection.EVENT);
  marketProjections.Add(MarketProjection.MARKET_DESCRIPTION);
  marketProjections.Add(MarketProjection.MARKET_START_TIME);

  try
  {
    StatusMessage = $"Getting events for {eventType.Name}...";
    var marketCatalogues = await JsonRpcClient.Instance.ListMarketCatalogue(marketFilter, marketProjections, marketSort, maxResults);

`

@abdulbarik
Copy link
Author

@mgwalm I just updated "key" with "marketTypeCodes", but still getting blank array.

Am I doing anything wrong in my API call?

@mgwalm
Copy link

mgwalm commented Aug 20, 2016

no, I said you should be using market type codes instead of marketids

what language/environment are you using.

try to mimic my code into whatever you are using.

@abdulbarik
Copy link
Author

I am integrating it with REST API.
Thanks for your suggestion.

@Tjorriemorrie
Copy link

I am also getting a lot of empty lists. Using python's betfairlightweight.

    time_ago = timezone.now() - datetime.timedelta(minutes=10)
    time_fwd = timezone.now() + datetime.timedelta(minutes=30)
    mfilter = market_filter(
        event_type_ids=[ET_HORSE_RACING, ET_GREYHOUND_RACING],
        market_start_time=time_range(
            from_=time_ago.strftime('%Y-%m-%dT%H:%I:%S.000Z'),
            to=time_fwd.strftime('%Y-%m-%dT%H:%I:%S.000Z')
        )
    )
    for i in range(10):
        res = trading.betting.list_market_catalogue(
            mfilter,
            market_projection=[
                'EVENT',
                'MARKET_START_TIME',
                'MARKET_DESCRIPTION',
                'RUNNER_METADATA',
            ],
            sort='FIRST_TO_START',
            max_results=1000,
            lightweight=True)

The body is just empty the whole time 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants