Then you'll need to go here:
https://www.autoitscript.com/site/autoit/downloads/
And install Auto-It , and the Autoit Scite Editor. (Top 2 download links)
Removing Unwanted Markets from Guardian - AutoIt Script
And from my first post:
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
Your location may differ, but my Include folder is here:
C:\Program Files (x86)\AutoIt3\Include
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
Your location may differ, but my Include folder is here:
C:\Program Files (x86)\AutoIt3\Include
Done. Thank you!sniffer66 wrote: ↑Thu Nov 09, 2023 7:26 amAnd from my first post:
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
Your location may differ, but my Include folder is here:
C:\Program Files (x86)\AutoIt3\Include
Ok, what I suggest we do is build the script in stages, rather than just give you the finished article. That way you understand what it's doing , and the affect any changes will make
So first, you need to open the Auto -It Scite editor, which is where we will paste the code and then run it
Once open, then copy the code below into it, and then save it with a file name i.e Guardian_Loader.au3
All Autoit scripts have the extension - *.au3
The below code will load the relevant coupon in BA, Clear Guardian and Watch List 1, then load the markets in your Coupons filter, adding new markets into the Watch List
Substituting "MY_COUPON_NAME" for a coupon in your BA that you would like to load. Leave any inverted commas etc in place
You run the code by doing "Tools = Go" in the Editor
So first, you need to open the Auto -It Scite editor, which is where we will paste the code and then run it
Once open, then copy the code below into it, and then save it with a file name i.e Guardian_Loader.au3
All Autoit scripts have the extension - *.au3
The below code will load the relevant coupon in BA, Clear Guardian and Watch List 1, then load the markets in your Coupons filter, adding new markets into the Watch List
Substituting "MY_COUPON_NAME" for a coupon in your BA that you would like to load. Leave any inverted commas etc in place
You run the code by doing "Tools = Go" in the Editor
Code: Select all
#include <Inet.au3>
#include <json.au3>
;~ #include <Array.au3>
#include <String.au3>
#include <File.au3>
#include <Date.au3>
#include <math.au3>
;Load BA Coupon
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyCoupon", '{"couponName":"MY_COUPON_NAME","clearOption":"CLEAR_GUARDIAN_AND_WATCH_LIST","watchListNumber":1}')
Do
Sleep(200)
Until StringInStr($Result, "status")
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
sniffer66 wrote: ↑Thu Nov 09, 2023 7:45 amOk, what I suggest we do is build the script in stages, rather than just give you the finished article. That way you understand what it's doing , and the affect any changes will make
So first, you need to open the Auto -It Scite editor, which is where we will paste the code and then run it
Once open, then copy the code below into it, and then save it with a file name i.e Guardian_Loader.au3
All Autoit scripts have the extension - *.au3
The below code will load the relevant coupon in BA, Clear Guardian and Watch List 1, then load the markets in your Coupons filter, adding new markets into the Watch List
Substituting "MY_COUPON_NAME" for a coupon in your BA that you would like to load. Leave any inverted commas etc in place
You run the code by doing "Tools = Go" in the Editor
Code: Select all
#include <Inet.au3> #include <json.au3> ;~ #include <Array.au3> #include <String.au3> #include <File.au3> #include <Date.au3> #include <math.au3> ;Load BA Coupon $Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyCoupon", '{"couponName":"MY_COUPON_NAME","clearOption":"CLEAR_GUARDIAN_AND_WATCH_LIST","watchListNumber":1}') Do Sleep(200) Until StringInStr($Result, "status") 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
Thanks again. I have to go feed the family. Can we come back to this later (maybe tomorrow)?
Thanks so much. Is your mum ok?
So I've installed as described above: I have a launcher that grabs the desired markets and puts them in Guardian, and I strip some out when the market goes inplay to free up Guardian - all based on the instructions in this thread. I presume they will operate without touch as long as I have those files open in AUTOIT and press tools / go?
The next step for me would be to automate adding an automation file to all markets once they are in Guardian.
I can see that I'll also have an issue with dealing with more than 3000 markets at a time. I presume that I'll be able to handle that using different accounts, or only loading up on certain countries per instance.
Thanks again for your help
My mum is recovering well thanks - hip replacement operation so a little sore
Ok, so to recap. We have a function called "Post_To_BA" which handles the multiple calls we will make to the BA API. It's the same process every time, just using different parameters, so as a function we can just keep re-using the code
Then we have this line:
Which passes the "Apply Coupon" JSON to the function and runs it
Now we need to query BA to see what markets we have loaded by the coupon. So we add another line:
and wait for the response using:
We then use the JSON UDF to decode the response, and count the number of markets returned
I'm making the assumption we are looking at football markets, but can always change that later. Let's say we want to get a list of all Football Match Odds markets.
So, we loop through the markets, using the count we returned above and look for all markets ID's with those parameters
using that list of ID's (comma delimited in the code), we can then apply our BAF to those ID's using: (Replacing "MY_BAF_NAME" with your own baf)
The entire code will then look like this:
Then if we want to apply a different baf to say, CS markets, its a quick copy, paste and edit, changing the parameters in the search and name of the return string, then applying that different baf to the returned CS markets
If you want it to be completely hands free, then we put the entire code in an endless loop, do a quick time check at say, 5am and run the code once, then wait until 5am the next day.
See if the above works OK for you and request any edits you need and we can look at adding in the loop code
Ok, so to recap. We have a function called "Post_To_BA" which handles the multiple calls we will make to the BA API. It's the same process every time, just using different parameters, so as a function we can just keep re-using the code
Then we have this line:
Code: Select all
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyCoupon", '{"couponName":"MY_COUPON_NAME","clearOption":"CLEAR_GUARDIAN_AND_WATCH_LIST","watchListNumber":1}')
Now we need to query BA to see what markets we have loaded by the coupon. So we add another line:
Code: Select all
;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"]}')
Code: Select all
Do
Sleep(200)
Until StringInStr($BA_Markets, "status")
Code: Select all
$objectBA = json_decode($BA_Markets)
Local $CountBA = Json_Get($objectBA, '.result.markets')
I'm making the assumption we are looking at football markets, but can always change that later. Let's say we want to get a list of all Football Match Odds markets.
So, we loop through the markets, using the count we returned above and look for all markets ID's with those parameters
Code: Select all
$FootballIDsMO = ""
For $p = 0 To UBound($CountBA) - 1
If Json_Get($objectBA, '.result.markets[' & $p & '].eventTypeId') = 1 And StringInStr(Json_Get($objectBA, '.result.markets[' & $p & '].name'), "Match Odds") Then
$FootballIDsMO = $FootballIDsMO & '"' & Json_Get($objectBA, '.result.markets[' & $p & '].id') & '",'
EndIf
Next
Code: Select all
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyRules", '{"rulesFileName":"MY_BAF_NAME","marketsFilter":{"filter":"SPECIFIED_IDS","ids":[' & $FootballIDsMO & ']},"guardianRulesColumn":1}}')
Do
Sleep(200)
Until StringInStr($Result, "status")
Sleep(2000)
The entire code will then look like this:
Code: Select all
#include <Inet.au3>
#include <json.au3>
;~ #include <Array.au3>
#include <String.au3>
#include <File.au3>
#include <Date.au3>
#include <math.au3>
;Load BA Coupon
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyCoupon", '{"couponName":"MY_COUPON_NAME","clearOption":"CLEAR_GUARDIAN_AND_WATCH_LIST","watchListNumber":1}')
Do
Sleep(200)
Until StringInStr($Result, "status")
$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"]}')
Do
Sleep(200)
Until StringInStr($BA_Markets, "status")
$objectBA = json_decode($BA_Markets)
Local $CountBA = Json_Get($objectBA, '.result.markets')
$FootballIDsMO = ""
For $p = 0 To UBound($CountBA) - 1
If Json_Get($objectBA, '.result.markets[' & $p & '].eventTypeId') = 1 And StringInStr(Json_Get($objectBA, '.result.markets[' & $p & '].name'), "Match Odds") Then
$FootballIDsMO = $FootballIDsMO & '"' & Json_Get($objectBA, '.result.markets[' & $p & '].id') & '",'
EndIf
Next
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyRules", '{"rulesFileName":"MY_BAF_NAME","marketsFilter":{"filter":"SPECIFIED_IDS","ids":[' & $FootballIDsMO & ']},"guardianRulesColumn":1}}')
Do
Sleep(200)
Until StringInStr($Result, "status")
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
Then if we want to apply a different baf to say, CS markets, its a quick copy, paste and edit, changing the parameters in the search and name of the return string, then applying that different baf to the returned CS markets
If you want it to be completely hands free, then we put the entire code in an endless loop, do a quick time check at say, 5am and run the code once, then wait until 5am the next day.
See if the above works OK for you and request any edits you need and we can look at adding in the loop code
Thanks for this. Apologies with the delay replying. I've given this one a spin today and after a couple of false starts I have got it mostly working!sniffer66 wrote: ↑Tue Nov 14, 2023 10:46 amMy mum is recovering well thanks - hip replacement operation so a little sore
Ok, so to recap. We have a function called "Post_To_BA" which handles the multiple calls we will make to the BA API. It's the same process every time, just using different parameters, so as a function we can just keep re-using the code
Then we have this line:
Which passes the "Apply Coupon" JSON to the function and runs itCode: Select all
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyCoupon", '{"couponName":"MY_COUPON_NAME","clearOption":"CLEAR_GUARDIAN_AND_WATCH_LIST","watchListNumber":1}')
Now we need to query BA to see what markets we have loaded by the coupon. So we add another line:
and wait for the response using:Code: Select all
;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"]}')
We then use the JSON UDF to decode the response, and count the number of markets returnedCode: Select all
Do Sleep(200) Until StringInStr($BA_Markets, "status")
Code: Select all
$objectBA = json_decode($BA_Markets) Local $CountBA = Json_Get($objectBA, '.result.markets')
I'm making the assumption we are looking at football markets, but can always change that later. Let's say we want to get a list of all Football Match Odds markets.
So, we loop through the markets, using the count we returned above and look for all markets ID's with those parameters
using that list of ID's (comma delimited in the code), we can then apply our BAF to those ID's using: (Replacing "MY_BAF_NAME" with your own baf)Code: Select all
$FootballIDsMO = "" For $p = 0 To UBound($CountBA) - 1 If Json_Get($objectBA, '.result.markets[' & $p & '].eventTypeId') = 1 And StringInStr(Json_Get($objectBA, '.result.markets[' & $p & '].name'), "Match Odds") Then $FootballIDsMO = $FootballIDsMO & '"' & Json_Get($objectBA, '.result.markets[' & $p & '].id') & '",' EndIf Next
Code: Select all
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyRules", '{"rulesFileName":"MY_BAF_NAME","marketsFilter":{"filter":"SPECIFIED_IDS","ids":[' & $FootballIDsMO & ']},"guardianRulesColumn":1}}') Do Sleep(200) Until StringInStr($Result, "status") Sleep(2000)
The entire code will then look like this:
Code: Select all
#include <Inet.au3> #include <json.au3> ;~ #include <Array.au3> #include <String.au3> #include <File.au3> #include <Date.au3> #include <math.au3> ;Load BA Coupon $Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyCoupon", '{"couponName":"MY_COUPON_NAME","clearOption":"CLEAR_GUARDIAN_AND_WATCH_LIST","watchListNumber":1}') Do Sleep(200) Until StringInStr($Result, "status") $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"]}') Do Sleep(200) Until StringInStr($BA_Markets, "status") $objectBA = json_decode($BA_Markets) Local $CountBA = Json_Get($objectBA, '.result.markets') $FootballIDsMO = "" For $p = 0 To UBound($CountBA) - 1 If Json_Get($objectBA, '.result.markets[' & $p & '].eventTypeId') = 1 And StringInStr(Json_Get($objectBA, '.result.markets[' & $p & '].name'), "Match Odds") Then $FootballIDsMO = $FootballIDsMO & '"' & Json_Get($objectBA, '.result.markets[' & $p & '].id') & '",' EndIf Next $Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyRules", '{"rulesFileName":"MY_BAF_NAME","marketsFilter":{"filter":"SPECIFIED_IDS","ids":[' & $FootballIDsMO & ']},"guardianRulesColumn":1}}') Do Sleep(200) Until StringInStr($Result, "status") 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
Then if we want to apply a different baf to say, CS markets, its a quick copy, paste and edit, changing the parameters in the search and name of the return string, then applying that different baf to the returned CS markets
If you want it to be completely hands free, then we put the entire code in an endless loop, do a quick time check at say, 5am and run the code once, then wait until 5am the next day.
See if the above works OK for you and request any edits you need and we can look at adding in the loop code
I'm having some issues with the Automation Rules not being added to every market. I'm currently using streaming with a 20ms refresh. I'm not sure if that is causing an issue with the AUTOIT loop delays? Manually triggering the script a few times seems to result in the AUTO being added to each market.
And yes, running hands-free would be ideal at some point!
Good stuff
I have a feeling it might be that we haven't put a delay in after applying the coupon, and then doing the GetMarkets call
Try this, and see if it helps
I've put a 1 minute sleep in, whilst the markets initialise via the coupon "Sleep(60000)". If that isn't long enough try increasing it - time is in milliseconds
I have a feeling it might be that we haven't put a delay in after applying the coupon, and then doing the GetMarkets call
Try this, and see if it helps
I've put a 1 minute sleep in, whilst the markets initialise via the coupon "Sleep(60000)". If that isn't long enough try increasing it - time is in milliseconds
Code: Select all
#include <Inet.au3>
#include <json.au3>
;~ #include <Array.au3>
#include <String.au3>
#include <File.au3>
#include <Date.au3>
#include <math.au3>
;Load BA Coupon
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyCoupon", '{"couponName":"MY_COUPON_NAME","clearOption":"CLEAR_GUARDIAN_AND_WATCH_LIST","watchListNumber":1}')
Do
Sleep(200)
Until StringInStr($Result, "status")
Sleep(60000)
$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"]}')
Do
Sleep(200)
Until StringInStr($BA_Markets, "status")
$objectBA = json_decode($BA_Markets)
Local $CountBA = Json_Get($objectBA, '.result.markets')
$FootballIDsMO = ""
For $p = 0 To UBound($CountBA) - 1
If Json_Get($objectBA, '.result.markets[' & $p & '].eventTypeId') = 1 And StringInStr(Json_Get($objectBA, '.result.markets[' & $p & '].name'), "Match Odds") Then
$FootballIDsMO = $FootballIDsMO & '"' & Json_Get($objectBA, '.result.markets[' & $p & '].id') & '",'
EndIf
Next
$Result = Post_to_BA("http://localhost:9000/api/guardian/v1.0/applyRules", '{"rulesFileName":"MY_BAF_NAME","marketsFilter":{"filter":"SPECIFIED_IDS","ids":[' & $FootballIDsMO & ']},"guardianRulesColumn":1}}')
Do
Sleep(200)
Until StringInStr($Result, "status")
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