Reply to ribogio7 (re: Profit & Loss)
The values shown near each runner name are the profit & loss values. These are the amount you would win (or lose) if that particular runner were to win the event.
The API call getMarketProfitAndLoss returns a set of values, but it only takes into account your matched bets. The website shows the IfWin values for proposed (unsubmitted) bets. Neither of these sets are particularly useful if you want to assess your current situation if you have several bets (matched, unmatched and proposed) on a market, so it’s probably best to calculate your own values. At least that way you know what you're getting.
For each runner:
Define a class (say, BetInfo) to hold details of each bet on the market:
Use this class for both back and lay bets, but use +ve amounts for Back, and -ve amounts for Lay. This will simplify the calculations. For example:
An algorithm the calculate the IfWin values for each runner is this:
It’s up to you what bets are added to the bet lists - matched, unmatched or proposed. Bear in mind that unmatched bets may not, of course, be matched at the desired price.
The values shown near each runner name are the profit & loss values. These are the amount you would win (or lose) if that particular runner were to win the event.
The API call getMarketProfitAndLoss returns a set of values, but it only takes into account your matched bets. The website shows the IfWin values for proposed (unsubmitted) bets. Neither of these sets are particularly useful if you want to assess your current situation if you have several bets (matched, unmatched and proposed) on a market, so it’s probably best to calculate your own values. At least that way you know what you're getting.
For each runner:
IfWin = Total profits from back bets on this runner - Total losses from lay bets on this runner
- Total amount of back bets on other runners + Total amount of lay bets on other runners
Here is an idea to calculate the IfWin values:- Total amount of back bets on other runners + Total amount of lay bets on other runners
Define a class (say, BetInfo) to hold details of each bet on the market:
Code:
Class BetInfo 'A class for bet details Property price As Decimal Property amount As Decimal 'Use + for back, - for lay 'Other bet properties End Class
Bet1.amount = 5 for a Back bet
Bet1.amount = -5 for a Lay bet
When you place a bet add an instance of this class to a separate bet List for each runner to model the bets on the market. Hold the Lists for all the runners in an array (say, Bets()). Bet1.amount = -5 for a Lay bet
An algorithm the calculate the IfWin values for each runner is this:
Code:
Dim Bets() As List(Of BetInfo), IfWin() As Decimal, i, j, k, m As Integer
'Build the array of bet lists
'.....
m = Bets.Count - 1 'The number of runners - 1
ReDim IfWin(m) 'An array to hold the profit(or loss) values for each runner
For i = 0 To m 'For each runner
For j = 0 To m 'Look at all runners
For k = 0 To Bets(j).Count - 1 'For each bet on this runner
With Bets(j)(k)
If j = i Then 'Runner is winner
IfWin(i) += .amount * (.price - 1) 'Accumulate totals
Else 'Other runners
IfWin(i) += -.amount
End If
End With
Next
Next
Next


Comment