Betfair API-NG

Post Reply
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Web app example posted on betfairs github:

https://github.com/betfair/sample-web-app-vendor

Any plans for a betangel web app in the future Peter?
User avatar
jimibt
Posts: 3641
Joined: Mon Nov 30, 2015 6:42 pm
Location: Narnia

c# example on github from a few days back... good basic usage example that will no doubt grow:

https://github.com/betfair/stream-api-sample-code
User avatar
Euler
Posts: 24700
Joined: Wed Nov 10, 2010 1:39 pm
Location: Bet Angel HQ

LinusP wrote:Any plans for a betangel web app in the future Peter?
Currently tackling streaming.
User avatar
LeTiss
Posts: 5386
Joined: Fri May 08, 2009 6:04 pm

Euler wrote:
Currently tackling streaming.
Really?

Whilst that would be an extraordinary addition to the software, that must be grossly expensive surely?
User avatar
Euler
Posts: 24700
Joined: Wed Nov 10, 2010 1:39 pm
Location: Bet Angel HQ

LeTiss 4pm wrote:Whilst that would be an extraordinary addition to the software, that must be grossly expensive surely?
Yep, anything to do with the software always is :) It's a bugger to test on Bet Angel as well!
User avatar
Euler
Posts: 24700
Joined: Wed Nov 10, 2010 1:39 pm
Location: Bet Angel HQ

At the end of the day, the software has always been a long-term project for us and subscriptions help fund that longer term goal. But a cash cow, it ain't!
xitian
Posts: 457
Joined: Fri Jul 08, 2011 2:08 pm

Whoop whoop! CustomerStrategyRef and CustomerOrderRef now released.

http://forum.bdp.betfair.com/showthread.php?t=3278

Might be a handy feature if BetAngel would let you tag your bets with different strategy names so that you can compare performance easier. Maybe a bit niche for most people though.
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Async bet placement released tomorrow as well.

Not sure if I a man going to use the new ref attributes, as i handle everything off the betId.
xitian
Posts: 457
Joined: Fri Jul 08, 2011 2:08 pm

For me, it's always been a tricky problem reconciling bets on my end with an ID that isn't available until the bet placement procedure is fully complete (e.g. until 1 second later for in-play racing). During that waiting time, I don't want to be blocking, since I could be trading other runners or races, but I want to know that I have a bet pending. When that bet finally completes all I have is a betId from Betfair, but no easy way to determine what strategy that bet should relate to.

I guess I could have a thread for every horse I'm trading, but then I would end up needing over 1000 threads to trade all runners at once. I also might be trading different strategies on a single runner within one program.

There's the other edge case which has happened before where Betfair matching engine has been hugely bogged down and not returned bets until over 60 seconds later and given a timeout response in the meantime. In this situation I have no betId at all for the actual request, I just have a random bet appearing out of nowhere over 60 seconds later with no way to relate it back to my strategies' positions.

Now, with customerOrderRef and customerStrategyRef, I don't need to worry with betIds so much. I know that any order I place I'm giving them a customerOrderRef, and whenever a bet appears I can match that up to whichever strategy is waiting for it. In effect it's making asynchronous bet placement easier.

I can also restart my programs because although I may have bets for multiple strategies on one runner, through the customerOrderRef and customerStrategyRef I can recover where the program was before the restart. With just a betId, I'm lost unless I'm writing all this info to database or something.
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Interesting to hear how your programs work, as mentioned before I use an event driven framework so I do things slightly differently.

When one of my strategies receives an event that triggers an order it creates an order data structure (size/price/orderType) along with what I call a 'letter', this stores info on how this order should be processed later (fillkill/stop/greening/batching etc.)

The order and the letter get chucked in a queue, when processed in the main handler it starts a new thread to be executed. When the betId is returned the letter which holds the order and any related orders gets stored and is used when processing currentOrders, thread then dies. The order/letter data is then also sent to a RestAPI which I use for reconciliation and tracking profitability per strategy.

I suppose I could create an internal orderId and match it up when processing currentOrders but I am not seeing the benefit at the moment. I only operate in short lived markets, inplay horse racing, so I don't need to rebuild my order book if my programs need to be restarted, although this would be possible using my api.
xitian
Posts: 457
Joined: Fri Jul 08, 2011 2:08 pm

That's interesting. I don't think our structures are that different when you look at it from a high level. I suppose my strategies are constantly reacting to an event which is new data, and at that point they will either: request that a bet be placed if none already exists, cancel an existing bet and place a new one (i.e. update), just cancel an existing bet, or do nothing and leave things as they are. The bet placement part is an asynchronous call, so effectively queuing it up to be processed on a separate thread.

So in your system, what happens when an event triggers an order to be placed, but while the bet is being placed (during bet delay, say) another event triggers another bet, which shouldn't be triggered given that a bet is already being placed?

I have a central "order tracking" system which I can query to ask, for any specific runner, if there are any pending bets in the process of being placed, retrieve the status of any unmatched bets, and query the current matched position so that I can manage exposure. All of those things affect what bet I'm potentially going to place next. It's this order tracker which will really benefit from the customerOrderRef and customerStrategyRef, because now I won't need the betId at all. I'll just subscribe to the Order Streaming API and listen to the statuses of bets which I've assigned my own IDs to.
PeterLe
Posts: 3715
Joined: Wed Apr 15, 2009 3:19 pm

Morning,
Just a question about API Keys please
I had my API keys before Betfair announced a few months ago that they would be charging £299/Account
I'm just about to convert my existing BOTs/Accounts onto the streaming service but I understand that not only do you have to have your API keys, you also have to contact Betfair to 'enable' your account to use the use the streaming service.
I sent an email to BDP on Friday but haven't heard back yet.
Just wondered If anyone else had been through this
Thanks
Regards
Peter
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Hi Peter, Neil activated mine after about two days from sending an email.

Tbh not sure why its not open to everyone if they class it as in production.
PeterLe
Posts: 3715
Joined: Wed Apr 15, 2009 3:19 pm

Thanks Liam,
I just assumed that it would be enabled automatically, anyway we will see.
With a bit of luck Neil will switch mine on too
Hope things are going well for you!
Regards
Peter
(I've mentioned it before on here, but of all the touch points into Betfair, Neil in BDP always stands out in terms of his excellent customer service).
User avatar
marksmeets302
Posts: 527
Joined: Thu Dec 10, 2009 4:37 pm

Agreed, he should be on their balance sheet under 'goodwill'!
Post Reply

Return to “Betfair Exchange API”