Hi there sorry to bother you but i am new here.
the tuts where great thanks.has anyone got a piece of code to parse the compressed data for vb2008 or a quick breakdown of the info in the compressed code so i can try ?? to parse it myself.
cheers glenn
Using VB2008 to acccess the Betfair API: A tutorial
Collapse
This topic is closed.
X
X
-
Null reference exception
waldjunge,
It look like you are getting an API error. If so, the response object property.marketPrices is not set (i.e. is set to Nothing). This causes the “Null Reference Exception”. You should always ensure that .errorCode = OK before accessing the .marketPrices object.
To fix this, swap the two If statements over in your code:
If you look at the .errorCode in the response header you will see what's causing the API error.Code:If .errorCode = BFUK.GetMarketPricesErrorEnum.OK Then If .marketPrices.marketStatus = BFUK.MarketStatusEnum.ACTIVE Then With .marketPrices .......
Leave a comment:
-
BFUK.MarketStatusEnum.ACTIVE Error?
I get sometimes a "Null reference exception Error" in the line 'If .marketPrices.marketStatus = BFUK.MarketStatusEnum.ACTIVE Then'
Anybody knows why?
Code:Sub findBestPrice4Betting(ByVal MpriceResp As BFUK.GetMarketPricesResp, ByVal horse2searchID As Integer, ByVal BackOrLay As String) Dim Back As String myFoundPrice = 0 With MpriceResp CheckHeader(.header) 'OK 'print6(TimeString & " Single Horse Price -> " & .errorCode) If .marketPrices.marketStatus = BFUK.MarketStatusEnum.ACTIVE Then If .errorCode = BFUK.GetMarketPricesErrorEnum.OK Then With .marketPrices For i = 0 To .runnerPrices.Length - 1
Leave a comment:
-
Thanks a lot Mumbles0.
Right Code is here.
What's the difference between BFExchange.MarketTypeEnum.O,L,R,A...?Code:Dim oGBHReq As New BFExchange.GetBetHistoryReq Dim oGBHResp As New BFExchange.GetBetHistoryResp With oGBHReq .header = oHeaderUK .placedDateFrom = Now.AddDays(-7) .placedDateTo = Now .startRecord = 0 .recordCount = 30 .betTypesIncluded = BFExchange.BetStatusEnum.S ReDim .eventTypeIds(0) : .eventTypeIds(0) = 1 'For soccer ReDim .marketTypesIncluded(0) : .marketTypesIncluded(0) = BFExchange.MarketTypeEnum.O .sortBetsBy = BFExchange.BetsOrderByEnum.PLACED_DATE End With
ps: Keep up the good work Mumbles0.
Leave a comment:
-
getBetHistory
ribogio7,
You need to include the .betTypesIncluded parameter in the request header. Use M or U for bets on open markets, or use S for settled markets.
For .marketTypesIncluded you are using R (for range markets). Do you have any bets on range markets? Perhaps try O (for Odds markets).
If you have placed bets on normal Odds markets in the past 7 days you should return some bet history with this request object:
Code:With oGBHReq .header = oHeaderUK() .placedDateFrom = Now.AddDays(-7) .placedDateTo = Now .recordCount = 30 .betTypesIncluded = BFExchange.BetStatusEnum.S ReDim .marketTypesIncluded(0) : .marketTypesIncluded(0) = BFExchange.MarketTypeEnum.O .sortBetsBy = BFExchange.BetsOrderByEnum.PLACED_DATE End With
Leave a comment:
-
Hello Mumbles0
First of all my english is not very good.
I try to write a method which it returns all the results of bet history.
It appears an Errorcode=No_Results. Please look this part of code.Code:Dim oGBHReq As New BFExchange.GetBetHistoryReq Dim oGBHResp As New BFExchange.GetBetHistoryResp With oGBHReq .header = oHeaderUK .placedDateFrom = Now.AddDays(-7) .placedDateTo = Now .recordCount = 30 ReDim .marketTypesIncluded(0) : .marketTypesIncluded(0) = BFExchange.MarketTypeEnum.R .sortBetsBy = BFExchange.BetsOrderByEnum.PLACED_DATE End With oGBHResp = BetfairUK.getBetHistory(oGBHReq) With oGBHResp CheckHeader(.header) MsgBox("ErrorCode = " & .errorCode.ToString) If .errorCode = BFExchange.GetBetHistoryErrorEnum.OK Then For i = 0 To .betHistoryItems().Length - 1 RichTextBox1.Text = .betHistoryItems(i).betId & .betHistoryItems(i).betType & .betHistoryItems(i).placedDate & .betHistoryItems(i).price & vbNewLine Next End If End With
Leave a comment:
-
Visual Basic 2010
Microsoft have recently released a new version of Visual Basic - VB2010. Like VB2008, an Express Edition is available free of charge. There are some new language features and the IDE has had a facelift. Any code you have developed using VB2008 should be fully compatible with the new compiler.
Existing projects created with VB2008 will require some conversion. For example, to run the Betfair tester project with VB2010 you can proceed along these lines:
Copy the solution folder BetfairX to a new location. Rename it to something like BetfairX2010. The original folder is retained as a backup.
Start VB2010 and from the File menu select "Open Project". Browse to BetfairX.sln in the new BetfairX2010 folder. Click Open. This launches the conversion wizard. Click Next. Select No to the backup question (because we already have a backup). Click Finish. The conversion is now done. Check “Show the conversion log” and close the wizard. Now run the project. The familiar Betfair TestForm should appear and operate as expected.
In general, the source files will not require conversion, but the solution file (*.sln) will. The means that, once converted, the solution cannot be loaded with VB2008.
I suggest that you install this new version and use it for future development. It has a very similar feel to VB2008. If you have problems post a comment.
M0.
Leave a comment:
-
Local time
Jaybeeb,
I guess you are in the UK. All times returned by the API are UTC (or GMT if you like).
Use the ToLocalTime method to convert the event times to your local time.
Change the code in the Step 18 example to do this:
Code:[COLOR="Gray"]For Each Race In TodaysCard 'Print the card With Race Names = .menuPath.Split("\") Print(.eventDate[COLOR="Black"].ToLocalTime[/COLOR].TimeOfDay.ToString & " " & .marketId & " " & Names(3) & " - " & .marketName) End With Next[/COLOR]
Leave a comment:
-
Loving this tutorial and making a good stab at extra things myself now but having an issue with the times returned, not sure if its after the clocks went forward but with the code in this thread for the todayscard() all the race times are an hour behind??
Leave a comment:
-
Linq
Osprey,
Thanks for the kind words.
LINQ allows you to query a data source using convenient VB-language statements. Data sources can be in-memory objects, XML files or SQL databases.
At this stage I don’t know much LINQ, not enough to write an authoritative tutorial. There are, of course, many articles about LINQ on the web.
Leave a comment:
-
A vote of thanks ...
Really great thread Mumbles,
I have been trying to make the painful transition from VB6 to VB.Net+++ for quite some time now, your tutorial has added that extra whatsit, making the journey much easier and more interesting to boot!
Thus far, touching wood, I have successfully followed all of your tutorials/suggestions and therefore have code that can potentially be extended to money making uses. :-)
One related idea occurred to me however, under the heading of "what next", it seemed to me that LINQ could simplify a lot of the 'housekeeping' that you have been describing. If you agree, perhaps a tutorial on LINQ implementations would be useful?
Osprey
Leave a comment:
-
problem with session token
i have a trouble with session token
Betfair3._0.BFUK.GetMarketPricesErrorEnum.API_ERRO R
MpriceResp.errorCodeField{4}
and header_field [error_code{8}
i am calling the betfair.getmarketprices from another class, what is hapenning with the session token?what its wrong?
Leave a comment:
-
Thanks a lot Numbles0 i was doing bad writting questions, your help was very importatn for me, i don´t mean thtat the paths were diferents.
Thansk a lot
Leave a comment:


Leave a comment: