Giter Site home page Giter Site logo

Help pulling market prices about abettor HOT 1 OPEN

phillc73 avatar phillc73 commented on June 14, 2024
Help pulling market prices

from abettor.

Comments (1)

Soccerama avatar Soccerama commented on June 14, 2024

Sam,

I don't think tidyverse handles these complex structures well. My code (which was written a while ago and may not be optimal) looks a bit like this. It catches some errors and empty fields but probably not all. Let me know if you are having trouble getting it to work:

eventWins <- listMarketCatalogue(eventTypeIds = "7", marketTypeCodes = "WIN", marketIds = yourMarketId, marketProjection = c("COMPETITION", "EVENT", "EVENT_TYPE", "RUNNER_DESCRIPTION",
                                      "MARKET_START_TIME", "MARKET_DESCRIPTION"))

        runnerData <- data.frame()
        winOdds <- listMarketBook(marketId = yourMarketId, priceData = "EX_BEST_OFFERS")
        numRunners <- nrow(winOdds$runners[[1]])
        for(j in 1:numRunners){
          runnerData[j,"runnerName"] <- eventWins$runners[[1]][[j,"runnerName"]]
          runnerData[j,"runnerNumber"] <- substr(runnerData[j,"runnerName"],1,str_locate(runnerData[j,"runnerName"]," ")[[1]]-2)
          if(placeOdds$status == "OPEN"){
            if(winOdds$runners[[1]]$status[[j]]=="ACTIVE"){
              runnerData[j,"selectionId"] <- placeOdds$runners[[1]]$selectionId[[j]]
              if(nrow(winOdds$runners[[1]]$ex[[1]][[j]])>0){
                runnerData[j,"bestLay"] <- winOdds$runners[[1]]$ex[[1]][[j]][[1,"price"]]
                runnerData[j,"layAmount"] <- winOdds$runners[[1]]$ex[[1]][[j]][[1,"size"]]
              } else {
                runnerData[j,"bestLay"] <- 1.01
                runnerData[j,"layAmount"] <- 5
              }
              if(nrow(winOdds$runners[[1]]$ex[[2]][[j]])>0){
                runnerData[j,"bestBack"] <- winOdds$runners[[1]]$ex[[2]][[j]][[1,"price"]] 
                runnerData[j,"backAmount"] <- winOdds$runners[[1]]$ex[[2]][[j]][[1,"size"]]
              } else {
                runnerData[j,"bestBack"] <- 1000
                runnerData[j,"backAmount"] <- 1
              }
              if(nrow(placeOdds$runners[[1]]$ex[[1]][[j]])>0){
                runnerData[j,"bestLayPlaceOdds"] <- placeOdds$runners[[1]]$ex[[1]][[j]][[1,"price"]]
              } else {
                runnerData[j,"bestLayPlaceOdds"] <- 1.01
              }
              if(nrow(placeOdds$runners[[1]]$ex[[2]][[j]])>0){
                runnerData[j,"bestBackPlaceOdds"] <- placeOdds$runners[[1]]$ex[[2]][[j]][[1,"price"]]
              } else {
                runnerData[j,"bestBackPlaceOdds"] <- 1000
              }
              numActiveRunners <- numActiveRunners + 1
            } else {
              runnerData[j,"bestLay"] <- 0
              runnerData[j,"layAmount"] <- 0
              runnerData[j,"bestBack"] <- 0
              runnerData[j,"backAmount"] <- 0
            }
          } else {
            runnerData[j,"bestLay"] <- 0
            runnerData[j,"layAmount"] <- 0
            runnerData[j,"bestBack"] <- 0
            runnerData[j,"backAmount"] <- 0
          }
        }

from abettor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.