tradedVolume in listMarketBook

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • doctormike
    replied
    tradedVolume continued

    Hi Denis,
    Here is my "MktBook" class (this is all in Visual Basic):

    Code:
    Imports Newtonsoft.Json
    Imports Newtonsoft.Json.JsonTextReader
    Imports Newtonsoft.Json.JsonTextWriter
    Imports Newtonsoft.Json.Converters
    
    Public Class MktBook
        <JsonProperty(PropertyName:="result")> _
        Public Property Result() As List(Of PriceInfo)
    End Class
    Public Class PriceInfo
        <JsonProperty(PropertyName:="marketId")> _
        Public Property MarkId() As String
    
        <JsonProperty(PropertyName:="numberOfWinners")> _
        Public Property NumberOfWinners() As Integer
    
        <JsonProperty(PropertyName:="numberOfActiveRunners")> _
        Public Property NumberOfActiveRunners() As Integer
    
        <JsonProperty(PropertyName:="runners")> _
        Public Property Horses() As List(Of RaceHorse)
    End Class
    
    Public Class RaceHorse
        <JsonProperty(PropertyName:="selectionId")> _
        Public Property sId() As Long
        <JsonProperty(PropertyName:="status")> _
        Public Property Status() As hseStatus
        <JsonProperty(PropertyName:="adjustmentFactor")> _
        Public Property Adjust() As Double
        <JsonProperty(PropertyName:="removalDate")> _
        Public Property RemTime() As Date
        <JsonProperty(PropertyName:="ex")> _
        Public Property Exes() As ExchangeP
        <JsonProperty(PropertyName:="totalMatched")> _
        Public Property TotMatched() As Double
        <JsonProperty(PropertyName:="lastPriceTraded")> _
        Public Property LastPriceTraded() As Double?
    End Class
    <JsonConverter(GetType(StringEnumConverter))> _
    Public Enum hseStatus
        ACTIVE
        WINNER
        LOSER
        REMOVED_VACANT
        REMOVED
    End Enum
    
    Public Class ExchangeP
        <JsonProperty(PropertyName:="availableToBack")> _
        Public Property Backps() As List(Of PSize)
        <JsonProperty(PropertyName:="availableToLay")> _
        Public Property Layps() As List(Of PSize)
        <JsonProperty(PropertyName:="tradedVolume")> _
        Public Property TradVol() As List(Of PSize)
    End Class
    Public Class PSize
        <JsonProperty(PropertyName:="price")> _
        Public Property p() As Double
        <JsonProperty(PropertyName:="size")> _
        Public Property s() As Double
    End Class
    To employ this class to acquire traded volume:

    Code:
    Dim ListMarketBookResponse As Object = Nothing
    Dim strRequest As String = ""
    Dim strMarketBook As String = ""
    strRequest = "{""jsonrpc"": ""2.0"", ""method"": ""SportsAPING/v1.0/listMarketBook"", ""params"": {""marketIds"":[""" & marketId & """],""priceProjection"":{""priceData"":[""EX_BEST_OFFERS"",""EX_TRADED""],""exBestOffersOverrides"":{""bestPricesDepth"":1}}}, ""id"": 1}"
    ListMarketBookResponse = CreateRequest(strKey, strSessTok, strRequest)
    strMarketBook = ListMarketBookResponse.ToString
    Dim objJson = Newtonsoft.Json.JsonConvert.DeserializeObject(Of MktBook)(strMarketBook)
    Dim pHse As Double
    Dim sHse As Double
    Dim vpHse As Double
    Dim vsHse As Double
    For y As Integer = 0 To objJson.Result.Count - 1
    With objJson.Result(y)
    Dim mktRef As String = .MarkId
    Dim listHse As List(Of RaceHorse)
    listHse = .Horses
    For Each Hse As RaceHorse In listHse
    With Hse
    Dim totvol As Double = .TotMatched
    Dim stat As hseStatus = .Status
    Dim selRef As Long = .sId
    Dim adfactor As Double = .Adjust
    Dim exHse As ExchangeP = .Exes
    Dim psHse As List(Of PSize) = exHse.Layps
    Dim pHse As Double
    Dim sHse As Double
      If psHse.Count > 0 Then
      pHse = psHse.Item(0).p
      sHse = psHse.Item(0).s
      Else
      pHse = Nothing
      sHse = Nothing
      End If
    Dim volHse As List(Of PSize) = exHse.TradVol   
    If volHse.Count > 0 Then
    For Each pitem As PSize In volHse
     With pitem
     vpHse = pitem.p
     vsHse = pitem.s
    End With
    Next
    Else
    ........
    End If
    ......
    End With
    ......
    Next
    .......
    End With
    I've left out the code I use to subsequently use this info as you will have your own ideas on that. I'm not sure if this is what you wanted - hope it is helpful.
    With regards
    Mike

    Leave a comment:


  • doctormike
    replied
    tradedVolume

    Hi, I use this string successfully:
    Code:
    strRequest = "{""jsonrpc"": ""2.0"", ""method"": ""SportsAPING/v1.0/listMarketBook"", ""params"": {""marketIds"":[""" & marketId & """],""priceProjection"":{""priceData"":[""EX_BEST_OFFERS"",""EX_TRADED""],""exBestOffersOverrides"":{""bestPricesDepth"":1}}}, ""id"": 1}"
    Will post details of the associated market book class & additional code shortly.

    With regards
    Mike

    Leave a comment:


  • denimen.
    started a topic tradedVolume in listMarketBook

    tradedVolume in listMarketBook

    Hi,

    I can't seem to get the tradedVolume in API response,

    I'm using the live api key (not 1.0-DELAY) and its still empty.

    here is my request json:
    Code:
    { "jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketBook", "params" :{"marketIds": [1.118647953], "priceProjection":{"priceData": ["EX_BEST_OFFERS"],"virtualise":"true"}}, "id": 1}

    I've tryed the EX_TRADED combinations with priceData but no job done. Any help or comment would be appreciated.

    Thanks,
    Denis
Working...
X