Announcement

Collapse
No announcement yet.

Profit Calculation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Profit Calculation

    Hello,

    Can someone please explain me if what is stated as "averagePriceMatched" in CurrentOrderSummary is the weighted average price matched or simply the average.

    Because I am trying to figure out if I can calculate by myself the profit. So if lets say my initial bet was £10@2.6 and got matched £5@2.6 and £5@2.7.
    Can someone tell me what Betfair will return to me as "averagePriceMatched"? Because if it is just the average 2.6+2.7 / 2 = 2.65. Then obviously I will not be able to calculate the profit by myself.

    Thanks in advance

  • #2
    PLV,
    It's a weighted average - your example's not great, as an equal split of £5 at each price will return the same either way, but if it was matched as £8@2.6 and £2@2.7 it would return (8 x 2.6 + 2 x 2.7) / 10 = 2.62

    It also gets rounded to 2 decimal places, so if you need a figure accurate to the penny, you need to check the individual fragment matches using listMarketBook with the orderProjection set to 'EXECUTION_COMPLETE' and the matchProjection set to 'NO_ROLLUP'.

    Cheers,

    Merlin

    Comment


    • #3
      Hi,

      If you want a slightly different approach I today posted some VB that I am using to call for the cashout available in the same way Betfair pages do it.

      Comment


      • #4
        hello Neil W., where can we find those VB calls? thanks

        Comment


        • #5
          this is the vb for getting the cashout values
          you need a marketid your token and appkey, think the thought police may have got to my thread. Be quick.

          Function MarketCashoutAvailable(MarketID As String) As Single


          Dim oHTTP As New MSXML2.XMLHTTP60

          AppKey="my appkey"
          token="my token"


          sReq = "http://www.betfair.com/cashout-service/readonly/v1.0/quote?alt=json&currencyCode=GBP&marketIds=" & MarketID

          With oHTTP

          ' .Open "POST", "https://api.betfair.com/exchange/account/json-rpc/v1"
          .Open "GET", sReq, 0

          .setRequestHeader "Host", "www.betfair.com"
          .setRequestHeader "Connection", "keep-alive"
          .setRequestHeader "Cache-Control", "Max-age=0"
          .setRequestHeader "X-Application", AppKey
          .setRequestHeader "Content-Type", "application/json"
          .setRequestHeader "Accept", "application/json"
          .setRequestHeader "X-Authentication", token
          End With


          oHTTP.send sReq


          returnstring = oHTTP.responseText



          End Function

          Comment


          • #6

            Thank you for answer.
            I didnt understand document. how to use betfair api in c# ??

            Comment

            Working...
            X