current order list
based on your code, i have the following class :
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Converters
Public Class CurrentOrderSummaryReport
<JsonProperty(PropertyName:="CurrentOrderSummary") > _
Public Property CurrentOrderSummary() As List(Of CurrentOrderSummary) 'The list of current orders returned by your query. This will be a valid list (i.e. empty or non-empty but never 'null').
<JsonProperty(PropertyName:="moreAvailable")> _
Public Property moreAvailable() As Boolean 'Indicates whether there are further result items beyond this page. Note that underlying data is highly time-dependent and the subsequent search orders query might return an empty result.
End Class
Public Class CurrentOrderSummary
<JsonProperty(PropertyName:="betId")> _
Public Property betIds() As ISet(Of String)
<JsonProperty(PropertyName:="marketId")> _
Public Property marketId() As String
<JsonProperty(PropertyName:="selectionId")> _
Public Property selectionId() As Long
<JsonProperty(PropertyName:="handicap")> _
Public Property Handicap() As Double
<JsonProperty(PropertyName:="priceSize")> _
Public Property priceSize() As Double
<JsonProperty(PropertyName:="bspLiability")> _
Public Property bspLiability() As Double
<JsonProperty(PropertyName:="side")> _
Public Property Side() As String
<JsonProperty(PropertyName:="status")> _
Public Property Status() As String
<JsonProperty(PropertyName:="persistenceType")> _
Public Property PersistenceType() As String
<JsonProperty(PropertyName:="orderType")> _
Public Property OrderType() As String
<JsonProperty(PropertyName:="placedDate")> _
Public Property placedDate() As Date
<JsonProperty(PropertyName:="matchedDate")> _
Public Property matchedDate() As Date
<JsonProperty(PropertyName:="averagePriceMatched") > _
Public Property averagePriceMatched() As Double
<JsonProperty(PropertyName:="sizeMatched")> _
Public Property sizeMatched() As Double
<JsonProperty(PropertyName:="sizeRemaining")> _
Public Property sizeRemaining() As Double
<JsonProperty(PropertyName:="sizeLapsed")> _
Public Property sizeLapsed() As Double
<JsonProperty(PropertyName:="sizeCancelled")> _
Public Property sizeCancelled() As Double
<JsonProperty(PropertyName:="sizeVoided")> _
Public Property sizeVoided() As Double
<JsonProperty(PropertyName:="regulatorAuthCode") > _
Public Property regulatorAuthCode() As String
<JsonProperty(PropertyName:="regulatorCode")> _
Public Property regulatorCode() As String
End Class
<JsonConverter(GetType(StringEnumConverter))> _
Public Enum SortDir
EARLIEST_TO_LATEST
LATEST_TO_EARLIEST
End Enum
and the aditional code :
Dim objJson = JsonConvert.DeserializeObject(Of CurrentOrderSummaryReport)(strCatalogue)
Dim listCurrentOrders As CurrentOrderSummaryReport
'listCurrentOrders = clientBF.listCurrentOrders()
PrintLog(listCurrentOrders.CurrentOrderSummary(0). betIds)
PrintLog(listCurrentOrders.CurrentOrderSummary(0). OrderType)
PrintLog(listCurrentOrders.CurrentOrderSummary(0). sizeMatched)
but i always get a null reference, can you help me?
thanks
is Bet matched?
Collapse
X
-
Guest repliedThanks betdynamics. I did what you said by printing out the returned JSON string from the Deserialize(Of T)(ByVal json As String) function to help my debug. In the end it was me causing the error. It would have been nice had betfair put together the below classes to save me a lot of time, but now I have gone through this I have learnt a fair bit and should be right here on in.
I now know what my listCurrentOrders error was. I was getting a JSON string with the correct parameters being passed back HOWEVER I was trying to force the response into the CurrentOrderSummaryReport and CurrentOrderSummary Classes which I had defined INCORRECTLY. In the CurrentOrderSummary class I created I had:
error 1) "betIds" when it should have just been "betId"
error 2) variable priceSize was defined as a List of priceSize when it should have just been priceSize.
I have now correct the classes below which means you can call the listCurrentOrders and then drill down through the class to get the data, ie
Classes and ENUMSCode:Dim listCurrentOrders As CurrentOrderSummaryReport listCurrentOrders = clientBF.listCurrentOrders() Debug.Print(listCurrentOrders.CurrentOrderSummary(0).marketId) Debug.Print(listCurrentOrders.CurrentOrderSummary(0).priceSize.Price)
[/QUOTE]Code:Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports Newtonsoft.Json Imports Newtonsoft.Json.Converters 'TROY ADDED THIS CODE HERE BASED ON BETFAIR WEBSITE 23 APR 2014 Namespace API_NG.TO Public Class CurrentOrderSummaryReport <JsonProperty(PropertyName:="CurrentOrderSummary")> _ Public Property CurrentOrderSummary() As List(Of CurrentOrderSummary) 'The list of current orders returned by your query. This will be a valid list (i.e. empty or non-empty but never 'null'). <JsonProperty(PropertyName:="moreAvailable")> _ Public Property moreAvailable() As Boolean 'Indicates whether there are further result items beyond this page. Note that underlying data is highly time-dependent and the subsequent search orders query might return an empty result. End Class Public Class CurrentOrderSummary <JsonProperty(PropertyName:="betId")> _ Public Property betIds() As ISet(Of String) 'The bet ID of the original place order. <JsonProperty(PropertyName:="marketId")> _ Public Property marketId() As String 'The market id the order is for. <JsonProperty(PropertyName:="selectionId")> _ Public Property selectionId() As Long 'The selection id the order is for. <JsonProperty(PropertyName:="handicap")> _ Public Property Handicap() As Double? 'The handicap of the bet. <JsonProperty(PropertyName:="priceSize")> _ Public Property priceSize() As PriceSize 'The price and size of the bet. <JsonProperty(PropertyName:="bspLiability")> _ Public Property bspLiability() As Double 'Not to be confused with size. This is the liability of a given BSP bet. <JsonProperty(PropertyName:="side")> _ Public Property Side() As Side 'BACK/LAY <JsonProperty(PropertyName:="status")> _ Public Property Status() As OrderStatus 'Either EXECUTABLE (an unmatched amount remains) or EXECUTION_COMPLETE (no unmatched amount remains). <JsonProperty(PropertyName:="persistenceType")> _ Public Property PersistenceType() As PersistenceType 'What to do with the order at turn-in-play. <JsonProperty(PropertyName:="orderType")> _ Public Property OrderType() As OrderType 'BSP Order type. <JsonProperty(PropertyName:="placedDate")> _ Public Property placedDate() As Date 'The date, to the second, the bet was placed. <JsonProperty(PropertyName:="matchedDate")> _ Public Property matchedDate() As Date 'The date, to the second, of the last matched bet fragment (where applicable) <JsonProperty(PropertyName:="averagePriceMatched")> _ Public Property averagePriceMatched() As Double 'The average price matched at. Voided match fragments are removed from this average calculation. <JsonProperty(PropertyName:="sizeMatched")> _ Public Property sizeMatched() As Double 'The current amount of this bet that was matched. <JsonProperty(PropertyName:="sizeRemaining")> _ Public Property sizeRemaining() As Double 'The current amount of this bet that is unmatched. <JsonProperty(PropertyName:="sizeLapsed")> _ Public Property sizeLapsed() As Double 'The current amount of this bet that was lapsed. <JsonProperty(PropertyName:="sizeCancelled")> _ Public Property sizeCancelled() As Double 'The current amount of this bet that was cancelled. <JsonProperty(PropertyName:="sizeVoided")> _ Public Property sizeVoided() As Double 'The current amount of this bet that was voided. <JsonProperty(PropertyName:="regulatorAuthCode")> _ Public Property regulatorAuthCode() As String 'The regulator authorisation code. <JsonProperty(PropertyName:="regulatorCode")> _ Public Property regulatorCode() As String 'The regulator Code End Class <JsonConverter(GetType(StringEnumConverter))> _ Public Enum SortDir EARLIEST_TO_LATEST 'Order from earliest value to latest e.g. lowest betId is first in the results. LATEST_TO_EARLIEST 'Order from the latest value to the earliest e.g. highest betId is first in the results. End Enum End NamespaceLast edited by Guest; 04-05-2014, 01:52 PM.
Leave a comment:
-
Instead of printing out:
can you get it to print out the ACTUAL full json string that it is sending?Code:Calling: SportsAPING/v1.0/listCurrentOrders With args: {"betIds":["3550545168"],"marketIds":null,"orderProjection":"ALL","dateRange":null,"orderBy":"BY_MATCH_TIME","sortDir":"EARLIEST_TO_LATEST","fromRecord":0,"recordCount":1000}
Leave a comment:
-
Guest repliedWorking
OK I got it working by using some code from davecon and I just hardcoded the JSON string shown below:
Code:strRequest = "{""jsonrpc"": ""2.0"", ""method"":""SportsAPING/v1.0/listCurrentOrders"",""params"":{}" & ", ""id"": 1}" Debug.Print("CALLING " & strRequest & vbCrLf) myJSON_Response = CreateJSON_TEST_Request(myBFdata.sKeyInUse, myBFdata.sSessionID, strRequest) Debug.Print("RESPONSE " & myJSON_Response.ToString & vbCrLf)
and the response
I also noted that it didn't matter what ID I set 1, or 2. I assumed it should be 2 for AUSTRALIA?Code:RESPONSE {"jsonrpc":"2.0","result":{"currentOrders":[{"betId":"3550545168","marketId":"2.100768838","selectionId":23401,"handicap":0.0,"priceSize":{"price":27.0,"size":10.0},"bspLiability":0.0,"side":"BACK","status":"EXECUTION_COMPLETE","persistenceType":"LAPSE","orderType":"LIMIT","placedDate":"2014-03-06T09:42:17.000Z","matchedDate":"2014-03-06T22:43:19.000Z","averagePriceMatched":27.0,"sizeMatched":10.0,"sizeRemaining":0.0,"sizeLapsed":0.0,"sizeCancelled":0.0,"sizeVoided":0.0}],"moreAvailable":false},"id":1}
I will now try to work out why the VB NET code I was building up did not work and post here at a later date.
PS. Thanks to bnl, betdynamics, for assisting me solve this issue (oh and Dave who gave me some code back in Jan)Last edited by Guest; 03-05-2014, 02:51 AM.
Leave a comment:
-
Guest repliedHmmm no - I think I will ask the betfair guys.
Here is a current bet in the market, Bet id 3550545168

