keydown problem...#2
what happens if the form doesn't exist..like when we made the buttons(i) form for the buttons....
i.e. i cant see this form in the properties box...
can i set in the code somehow so when i load up the form it always has keypreview = true?
Using VB2008 to acccess the Betfair API: A tutorial
Collapse
This topic is closed.
X
X
-
I've had a reasonable scan throughout this post to see if it was going to be any use to me and have to say that Mumbles0 must be approaching sainthood by now. Firstly many thanks just for imparting your knowledge but what impresses me most is your patience with mere mortals trying to understand. You seem to have answered any question posed and in such an understanding way with no hint patronising, hats off to you.
BTW this was exactly what I was hoping to find .... only trouble now is I have to start writing some code aaarrrggghhh!!!!!! World beware ( or should I rephrase with ' Mumbles0 Prepare ').
Leave a comment:
-
granted,
Set the KeyPreview property to True in the properties window for Form1 before you run the project.
Leave a comment:
-
keydown problem...anyone know about keydown stuff?
i have 2 checkboxes
all i want to do is:
if i press the letter Z it selects checkbox 2 otherwise checkbox 1 is selected
it tried this, but nothing happens
Code:Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown Me.KeyPreview = True If e.KeyCode = Keys.Z Then Me.RadioButton1.Checked = True Me.RadioButton2.Checked = False Else Me.RadioButton1.Checked = False Me.RadioButton2.Checked = True End If End Sub
Leave a comment:
-
Reply to ribogio7 (re: Profit & Loss)
The values shown near each runner name are the profit & loss values. These are the amount you would win (or lose) if that particular runner were to win the event.
The API call getMarketProfitAndLoss returns a set of values, but it only takes into account your matched bets. The website shows the IfWin values for proposed (unsubmitted) bets. Neither of these sets are particularly useful if you want to assess your current situation if you have several bets (matched, unmatched and proposed) on a market, so it’s probably best to calculate your own values. At least that way you know what you're getting.
For each runner:
IfWin = Total profits from back bets on this runner - Total losses from lay bets on this runnerHere is an idea to calculate the IfWin values:
- Total amount of back bets on other runners + Total amount of lay bets on other runners
Define a class (say, BetInfo) to hold details of each bet on the market:
Use this class for both back and lay bets, but use +ve amounts for Back, and -ve amounts for Lay. This will simplify the calculations. For example:Code:Class BetInfo 'A class for bet details Property price As Decimal Property amount As Decimal 'Use + for back, - for lay 'Other bet properties End Class
Bet1.amount = 5 for a Back betWhen you place a bet add an instance of this class to a separate bet List for each runner to model the bets on the market. Hold the Lists for all the runners in an array (say, Bets()).
Bet1.amount = -5 for a Lay bet
An algorithm the calculate the IfWin values for each runner is this:
It’s up to you what bets are added to the bet lists - matched, unmatched or proposed. Bear in mind that unmatched bets may not, of course, be matched at the desired price.Code:Dim Bets() As List(Of BetInfo), IfWin() As Decimal, i, j, k, m As Integer 'Build the array of bet lists '..... m = Bets.Count - 1 'The number of runners - 1 ReDim IfWin(m) 'An array to hold the profit(or loss) values for each runner For i = 0 To m 'For each runner For j = 0 To m 'Look at all runners For k = 0 To Bets(j).Count - 1 'For each bet on this runner With Bets(j)(k) If j = i Then 'Runner is winner IfWin(i) += .amount * (.price - 1) 'Accumulate totals Else 'Other runners IfWin(i) += -.amount End If End With Next Next Next
Leave a comment:
-
Hi, can anyone give some pointers on how to automatically select the next market once the market timer reaches zero.
Thanks
Tony
Leave a comment:
-
Hello Mumbles0,
First of all,i am grateful for all your help.
I have one more question about profit and loss in particular market.
How can i get the profit or loss in every selection before place the bet...?
Which method can i use to display these values...?
ps:I have upload an image to help you about this issue.Attached Files
Leave a comment:
-
Depends if you're using the free api or full api.Originally posted by granted View Postdoes anyone know how i can cancel all unmatched bets for a market id?
The full API has a call CancelBetsByMarket which only requires the header and marketId (or array of marketIds) - downside is you don't get a full breakdown to the bets in the market i'e. if some of the bets have been matched between sending the request and it hitting the exhange and may still have to call up getMUBets to monitor any positions you have in the market.
With the free api you're only option is to call getMUBets and request a list of unmatched bets then send the array of betIds to cancelBets - cancelBets will then give you a fuller picture confirming the status of your outstanding bets including if any have been matched whilst the request was sent.
Leave a comment:
-
cancel all unmatched bets
does anyone know how i can cancel all unmatched bets for a market id?
Leave a comment:
-
John10,
The special bet pertains to the Melbourne Cup, event date 2 November 2010, but your date limits are set for today only. So put
.fromDate = Todayto return this market.
.toDate = #11/3/2010#
Leave a comment:
-
Market return differance
Mumbles0
image of my treeview created as per this tutorial
Attachment MyTree.jpg
image of BfExplorer
Attachment Bfexplorer.jpg
My question is, What changes are required to the following code to get the special bet under horse racing
Code:Private Sub bMarkets_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bAUMarkets.Click Print("*** AU Markets ***") Dim oMarketsReq As New BFAU.GetAllMarketsReq Dim oMarketsResp As BFAU.GetAllMarketsResp With oMarketsReq .header = oHeaderAU() ReDim .eventTypeIds(1) : .eventTypeIds(0) = 7 : .eventTypeIds(1) = 4339 'For horse , greyhound ReDim .countries(1) : .countries(0) = "AUS" : .countries(1) = "NZL" .fromDate = Today .toDate = Today.AddDays(1) End With oMarketsResp = BetFairAU.getAllMarkets(oMarketsReq) 'Call the AU API With oMarketsResp CheckHeader(.header) Print("ErrorCode = " & .errorCode.ToString) If .errorCode = BFAU.GetAllMarketsErrorEnum.OK Then 'Print(.marketData) Dim AllMarkets As New UnpackAllMarkets(.marketData) 'Create an object and unpack the string PopulateTreeView(AllMarkets, tvMarkets) 'With AllMarkets ' For i = 0 To .marketData.Length - 1 ' With .marketData(i) ' Print(.eventHeirachy & " " & .marketId & " " & .marketStatus & " " & .marketName & " " & .menuPath & " " & .countryCode) ' End With ' Next 'End With End If End With End SubAttached Files
Leave a comment:
-
Thanks labus. The tutorial has gown quite large (mainly unplanned). That ties it down nicely.
Leave a comment:
-
Hi i made list of all steps for better orientation this great tutorial
Step 1. Build a Test Form
Step 2. Connecting to the Global service
Step 3. Saving the Session Token
Step 4. Typical API call: getActiveEventTypes
Step 5. Accessing an Exchange API
Step 6. Unpacking Response Strings
Step 7. Restrictions of the Free API
Step 8. Using a Call Timer
Step 9. Making Async API Calls
Step 10. Calling getCompleteMarketPricesCompressed
Step 11. A Look at Multithreading
Step 12. Getting a List of Runners
Step 13. Enabling gzip Compression
Step 14. Calling getMarketPricesCompressed
Step 15. Using TreeView to show events and markets
Step 16. Unpacking Removed Runners
Step 17. Sorting Runner Info Arrays
Step 18. Horse Racing - Today’s Card
Step 19. Placing a Bet
Step 20. Monitoring Bet Status
Step 21. Cancelling a Bet
Step 22. Changing the bet size and price
Step 23. Changing a Bet
Step 24. Calling getMarketTradedVolumeCompressed
Step 25. Accessing Australian Markets
Step 26. Array fundamentals
Step 27. Understanding Object References
Step 28. Placing Multiple Bets with placeBets
Step 29. Adding controls to a form at run time
Step 30. Saving your project’s settings
Leave a comment:
-
GetBetHistory
Hello
Thanks to everyone and especially to Mumbles0
One question that I can not solve. I'm using the call to Get Bet History (exchange) and I ask the ProfitAndloss and he returns the amount without applying the commission. However, in support of the API says that returns "Net result of bet"
I'm using the code ribogio7
http://bdphelp.betfair.com/API6/6.0/...tml/wwhelp.htmCode: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 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).profitAndloss & vbNewLine Next End If End With
Any suggestions, thanksLast edited by Monairda; 19-09-2010, 06:46 PM.
Leave a comment:
-
Munbles0 I didn't know that you can load the DataGridView directly. thanks for the Tip.
It Works Great.
Leave a comment:


Leave a comment: