calling captain sensible: Mk-2

Discuss anything related to using the program (eg. triggered betting tactics)

Moderator: 2020vision

calling captain sensible: Mk-2

Postby rave154 » Wed Apr 30, 2008 4:14 pm

Hi again cap,

got well into converting my prior app which accessed BF using simple http...and am converting it to use the API. Got it to log in and get a list of events ( in my case horse racing ) with associated data ( market id's etc ).

Ok, now for the hard part....

in this app, i had it set up as a main app plus a seperate thread to handle the requests to BF for race-price data, the thread would then "post a message" ( Delphi term ) back to the main app to say "ok, your new data is ready"...

but now, with the api, the price-getting thread must "have" / "use" the same Session token as the main app aquired during the last call(whatever that may be, login, get events, whatever)...

My point is, whats the safest thread-safe way.......to allow the seperate price-getting thread to be always using the same session token as the was returned by the most recent Response from the API?

Any Ideas / frameworks appreciated.
rave154
 
Posts: 19
Joined: Mon Apr 21, 2008 6:46 am

Postby Captain Sensible » Wed Apr 30, 2008 6:35 pm

I just use php so not too sure how delphi handles global variables etc but with my scripts I just update the session token and APIRequestHeader after every API call so it holds the most recent sessiontoken response and then the upadated header is available for whenever the API is called again.

Delphi must have some way of either storing session variables or global variables as I guess your old prog must have had someplace to store the http session cookies for when placing bets etc.

After ever call I just check to see if the API returns an OK result then update the header and timestamp it so I can call keepalive if there's a large gap between the next call it makes.

if ( $loginresult->Result->errorCode == "OK")
{
// Setup the global header required for all calls
$BFHeader= new stdClass();
$BFHeader->clientStamp = 0; $BFHeader->sessionToken= $loginresult->Result->header->sessionToken;
$_SESSION['sessionToken']=$loginresult->Result->header->sessionToken;
$_SESSION['timestamp']=time();
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby rave154 » Sat May 03, 2008 5:13 am

Thanks Cap,gave me some ideas and i got something up and running.

In case it helps anyone esle, here it is

I placed two THTTPRIO comps on the main form, 1 for global 1 for exchange......and also a 3rd THHTPRIO......which will be used by the get_prices thread...now i know what yo umight be thinking...a seperate thread should not be using components on a main form as they are not "thread-safe"........but......since this is a non-visible comp....and since no other code in the main forms source will reference that 3rd THHTTP comp......then i think i should be safe. Also of course, my thread has a variable accessable from the main form callled s_token, which is set to my main forms CurrentSession using ..
Get_prices_thread.s_token := CurrentSession;
Get_prices_thread.Resume;
rave154
 
Posts: 19
Joined: Mon Apr 21, 2008 6:46 am

Postby rave154 » Sun May 04, 2008 4:48 pm

Me again, lol

Ive just noticed some weird behaviour when calling the GetMarketPricesCompressed call.

Im calling it 4 times a second ( hardly bashing the server)...and after about....20-30 seconds i get a blank response in the MarketPrices field of the response.....completely blank.

Anybody ever had this?
rave154
 
Posts: 19
Joined: Mon Apr 21, 2008 6:46 am

Postby rave154 » Sun May 04, 2008 4:54 pm

Ok, even stranger now,

I just set it to call twice a second just to make sure i wasnt breaking the 20 timews per second limit or anything....and sure enough i still geta blank response after 15-20 seconds......and..........continue getting a blank response after that for each call.

Am i getting blocked out here or something?
rave154
 
Posts: 19
Joined: Mon Apr 21, 2008 6:46 am

Postby rave154 » Sun May 04, 2008 4:56 pm

ahh * emabressed*..........i just realised, that call is restricted to 60 calls per minute............oops.......

so really........the free Api, is pretty useless for a real-time App, isnt it?
rave154
 
Posts: 19
Joined: Mon Apr 21, 2008 6:46 am

Postby Captain Sensible » Sun May 04, 2008 8:54 pm

Yep the throttle restriction comes into play after 60 calls in a minute rather than 1 per second. If your app needs quick prices for more than one market the free api isn't going to meet your needs.

For one market it shouldn't be too bad as you you can switch between Get Market Prices Compressed & Get Complete Market Prices Compressed to give a total of 120 calls a second without much extra coding which should easily be adaquate, even squeeze in an extra 10 using Get Market Prices.

There have been a few discussions regrading the caching of the prices and it's een said the data is only updated at betfairs cache twice a second so anything over that will just pull cached data anyway.

Dunno what your bots doing to need the data at 4 times a second,probably playing the overrounds ?, but you could always try a mix of web scraping (need to be logged in for fresh data now) and api. It's easy enough to set up other betfair accounts to start getting your call quota up too.
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby rave154 » Mon May 05, 2008 6:10 am

Thanks for the reply cap,

hmmmm interesting, i hadnt thought of using both two different api calls.

As for the data being cached and therefore anything requesting over twice per second will only return cached data...i dunno about that, i can say with my http code there is a signifanct difference in the data that comes in say twice a second.......and that which comes in at 4 times a second.......but.....thats http and not api......so i dont know for sure.
rave154
 
Posts: 19
Joined: Mon Apr 21, 2008 6:46 am


Return to Discussion

Who is online

Users browsing this forum: No registered users and 103 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.