Here is the JSON call and again response with nothing
Code:Calling: SportsAPING/v1.0/listCurrentOrders With args: {"betIds":["3550545168"],"marketIds":null,"orderProjection":"ALL","dateRange":null,"orderBy":"BY_MATCH_TIME","sortDir":"EARLIEST_TO_LATEST","fromRecord":0,"recordCount":1000} Got Response: {"jsonrpc":"2.0","result":{"moreAvailable":false},"id":1}
Leave a comment:
-
You should get unmatched bets returned if your orderProjection is set to ALL (or EXECUTABLE)Last edited by betdynamics; 30-04-2014, 06:47 AM.
Leave a comment:
-
Guest repliedyeah you have to ask. I do have a current bet for the League 2014 premiers being my Bronco team. This bet has been matched and I can see it in Betfair. However after your question I thought maybe the ListCurrentOrders is only applicable to orders made by my bot.
So here my bot places a bet in market for a future race (in 2 hours).
Looks good - I can see the Bet come up in my bot on the screen. Note the bet is NOT matched as its odds are above the asking, therefore the bet comes up on the lay side as expected waiting to be taken. I also can see it on the Betfair website if I log in.Code:Calling: SportsAPING/v1.0/placeOrders With args: {"marketId":"2.100951097","instructions":[{"orderType":"LIMIT","selectionId":8493136,"handicap":0.0,"side":"BACK","limitOrder":{"size":5.0,"price":12.0,"persistenceType":"LAPSE"}}],"customerRef":"Troy3","locale":null} Got Response: {"jsonrpc":"2.0","result":{"status":"SUCCESS","errorCode":"ERROR_IN_MATCHER","marketId":"2.100951097","instructionReports":[{"status":"SUCCESS","errorCode":"INVALID_BET_SIZE","instruction":{"orderType":"LIMIT","selectionId":8493136,"handicap":0.0,"side":"BACK","limitOrder":{"size":5.0,"price":12.0,"persistenceType":"LAPSE"}},"betId":"3727451117","placedDate":"2014-04-29T23:39:58Z","averagePriceMatched":0.0,"sizeMatched":0.0}],"customerRef":"Troy3"},"id":1} PlaceExecutionReport error code is: 0 InstructionReport error code is: 0 CustomerREF Troy3 Error Code 0 Bet ID 3727451117 Market ID 2.100951097 Status to string SUCCESS
I also tested a bet on a UK race (ie using UK endpoints) and I get the same NO RESPONCE
Does my Bet need to be taken (matched) to be shown in ListCurrentOrders ?Last edited by Guest; 29-04-2014, 11:55 PM.
Leave a comment:
-
Yes, I'm in the UK.
And I'm using 'https://api.betfair.com/exchange/betting/json-rpc/v1'
I'm not using VB so can't help you there.
You are getting a correct response from your request, but no orders shown, as if you don't have any open currently.
This is a daft question, but are you 100% positive that you have an open order with the Betfair account that is being used by your program? I'd double check this. Are you using test accounts / other accounts and switching between them?
Tony
Leave a comment:
-
Guest repliedThanks Tony
Can I just ask are you in the UK or AUS ? My assumption is that UK. I am in Aus and I cannot get the Betting visualizer to even work ? I am wondering if other Aussies have this problem. Hmmm may post the question.
Anyway I tried just calling listCurrentOrders with no args as shown below but I get nothing
The URI I am calling is https://api-au.betfair.com/exchange/...v1/json-rpc/v1 Can you tell me what you are using ? Maybe is a JSON v JSON RPC difference.Code:Calling: SportsAPING/v1.0/listCurrentOrders With args: {} Got Response: {"jsonrpc":"2.0","result":{"moreAvailable":false},"id":1}
Hey does Betfair have classes for listCurrentOrders and listClearedOrders similar to what they provided for the VB net APING example ??
What class/datatype/variable do you use to get the response? I created several classes based on the betfair data and have posted above - maybe this is why I am having errors. I have the following code in my VB NET JsonRpcClient.vb module.
Code:Public Function listCurrentOrders(ByVal betIds As IList(Of String), ByVal marketIds As IList(Of String), ByVal OrderProjection? As OrderProjection, ByVal placedDateRange As TimeRange, ByVal dateRange As TimeRange, ByVal OrderBy As OrderBy, ByVal SortDir As SortDir, ByVal intfromRecord As Integer, ByVal intrecordCount As Integer) As CurrentOrderSummaryReport Implements IClient.listCurrentOrders Dim args = New Dictionary(Of String, Object)() args(BET_IDS) = betIds 'BET_IDS is defined as "betIds args(MARKET_IDS) = marketIds 'MARKET_IDS is defined as "marketIds" args(ORDER_PROJECTION) = OrderProjection Return Invoke(Of CurrentOrderSummaryReport)(LIST_CURRENT_ORDERS, args) End FunctionLast edited by Guest; 29-04-2014, 01:33 PM.
Leave a comment:
-
I've just run listClearedOrders in the Visualiser with a betStatus = SETTLED.
This creates the following request:
This listed my settled bets.Code:{"betStatus":"SETTLED","settledDateRange":{}}
I also tried with includeItemDescription = false which created the following request:
This also listed my settled betsCode:{"betStatus":"SETTLED","settledDateRange":{},"includeItemDescription":"false"}
Tony
Leave a comment:
-
Originally posted by troyedwards8 View PostHey mate - thanks for your reply. It is good to know people out there helping others
Just on the visualizers, it might be an Australian thing but the account visualizer works ok, but the betting one has never worked for me (regardless of endpoint UK or AUS).
With regards to that bet I showed above, it is a current market (setup about 4 months ago) and I have a current bet on it.
I have also gone to Betfair - looked up a current horse race, placed a high bet on it like Horse 1 to win at 80:1 and still I can't get any details on the bet through the ListcurrentOrders call ?
Do you have the full JSON parameter call for ListCurrentOrders and ListClearedOrders ? For instance is the following JSON call correct ?
Code:Calling: SportsAPING/v1.0/listCurrentOrders With args: {"marketId":"2.100947624","orderProjection":"ALL"}
Also here is a call to ListClearedOrders which takes around 3 seconds to return a response, and doesn't return what I would expect. The response I do get looks like help on the call ..
Code:Calling: SportsAPING/v1.0/listClearedOrders With args: {"betStatus":"SETTLED","includeItemDescription":false} Got Response: {"jsonrpc":"2.0","result":{"betStatus":"SETTLED","side":"BACK","groupBy":"EVENT_TYPE","includeItemDescription":false,"fromRecord":0,"recordCount":0},"id":1}
Hi Troy,
You have a typo in your listCurrentOrders:
marketId should be marketIdsI spotted this as I have made this exact mistake many times...marketId, marketIds, phah :-)
Also, you need to use [ ] around the market Id list:
I use listCurrentOrders without any parameters as this returns all current orders:Code:{"marketIds":["2.100947624"],"orderProjection":"ALL"}
Code:{}
As for listClearedOrders, I don't use it, but I'd recommend putting double quotes around false:
Hope that helps,Code:{"betStatus":"SETTLED","includeItemDescription":"false"}
Tony
Leave a comment:
-
Guest repliedTa mate
Programing other stuff atm, and I haven't got ListCurrentOrders OR ListClearedOrders to work yet for me but as soon as I do I will post to this forum telling all what my mistake was.
Its a pity that the betfair team don't include an example in each of the code on how to use these calls. For instance I have based my bot on the free API NG VB NET example that was provided which shows you listEventTypes, MarketCatalog, MarketBook, and PlaceOrder.
Below are the four functions from there JsonRpcClient.vb module.
I have gone to code up CancelOrders which was straight forward, but am having probs with the ListCurrentOrders and ListClearedOrders.Code:Public Function listEventTypes(ByVal marketFilter As MarketFilter, Optional ByVal locale As String = Nothing) As IList(Of EventTypeResult) Implements IClient.listEventTypes Dim args = New Dictionary(Of String, Object)() args(FILTER) = marketFilter args(JsonRpcClient.LOCALE) = locale Return Invoke(Of List(Of EventTypeResult))(LIST_EVENT_TYPES_METHOD, args) End Function Public Function listMarketCatalogue(ByVal marketFilter As MarketFilter, ByVal marketProjections As ISet(Of MarketProjection), ByVal marketSort As MarketSort, Optional ByVal maxResult As String = "1", Optional ByVal locale As String = Nothing) As IList(Of MarketCatalogue) Implements IClient.listMarketCatalogue Dim args = New Dictionary(Of String, Object)() args(FILTER) = marketFilter args(MARKET_PROJECTION) = marketProjections args(SORT) = marketSort args(MAX_RESULTS) = maxResult 'args(JsonRpcClient.LOCALE) = locale Return Invoke(Of List(Of MarketCatalogue))(LIST_MARKET_CATALOGUE_METHOD, args) End Function Public Function listMarketBook(ByVal marketIds As IList(Of String), ByVal priceProjection As PriceProjection, Optional ByVal orderProjection? As OrderProjection = Nothing, Optional ByVal matchProjection? As MatchProjection = Nothing, Optional ByVal currencyCode As String = Nothing, Optional ByVal locale As String = Nothing) As IList(Of MarketBook) Implements IClient.listMarketBook Dim args = New Dictionary(Of String, Object)() args(MARKET_IDS) = marketIds args(PRICE_PROJECTION) = priceProjection args(ORDER_PROJECTION) = orderProjection args(MATCH_PROJECTION) = matchProjection 'args(JsonRpcClient.LOCALE) = locale args(CURRENCY_CODE) = currencyCode Return Invoke(Of List(Of MarketBook))(LIST_MARKET_BOOK_METHOD, args) End Function Public Function placeOrders(ByVal marketId As String, ByVal customerRef As String, ByVal placeInstructions As IList(Of PlaceInstruction), Optional ByVal locale As String = Nothing) As PlaceExecutionReport Implements IClient.placeOrders Dim args = New Dictionary(Of String, Object)() args(MARKET_ID) = marketId args(INSTRUCTIONS) = placeInstructions args(CUSTOMER_REFERENCE) = customerRef args(JsonRpcClient.LOCALE) = locale Return Invoke(Of PlaceExecutionReport)(PLACE_ORDERS_METHOD, args) End Function
I shall plug on .....
oh and on the ID=1, not sure either - I do see that in the Function below (which serializes up the JSON call) that the ID=1 is thrown in.
Code:Public Function Invoke(Of T)(ByVal method As String, Optional ByVal args As IDictionary(Of String, Object) = Nothing) As T <code above removed> Dim [call] = New JsonRequest With {.Method = method, .Id = 1, .Params = args} <code below removed>Last edited by Guest; 28-04-2014, 11:02 PM.
Leave a comment:
-
It's part of the standard JSON-RPC message format.
Here's the example on the API-NG Getting Started page:
https://api.developer.betfair.com/se...ed+with+API-NGCode:{ "params": { "filter": { "eventTypeIds": [1] } }, "jsonrpc": "2.0", "method": "SportsAPING/v1.0/listCompetitions", "id": 1 }
I have no idea what the "id" is for, or whether it is necessary.
I have it in all of my calls to the API.
Leave a comment:
-
Guest repliedHey how is ID=1 passed ? and what does that mean. I can't see anything info about this under https://api.developer.betfair.com/se...tCurrentOrders
Leave a comment:
-
Here is what I get:
Code:17:10:44:121,{"jsonrpc":"2.0","method":"SportsAPING/v1.0/listCurrentOrders","params":{"betIds":[],"marketIds":["1.113801671","1.113801667"],"fromRecord":0,"recordCount":0},"id":1}Code:17:10:44:223,{"jsonrpc":"2.0","result":{"currentOrders":[{"betId":"36746080515","marketId":"1.113801671","selectionId":58805,"handicap":0.0,"priceSize":{"price":3.8,"size":2.0},"bspLiability":0.0,"side":"LAY","status":"EXECUTION_COMPLETE","persistenceType":"PERSIST","orderType":"LIMIT","placedDate":"2014-04-27T17:09:53.000Z","matchedDate":"2014-04-27T17:09:53.000Z","averagePriceMatched":3.8,"sizeMatched":2.0,"sizeRemaining":0.0,"sizeLapsed":0.0,"sizeCancelled":0.0,"sizeVoided":0.0,"regulatorCode":"GIBRALTAR REGULATOR"}],"moreAvailable":false},"id":1}Last edited by betdynamics; 27-04-2014, 05:15 PM.
Leave a comment:


Leave a comment: