Go Back   Developer Program Forum > Sports API > General Sports Programming

General Sports Programming General Sports API programming discussion

Post Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2012, 08:26 PM
HotCalix HotCalix is offline
Junior Member
 
Join Date: May 2011
Posts: 3
Unhappy In-Play specific runner Profit And Loss calculation formula

Hi all,

I'm struggling to find a way of calculating this:

Supose we've backed a runner with 100€ @ 12.00
The market moved in our favour and we layed 2€ @ 9.00

What is my current liability for this specific runner?
What is my current profit and loss for this specific runner?

The market moves again in our favour, and we wish to display a possible profit if we lay 2 @ 6.00

Is there anyway of doing this with the api?

Thank you for your time.
  #2  
Old 04-10-2012, 09:55 PM
wotsisname wotsisname is offline
Senior Member
 
Join Date: Jan 2009
Posts: 217
Default

This API may help: https://docs.developer.betfair.com/b...MC.00008308-MC


When trading bets, it's best to work to a "target" value. This will spread the profit equally across all runners:
Code:
target = backPrice x backSize
laySize = target / layPrice


therefore...


target = 12.0 x 100€
target = 1200€
laySize = 1200€ / 9.0
laySize = 133.33€



Quote:
Originally Posted by HotCalix View Post
What is my current liability for this specific runner?
You have to calculate the worst possible outcome:
Code:
backBetLiability = backBetSize
layBetLiability = layBetSize x (layBetPrice - 1)
if backBetLiability > layBetLiability:
    totalLiability = backBetLiability - layBetLiability
else:
    totalLiability = layBetLiability - backBetLiability


therefore...


backBetLiability = 100€
layBetLiability = 2€ x (9.0 - 1)
layBetLiability = 16€
totalLiability = 100€ - 16€
totalLiability = 84€



Quote:
Originally Posted by HotCalix View Post
What is my current profit and loss for this specific runner?
Code:
ifRunnerWins = (backSize x (backPrice - 1) - (laySize x (layPrice - 1))
ifRunnerLoses = laySize - backSize


therefore...


ifRunnerWins = (100€ x (12.0 - 1) - (2€ x (9.0 - 1))
ifRunnerWins = 1084€
ifRunnerLoses = 2€ - 100€
ifRunnerLoses = -98€
__________________
http://www.bespokebots.com
  #3  
Old 04-10-2012, 10:08 PM
wotsisname wotsisname is offline
Senior Member
 
Join Date: Jan 2009
Posts: 217
Default

I missed your last question in post #1...


Quote:
Originally Posted by HotCalix View Post
The market moves again in our favour, and we wish to display a possible profit if we lay 2 @ 6.00
Again, you have to calculate it.

Code:
layBetLiability = 2€ x (6.0 - 1)
layBetLiability = 10€


using the values we calculated previously...


ifRunnerWins = 1084€ - 10€
ifRunnerWins = 1074€
ifRunnerLoses = -98€ + 2€
ifRunnerLoses = -96€
__________________
http://www.bespokebots.com
  #4  
Old 04-10-2012, 10:31 PM
HotCalix HotCalix is offline
Junior Member
 
Join Date: May 2011
Posts: 3
Smile Brilliant !

A million thank yous...

You have earned another brick to your suite in heaven...
  #5  
Old 04-11-2012, 02:03 AM
HotCalix HotCalix is offline
Junior Member
 
Join Date: May 2011
Posts: 3
Lightbulb The Green Button

I'm trying to combine all the previous math i've learned with you, my final goal is to place a "Green Button" in front of each runner, do i need additional calculation, or the previous math shown is enough?

Thank you for your time.
Post Reply

Tags
runner profit & loss

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 04:13 AM.


BETFAIR® and the BETFAIR LOGO are registered trade marks of The Sporting Exchange Limited. Data on Betfair website(s) (including pricing data) is protected by © and database rights. It may not be used for any purpose without a licence. © The Sporting Exchange Limited. All rights reserved.