Using VB2008 to acccess the Betfair API: A tutorial
Collapse
This topic is closed.
X
X
-
Ladder
I wanted to know if you can insert and manage multiple markets on the same page.
and.... if is possible to access to Odds over the third level in order to prepare a ladder.
Leave a comment:
-
More market togheter
Dear Mumbles0,
I wanted to know if you can insert and manage multiple markets on the same page.
Thank's
Leave a comment:
-
Placebets with low stakes
Hello Mumbles0 and friends,
I changed the placebet to accept even lower stakes in 2 ($ or €). I have developed only to back but it will be easy to modify for the Lay bet:
Code:Private Sub bPlaceBet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bPlaceBet.Click Dim Market As Integer = Int(Val(Mark_id.Text)) 'The Id of your market Dim Selection As Integer = Nothing 'The Id of your selection Dim BetType As BFUK.BetTypeEnum 'For back or lay bet Dim tempIdBet As Long Dim secIdBet As Long = 0 For i As Byte = 0 To 30 If C_chk(i).Checked = True Then Selection = Int(Val(M_id(i).Text)) End If Next If rbBack.Checked Then BetType = BFUK.BetTypeEnum.B Else BetType = BFUK.BetTypeEnum.L 'Select Back or Lay bet BetPrice = nudPrice.Value 'The selected price BetSize = nudSize.Value 'The selected bet size If nudSize.Value < 2 And rbBack.Checked Then Dim prev_odd = nudPrice.Value 'memorize value nudprice per future use Dim Prev_stake = nudSize.Value ''memorize value nudsize per future use nudPrice.Value = 1000 ' place nudprice to odd 1000,00 nudSize.Value = 2 ' place nudsize to stake 2 TheBetId = 0 ' reset Thebetid variable PlaceBet(Market, Selection, BetType, nudPrice.Value, nudSize.Value) 'place the bet . it will not be placed While tempIdBet = 0 'Placebet is too fast. I expect the variable to be matched tempIdBet = TheBetId 'I store the id to cancel the bet after End While nudPrice.Value = 1000 ' I confirm Odd to 1000 BetPrice = 1000 ' Odd to 1000 should not change BetSize = nudSize.Value 'Old value = nudsize nudSize.Value = nudSize.Value + Prev_stake ' New value= oldvalue + prev_stake TheBetId = 0 : secIdBet = 0 UpdateBet(tempIdBet, nudPrice.Value, BetPrice, nudSize.Value, BetSize) ' Update the bet at new values 'Now I will have two bets. The first bet to odd=1000 with stakes= 2 Euro and the second Bet to Odd=1000 but with right stakes While secIdBet = 0 secIdBet = TheBetId ' stores the id of the bet to change it later End While nudPrice.Value = prev_odd ' new odd = prev_odd (the initial odd) BetPrice = 1000 ' Odd to modify nudSize.Value = Prev_stake ' original stake UpdateBet(secIdBet, nudPrice.Value, BetPrice, nudSize.Value, BetSize) ' I change the bet at the right Odd and the right stake CancelBet(tempIdBet) ' cancel the first bet 'all done Exit Sub End If If nudSize.Value >= 2 And rbBack.Checked Then PlaceBet(Market, Selection, BetType, BetPrice, BetSize) 'piazzo la scommessa che non verra' accettata . End If End Sub
Leave a comment:
-
I placed a Lay bet which had a price of 5.9 with 7.9 instead. The following ".errorCode = BFUK.PlaceBetsErrorEnum.OK" gave me OK.
However the .PlaceBetsResults.success was not successful and I have gotten "INVALID_INCREMENT"
What does this INVALID_INCREMENT exactly mean? The bet was not matched because of this error (message), what did I do wrong, and how can I prevent this in future?
thanks,
WaldjungeLast edited by waldjunge; 05-08-2010, 03:56 PM.
Leave a comment:
-
PlaceBet
Alth79,
I don't know why you're not using the sub's calling parameters, but it works!
Is anything being "printed"? If not, the Sub is not being called.
Leave a comment:
-
Placing a bet
Hi Mumbles0
Thanks for getting back to me about ste 19 - placing a bet.
I am still struggling to get this working - I have changed my code as you suggested and no longer receive an error message. I am still not able to place a test bet on my application.
Below is the code which i have (the market, and id's were correct at the time of testing.
(CODE):
Private Sub PlaceBet(ByVal YourMarket As Integer, ByVal YourSelection As Integer, ByVal YourBetType As BFUK.BetTypeEnum, ByVal BetPrice As Decimal, ByVal BetSize As Decimal)
Dim oPlaceBetsReq As New BFUK.PlaceBetsReq
Dim oPlaceBetsResp As BFUK.PlaceBetsResp
Dim oBet As New BFUK.PlaceBets
With oPlaceBetsReq
.header = oHeaderUK()
With oBet
.asianLineId = 0
.betCategoryType = BFUK.BetCategoryTypeEnum.E
.betPersistenceType = BFUK.BetPersistenceTypeEnum.NONE
.betType = 0
.marketId = 101599071
.price = 8.8
.selectionId = 3804941
.size = 2.0
.bspLiability = 0
End With
ReDim .bets(0)
.bets(0) = oBet
End With
oPlaceBetsResp = BetFairUK.placeBets(oPlaceBetsReq)
With oPlaceBetsResp
CheckHeader(.header)
Print("ErrorCode = " & .errorCode.ToString)
If .errorCode = BFUK.PlaceBetsErrorEnum.OK Then
For i = 0 To .betResults.Length - 1
With .betResults(i)
Print(.resultCode.ToString)
If .success Then
Print("BetId = " & .betId)
TheBetID = .betId
End If
End With
Next
End If
End With
End Sub
Dim TheBetID As Long
(CODE END)
If you could take a look at this to see where I am going wrong I would be most grateful.
Cheers
Leave a comment:
-
Bet < 2
[QUOTE=supunsilva.;2181] I have found how to place low amount(Stake<2) bets.
Hi friend,
I'm also looking for a way to bet <2. Can you explain what method you used? Thanks
Leave a comment:
-
MyApiProg
Thank's for All!!!

This is just the beginning but I like and I'm proud.
gvigliani
Leave a comment:
-
Thank you
Dear friend Mumbles0,
You have absolutely right and the program works perfectly and without any problems.
I thank you for the fast reply.
Gvigliani
Leave a comment:
-
Declaring variables
gvigliani,
Your Dim statements are OK (but there’s no point in setting the values to Nothing).
The variables BetPrice, BetSize, etc. were declared previously in Step 19. I did not re-declare them in step 23. These variables are declared outside the Subs that use them. Perhaps this has caused some confusion.
Declaring variables
All variables that you use must be declared somewhere within your program. The first thing the complier does is build a list of variables declared within your program. When you use a variable, the compiler looks for its name in this list. If it doesn’t find it, it gives the 'name' is not declared error.
For example, if you have a simple assignment statement:
BetPrice = 3.5and you see the message 'BetPrice' is not declared in the error list, this is telling you that the complier does not know what BetPrice is. You must tell the compiler what BetPrice is before you use it. You do this with a declaration statement, for example:
Dim BetPrice as DecimalThe "not declared" error should now disappear.
We can combine these two statements into one:
Dim BetPrice as Decimal = 3.5Here we declare the variable BetPrice and initialize it to 3.5 in one line. This can be handy.
You can declare several variables in one Dim statement:
Dim BetPrice As Decimal, BetSize As Decimal, TheBetId As LongBecause BetSize and BetPrice are both of type Decimal you can simplify this to:
Dim BetPrice, BetSize As Decimal, TheBetId As LongThis is same as writing:
Dim BetSize As DecimalThese declarations are said to be non-executable statements. They simply instruct the compiler to reserve space in memory for the variables. However, if you initialize a variable, for example:
Dim BetPrice As Decimal
Dim TheBetId As Long
Dim BetSize as Decimal = 2you now have an executable statement - the value 2 is assigned at run time.
Variable access
You can use the Private, Friend or Public keywords instead of Dim for variables declared outside a sub or function:
Private BetPrice, BetSize As Decimal, TheBetId As LongIf the declared variable are to be accessed by code anywhere in your project (e.g. from another form) use Friend or Public. Use Private or Dim for variables that are only accessed by code within the current class.
Variables declared within a procedure (a procedure is a sub or function) can only be declared with Dim. These variables are local to the procedure and cannot be accessed from outside the procedure directly.
Variable access (variable scope) is a fairly large topic, This is just a brief introduction.Last edited by Mumbles0; 02-08-2010, 02:54 PM.
Leave a comment:
-
Hi Mumbles0,
I put the following dim in Class Test Forms
Dim TheBetId As Long 'The betId (returned from placeBets)
Dim BetPrice As Decimal = Nothing 'Your desired odds
Dim BetSize As Decimal = Nothing 'Your bet amount in currency units
the problem is gone but I know if it is justified and then do exactly this way.
Greetings
Leave a comment:
-
Hi Mumbles0,
excuse if you do not write well in English but I hope to be able to make myself understood. I can first declare that I have learned more by following your posts you read all the books on Betfair.
I was trying to do a test on Step 23. Changing Beth.
my program that works well, but with this function fails giving error:
BetPrice = .newPrice
BetSize = .newSize 'Update with the new values
nudPrice.Value = .newPrice
nudSize.Value = .newSize
1) BetPrice is not Declared
2) BetSize is not Declared
I checked Function Placebet and is identical to the one you published and this, with the button and place your bets bPlaceBet works but the function UpdateBet gives me those errors. May depend on what?
Thanks
Leave a comment:


Leave a comment: