Hi,Bigsprout!
Thank you for quick answer.
I have other code to write to a file:
Probably, I will give a bigger piece of code. Can anyone see a non-optimal code.I am no programmer, wrote as he could.
Thank you for quick answer.
I have other code to write to a file:
Code:
logfile = "C:\scachki\new\" & MarketId & ".txt" My.Computer.FileSystem.WriteAllText(logfile, allttr & vbCrLf, True)
Code:
Private Sub BFindMarket_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BFindMarket.Click
With FindTimer
If .Enabled Then
.Stop()
BFindMarket.ForeColor = Color.Black
Else
.Interval = 60000
.Start()
BFindMarket.ForeColor = Color.Green
End If
End With
End Sub
Private Sub FindTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindTimer.Tick
Print("*** Find(timer) ***")
FindMatch(BetFairUK.getMarketPrices(MpricesReq))
End Sub
Sub FindMatch(ByVal MpriceResp As BFUK.GetMarketPricesResp)
Dim result As String
Dim oMarketsReq As New BFUK.GetAllMarketsReq
Dim oMarketsResp As BFUK.GetAllMarketsResp
Dim ttl As Double
Dim strtarget, nott As Integer
With oMarketsReq
.header = oHeaderUK()
ReDim .eventTypeIds(0) : .eventTypeIds(0) = 7
ReDim .countries(1) : .countries(0) = "GBR" : .countries(1) = "IRL"
.fromDate = Today
.toDate = Today.AddDays(1)
End With
Print("proces=" & proces)
If (proces = 0) Then
Print("*** WE SEEK A NEW MATCH ***")
oMarketsResp = BetFairUK.getAllMarkets(oMarketsReq)
With BetFairUK.getAllMarkets(oMarketsReq)
CheckHeader(.header)
Print("ErrorCode = " & .errorCode.ToString)
If .errorCode = BFUK.GetAllMarketsErrorEnum.OK Then
Dim AllMarkets As New UnpackAllMarkets(.marketData)
Dim Names As String(), TodaysCard As New List(Of MarketDataType)
With AllMarkets
For i = 0 To .marketData.Length - 1
Names = .marketData(i).menuPath.Split("\")
If Names.Length = 4 AndAlso Not Names(3).StartsWith("Daily") Then
If .marketData(i).noOfWinners = 1 Then
TodaysCard.Add(.marketData(i))
End If
End If
Next
End With
TodaysCard.Sort(New CompareMarketTimes)
For Each Race In TodaysCard
With Race
ttl = .totalAmountMatched
result = .marketId
Print("ttl=" & ttl & " proces=" & proces & " result=" & result)
Dim reader = My.Computer.FileSystem.ReadAllText("C:\scachki\new\UsedMarket.txt")
strtarget = reader.IndexOf(result)
Print("strtarget=" & strtarget & " proces=" & proces)
If (strtarget = -1) Then
My.Computer.FileSystem.WriteAllText("C:\scachki\new\UsedMarket.txt", result & vbCrLf, True)
If ttl > 2000 Then
MarketId = .marketId
proces = 1
find_match = 1
strk = .marketName
strt = .eventDate.ToLocalTime.AddHours(1).TimeOfDay.ToString
With FindTimer
If .Enabled Then
.Stop()
BFindMarket.ForeColor = Color.Black
End If
End With
With PriceTimer
If .Enabled Then
nott = 0
Else
.Interval = 2000
.Start()
BPrices.ForeColor = Color.Green
End If
End With
End If
End If
End With
Next
End If
End With
End If
End Sub
Private Sub BPrices_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BPrices.Click
With PriceTimer
If .Enabled Then
.Stop()
BPrices.ForeColor = Color.Black
Else
.Interval = 2000
.Start()
BPrices.ForeColor = Color.Green
End If
End With
End Sub
Private Sub PriceTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PriceTimer.Tick
Print("*** Prices(timer) ***")
Dim oMPCreq As New BFUK.GetMarketPricesCompressedReq
With oMPCreq
.header = oHeaderUK()
.marketId = MarketId
End With
StateCount += 1
BetFairUK.getMarketPricesCompressedAsync(oMPCreq, StateCount)
End Sub
Private Sub BetFairUK_getMarketPricesCompressedCompleted(ByVal sender As Object, ByVal e As BFUK.getMarketPricesCompressedCompletedEventArgs) Handles BetFairUK.getMarketPricesCompressedCompleted
Dim Lay, Back, allttr, yy, logfile, nott As String
Dim oMarketsReq As New BFUK.GetAllMarketsReq
Dim back1, lay1 As Double
Dim dly As Integer
Dim yy1, yy2 As DateTime
allttr = ""
'...............................................................................................................
If (proces = 0) Then
If (find_match = 1) Then
Print("*** WE SEEK A NEW MATCH ***")
With PriceTimer
If .Enabled Then
.Stop()
BPrices.ForeColor = Color.Black
End If
End With
With FindTimer
If .Enabled Then
nott = 0
Else
.Interval = 60000
.Start()
BFindMarket.ForeColor = Color.Green
End If
End With
Else
Print("*** BOT STOPPED ***")
With PriceTimer
If .Enabled Then
.Stop()
BPrices.ForeColor = Color.Black
End If
End With
End If
Else
Try
If Not e.Cancelled Then
With e.Result
CheckHeader(.header)
yy = .header.timestamp.ToLocalTime.AddHours(1).ToString
Print("ErrorCode = " & .errorCode.ToString)
If .errorCode = BFUK.GetMarketPricesErrorEnum.OK Then
Dim oMarketPrices As New UnpackMarketPricesCompressed(.marketPrices)
With oMarketPrices
Print("MarketID = " & .marketId & " in play=" & .delay)
dly = .delay
'----------------- Prepare --------------------------------------------------
allttr = allttr & yy & " "
For i = 0 To .runnerPrices.Length - 1
With .runnerPrices(i)
Back = ""
For j = 0 To .bestPricesToBack.Length - 1
With .bestPricesToBack(j)
Back = Back & " " & .price & "/" & Int(.amountAvailable)
End With
Next
If .bestPricesToBack.Length > 0 Then
back1 = .bestPricesToBack(0).price
Else
Print("CURVE DATA")
back1 = 0.999
proces = 0
Print("*** MATCH CLOSED ***")
End If
allttr = allttr & i + 1 & "= " & back1
Lay = ""
For j = 0 To .bestPricesToLay.Length - 1
With .bestPricesToLay(j)
Lay = Lay & " " & .price & "/" & Int(.amountAvailable)
End With
Next
If .bestPricesToLay.Length > 0 Then
lay1 = .bestPricesToLay(0).price
Else
lay1 = 999
End If
allttr = allttr & "-" & lay1 & " "
Print(i + 1 & " Back = " & Back & " Lay = " & Lay)
End With
Next
If My.Computer.FileSystem.FileExists(logfile) Then
nott = ""
Else
pred_yy = "23.09.2011 5:02:57"
logfile = "C:\scachki\new\" & MarketId & ".txt"
My.Computer.FileSystem.WriteAllText(logfile, strt & " " & strk & vbCrLf, True)
Print2(strt & " " & strk)
End If
yy1 = DateTime.Parse(pred_yy)
yy2 = DateTime.Parse(yy)
'-------------------- main part -----------------------------------------------
If yy2 > yy1 Then
allttr = allttr & " " & dly
logfile = "C:\scachki\new\" & MarketId & ".txt"
My.Computer.FileSystem.WriteAllText(logfile, allttr & vbCrLf, True)
pred_yy = yy
End If
'-------------------------------------------------------------------------------------------------
End With
End If
End With
End If
Catch ex As ApplicationException
Print(e.Error.Message)
End Try
End If
End Sub


Dime........bar.
Comment