Giter Site home page Giter Site logo

abettor's People

Contributors

alvisetrevisan avatar dashee87 avatar phillc73 avatar soccerama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

abettor's Issues

Unable to retrieve any list

Hi, I've received this error when running any of the 'list' commands. Any ideas what the bug might be?

listCompetitions(eventTypeIds=1,
toDate = (format(Sys.time() + 86400 * 365, "%Y-%m-%dT%TZ"))
)
Error in function (type, msg, asError = TRUE) :
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

Check valid login status

Hi there Phil - great package and I'm loving it's simplicity and ease of use - Thanks!!

I'm building a shiny app that looks for value bets by combining a web-scraper for bookmaker odds and betfair markets.

One thing that repeatedly halts the Shiny app is when I forget to run the Login function upfront.

Is there any opportunity to check for "Logged In" status at Betfair? Or is a better alternative to use a Login and Logout call for every session?

getAccountStatement not returning all columns

This question was raised in another forum:
Has the output of the getAccountStatement() function in the R abettor library changed recently? I haven't run this function in awhile as I've been paper trading, but ran it today to find my code crashing due to missing columns/new columns.
When I looked at the code and output it seems that only the legacy data is being returned correctly. I'm working on a solution which looks obvious but untangling the structure into a clean dataframe is proving challenging.

Lay Starting Price Error

Laying on a horse with starting price like this

placeOrders(
marketId = market_id,
selectionId = runners[1,]$selectionId,
betSide = "LAY",
betSize = "2",
betType = "MARKET_ON_CLOSE"
)

throws the error "INVALID_BET_SIZE". Backing the horse runs normally. I read that another person in 2017 had the same problem, but I already updated the newest version...

Rename checkBalance and listMarketPandL Functions

The functions checkBalance and listMarketPandL should be renamed to match the naming convention used in the Betfair API calls, for consistency with the rest of the library.

Specifically that is:

  • checkBalance to getAccountFunds
  • listMarketPandL to listMarketProfitAndLoss

Old function names should re-direct to new function names for backwards compatibility.

Heartbeat API

abettor does not currently support the Betfair Heartbeat API, but probably should.

Looks like one API call, with three endpoints for UK (global?), Italian and Spanish exchange.

listMarketBook function returning identical results

Hi, I've read the documentation on the listMarketBook function but I'm not sure where I'm going wrong.

I'd like to create a dataframe which, for a particular marketId, shows the total volume traded at each price. (Anyone can find this through the betfair website if you click the little graph icon next to each runner in a market.) I've used the listMarketBook function and tried each permutation of orderProjection, matchProjection, rollupModel and priceData. Each time the same identical information comes back, which is the current prices availableToBack, availableToLay; but not the information on what's been matched already. Can anyone advise what arguments I should be using in the function?

Live odds

Hi phillc73,

Is there a way to see inplay markets with abettor?

I have a live score scraper that I want to combine with the current live odds of a match to determine if a bet should be placed. Basically, if a bunch of scenarios with the score and the odds happen simultaneously I will get an alert from R through a text or email (in Australia we have to call betfair to place the bet so I can't automate the placing of the order).

Is it possible to get these odds in abettor or is there another way to get this?

thanks,
Nick

Horseracing betting at SP

Hi Phil,

I can't seem to get the horseracing place bet at SP working. I'm using either of these lines:

placeOrders(marketId="1.122275822",selectionId="9414882",betSide="BACK",betType="LIMIT_ON_CLOSE",betSize="2",reqPrice ="1.01",persistenceType="MARKET_ON_CLOSE", sslVerify = FALSE)
or
placeOrders(marketId="1.122275822",selectionId="9414882",betSide="BACK",betType="MARKET_ON_CLOSE",betSize="2",reqPrice ="1.01",persistenceType="MARKET_ON_CLOSE", sslVerify = FALSE)

And checking my betfair account afterwards but nothing appears to be happening. It works find in normal back immediate markets but not SP - Is there a setting that i have wrong?

thanks,

Jake.

Not able to login

For some reason, I just cannot login?? betfairlightweight in python works with the same credentials (username, pwd and applicationkey), but I keep getting the error: "FAIL:INVALID_USERNAME_OR_PASSWORD" in R? Maybe it is an issue with the 2FA? Any advice?

Help pulling market prices

Hi team - apologies in advance for logging an issue if this is not the right place to put it - but I wasn't sure how else to ask for help.

I'm attempting to build a betting bot and I'm keen to try and find market value amongst bookies, using the betfair lay markets as a guide close to jump time.

Abettor is magical in granting rapid, reliable access to the Betfair API - thanks so much for building it! My troubles start in the data-wrangling after executing a "listMarketBook" call. Essentially, I'm really struggling using any of the base or tidyverse methods to be able to pull the "availableToLay" list up to a level that also includes the marketId and SelectionId variables. ie - what I'd like to end up with is a long list of selectionId's (runner name would be even better, but let's start with what we've got first!) and prices - but I have to traverse through the "ex" list and that seems to be breaking every single time.

I've tried unnest(), unnest_longer() and unnest_wider(), hoist(), pluck() and flatten() but nothing seems to run without error!

Any tips or pointers that might help push me in the right direction?

I've tried all sorts of documentation for the tidyverse and this doesn't seem to be something that anyone on StackOverrflow has face either!

Again - apologies if this isn't the right forum - but I'm running out of ideas to get help!

Cheers,

Sam

Race Status API

abettor does not currently support the Race Status API, but probably should.

Looks like one API call. - listRaceDetails

From the Betfair website:

The listRaceDetails operation is provided to allow customers to establish the status of a horse or greyhound race market both prior to and after the start of the race. This information is available for UK, Ireland and South African races only and is provided for information purposes only

increase getAccountStatement limit above 100 records

The maximum number of records that can be returned from an API call is 100. This means users of this function have to use the function repetitively to get their full account statement. It would be preferable if the function handled this and returned all available records as the default.

I have written some code to address this and will do a pull request in the next day or so.

Politics markets error

Hi there.

I'm getting a strange result when I try listMarketCatalogue for the politics market through the api. This is the code I am running:

event.Types <- listEventTypes()

politics.ID <- event.Types$eventType$id[grep("Politics",event.Types$eventType$name)]

listCountries(eventTypeIds=politicsID)

market.Type <- listMarketTypes(eventTypeIds=politics.ID)$marketType

listMarketCatalogue(eventTypeIds=politics.ID, marketCountries="GB", marketTypeCodes = market.Type)

But it seems to return:

> listMarketCatalogue(eventTypeIds=politics.ID, marketCountries="GB", marketTypeCodes = market.Type)
data frame with 0 columns and 0 rows

Any idea what I might be doing wrong?

Thanks for the nice package, btw!

J

Unable to logout

Hi Phill
When trying to use logoutBF(), I get this message returned:

Error in function (type, msg, asError = TRUE) :
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Am able login successfully. Error message is returned when sslVerify is set to F or T.

Thanks
Chris

date range in getAccountStatement not working correctly

Received this on another forum:
I've been messing about with the getAccountStatement function lately trying to work out why it always goes back 90 days when I just want the last 24 hrs worth of activity. It seems that the function isn't passing the date range I specify as the correct variable. In the function there are these two lines to set the date range:

getAccStatOps$params$daterange$from <- fromDate
getAccStatOps$params$daterange$to <- toDate

But according to the API docs the parameter should be called itemDateRange not daterange. Changing the parameter name speeds up the call by a lot!

placeOrders function does not include all fields

The current implementation of the placeOrders function covers the required elements and some others but there are more fields that are not currently implemented. Adding each field into the function definition would be messy and deviates from Betfair's definition in the API docs. I'm developing an alternative methodology where the instruction list is passed in as a dataframe which seems to work after a lot of experimentation. The order list is built using some simple rules and only required fields need to be supplied.
What is the best way to share this? Give it a new name like placeOrdersDF and add it to my fork? (Sorry I'm still a github noob).

Login failure

Hi,

Yesterday I started getting this error at login:

> loginBF(username = user, password = pass, applicationKey = appKey)
<SSL_CONNECT_ERROR in function (type, msg, asError = TRUE) {    if (!is.character(type)) {        i = match(type, CURLcodeValues)  typeName = if (is.na(i))   character()  else names(CURLcodeValues)[i]    }    typeName = gsub("^CURLE_", "", typeName)    fun = (if (asError)    stop  else warning)    fun(structure(list(message = msg, call = sys.call()), class = c(typeName,   "GenericCurlError", "error", "condition")))}(35L, "error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol",     TRUE): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol>
Error in function (type, msg, asError = TRUE)  : 
  error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Is this related with Betfair's recent change in communications security settings, allowing only TLS 1.2 protocols?

This is the email I got from Betfair, on 01/02/2019.

Subject: Betfair API - TLS 1.2 - from 7th February 2019
(...)
Please be aware that from 7th February, the only protocol for securing the communication between Betfair servers and web browsers at login will be TLS 1.2. Older versions (TLS.1.0, TLS.1.1 or SSLv3) will no longer work.
Although we don't expect this to have an impact on API clients we'd recommend that you refer to the following resources depending on your programming language/framework to confirm that your using TLS 1.2 or above:
(...)

My current version of RCurl appears to be using an older protocol

> RCurl::curlVersion()$ssl_version
[1] "OpenSSL/1.0.0o"

Is there a quick fix to this?

Thank you!

listRunnerBook Fails to Generate Documentation

When using Roxygen, listRunnerBook fails with the following error:

r$> roxygen2::roxygenise()                                                                                                                                                                           
Loading abettor
Warning: [/home/phillc/Development/Horse Racing/abettor/R/listRunnerBook.R:1] @title Missing name
Warning: The existing 'NAMESPACE' file was not generated by roxygen2, and will not be overwritten.
Warning messages:
1: roxygen2 requires Encoding: UTF-8 
2: In readLines(con, warn = FALSE, n = n, ok = ok, skipNul = skipNul) :
  invalid input found on input connection '/home/phillc/Development/Horse Racing/abettor/R/listRunnerBook.R'

SSL error

Error in function (type, msg, asError = TRUE) :
SSL certificate problem: self signed certificate in certificate chain

loginBF wants to verify SSL certificates with path inputs
Fix:

loginBF2 = function(username, password, applicationKey)
{
credentials <- paste("username=", username, "&password=", password, sep = "")
headersLogin <- list(Accept = "application/json", X-Application = applicationKey)
loginReturn <- RCurl::postForm("https://identitysso.betfair.com/api/login", .opts = list(postfields = credentials, httpheader = headersLogin, ssl.verifypeer = FALSE))
authenticationKey <- jsonlite::fromJSON(loginReturn)
headersPostLogin <- NULL
headersPostLogin <<- list(Accept = "application/json", X-Application = authenticationKey$product,
X-Authentication = authenticationKey$token, Content-Type = "application/json")
}

just added the ssl verification = FALSE in the RCurl options

getAccountStatement crash with dead heat

Hi

getAccountStatement crashes at the line

accNewOrders[, fixColNames]

with the error

Error in `[.data.frame`(accNewOrders, , fixColNames) : 
  undefined columns selected

...if the first page of results contained the column deadHeatPriceDivisor but the current page doesn't contain this column. Looks like fixColNames only gets set the first time through the main loop so whatever columns are present on that page, it expects to see on subsequent pages -- but appears the API doesn't include at least that specific column unless statement items on the current page require it -- hence the error.

A simple hack is to add deadHeatPriceDivisor to the list of columns excluded when the data is pulled in.

accNewOrders[, "legacyData"] <- NULL

is already executed... just add

accNewOrders[, "deadHeatPriceDivisor"] <- NULL

I'm not sure if there would be knock-on effects from implementing this as a fix, but it works for me for this specific issue. I would imagine there are other 'special case' columns which would create the same problem so a more general solution would be preferable.

Error when placing more than two lay/back bets

Hi,

The function placeOrders() doesn't seem to allow for more than 2 simultaneous back/lay orders, returning "Error: Expectation Failed".

placeOrders(
marketId = "1.130459350",
selectionId = as.character(c(10463405, 10463405, 11160430)),
betSide = rep("LAY", 3),
betType = "LIMIT",
betSize = rep(as.character(2), 3),
reqPrice = rep(as.character(1.2), 3),
persistenceType = rep("LAPSE", 3)
)
Error: Expectation Failed

Am I wrongly specifying any of the arguments? Or is there a limit on the number of bets per request imposed by the betfair API?

Looking at the betfair's API documentation on placing orders, it reads: "The limit of place instructions per request is 200 for the UK/AUS Exchange (...)"

In any case, I must also add that the package works a treat - you've than an excellent job!

Many thanks in advance,
Bruno

Same error everytime

Hi

I am an Italian user of Betfair and I just installed abettor to access Betfair's API. I am currently able to log in to the API using the Italian API Endpoint but then every time I run a command I get always the same error :
code message data.APINGException.requestUUID data.APINGException.errorCode data.APINGException.errorDetails data.exceptionname 1 -32099 ANGX-0007 prdang036-11151112-0006a5fb53 INVALID_APP_KEY APINGException Warning message: In listEventTypes() : Error- See output for details

I really don't know what to do to fix it, I hope you can help me with this issue.
Thank you for your time and consideration

Error in download(dest, src, auth) : client error: (404) Not Found

Hi @phillc73 ,

I am currently trying to build a betfair app and have come across your package. I am trying to download install the package according to the README file.

I am running Windows 7 64-bit and have installed Rtools v3.1

The code I am looking to run and the response is as follows

> devtools::install_github('phillc73/abbetor')
Downloading github repo phillc73/abbetor@master
Error in download(dest, src, auth) : client error: (404) Not Found

Are you able to help me to download the package?

Many thanks!

getAccountStatement uses legacyData fields and code is messy

I rewrote this function a few months ago to allow the retrieval of more than 100 records. It works but the code uses the legacyData fields rather than the itemClassData json field. This was my first contribution to abettor and it shows - the code is messy, difficult to read and this may make it more error prone.
I've been trying to work out how to unpack the json in a more efficient manner but it is proving difficult. Seeking the help of some experts on this. If anybody reading this can help with unpacking a dataframe of elements, each of which is in a json (key/value pair) format that would be greatly appreciated.
My attempts have been along these lines and have all ended in a similar place, none of them with the clean dataframe structure that is required as an output from the function. I put the json field into a dataframe using
accItem <- accOrder$result$accountStatement$itemClassData
Then have tried using
accDF <- map(accItem[,1], jsonlite::fromJSON(simplifyDataFrame = simplifyDataFrame))
which appears to give a dataframe with 100 eelements, each of which is a list with 21 elements - the 21 fields from within itemClassData.

Limit_on_close

Hi,

I seem to be getting bet failures when using the limit on close functionality:

Back bet example at BSP which is working well
placeOrders(
marketId=nmarketId,
selectionId=nselectionId,betSide="BACK",
betSize=2,
reqPrice="1.01",
betType="MARKET_ON_CLOSE",
persistenceType="MARKET_ON_CLOSE",
customerRef=nref,
sslVerify=FALSE)

Lay bet example at BSP which is limit on close and is not working - have i got syntax wrong at all?
placeOrders(
marketId=nmarketId,
selectionId=nselectionId,
betSide="LAY",
betSize=nstake,
reqPrice="5.00",
betType="LIMIT_ON_CLOSE",
customerRef=nref,
sslVerify=FALSE)

Many thanks

Jake.

listMarketBook function

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,

Betfair balance

Hi Phill,

It would nice to be able to access your betfair balance so that I could instruct the automated program to bet a proportion of bank rather than flat stakes.

It would also be great if it were possible to access profit and loss (or just simple account bet result data) in order to produce daily/weekly betting reports relevant to selections.

Many thanks,

Jake.

listCurrentOrders does not include all parameters

The listCurrentOrders function does not currently include the customerOrderRefs and customerStrategyRefs parameters. These are optional parameters which can be used to restrict the results to particular customer order/strategy refs.

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.