Betfair Developers


Exchange API
Discussion about the Betfair Sports Application Programming Interface - API NG

Thread Closed
HotCalix HotCalix is offline
Junior Member
 
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.
wotsisname wotsisname is offline
Senior Member
 
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
wotsisname wotsisname is offline
Senior Member
 
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
HotCalix HotCalix is offline
Junior Member
 
Smile Brilliant !

A million thank yous...

You have earned another brick to your suite in heaven...
HotCalix HotCalix is offline
Junior Member
 
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.
Thread Closed

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