Forums

General Betting

Welcome to Live View – Take the tour to learn more
Start Tour
There is currently 1 person viewing this thread.
Feck N. Eejit
19 Apr 12 16:12
Joined:
Date Joined: 10 Jan 02
| Topic/replies: 8,841 | Blogger: Feck N. Eejit's blog
If 3 different functions each have a limit of 60 per minute does that mean you can call each of them 60 times inside 60 seconds (a total of 180 calls)?

While I'm at it, in a place market does the ifWin and ifLoss fields of the GetMarketProfitAndLoss response just return the prospective winnings and liability respectively for matched bets on an individual horse (i.e. they don't take into account any bets on other horses)?
Pause Switch to Standard View Free API limits
Show More
Loading...
Report Feck N. Eejit April 19, 2012 7:32 PM BST
Damn it. RESPECT MY AUTHORITAH.
Report gus April 19, 2012 7:42 PM BST
On the first question, yes, the throttles apply to each function individually, so you can call the 3 functions 60 times each within the same minute.

On the second ... I've never used getMarketProfitAndLoss, but looking at the manual it says that for a Multi-Winner Line Market (e.g Horse Place Markets):


ifWin: If this selection is the winner, this is the profit and loss for the market (based on matched bets only)


ifLoss: If this selection is the loser, this is the profit and loss for the market (based on matched bets only)

http://bdphelp.betfair.com/API6/6.0/RefGuide/wwhelp/wwhimpl/js/html/wwhelp.htm

you'd need to use getProfitAndLoss in getBet to get the P/L for an individual runner i think.
Report gus April 19, 2012 7:46 PM BST
Sir ! Happy
Report Feck N. Eejit April 19, 2012 7:49 PM BST
Cheers gus. On the place market question I found this earlier but I always thought the place P/L was a bit more sophisticated than just displaying the P/L for each individual selection.

http://help.betfair.com/contents/itemId/i65767349/index.en.html
Report Feck N. Eejit April 19, 2012 7:50 PM BST
Place markets and markets where there can be more than one winner: The left-hand figure is your profit/loss on that selection if it is placed. The right-hand figure is your profit/loss if it is not placed. Calculations are made from your matched bets on each selection independently.
Report Baby Jesus April 19, 2012 11:52 PM BST
As long as you're a bit creative by alternating calls and not covering lots of markets at once the free API should easily cover most peoples needs. Or are you going to start hammering the markets with some uber trading bot , Feck ?

Worth remembering those 60 p/m calls can be called anytime within that minute rather than 1 per second, I'd imagine it resets on the minute bit like the transaction charge limits reset on the hour.

GetMarketProfitAndLoss can't accurately cover the place markets because there could be many different outcome with 3 or more places up for grabs each with their own different pnl's, it just gives you a win or loss figure for each horse separately
Report TheInvestor2 April 20, 2012 12:06 AM BST
This is what those bots have done!
http://www.youtube.com/watch?v=768h3Tz4Qik
Report Feck N. Eejit April 20, 2012 9:47 AM BST
Thanks BJ.

Investor, drugs are bad m'kay.
Report Feck N. Eejit April 20, 2012 5:02 PM BST
Anybody know if there's a way to get ALL your matched and unmatched bets for a particular market in one call. I've seen it asked on the bdp forum but it was not answered definitively.

Would a call to the getMUBets function (https://docs.developer.betfair.com/betfair/#!page=00008360-MC.00008315-MC) with the matchedSince parameter set 1900-01-01 work?
Report Feck N. Eejit April 20, 2012 5:03 PM BST
*set to
Report Contrarian April 20, 2012 5:23 PM BST
Feck,

You just have to make a call to getMUBets, with the betStatus set to MU, and specifying the relevant marketId.

This will return up to a maximum of 200 matched and unmatched bets for that market. Of course if you have more than 200, you have to use more than 1 call.
Report Contrarian April 20, 2012 5:24 PM BST
The matchedSince parameter can be omitted in this case.
Report Contrarian April 20, 2012 5:28 PM BST
Paul,

Back again already?
Report gus April 20, 2012 5:33 PM BST
you're better to use no parameters other than the marketId Feck, that way it'll return all of your Matched and UnMatched Bets for that market (up to a maximum of 200 bets) ... if you think you may have more than 200 Bets (which perhaps you might if one of your megaWagers has been matched in dribs and drabs) then you'd have to be a bit more sophisticated, iterating getMUBets with the startRecord parameter = 0 , then 200 and so on, until you'd got them all, in which case you might need to be careful about Data Call charges.
Report gobetween April 20, 2012 5:51 PM BST
you snitch Contrarian?
Report JLivermore April 20, 2012 5:52 PM BST
Feck - are you aware of the bdp forum?  It's probably a better resource than here.

http://forum.bdp.betfair.com/
Report gus April 20, 2012 5:56 PM BST
sorry Contrarian ... i was researching my reply to Feck, while you were answering him, so i didn't see you'd already anwered Sad
Report catfleppo April 20, 2012 6:07 PM BST
When is the Feckbot due to be launched?
Report Ghetto Joe April 20, 2012 6:20 PM BST
JLivermore , never anyone on the bdp forum to answer :(

Like others have said feck, getMUBets with the marketID should be enough but you also have the lite calls and Get Current Bets etc.

With some of my stuff I keep a track of the betIDs of bets and then send a getMUBets with an array of betids rather than marketID as some of my stuff overlaps. None of my stuff exceeds the 200 bets but if it did it'd be easy to split any arrays into separate chunks
Report Contrarian April 20, 2012 6:23 PM BST
Paul,

I didn't grass you up.

It was probably one of the other people you've been harassing today (narrows it down to about 8 suspects).
Report Feck N. Eejit April 20, 2012 6:38 PM BST
Contrarian, gus, thanks but I was aware of the 200 record limit and that was what was putting me off as a) each call contributes towards the 60 p/m limit and b) something could be matched between calls or maybe even RF's applied. If you read that link I put up to the getMUBets documentation it states (for the matchedSince paramater) "Specifies a date and time to start from for the list of returned bets..... If you use the matchedSince parameter and you have specified a betStatus of MU, the bets returned will ignore any limit you set (using recordCount) for the number of records to be returned. Specifying a betStatus of MU causes the API to return your unmatched bets along with the matched ones." To me this suggests if you set that parameter (to 1/1/1900) it will return them all at once even if there is more than 200. If that's the case though I'm surprised that it did not form the basis of a reply to a couple of similar questions on the bdp forum.

Also, if you look at the getCurrentBets documentation there's no mention of a limit on the recordCount parameter. That suggests if you set the marketId=0 it will return every matched and unmatched you have on the exchange across all markets. It would seem strange that they're actually steering you towards retrieving more info than you actually require.

JLivermore, thanks for the link. I was aware of it but two similar questions were unanswered on it.

catfloppo, hopefully around June when I'd normally start back on the flat. It's taken me longer than I thought though as I had to make a lot of changes to my programme to support it and, as is always the case with coding, one change seems to require two changes elsewhere which in turn ..... Cry

Joe, I glanced at the lite call but it looked as though it didn't tell you if the bet was a back or a lay. Is that the case? I thought about keeping track of my own betIDs but this just seemed as though it would support a cleaner bit of coding.
Report Feck N. Eejit April 20, 2012 6:41 PM BST
I should've bolded If you use the matchedSince parameter and you have specified a betStatus of MU, the bets returned will ignore any limit you set (using recordCount) for the number of records to be returned

Also, not that the getCurrentBets I mention in the 2nd para referes to a different function in case you're a speed reader.
Report Feck N. Eejit April 20, 2012 6:49 PM BST
I don't want to start coding only to find out later that it's just sh1t documentation.
Report Feck N. Eejit April 20, 2012 7:06 PM BST
Where is Captain Hindsight when you need him? Cry
Report Contrarian April 20, 2012 7:37 PM BST
Feck,

You're right that the documentation leaves that open as a possibility (that you could get more than 200 bets returned), but I think it EXTREMELY unlikely. They impose those limits for a reason - partly to prevent us from hogging the servers if we happen to be operating with large numbers of MUbets - and I'm sure that it wouldn't be possible to circumvent them in the way that you're suggesting.
Report Contrarian April 20, 2012 7:46 PM BST
Just tested it for getMUBets, and if you have > 200, and specify an early date as you suggested, it just returns exactly 200 bets.
Report Feck N. Eejit April 20, 2012 8:16 PM BST
Thanks for your trouble Contrarian. What about the getCurrentBets with marketId=0. No mention of a limit on recordCount although if there isn't then it's an invitation to hog the servers even more.
Report Feck N. Eejit April 20, 2012 8:18 PM BST
If you use the matchedSince parameter and you have specified a betStatus of MU, the bets returned will ignore any limit you set (using recordCount) for the number of records to be returned

Sh1t documentation is right. How do they manage an error like that?
Report Feck N. Eejit April 20, 2012 8:21 PM BST
Having read the bdp forum and noted the comments regarding getMarketPricesCompressed returning incorrect market status values finding out the documentation is unreliable is no shock but it does not inspire confidence.
Report Contrarian April 20, 2012 8:39 PM BST
Feck,

I'll test it in a bit. I'm just doing the Mainz game at the moment.
Report Feck N. Eejit April 20, 2012 8:40 PM BST
Thanks Contrarian. No rush.
Report Contrarian April 20, 2012 8:57 PM BST
Feck,

I just tested the getCurrentBets with marketId = 0, and 380 unmatched bets, and it does work! The downside, though, is that you have to specify either M or U, you can't do MU. So you're still going to have to do 2 calls to the exchange. It does make the programming much simpler though.
Report Contrarian April 20, 2012 8:59 PM BST
It's also possible that getCurrentBets will be dropped sooner or later. They "recommend" using the newer getMUBets, which mean that in the next version of the API, getCurrentBets is not included.
Report catfleppo April 20, 2012 9:21 PM BST
What next version?
Report Contrarian April 20, 2012 9:24 PM BST
cat,

I'm just assuming that there will be a next version!
Report catfleppo April 20, 2012 9:25 PM BST
Phew!  I'm surprised there hasn't been yet, I'm still using v5!
Report Feck N. Eejit April 20, 2012 9:32 PM BST
Thanks a lot Contrarian, you've probably saved me wasting a lot of time. The getMUBets documentation is a load of sh1te, the getCurrentBets documentation is a load of sh1te and, going by the forum, the GetMarketPricesCompressed Status is a load of sh1te. It does sound like a betfair api.
Report Contrarian April 20, 2012 9:40 PM BST
No problem.
Report catfleppo April 20, 2012 9:44 PM BST
Good luck with the project Feck.  Unless you start pinching money off me of course Excited
Report Feck N. Eejit April 21, 2012 7:56 AM BST
Thanks catfloppo, you needn't worry as most of my bets will be elsewhere.

I think Joe's way is the way to go but it means having to note the betid of every bet you place so you're only sending unmatched betid's in the betid array (in that case I'd probably be sending at most 1 betid per runner which would be way short of the 200). A call that would send back a summary of matched bets for each runner (potential profit and stake) along with unmatched bets in one call would've saved a lot of coding.

Another thing that really shocked me was that you're unable to specify you're not betting ir when submitting bets (to combat the bet just being sent as the market goes in play). It's not even like you can call up the market status right after and cancel immediately as you're stuck behind the clock. Is that a bertie bonus for mugging crews or something?
Report catfleppo April 21, 2012 3:07 PM BST
The three forumites should take reponsibility for their own actions
Report Contrarian April 21, 2012 3:52 PM BST
Paul, you, pathetic little c0ck, what I saw was that you had a little fit, and starting abusing me as well as some other forumites.

By the way, have you seen this video?

http://www.youtube.com/watch?v=Vwigmktix2Y
Report gobetween April 21, 2012 4:07 PM BST
yes but i see no reason for you to post videos of your family on a public forum. show some dignity idiot
Report Ghetto Joe April 21, 2012 4:11 PM BST
Not much you can do to avoid hitting the market just as it goes inplay Feck, I do a getprices call before submitting any bet for latest prices and just use the inplay flag in the response to avoid betting inplay that's probably the best you can do to avoid it.
Report Feck N. Eejit April 21, 2012 4:59 PM BST
Thanks Joe. I read a few posts on the bdp forum that suggested the marketstatus and inplay values returned by the getmarketpricescompressed weren't exactly 100% reliable but I suppose there's not much else you can do. The absence of a flag in placebets that you can set to signify you don't want ir is a shocking omission.
Report Ghetto Joe April 21, 2012 7:45 PM BST
Only other thing I'd suggest is you could consider including a BSP limit bet in each bet array. Usually if a bet is rejected in a placebet request it rejects all the bets in that request so a BSP bet placed after the off would be rejected. By sending a BSP limit bet you'd be able to send a valid bet that had no chance of being matched i.e. lay £10 liability with a max price of 1.1 on an outsider.
Report Feck N. Eejit April 21, 2012 9:38 PM BST
Good idea Joe. Even without that, I suppose the duration of the suspend at the off would probably be enough to save me in cases where the api was working as it should.

I think I've got a rough idea now of how to track my bets but one thing I'm not sure of is, if I detect a horse has been withdrawn I take it I can find what backs have been automatically cancelled by calling getCurrentBets with marketID=0 but do I call it with betStaus=C or betStaus=V?
Report Feck N. Eejit April 21, 2012 9:39 PM BST
*I take it I can find what lays have been automatically cancelled
Report Feck N. Eejit April 21, 2012 10:23 PM BST
if I detect a horse has been withdrawn I take it I can find what backs have been automatically cancelled by calling getCurrentBets with marketID=0 but do I call it with betStaus=C or betStaus=V?

I'm talking about the lays betfair automatically cancel when a horse is withdrawn and has a RF>0. I'm no longer sure if you can retrieve these using getCurrentBets. Anyone know?
Report Feck N. Eejit April 22, 2012 9:29 AM BST
Forget those last 3 posts regarding cancelled bets. I'm hoping I've found a way of processing a race without having to store betId's or worry about withdrawals and RF's.

The information I need is

a) My stakes matched so far and average odds obtained on each individual runner (after any RF's).
b) My current unmatched bets in system.
c) The current state of the market (i.e. odds and stakes on offer).

For place markets a) can be obtained simply by calling getMarketProfitAndLoss. For win markets I'm thinking I'll call getCurrentBets for the appropriate MarketID with betStatus M and total the matchedSize and profitAndLoss fields by selectionID. I'm not using getMUBets for this because of the returned records limit and the fact it could theoretically return 200 records for one £2 matched bet (I require only a summary on matched bets).

I'll get b) by calling getMUBets with betStatus U. This will only return 1 record per betId and, as I don't expect to have any more than 2 or 3 unmatched bets per runner, this will be well within the 200 max record limit.

[Note: I could skip b) altogether if getCurrentBets accepted a betStatus of MU in the request but Contrarian said it didn't with marketID=0 and the documentation says you must choose M or U if a marketID is supplied.]

For c) I'll call getMarketPricesCompressed.

The information from a,b & c will allow me to cancel any unwanted bets, and update / add to existing unmatched bets based on my opinion where the value is. After that I can then move on to process the next market (or re-process that one) without the need to store or track anything.

As I've yet to try any of this I may be misunderstanding the less than reliable documentation so if anyone sees any pitfalls (beyond the obvious changes between calls) I'd welcome your comments.
Report Feck N. Eejit April 22, 2012 9:36 AM BST
Once I've worked out a Kelly type staking formula I'm hoping I'll be able to use the getMarketProfitAndLoss for both place and win markets for a) but I'm anticipating coming up with this formula will be no easy task. Any links to Kelly formula for multiple bets in same event that takes into account back and lay bets already placed gratefully received.
Report catfleppo April 22, 2012 10:25 PM BST
I think he was merely satirising your apparent inability to recall any of a threads preceding posts.  Your questions do appear, at least on occasions, much like the blinking man in the video, as if you have only just joined the forums.  Which actually you usually have Excited
Report Contrarian April 23, 2012 11:02 AM BST
bob,

No, I don't admit that at all. As Cat says, it was a bit of satire.

There's a distinction between bullying (e.g. your constant attempts to ridicule certain regulars on the football forum), and a bit of gentle mockery. You have to ask yourself why you're on about your 25th forum name, while I've managed to keep the same one for nearly 9 years.
Report Feck N. Eejit May 16, 2012 1:20 PM BST
Does getAccountStatement work properly. Regardless of what I set Req->startDate to (even today's date) I get the same 52 records returned that belong to over a month ago.

GetAccountStatement *Req = new GetAccountStatementRequest;
Req->header = new NS_BFExchangeService::APIRequestHeader;
Req->header->sessionToken = SessionToken;

int FetchSize=20000;
Req->recordCount=FetchSize;
Req->startDate=new TXSDateTime;
Req->startDate->AsDateTime=TDateTime().CurrentDate();
Req->endDate=new TXSDateTime;
Req->endDate->AsDateTime=TDateTime().CurrentDate();
Req->itemsIncluded=AccountStatementIncludeEnum::EXCHANGE;


While I'm at it, if anyone uses c++, can you tell me why I've got to use new to create the startDate and endDate request variables whereas the Request constructers for all other api functions seems to take care of creating / destroying internal variables.
Report JLivermore May 16, 2012 6:48 PM BST
It works fine, imho.

It wont return all your bets in one call.

I'm not sure you can set recordCount to >100
You need to use startRecord to page through the items

Make a call, you should get totalRecordCount > 100.  Then increment startRecord by 100 and call again.  If you are getting totalRecordCount =52 and you are certain you have more settled bets than this then your call has something wrong with it (you can't infinitely old bets).

rinse and repeat.
Report Feck N. Eejit May 16, 2012 7:06 PM BST
Thanks for the reply JL. The FetchSize=20000 was just part of a test but there's no mention of a limit in the documentation. I wasn't expecting any more than 52 records (that's all my activity within the last 3 months), I was expecting zero as I set the startDate to today and my last activity was around a month ago.

PS You're only allowed a call a minute with the free API so if you don't get all the records in a oner you have to wait a minute before the second call or it returns API_ERROR.
Report JLivermore May 16, 2012 10:13 PM BST
ok, I'm with you now.

Are you submitting a datetime instead of a date?

startDate    Y    Date    Return records on or after this date
endDate    Y    Date    Return records on or before this date

http://docs.developer.betfair.com/betfair/#!page=00008360-MC.00008318-MC
Report subversion May 17, 2012 3:38 AM BST
If itemsIncluded = EXCHANGE, the startdate and endate properties on the GetAccountStatementReq are ignored. startDate and endDate are used when itemsIncluded = ALL
Report Feck N. Eejit May 17, 2012 9:05 AM BST
Ah, thanks subversion. Staring me in the face.
Report The_E_Dead_Group June 1, 2012 11:56 AM BST
Yesterday was the first chance I had to test the GetAccountStatement function. As subversion kindly pointed out setting ItemsIncluded to ALL means the startDate and endDate properties are ignored BUT, as I found out yesterday, if I set ItemsIncluded to ALL then NO_RESULTS is returned. I had to set it to EXCHANGE to get yesterdays bets.

Feck here BTW.
Report The_E_Dead_Group June 1, 2012 12:06 PM BST
I suppose it depends on how you bet but does anyone else agree with me that if getMarketProfitAndLoss for Win markets just restricted the potential profit and loss figures to wagers on the runner in question (the way it does in place markets) api life would be so much easier? It would be a simple job to use those figures to determine the P/L for each runner over the market as a whole (so no loss there) yet it would enable us to gain a summary of bets so far without having to keep running totals (watching out for RF's) or calling getCurrentBets and summing all bets so far.
Post Your Reply
<CTRL+Enter> to submit
Please login to post a reply.

Wonder

Instance ID: 13539
www.betfair.com