phillc73 / abettor

An R package for connecting to the online betting exchange Betfair, via their API-NG product, using JSON-RPC.
Other
51 stars 36 forks source link

listMarketBook function #3

Closed Tammboy closed 9 years ago

Tammboy commented 9 years ago

I'm a bit new to this but with the function:

listMarketBook(marketIds = racetemp, priceData = "EX_ALL_OFFERS", sslVerify = FALSE)

is it possible to list a vector of marketIds to create a dataframe or can it only handle one marketid at a time?

thanks,

phillc73 commented 9 years ago

Yes, multiple marketIds are supported. Simply add them comma separated.

e.g. listMarketBook(marketIds = "marketId1, marketId2, marketId3", priceData = "EX_ALL_OFFERS", sslVerify = FALSE)

Hope that helps. I can put some more details together tomorrow if required.

Tammboy commented 9 years ago

Great, i managed to put in a few marketIds manually like in your example. However, is there a way to put in a range of marketids dynamically?

for example, if i load marketids into a vector: AllMarketIDs [1] "1.117689626" "1.117689627" "1.117707779" "1.117707780" "1.117707813" "1.117707814" temp = listMarketBook(marketIds = AllMarketIDs, priceData = "EX_ALL_OFFERS", sslVerify = FALSE) doesn't seem to work?

thanks,

phillc73 commented 9 years ago

Try something like this:

# Extract market catalogue data for horse racing in UK and IE over next 24 hours

marketCat <- abettor::listMarketCatalogue(eventTypeIds = "7", marketCountries = c("GB", "IE"), marketTypeCodes = "WIN", sslVerify = FALSE)

# Hold just the marketIds in a new variable

todayMarketIds <- data.frame(marketCat$marketId)

# Use lapply to work across all items in todayMarketIds

marketIds <- lapply(todayMarketIds$marketCat.marketId, function(x) abettor::listMarketBook(marketIds = x, priceData = "EX_BEST_OFFERS", sslVerify = FALSE))
phillc73 commented 9 years ago

Assuming fixed, so closing.