VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,358 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,918 people online right now. Registration is fast and FREE... Join Now!




Betfair Green-Up

 

Betfair Green-Up, Looking for an algorithm

HiArt

2 Jul, 2009 - 11:24 AM
Post #1

New D.I.C Head
*

Joined: 14 Apr, 2008
Posts: 11

Hi Folks,

here is what I am trying to achieve:

Want to make £10 profit after Betfair commission.

Want to set my code so, let's say I back at 5.o and Lay at 4.0, it will calculate the Back stake and the Lay stake so, if matched, I would be guaranteed the profit target regardless of result.

Has anyone an algorithm that will get me some way to achieving this aim?

can handle Betfair API if I can sort out what the stakes are!

Ta

Art

User is offlineProfile CardPM
+Quote Post


PsychoCoder

RE: Betfair Green-Up

2 Jul, 2009 - 11:26 AM
Post #2

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,711



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks.
User is offlineProfile CardPM
+Quote Post

HiArt

RE: Betfair Green-Up

10 Aug, 2009 - 02:09 AM
Post #3

New D.I.C Head
*

Joined: 14 Apr, 2008
Posts: 11

OK, here goes....

We want to make £10 after 5% deduction.

x * 0.95 = 10
so
x = 10 / .95
rounded this makes x = £10.53 and this is the profit target.

Step 1 - Back a selection
==========================
In my first post I gave an example of backing at 5.0, so lets use this.
B is the amount I am backing for, giving rise to P as the potential profit should the selection win.
On Betfair you have to subtract 1 to get the true odds; e.g. 2/1 = 3.0 on Betfair

P = B * (5.0 - 1)

So if B = 100, P = 100 * (5.0 - 1) = 400

Step 2 - Lay a selection at lower odds
======================================
In my first post I gave an example of laying at 4.0, so lets use this.
L is the amount I am laying for, giving rise to M as the liability should the selection win.

M = L * (4.0 - 1)

So if L = 100, M = 100 * (4.0 - 1) = 300

I now in the situation that if the selection wins I win P but lose M; that is I win 400 and lose 300, a 100 profit.
If the selection loses, I lose B but win L; that is I lose 100 and win 100, no profit and no loss.

Step 3 - green up
======================================
Now I divide my potential profit (P - M) by the Lay odds and Lay at this value. Note that this time we DO NOT subtract 1 from the lay odds.

G = Potential Profit / 4.0

So, I have a potential profit of 100, I am Laying at 4.0 in this example, so G = 100 / 4 = 25
This generates an additional liability of 25 * (4.0 - 1), that is 75.00.

So the selections wins, I win 400, and lose 2 lay bets of 100 * (4.0 - 1) and 25 * (4.0 - 1) or 375, a profit of 25.
If the selection loses I lose my back stake (100) but win the Lay stakes of 100 + 25, a profit of 25.

Greened up nicely!

So, back to the original problem....
=====================================
What stakes should i use to return a profit target? Using 100 gave 25 profit, and I only wanted 10.53.

So if I divide 10.53 by 25 and multiply this by 100, I should get the stakes I am after.

10.53/25*100 = 42.12

let's see if this works:

P = 42.12 * 4 = 168.48
M = 42.12 * 3 = 126.36
Potential profit is 42.12
G = 42.12 / 4 = 10.53
Liability on G = 10.53 * 3 = 31.59

Selection wins, I win 168.48 but lose 126.36 + 31.59 = 10.53
Selection loses, I lose 42.12 but win 42.12 + 10.53 = 10.53

Woo Hoo.

So my solution is going to look something like this:
======================================================
Let X be my profit target
Let OB be the backing odds (as shown on Betfair)
Let OL be the laying odds (as shown on Betfair)

The Back Stake ( B ) will be
(X/0.95)/(((100*(OB-1))-(100*(OL-1)))/OL)*100

The Lay stake will be
=B+(((B*(OB-1))-(B*(OL-1)))/OL)

Let's check this
X = 10, OB = 5 and OL = 4
Back Stake = (10/0.95)/(((100*(5-1))-(100*(4-1)))/4)*100 = 42.11
Lay stake = 42.11+(((42.11*(5-1))-(42.11*(4-1)))/4) = 52.64

Win = (42.11 * 4) - (52.64 * 3) = 10.51
Lose = -42.11 + 52.64 = 10.53

Looks like a winner!

One more worked example just to make sure
X = 20, OB = 2.2 and OL = 1.23

Back Stake = (20/0.95)/(((100*(2.2-1))-(100*(1.23-1)))/1.23)*100 = 26.70
Lay stake = 26.70+(((26.70*(2.2-1))-(26.70*(1.23-1)))/1.23) = 47.76

Win = (26.70 * 1.2) - (47.76 * 0.23) = 21.06
Lose = -42.11 + 52.64 = 21.06

and 5% of £21.06 is £20.01

TA DA

Easy in the end....erm smile.gif

User is offlineProfile CardPM
+Quote Post

Bort

RE: Betfair Green-Up

10 Aug, 2009 - 07:46 AM
Post #4

VBort.NET
Group Icon

Joined: 18 Sep, 2006
Posts: 1,353



Thanked: 27 times
Dream Kudos: 350
My Contributions
QUOTE(HiArt @ 10 Aug, 2009 - 02:09 AM) *

and 5% of £21.06 is £20.01


blink.gif

Hmm...I see a small problem here...

Plus Psychocoder meant for you to show some effort with the programming aspect of it, not your number crunching.

Edit:
If you are not able or willing to do the coding part yourself, try putting your idea in the Post A Job forum.

This post has been edited by Bort: 10 Aug, 2009 - 07:49 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 07:37PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month