In-running football

Please post any questions regarding the program here.

Moderator: 2020vision

In-running football

Postby Drunkenight » Sat Sep 04, 2010 5:11 pm

Hi, Does anyone know a way of stopping excel from placing bets, for say 10 seconds, after the market has reopened following a suspension? For example during an in-running football match, when there is a goal the market is suspended, then about 20-30 seconds later the market is normally reopened. I find that the prices that come back after the market reopens can be very volitle. I would like to stop my robots putting up any prices until the market has settled, say about 10 seconds after the market has reopened. Does anyone know of a way of doing this in excel?

Hope this makes sense :)
Drunkenight
 
Posts: 247
Joined: Thu Apr 02, 2009 1:38 pm

Postby Captain Sensible » Sat Sep 04, 2010 10:24 pm

You could add a timer to log the time the markets in play and have it reset to zero for anything other than "In Play" in E2(?). Then just add another condition to your triggers saying don't be til that's a least 10 seconds.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Drunkenight » Sat Sep 04, 2010 11:11 pm

Hi Captain, thanks - yes that is an excellent idea! I can set a trigger to block any bets within 10 seconds of the market opening. If the market is suspended it should set the timer to Zero and only allow bets once the timer has got to say 10 seconds. Do you have any idea what the formula would be?
Drunkenight
 
Posts: 247
Joined: Thu Apr 02, 2009 1:38 pm

Postby Captain Sensible » Sun Sep 05, 2010 12:48 am

You'd need to use VBA to log the time, my vb is pretty limited so hopefully one of the VB experts will post something up but my effort would be something like


Dim check As Integer
Dim timer As Date

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Columns.Count <> 16 Then Exit Sub


If Range("F2").Value = "Suspended" Or Range("E2").Value <> "In Play" Then
check = 0
Range("X1").Value = ""
timer = Now()
GoTo Xit
ElseIf Range("E2").Value = "In Play" And check = 0 Then
check = 1
timer = Now()
End If

If Range("F2").Value = "" And Range("E2").Value = "In Play" And check = 1 Then
Range("X1").Value = Now() - timer
Else
Range("X1").Value = ""
End If



Xit:
End Sub


That should take a snapshot of the current time when the markets in play and not suspended then output the difference to X1. If the market gets suspended or not in play it resets all variables
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Drunkenight » Sun Sep 05, 2010 1:13 pm

Thanks! This has given me a lot of ideas. How about if I just add the following code to my VBA:-
If Range("F2").Value = "Suspended" Then Application.Wait Now + TimeValue("00:00:10")

Will this pause the macro for 10 seconds if the market is suspended?
Drunkenight
 
Posts: 247
Joined: Thu Apr 02, 2009 1:38 pm

Postby Captain Sensible » Sun Sep 05, 2010 1:26 pm

Like I said I'm a VBA novice DK, no idea how Application.Wait works and if it stops the app receiving data as well i.e. when it starts responding again "Suspended" is no longer present but cleared a second or two ago so you wouldn't get the full benefit of 10second delay if that makes sense.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Drunkenight » Mon Sep 06, 2010 11:46 am

Yes you are right, it will have the effect of anywhere between 0 - 10 seconds delay after the market has been reopened. I have tested it out and seems to work ok, but will keep an eye on it. Thanks for your help!
Drunkenight
 
Posts: 247
Joined: Thu Apr 02, 2009 1:38 pm

Postby Captain Sensible » Mon Sep 06, 2010 12:17 pm

You could always tweak it slightly so "Suspended" sets a marker i'.e.

Dim suspendcheck As Integer

If Range("F2").Value = "Suspended" Then suspendcheck =1 Exit sub

If Range("F2").Value <> "Suspended" And suspendcheck =1 Then
Application.Wait Now + TimeValue("00:00:10")
check = 0
End If

That way it'll continue updating and only go into the wait routine after the market has reopened then clear the suspended check
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Drunkenight » Mon Sep 06, 2010 4:48 pm

Brilliant! Yes this is exactly what I want to do.

A couple of questions:-
1. Can I just add this to my existing macro?
2. If Range("F2").Value = "Suspended" Then suspendcheck =1 Exit sub. What does the 'Exit sub' do? Will I have to change this to fit in with my existing code?
3. 'check = 0' should this be 'suspendcheck = 0'
Drunkenight
 
Posts: 247
Joined: Thu Apr 02, 2009 1:38 pm

Postby Captain Sensible » Mon Sep 06, 2010 5:17 pm

Drunkenight wrote:Brilliant! Yes this is exactly what I want to do.

A couple of questions:-
1. Can I just add this to my existing macro?
2. If Range("F2").Value = "Suspended" Then suspendcheck =1 Exit sub. What does the 'Exit sub' do? Will I have to change this to fit in with my existing code?
3. 'check = 0' should this be 'suspendcheck = 0'



1. can't see any reason why not especially if your code is already using

If Range("F2").Value = "Suspended" Then Application.Wait Now + TimeValue("00:00:10")

2. I just put Exit Sub in there so it would exit the VBA routine and not bother with processing any of the other stuff in your routine cos there's probably no need for it to execute the rest of the code. There's no need to add it especially if the rest of the code is doing something useful whilst the market is suspended.

3. I just changed the variable name to suspendcheck as it was a bit more representative of what it did, and forgot to change the check=0 as I cut and pasted :(


You'd just need to add the following to your current Worksheet_Change routine.

Declare the variable suspendCheck

Dim suspendCheck as Integer

then inside your Worksheet_Change routine add these at the top of the routine

If Range("F2").Value = "Suspended" Then
suspendCheck =1
End If


If Range("F2").Value <> "Suspended" And suspendCheck =1 Then
Application.Wait Now + TimeValue("00:00:10")
suspendCheck = 0
End If



The first If should set suspendCheck as 1 once the market shows as suspended. As soon as the suspension is lifted the next If with the delay code will come into play as F2 is no longer "Suspended" & suspendCheck contains 1, that should delay for 10 seconds then reset suspendCheck back to 0 and run the rest of your code.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Drunkenight » Thu Sep 09, 2010 1:09 am

Excellent. Thanks for the code - works a treat!

My robots now wait at least 10 seconds after the suspend comes off - which is exactly what I wanted. :)
Drunkenight
 
Posts: 247
Joined: Thu Apr 02, 2009 1:38 pm

Postby Captain Sensible » Thu Sep 09, 2010 4:03 pm

No problem, glad it worked for you. I'd never heard of Application.Wait Now and used to use sleep for my delays which is more long winded so it'll come in useful next time i need delays in my code
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm


Return to Help

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 38 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.