https://www.autoitscript.com/site/
Typically I load up to 3000 footy markets in Guardian on a busy Saturday. As I'm then forced to use polling, that makes for a very long refresh cycle at 3pm, even with restricted refresh set. So, what I do is use my Guardian baf to set a Stored Value called "RemoveMe" on any markets I don't need post KO, using any rules available in the baf i.e no bets entered, volume < x, time < y etc
Setting the SV via a baf means you have a very granular level of control over which markets get removed
Obviously you can use your own baf rules to set the criteria for "RemoveMe" to be set
This script runs from the AutoIt Scite console and checks each market on a loop to see if the "RemoveMe" SV is set, if it is it removes the market immediately. Keeps Guardian nice and tidy and really speeds up refresh times. Script is set to a 30s loop but that can be edited as you see fit
You'll need to add the 2 files posted on my Google Drive to your Autoit Includes folder - these are the UDF's (User Defined Functions) that allow the parsing of the retrieved JSON data
https://drive.google.com/drive/folders/ ... sp=sharing
Files are:
Json.au3
BinaryCall.au3
The script is only set up for football markets at the moment, using eventTypeId = 1 but editing out that line will open it up to any sport, it will also only look at in-play markets, to speed things up
Hope this is useful to someone
Code: Select all
#include <Inet.au3>
#include <json.au3>
;~ #include <Array.au3>
#include <String.au3>
#include <File.au3>
#include <Date.au3>
#include <math.au3>
While 1
;Get markets in BA via API
$BA_Markets = Post_to_BA("http://localhost:9000/api/markets/v1.0/getMarkets", '{"dataRequired":["ID","NAME","MARKET_START_TIME","EVENT_ID","EVENT_TYPE_ID","MARKET_TYPE","MARKET_INPLAY_STATUS"]}')
Do
Sleep(200)
Until StringInStr($BA_Markets, "status")
$objectBA = json_decode($BA_Markets)
Local $CountBA = Json_Get($objectBA, '.result.markets')
For $p = 0 To UBound($CountBA) - 1
If Json_Get($objectBA, '.result.markets[' & $p & '].inPlay') = "True" Then
If Json_Get($objectBA, '.result.markets[' & $p & '].eventTypeId') = 1 Then
$FootballID = Json_Get($objectBA, '.result.markets[' & $p & '].id')
$BA_StoredValues = Post_to_BA("http://localhost:9000/api/automation/v1.0/getStoredValues", '{"marketsFilter":{"filter":"SPECIFIED_IDS","ids":["' & $FootballID & '"]},"selectionsFilter":{"filter":"ALL"},"storedValueFilterMarketLevel":{"storedValueFilter":"ALL"},"storedValueFilterSelectionLevel":{"storedValueFilter":"ALL"}}')
If StringInStr($BA_StoredValues, "RemoveMe") Then
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/removeMarkets", '{"marketsFilter":{"filter":"SPECIFIED_IDS","ids":["' & $FootballID & '"]},"marketStatus":"ANY"}')
Do
Sleep(200)
Until StringInStr($Result, "status")
EndIf
EndIf
EndIf
Next
Sleep(30000) ;loop delay
WEnd
Func Post_to_BA($sEndpoint, $sRaw_JSON)
Local $oHttp = Null, _
$oComErr = Null
Local $iHttpStatus = 0
Local $sResponse = "", _
$sPostData = ""
;Create a HTTP COM object
$oHttp = ObjCreate("winhttp.winhttprequest.5.1")
With $oHttp
;Open POST request
.Open("POST", $sEndpoint, False)
;Set request headers and options
.SetRequestHeader("Content-Type", "application/json")
;Send request
.Send($sRaw_JSON)
;Get status code and response
$iHttpStatus = .Status
$sResponse = .ResponseText
EndWith
Return ($sResponse)
EndFunc ;==>Post_to_BA