VBNet Sample (Yes really)

Collapse
This is a sticky topic.
X
X
 
  • Time
  • Show
Clear All
new posts

  • betdynamics
    replied
    You can't have the to and from date/times as the same value. Make the to date/time one minute later and everything should be dandy.

    Another thing to watch out for - when you get to British Summer Time, you will need to adjust your start times by one hour (as all date/times in the API-NG are UTC, i.e. GMT)

    Leave a comment:


  • SimonN
    replied
    Betdymanics,

    I can't thank you enough for getting that working for me ! Have been toiling over that for weeks!

    So simple when you know how! Whatever happened to straightforward comma separated lists, lol!!

    So now that I can change the range am trying to get it to work for one race eg Lingfield 1600 but just by making the from and to dates the same which I was hoping would be a simple next step is not working.

    Using your JSON string, I have:

    'EG> 16/10/2015 16:00:00 Lingfield

    Dim dFromDate As Date: dFromDate = #10/16/2015 4:00:00 PM#
    Dim dToDate As Date: dToDate = #10/16/2015 4:00:00 PM#

    '** Now you convert to the String **

    Dim FromDate As String: FromDate = Format(dFromDate, "yyyy-MM-ddTHH:mm:ssZ")
    Dim ToDate As String: ToDate = Format(dToDate, "yyyy-MM-ddTHH:mm:ssZ")


    But it is failing at line saying "Invalid Proc call or arg":

    GetMarketIdFromMarketCatalogue = Response.Item(1).Item("marketId")

    It's not getting the marketID - am fiddling and tracing - will let you know what if any progress I am able to make.

    Thank you!

    S

    Originally posted by betdynamics View Post
    I think your JSON string is incorrect.

    There is a closing brace in the wrong position which is truncating your filter parameter.

    Remove the closing } after ["WIN"] and move it to after the closing brace just after the second time so it becomes :33Z"}} (i.e. two closing braces).

    Your modified code string should be:

    GetListMarketCatalogueRequestString = "{""filter"":{""eventTypeIds"":[""" & EventTypeId & """],""marketCountries"":[""GB""],""marketTypeCodes"":[""WIN""],""marketStartTime"":{""from"":""" & FromDate & """,""to"":""" & ToDate & """}},""sort"":""FIRST_TO_START"",""maxResults"":" " 10"",""marketProjection"":[""RUNNER_DESCRIPTION"",""MARKET_START_TIME""]}"

    Leave a comment:


  • betdynamics
    replied
    I think your JSON string is incorrect.

    There is a closing brace in the wrong position which is truncating your filter parameter.

    Remove the closing } after ["WIN"] and move it to after the closing brace just after the second time so it becomes :33Z"}} (i.e. two closing braces).

    Your modified code string should be:

    GetListMarketCatalogueRequestString = "{""filter"":{""eventTypeIds"":[""" & EventTypeId & """],""marketCountries"":[""GB""],""marketTypeCodes"":[""WIN""],""marketStartTime"":{""from"":""" & FromDate & """,""to"":""" & ToDate & """}},""sort"":""FIRST_TO_START"",""maxResults"":" " 10"",""marketProjection"":[""RUNNER_DESCRIPTION"",""MARKET_START_TIME""]}"

    Leave a comment:


  • SimonN
    replied
    Hi All,

    I saw DaveCon's reply about date formatting on the APING thread and have tried it but whenever I try to amend the sample code to return a specific race meeting or range of race meetings after the first race meeting from now it ALWAYS returns the first race meeting from Now.

    Here is my string

    {"filter":{"eventTypeIds":["7"],"marketCountries":["GB"],"marketTypeCodes":["WIN"]},"marketStartTime":{"from":"2015-01-17T02:25:33Z","to":"2015-01-20T02:25:33Z"},"sort":"FIRST_TO_START","maxResults ":"10","marketProjection":["RUNNER_DESCRIPTION","MARKET_START_TIME"]}

    Rather than find races from Now, all I want to do is return a specific race meeting by date.

    Please can you help..code below

    Am using Excel VBA.

    Kind regards,

    Simon



    Dim dFromDate As Date: dFromDate = DateAdd("d", 1, Now)
    Dim dToDate As Date: dToDate = DateAdd("d", 3, dFromDate)


    '** Now you convert to the String **

    Dim FromDate As String: FromDate = Format(dFromDate, "yyyy-MM-ddTHH:mm:ssZ")
    Dim ToDate As String: ToDate = Format(dToDate, "yyyy-MM-ddTHH:mm:ssZ")


    GetListMarketCatalogueRequestString = "{""filter"":{""eventTypeIds"":[""" & EventTypeId & """],""marketCountries"":[""GB""],""marketTypeCodes"":[""WIN""]},""marketStartTime"":{""from"":""" & FromDate & """,""to"":""" & ToDate & """},""sort"":""FIRST_TO_START"",""maxResults"":"" 10"",""marketProjection"":[""RUNNER_DESCRIPTION"",""MARKET_START_TIME""]}"

    MakeJsonRpcRequestString = "{""jsonrpc"": ""2.0"", ""method"": ""SportsAPING/v1.0/" & Method & """, ""params"": " & RequestString & ", ""id"": 1}"

    Leave a comment:


  • nestor1971
    replied
    We first use a timer I always code with a button, I tried it and it works well thanks dave.

    Leave a comment:


  • davecon
    replied
    Originally posted by nestor1971 View Post
    Hi,
    sorry for my English, I had created my bot with old bees following the tutorial Mumbles0 but now with the new bees I'm in trouble, I downloaded BasicApp I modified the datagridview adding six columns back1, back2, back3, lay1, lay2 , lay3 but I can not call the market prices to include them in datagridview can you help me?
    Hiya Nestor

    This is nothing like the Old Api so try not to confuse things- start fresh and Play around with it
    If you use BestPricesDepth you can have as many prices as you like
    So start off simple and just use One Back and Lay price and Try it with a Button before using a Price Timer
    Start by just using the Top bit with a TextBox so you can see the Json String before you start
    That’s the Bit before it says Get Prices
    I have enclosed the Classes you need
    I can’t do anything more as we have to use our own personal means of what we want to achieve
    Hope this helps you a little
    Dave

    Code:
    Sub LoadMktBook()
            'When the race finishes they put the non-runners to the Top so Using Status We terminate at Suspended same as old api
            ''''''''''''''''Make the Market Book Request'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            Dim strBookRequest As String = "{""jsonrpc"": ""2.0"", ""method"": ""SportsAPING/v1.0/listMarketBook"", ""params"": {""marketIds"":[""" & txtMktID.Text & """],""priceProjection"":{""priceData"":[""EX_BEST_OFFERS"",""SP_AVAILABLE""],""exBestOffersOverrides"":{""bestPricesDepth"":1} }}, ""id"": 1}"
            ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            Dim ListMarketBookResponse = CreateRequest(UseAppKey, GetSessToken, strBookRequest)
      Try '
                'Get the Response and convert the Text to Classes from MarketBook
                Dim jsonBookObject = Newtonsoft.Json.JsonConvert.DeserializeObject(Of MarketBook)(ListMarketBookResponse)
                'TEXT - Show the Json Text Response in the Text Editor or similar if required 
                ‘ShowJsonText(ListMarketBookResponse)
                'Json Class Results
    '===========Get Prices===============
                Dim strPrices As String = ""
                Dim BackList As New List(Of Double)
                Dim LayList As New List(Of Double)
                BackList.Clear()
                LayList.Clear()
    
                'We could use the Runners Count here but if we use RowCount it is more Visible (Less 1 for Extra Bottom Row)
                For i = 0 To objDataGrid.RowCount - 2 '1 is the Btm Info Row Or use .NumberOfRunners-1 (Not NumberOfActiveRunners)
                    'Get the Exchange Prices We are only Using Best Prices Depth == 1
                    With jsonBookObject.Result(0).Runners(i).ExchangePrices
                        Dim dblBack() As Double = {}
                        Dim dblLay() As Double = {}
                        'Get the Prices in the array
                        For t = 0 To .AvailableToBack.Count  'I only have the one here
                            If .AvailableToBack IsNot Nothing AndAlso .AvailableToBack.Count > 0 Then
                                dblBack = {.AvailableToBack(0).Price} '
                            Else
                                dblBack = {0.0} 'Use zero rather than nothing
                            End If
                            If .AvailableToLay IsNot Nothing AndAlso .AvailableToLay.Count > 0 Then
                                dblLay = {.AvailableToLay(0).Price}
                            Else
                                dblLay = {0.0} 'Use zero rather than nothing
                            End If '
                        Next t
                        strPrices = dblBack(0) & "  |  " & dblLay(0) & vbCrLf 'Use/Test in a TextBox etc
                        BackList.Add(dblBack(0)) 'Add to our List
                        LayList.Add(dblLay(0)) 'Add to our List
                    End With 'Json Book Exchange prices
              With objDataGrid.Rows(i) 'All the Grid Rows Fill in the Cell Values/Properties/Formats as Required 
                        '
                        '=======Back and Lay Prices Col/Cells 3 and  4======
                        '
                        'Back Column 3 Cell 3
                        .Cells(3).Value = BackList.Item(i)
                        '
                        'Lay Column 4 Cells 4
                        .Cells(4).Value = LayList.Item(i)
              End With
          Next i
                Catch ex As Exception
    
                End Try
    End Sub
    Here is the Market Book Class

    Code:
    '{"jsonrpc":"2.0","result":[{"marketId":"1.112356482","isMarketDataDelayed":true,"status":"OPEN","betDelay":0,"bspReconciled":false,"complete":true,"inplay":false,"numberOfWinners":1,"numberOfRunners":7,"numberOfActiveRunners":7,"totalMatched":9052.89,"totalAvailable":45390.63,"crossMatching":true,"runnersVoidable":false,"version":665893793,"runners":[{"selectionId":7860579,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":35.0,"totalMatched":0.0,"ex":{"availableToBack":[{"price":3.0,"size":12.0},{"price":2.92,"size":9.72},{"price":2.9,"size":61.49}],"availableToLay":[{"price":3.05,"size":21.22},{"price":3.1,"size":40.0},{"price":3.15,"size":3.24}],"tradedVolume":[]}},{"selectionId":7554252,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":27.7,"totalMatched":0.0,"ex":{"availableToBack":[{"price":3.45,"size":21.62},{"price":3.35,"size":16.72},{"price":3.3,"size":14.0}],"availableToLay":[{"price":3.5,"size":46.95},{"price":3.55,"size":24.32},{"price":3.6,"size":12.89}],"tradedVolume":[]}},{"selectionId":7267924,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":16.6,"totalMatched":0.0,"ex":{"availableToBack":[{"price":5.7,"size":14.01},{"price":5.6,"size":32.0},{"price":5.5,"size":53.0}],"availableToLay":[{"price":6.0,"size":13.32},{"price":6.2,"size":25.0},{"price":6.4,"size":3.89}],"tradedVolume":[]}},{"selectionId":7323197,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":8.3,"totalMatched":0.0,"ex":{"availableToBack":[{"price":11.0,"size":8.74},{"price":9.8,"size":4.03},{"price":9.2,"size":3.63}],"availableToLay":[{"price":12.0,"size":8.0},{"price":12.5,"size":4.97},{"price":13.0,"size":13.31}],"tradedVolume":[]}},{"selectionId":7588394,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":5.0,"totalMatched":0.0,"ex":{"availableToBack":[{"price":20.0,"size":2.51},{"price":18.0,"size":2.07},{"price":17.5,"size":3.54}],"availableToLay":[{"price":22.0,"size":4.68},{"price":23.0,"size":6.0},{"price":25.0,"size":3.62}],"tradedVolume":[]}},{"selectionId":7554256,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":4.5,"totalMatched":0.0,"ex":{"availableToBack":[{"price":24.0,"size":4.45},{"price":23.0,"size":9.48},{"price":22.0,"size":6.65}],"availableToLay":[{"price":29.0,"size":5.15},{"price":30.0,"size":3.64},{"price":38.0,"size":3.72}],"tradedVolume":[]}},{"selectionId":7615290,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":2.8,"totalMatched":0.0,"ex":{"availableToBack":[{"price":36.0,"size":4.35},{"price":34.0,"size":3.48},{"price":32.0,"size":2.72}],"availableToLay":[{"price":50.0,"size":3.65},{"price":55.0,"size":7.59},{"price":60.0,"size":2.0}],"tradedVolume":[]}}]}],"id":1}
    Imports Newtonsoft.Json '~~> Enable the the use of Json Objects
    Imports Newtonsoft.Json.Converters
    Public Class MarketBook
        Private m_result As List(Of BookInfo) '~~> "result"
        <JsonProperty(PropertyName:="result")> _
        Public Property Result() As List(Of BookInfo) '~~> This can now be called anything InfoResult etc
            Get
                Return m_result
            End Get
            Set(value As List(Of BookInfo))
                m_result = value
            End Set
        End Property '"result" 
    End Class 'MarketBook Top Level
    Public Class BookInfo
        Private m_marketId As String
        <JsonProperty(PropertyName:="marketId")> _
        Public Property MarketId() As String
            Get
                Return m_marketId
            End Get
            Set(value As String)
                m_marketId = value
            End Set
        End Property '~~>"marketId" for Meeting
        <JsonProperty(PropertyName:="isMarketDataDelayed")> _
        Public Property IsMarketDataDelayed() As Boolean
            Get
                Return m_IsMarketDataDelayed
            End Get
            Set(value As Boolean)
                m_IsMarketDataDelayed = Value
            End Set
        End Property
        Private m_IsMarketDataDelayed As Boolean
        <JsonProperty(PropertyName:="status")> _
        Public Property MarketStatus() As MarketStatus
            Get
                Return m_Status
            End Get
            Set(value As MarketStatus)
                m_Status = value
            End Set
        End Property
        Private m_Status As MarketStatus
        <JsonProperty(PropertyName:="betDelay")> _
        Public Property BetDelay() As Integer
            Get
                Return m_BetDelay
            End Get
            Set(value As Integer)
                m_BetDelay = value
            End Set
        End Property
        Private m_BetDelay As Integer
        <JsonProperty(PropertyName:="bspReconciled")> _
        Public Property IsBspReconciled() As Boolean
            Get
                Return m_IsBspReconciled
            End Get
            Set(value As Boolean)
                m_IsBspReconciled = Value
            End Set
        End Property
        Private m_IsBspReconciled As Boolean
        <JsonProperty(PropertyName:="complete")> _
       Public Property IsComplete() As Boolean
            Get
                Return m_IsComplete
            End Get
            Set(value As Boolean)
                m_IsComplete = value
            End Set
        End Property
        Private m_IsComplete As Boolean
        <JsonProperty(PropertyName:="inplay")> _
        Public Property IsInplay() As Boolean
            Get
                Return m_IsInplay
            End Get
            Set(value As Boolean)
                m_IsInplay = value
            End Set
        End Property
        Private m_IsInplay As Boolean
        <JsonProperty(PropertyName:="numberOfWinners")> _
        Public Property NumberOfWinners() As Integer
            Get
                Return m_NumberOfWinners
            End Get
            Set(value As Integer)
                m_NumberOfWinners = Value
            End Set
        End Property
        Private m_NumberOfWinners As Integer
        <JsonProperty(PropertyName:="numberOfRunners")> _
        Public Property NumberOfRunners() As Integer
            Get
                Return m_NumberOfRunners
            End Get
            Set(value As Integer)
                m_NumberOfRunners = value
            End Set
        End Property
        Private m_NumberOfRunners As Integer
        <JsonProperty(PropertyName:="numberOfActiveRunners")> _
        Public Property NumberOfActiveRunners() As Integer
            Get
                Return m_NumberOfActiveRunners
            End Get
            Set(value As Integer)
                m_NumberOfActiveRunners = Value
            End Set
        End Property
        Private m_NumberOfActiveRunners As Integer
        <JsonProperty(PropertyName:="lastMatchTime")> _
        Public Property LastMatchTime() As System.Nullable(Of DateTime)
            Get
                Return m_LastMatchTime
            End Get
            Set(value As System.Nullable(Of DateTime))
                m_LastMatchTime = value
            End Set
        End Property
        Private m_LastMatchTime As System.Nullable(Of DateTime)
        <JsonProperty(PropertyName:="totalMatched")> _
        Public Property TotalMatched() As Double
            Get
                Return m_TotalMatched
            End Get
            Set(value As Double)
                m_TotalMatched = value
            End Set
        End Property
        Private m_TotalMatched As Double
        <JsonProperty(PropertyName:="totalAvailable")> _
        Public Property TotalAvailable() As Double
            Get
                Return m_TotalAvailable
            End Get
            Set(value As Double)
                m_TotalAvailable = Value
            End Set
        End Property
        Private m_TotalAvailable As Double
        <JsonProperty(PropertyName:="crossMatching")> _
        Public Property IsCrossMatching() As Boolean
            Get
                Return m_IsCrossMatching
            End Get
            Set(value As Boolean)
                m_IsCrossMatching = value
            End Set
        End Property
        Private m_IsCrossMatching As Boolean
        <JsonProperty(PropertyName:="runnersVoidable")> _
       Public Property IsRunnersVoidable() As Boolean
            Get
                Return m_IsRunnersVoidable
            End Get
            Set(value As Boolean)
                m_IsRunnersVoidable = value
            End Set
        End Property
        Private m_IsRunnersVoidable As Boolean
        <JsonProperty(PropertyName:="version")> _
        Public Property Version() As Long
            Get
                Return m_Version
            End Get
            Set(value As Long)
                m_Version = value
            End Set
        End Property
        Private m_Version As Long
        <JsonProperty(PropertyName:="runners")> _
        Public Property Runners() As List(Of Runners)
            Get
                Return m_Runners
            End Get
            Set(value As List(Of Runners))
                m_Runners = value
            End Set
        End Property
        Private m_Runners As List(Of Runners)
    End Class 'Book Info
    Public Class Runners
        <JsonProperty(PropertyName:="selectionId")> _
        Public Property SelectionId() As Long
            Get
                Return m_SelectionId
            End Get
            Set(value As Long)
                m_SelectionId = value
            End Set
        End Property
        Private m_SelectionId As Long
        <JsonProperty(PropertyName:="handicap")> _
        Public Property Handicap() As System.Nullable(Of Double)
            Get
                Return m_Handicap
            End Get
            Set(value As System.Nullable(Of Double))
                m_Handicap = Value
            End Set
        End Property
        Private m_Handicap As System.Nullable(Of Double)
        <JsonProperty(PropertyName:="status")> _
        Public Property RunnerStatus() As RunnerStatus
            Get
                            Return m_Status
            End Get
            Set(value As RunnerStatus)
                m_Status = value
            End Set
        End Property
        Private m_Status As RunnerStatus
        <JsonProperty(PropertyName:="adjustmentFactor")> _
        Public Property AdjustmentFactor() As System.Nullable(Of Double)
            Get
                Return m_AdjustmentFactor
            End Get
            Set(value As System.Nullable(Of Double))
                m_AdjustmentFactor = value
            End Set
        End Property
        Private m_AdjustmentFactor As System.Nullable(Of Double)
        <JsonProperty(PropertyName:="lastPriceTraded")> _
        Public Property LastPriceTraded() As System.Nullable(Of Double)
            Get
                Return m_LastPriceTraded
            End Get
            Set(value As System.Nullable(Of Double))
                m_LastPriceTraded = value
            End Set
        End Property
        Private m_LastPriceTraded As System.Nullable(Of Double)
        <JsonProperty(PropertyName:="totalMatched")> _
       Public Property TotalMatched() As Double
            Get
                Return m_TotalMatched
            End Get
            Set(value As Double)
                m_TotalMatched = value
            End Set
        End Property
        Private m_TotalMatched As Double
        'SPSP Pre off
        '"runners":[{"selectionId":7934226,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":22.9,"lastPriceTraded":4.6,"totalMatched":14270.64,"sp":{"nearPrice":4.7,"farPrice":6.262127089148748,"backStakeTaken":[],"layLiabilityTaken":[]},"ex":{"availableToBack":[{"price":4.6,"size":76.83}],"availableToLay":[{"price":4.7,"size":82.07}],"tradedVolume":[]}},{"
        'Off
        '"runners":[{"selectionId":8587406,"handicap":0.0,"status":"ACTIVE","adjustmentFactor":23.3,"lastPriceTraded":5.0,"totalMatched":136460.37,"sp":{"backStakeTaken":[],"layLiabilityTaken":[],"actualSP":4.4},"ex":{"availableToBack":[{"price":5.0,"size":113.74}],"availableToLay":[{"price":5.5,"size":2.0}],"tradedVolume":[]}},{"
        <JsonProperty(PropertyName:="sp")> _
        Public Property StartingPrices() As StartingPrices
            Get
                Return m_StartingPrices
            End Get
            Set(value As StartingPrices)
                m_StartingPrices = value
            End Set
        End Property
        Private m_StartingPrices As StartingPrices
        <JsonProperty(PropertyName:="ex")> _
        Public Property ExchangePrices() As ExchangePrices
            Get
                Return m_ExchangePrices
            End Get
            Set(value As ExchangePrices)
                m_ExchangePrices = value
            End Set
        End Property
        Private m_ExchangePrices As ExchangePrices
    End Class 'Runners
    Public Class StartingPrices
        <JsonProperty(PropertyName:="nearPrice")> _
        Public Property NearPrice() As Double
            Get
                ' Return Math.Round(m_nearPrice, 2)
                Return m_nearPrice
            End Get
            Set(value As Double)
                m_nearPrice = value
            End Set
        End Property
        Private m_nearPrice As Double
        <JsonProperty(PropertyName:="farPrice")> _
        Public Property FarPrice() As Double
            Get
                'Return Math.Round(m_farPrice, 2)
                Return m_farPrice
            End Get
            Set(value As Double)
                m_farPrice = value
            End Set
        End Property
        Private m_farPrice As Double
        <JsonProperty(PropertyName:="actualSP")> _
        Public Property ActualSP() As Double
            Get
                'Return Math.Round(m_farPrice, 2)'Or Format in app
                Return m_actualSP
            End Get
            Set(value As Double)
                m_actualSP = value
            End Set
        End Property
        Private m_actualSP As Double
    End Class 'StartingPrices
    Public Class ExchangePrices
        <JsonProperty(PropertyName:="availableToBack")> _
        Public Property AvailableToBack() As List(Of PriceSize)
            Get
                Return m_AvailableToBack
            End Get
            Set(value As List(Of PriceSize))
                m_AvailableToBack = value
            End Set
        End Property
        Private m_AvailableToBack As List(Of PriceSize)
        <JsonProperty(PropertyName:="availableToLay")> _
        Public Property AvailableToLay() As List(Of PriceSize)
            Get
                Return m_AvailableToLay
            End Get
            Set(value As List(Of PriceSize))
                'If AvailableToLay IsNot Nothing AndAlso AvailableToLay.Count > 0 Then
                m_AvailableToLay = value
                'End If
            End Set
        End Property
        Private m_AvailableToLay As List(Of PriceSize)
        <JsonProperty(PropertyName:="tradedVolume")> _
        Public Property TradedVolume() As List(Of PriceSize)
            Get
                Return m_TradedVolume
            End Get
            Set(value As List(Of PriceSize))
                m_TradedVolume = value
            End Set
        End Property
        Private m_TradedVolume As List(Of PriceSize)
    End Class 'Xchange Prices
    Public Class PriceSize
        <JsonProperty(PropertyName:="price")> _
        Public Property Price() As Double
            Get
                Return m_Price
            End Get
            Set(value As Double)
                m_Price = value
            End Set
        End Property
        Private m_Price As Double
        <JsonProperty(PropertyName:="size")> _
        Public Property Size() As Double
            Get
                Return m_Size
            End Get
            Set(value As Double)
                m_Size = value
            End Set
        End Property
        Private m_Size As Double
    End Class 'PriceSize
    <JsonConverter(GetType(StringEnumConverter))> _
    Public Enum MarketStatus
        INACTIVE
        OPEN
        SUSPENDED
        CLOSED
    End Enum
    <JsonConverter(GetType(StringEnumConverter))> _
    Public Enum RunnerStatus
        ACTIVE
        WINNER
        LOSER
        REMOVED_VACANT
        REMOVED
    End Enum

    Leave a comment:


  • nestor1971
    replied
    Hi,
    sorry for my English, I had created my bot with old bees following the tutorial Mumbles0 but now with the new bees I'm in trouble, I downloaded BasicApp I modified the datagridview adding six columns back1, back2, back3, lay1, lay2 , lay3 but I can not call the market prices to include them in datagridview can you help me?
    Last edited by nestor1971; 19-11-2014, 04:00 AM.

    Leave a comment:


  • LABE
    replied
    Originally posted by troyedwards8 View Post
    I am looking for a VB.NET windows app which has just the basic betfair login and say get a market. Then I am confident I can write the rest of the code for my bet bot.

    I am quite surprised that Betfair havn't provided a good example and I have spent around 2 days surfing the web looking for stuff.

    Troy
    Troy try link: http://www.betoptim.com/index.aspx?l...start=DownInst
    - programming tools for support Betfairs Api-NG operations
    - demoversions including source code both console applications and Windows form applications
    - Windows Form application in VB.NET (in C# also) contains login, getting of fixtures (with selections) and current odds (for asked markets)
    - DLL-libraries for sportsbetting, matching with offer of other bookies ...

    Leave a comment:


  • racrego
    replied
    bet status

    does anyone know how to display a bet status? matched, unmatched?

    thanks

    Leave a comment:


  • Mr Ed
    replied
    Thanks again Dave
    I looked at your code and just plucked out a couple of bits. It is not that important that the tabs stay in the same order to me so I just remove and re add it now.

    Cheers

    Leave a comment:


  • NatHunter
    replied
    AccountStatement - Class Generating string Correction

    Anything to make things easier and lazier, DaveCon!

    A slight correction to the string used to generate the accountstatement
    class. It should have 'result' included as well as this is returned by the JSON call:

    Code:
    {"result":{"accountStatement":
    [{"refId":"0","itemDate":"2014-10-29T16:18:11.000Z","amount":-600.0,"balance":1094.7,"itemClassData":{"unknownStatementItem":"{\"avgPrice\":0.0,\"betSize\":0.0,\"betType\":\"B\",\"betCategoryType\":\"E\",\"commissionRate\":null,\"eventId\":0,\"eventTypeId\":0,\"fullMarketName\":\"Card Payment - Halibert\",\"grossBetAmount\":0.0,\"marketName\":\"WITHDRAWAL\",\"marketType\":\"NOT_APPLICABLE\",\"placedDate\":\"2014-10-29T16:18:11.000Z\",\"selectionId\":0,\"selectionName\":null,\"startDate\":\"0001-01-01T00:00:00.000Z\",\"transactionType\":\"ACCOUNT_DEBIT\",\"transactionId\":200000017074820,\"winLose\":\"RESULT_NOT_APPLICABLE\"}"},"legacyData":{"avgPrice":0.0,"betSize":0.0,"betType":"B","betCategoryType":"E","eventId":0,"eventTypeId":0,"fullMarketName":"Card Payment - Halibert","grossBetAmount":0.0,"marketName":"WITHDRAWAL","marketType":"NOT_APPLICABLE","placedDate":"2014-10-29T16:18:11.000Z","selectionId":0,"startDate":"0001-01-01T00:00:00.000Z","transactionType":"AC
    COUNT_DEBIT","transactionId":200000017074820,"winLose":"RESULT_NOT_APPLICABLE"},"itemClass":"UNKNOWN"}]}}

    Leave a comment:


  • davecon
    replied
    Originally posted by NatHunter View Post

    To generate a class go to the site http://jsonutils.com/

    Natty
    Hi Natty
    Thats a nice lazy way of doing the Classes
    Cheers for that
    Dave

    Leave a comment:


  • NatHunter
    replied
    I wonder if the old Betfair API has been turned off now? Must check my old program.

    Thanks for the reply to the account statement query, DaveCon. The account statement is a nice to have as I say, but I keep a record of all bets and having to go to the P&L part of the betfair site is more tedious than clicking a button in my App.

    I have got to grips with the Deserialisation for Account Statement and other data for that matter.

    To generate a class go to the site http://jsonutils.com/

    and plug in the returned JSON string.

    For Account Statement I used this

    Code:
    {"accountStatement":
    [{"refId":"0","itemDate":"2014-10-29T16:18:11.000Z","amount":-600.0,"balance":1094.7,"itemClassData":{"unknownStatementItem":"{\"avgPrice\":0.0,\"betSize\":0.0,\"betType\":\"B\",\"betCategoryType\":\"E\",\"commissionRate\":null,\"eventId\":0,\"eventTypeId\":0,\"fullMarketName\":\"Card Payment - Halibert\",\"grossBetAmount\":0.0,\"marketName\":\"WITHDRAWAL\",\"marketType\":\"NOT_APPLICABLE\",\"placedDate\":\"2014-10-29T16:18:11.000Z\",\"selectionId\":0,\"selectionName\":null,\"startDate\":\"0001-01-01T00:00:00.000Z\",\"transactionType\":\"ACCOUNT_DEBIT\",\"transactionId\":200000017074820,\"winLose\":\"RESULT_NOT_APPLICABLE\"}"},"legacyData":{"avgPrice":0.0,"betSize":0.0,"betType":"B","betCategoryType":"E","eventId":0,"eventTypeId":0,"fullMarketName":"Card Payment - Halibert","grossBetAmount":0.0,"marketName":"WITHDRAWAL","marketType":"NOT_APPLICABLE","placedDate":"2014-10-29T16:18:11.000Z","selectionId":0,"startDate":"0001-01-01T00:00:00.000Z","transactionType":"AC
    COUNT_DEBIT","transactionId":200000017074820,"winLose":"RESULT_NOT_APPLICABLE"},"itemClass":"UNKNOWN"}]}
    Which generated the following class (I added imports and JSONProperty statements afterwards)

    Code:
    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports Newtonsoft.Json
    
    
    Public Class ItemClassData
        '<JsonProperty(PropertyName:="unknownStatementItem")> _
        'Public Property unknownStatementItem() As String
    
        <JsonProperty(PropertyName:="unknownStatementItem")> _
        Public Property ItemClassDetail() As String
    
        '<JsonProperty(PropertyName:="unknownStatementItem")> _
        'Public Property unknownStatementItem() As clsAccountStatementItemDetail
    
    End Class
    
    Public Class LegacyData
        <JsonProperty(PropertyName:="avgPrice")> _
        Public Property avgPrice() As Double
    
        <JsonProperty(PropertyName:="betSize")> _
        Public Property betSize() As Double
    
        <JsonProperty(PropertyName:="betType")> _
        Public Property betType() As String
    
        <JsonProperty(PropertyName:="betCategoryType")> _
        Public Property betCategoryType() As String
    
        <JsonProperty(PropertyName:="eventId")> _
        Public Property eventId As Integer
    
        <JsonProperty(PropertyName:="eventTypeId")> _
        Public Property eventTypeId As Integer
    
        <JsonProperty(PropertyName:="fullMarketName")> _
        Public Property fullMarketName() As String
    
        <JsonProperty(PropertyName:="grossBetAmount")> _
        Public Property grossBetAmount() As Double
    
        <JsonProperty(PropertyName:="marketName")> _
        Public Property marketName() As String
    
        <JsonProperty(PropertyName:="marketType")> _
        Public Property marketType() As String
    
        <JsonProperty(PropertyName:="placedDate")> _
        Public Property placedDate() As DateTime
    
        <JsonProperty(PropertyName:="selectionId")> _
        Public Property selectionId As Integer
    
        <JsonProperty(PropertyName:="startDate")> _
        Public Property startDate() As DateTime
    
        <JsonProperty(PropertyName:="transactionType")> _
        Public Property transactionType() As String
    
        <JsonProperty(PropertyName:="transactionId")> _
        Public Property transactionId() As Long
    
        <JsonProperty(PropertyName:="winLose")> _
        Public Property winLose() As String
    
    End Class
    
    Public Class AccountStatement
        <JsonProperty(PropertyName:="refId")> _
        Public Property refId() As String
    
        <JsonProperty(PropertyName:="itemDate")> _
        Public Property itemDate() As DateTime
    
        <JsonProperty(PropertyName:="amount")> _
        Public Property amount() As Double
    
        <JsonProperty(PropertyName:="balance")> _
        Public Property balance() As Double
    
        <JsonProperty(PropertyName:="itemClassData")> _
        Public Property itemClassData As ItemClassData
    
        <JsonProperty(PropertyName:="legacyData")> _
        Public Property legacyData As LegacyData
    
        <JsonProperty(PropertyName:="itemClass")> _
        Public Property itemClass() As String
    End Class
    
    Public Class Result
        <JsonProperty(PropertyName:="AccountStatement")> _
        Public Property accountStatement As AccountStatement()
    End Class
    
    Public Class Accounts
    
        <JsonProperty(PropertyName:="result")> _
        Public Property result As Result
    End Class
    For some reason the main piece of information is not 'decoded', so I had to plug in another string (sTest, below)

    Code:
                oListAccountStatementResponse = JsonConvert.DeserializeObject(Of Accounts)(sAccountStatement)
    
                Dim sTest = oListAccountStatementResponse.result.accountstatement(4).itemclassdata.itemclassdetail
    which gave me another class:

    Code:
    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports Newtonsoft.Json
    
    Public Class clsAccountStatementItemDetail
    
        <JsonProperty(PropertyName:="avgPrice")> _
        Public Property avgPrice() As Double
    
        <JsonProperty(PropertyName:="betSize")> _
        Public Property betSize() As Double
    
        <JsonProperty(PropertyName:="betType")> _
        Public Property betType() As String
    
        <JsonProperty(PropertyName:="betCategoryType")> _
        Public Property betCategoryType() As String
    
        <JsonProperty(PropertyName:="commissionRate")> _
        Public Property commissionRate() As Object
    
        <JsonProperty(PropertyName:="eventId")> _
        Public Property eventId() As Integer
    
        <JsonProperty(PropertyName:="eventTypeId")> _
        Public Property eventTypeId() As Integer
    
        <JsonProperty(PropertyName:="fullMarketName")> _
        Public Property fullMarketName() As String
    
        <JsonProperty(PropertyName:="grossBetAmount")> _
        Public Property grossBetAmount() As Double
    
        <JsonProperty(PropertyName:="marketName")> _
        Public Property marketName() As String
    
        <JsonProperty(PropertyName:="marketType")> _
        Public Property marketType() As String
    
        <JsonProperty(PropertyName:="placedDate")> _
        Public Property placedDate() As DateTime
    
        <JsonProperty(PropertyName:="selectionId")> _
        Public Property selectionId() As Integer
    
        <JsonProperty(PropertyName:="selectionName")> _
        Public Property selectionName() As Object
    
        <JsonProperty(PropertyName:="startDate")> _
        Public Property startDate() As DateTime
    
        <JsonProperty(PropertyName:="transactionType")> _
        Public Property transactionType() As String
    
        <JsonProperty(PropertyName:="transactionId")> _
        Public Property transactionId() As Long
    
        <JsonProperty(PropertyName:="winLose")> _
        Public Property winLose() As String
    
    End Class
    It can be accessed using code like the following and accessing the 'oDetail' object:

    Code:
    Dim oDetail = JsonConvert.DeserializeObject(Of clsAccountStatementItemDetail)(sTest)


    So it is a two step process to retrieve account statement information.

    Thanks again, DaveCon

    Natty

    Leave a comment:


  • racrego
    replied
    thank you mike

    Leave a comment:


  • davecon
    replied
    Originally posted by Mr Ed View Post
    Hi ED Annoying Isn’t it hehe Same prob here but sorted it although a bit complex
    The Problem is when you create a New DataGrid the Old one is Kaput so a new one is required each time
    So you need to sort out not only the Tree Click but the Tab Click as well to do this (Depends what you are doing)
    So try it from here anyway and see how you get On
    First to make life easy Take all your DataGrid stuff out of where it is and place it in a Separate Sub otherwise you will have miles of code to trawl through – You can just Edit it from the New sub then when you want new Columns etc
    This is A SNIP what I’m using at the mo so see how you get on
    Dave

    Code:
     Private WithEvents objDataGrid As DataGridView 'For Click Events etc OK 28th Oct
        'Data Grid Designand Properties here - Add Cols Rows as req etc OK 28th Oct
        Sub BuildDataGrid() 'http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview(v=vs.110).aspx
            With objDataGrid
                .ColumnCount = 9 'Actually 10 but the cbx Col is added s extra
                .Columns(0).Name = "Runners"
                .Columns(1).Name = "Sel ID"
                .Columns(2).Name = "Back"
                .Columns(3).Name = "Lay"
                .Columns(4).Name = "SP"
                .Columns(5).Name = "Liab"
                .Columns(6).Name = "Stk"
                .Columns(7).Name = "MUM" 'Matched or Unmatched
                .Columns(8).Name = "Status" 'Moved this after the New Checkboxes (It is still Col 8 although it is 9)
                ' ======Header Style======
                With .ColumnHeadersDefaultCellStyle
                    .BackColor = Color.Blue 'xx Does not Work here??
                    .ForeColor = Color.White 'xx Why not?
                    .Font = New Font(objDataGrid.Font, FontStyle.Bold) 'xx Because these work?
                    .Alignment = DataGridViewContentAlignment.MiddleCenter 'and this
                End With
                '====Default Settings=======
                .ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single
                .CellBorderStyle = DataGridViewCellBorderStyle.Single
                .GridColor = Color.Black
                .RowHeadersVisible = False 'No thanks
                .Dock = DockStyle.Fill
                .AllowUserToAddRows = False
                .AllowUserToOrderColumns = False
                .AllowUserToResizeColumns = True 'Only if Width is Not set to Auto
                .AllowUserToResizeRows = False
                '.ReadOnly = True Do seperatly as some are like stakes and liability
                '.SelectionMode = DataGridViewSelectionMode.CellSelect 'Selects Single cell for click events etc
                .SelectionMode = DataGridViewSelectionMode.FullRowSelect 'Selects The Full Row but above can still be accessed 
                .MultiSelect = False
                .BackgroundColor = Color.CadetBlue
                'Selections
                With .Columns(0) 'Horse Names
                    .HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .SortMode = DataGridViewColumnSortMode.NotSortable
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
                    .ReadOnly = True
                End With 'Selections
                'Selection ID
                With .Columns(1) 'Sel Id Hide this Later
                    .SortMode = DataGridViewColumnSortMode.NotSortable
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
                    .ReadOnly = True
                End With 'sel ID
                With .Columns(2) 'Back Column Format
                    .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
                    .DefaultCellStyle.BackColor = Color.AliceBlue
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .ReadOnly = True
                End With 'Back Column Format
                With .Columns(3) 'Lay Column Format
                    .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
                    .DefaultCellStyle.BackColor = Color.MistyRose
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .ReadOnly = True
                End With 'Lay Column Format
                With .Columns(4) 'SP Column
                    '.Width = .AutoSizeMode
                    .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
                    .DefaultCellStyle.BackColor = Color.LightBlue
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .ReadOnly = True
                End With 'SP Column Format
                '======Editable Liability and stks Columns========
                With .Columns(5) ''Liability
                    .Width = 60
                    .DefaultCellStyle.BackColor = Color.LightSeaGreen
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .ReadOnly = False
                End With 'Liability Column Format
                'Stakes Column
                With .Columns(6) 'Stakes
                    .Width = 60
                    .DefaultCellStyle.BackColor = Color.LightBlue
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .ReadOnly = False
                End With 'Stakes
                'Matched or Unmatched Column
                With .Columns(7) 'MU
                    .Width = 30
                    .DefaultCellStyle.BackColor = Color.LightBlue
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .ReadOnly = True
                End With 'Matched Unmatched Not editable
                'Runner Status Column
                With .Columns(8) 'Status Column Format
                    .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
                    .DefaultCellStyle.BackColor = Color.LightGray
                    .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    .ReadOnly = True
                End With 'Status Column Format
                ''CheckBoxes Extra column 'http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcheckboxcolumn(v=vs.110).aspx
                Dim column As New DataGridViewCheckBoxColumn()
                With column
                    .HeaderText = "Bet"
                    .Name = "colBet"
                    .ReadOnly = False
                    .AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
                    .FlatStyle = FlatStyle.Standard
                    .CellTemplate = New DataGridViewCheckBoxCell()
                    .CellTemplate.Style.BackColor = Color.Beige
                End With
                objDataGrid.Columns.Insert(8, column) 'Insert 1 from the End this is inserted between 8 and 9
            End With '========Data Grid==========
        End Sub 'Create the Basic Data Grid and the properties 'OK 28th Oct
    All I can really do for you now is give you a snip from mine as yours will be completely different as I'm just doing Racing

    Code:
         'Display the Runners and Selection ID's
                        For i = 0 To selList.Count - 1
                            With objDataGrid
                                .Rows.Add(selList.Item(i), idList.Item(i))
                            End With
                        Next
                        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                        'Add an Extra row for other Data 
                        objDataGrid.Rows.Add(selList.Count & " Declared")
                    End With 'tabMarkets '
             [B][COLOR="Red"]   Else 'We have a Tab ID but the Grid does need a new one again for reloads as Book will not Update otherwise[/COLOR][/B]
                    'The Problem here is after a Non runner and the BF wankers think its a good idea to Move them around!
                    tabMarkets.SelectedTab = tabMarkets.TabPages(MarketID) 'Because this is tree click
                    ''==============NEW GRID IF TREE IS CLICKED AFTERWARDS===================================
                    Try 'Delete the Tab and get new one (DO IF IN TREE LIST--Else New Info closed!)
                        'Need to put back in right place and Insert not Add as Above for first creation
                        'Store the MarketID
                        Dim newMktId As String = tabMarkets.SelectedTab.Name
                        'This was the Position of the Tab prior to removal using the Current tab Index
                        Dim OldPageIndex As Integer = tabMarkets.TabPages.IndexOf(tabMarkets.SelectedTab)
                        nudTabIndex.Value = OldPageIndex 'This displays the Index in a Numeric Up Down Control
                        'Remove the Existing Tab
                        tabMarkets.TabPages.Remove(tabMarkets.SelectedTab)
                        'Load a New Tab and New Data Grid Oct 23rd
                        With tabMarkets
                            ' Create New Tab and Select ready to apply new datagrid
                            Tab.Name = newMktId 'This was the Old market ID stored previously'
                            'Note Insert and NOT Add
                            .TabPages.Insert(OldPageIndex, Tab) 'Add this tab to the TabPages Collection 
                            .SelectedTab = Tab 'Select the Tab page
                            'New Data Grid so the Book will Reload its values
                            objDataGrid = New DataGridView 'Use declared Data grid object and setup
                            Tab.Controls.Add(objDataGrid) 'Put a DataGridView/textbox on the Tab
                            .SelectedTab = Tab 'Reselect Tab Page
                            'Activate the New Datagrid
                            BuildDataGrid()  '========Create the Data Grid==========

    Leave a comment:

Working...
X