Removing Unwanted Markets from Guardian - AutoIt Script

The Bet Angel API makes it easy for you to further enhance your betting and trading by integrating your own code into Bet Angel
Post Reply
sniffer66
Posts: 1681
Joined: Thu May 02, 2019 8:37 am

A few people have suggested this facility in Guardian, but this is what I do via the BA API, using Auto-It - which I know a few people on here use

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




Last edited by sniffer66 on Wed Nov 08, 2023 7:47 pm, edited 2 times in total.
User avatar
Dallas
Posts: 22731
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

Thanks for sharing with others

Image
Anbell
Posts: 2062
Joined: Fri Apr 05, 2019 2:31 am

sniffer66 wrote:
Wed Nov 08, 2023 5:20 pm
A few people have suggested this facility in Guardian, but this is what I do via the BA API, using Auto-It - which I know a few people on here use

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




Thanks for posting this. I've been experimenting with different solutions to the same problem. One partial solution for some situations is to just load up different instances of BA and spreading the load that way.

Why do you need to switch to polling?
sniffer66
Posts: 1681
Joined: Thu May 02, 2019 8:37 am

Anbell wrote:
Thu Nov 09, 2023 5:50 am
sniffer66 wrote:
Wed Nov 08, 2023 5:20 pm
A few people have suggested this facility in Guardian, but this is what I do via the BA API, using Auto-It - which I know a few people on here use

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




Thanks for posting this. I've been experimenting with different solutions to the same problem. One partial solution for some situations is to just load up different instances of BA and spreading the load that way.

Why do you need to switch to polling?

I exchange prices and other data between the football markets I load, so I have 6 markets per match. To split matches between instances would then be a pain. Plus working with all the multiple windows I find annoying.

There's a 1000 market limit using streaming, so going over that with 3000 markets isn't possible in one instance.

Using this script, combined with restricted refresh, is neat way of solving that issue. With the strats I use I can get rid of most markets immediately after KO, as I've captured the pre off pricing
Anbell
Posts: 2062
Joined: Fri Apr 05, 2019 2:31 am

sniffer66 wrote:
Thu Nov 09, 2023 5:56 am
Anbell wrote:
Thu Nov 09, 2023 5:50 am
sniffer66 wrote:
Wed Nov 08, 2023 5:20 pm
A few people have suggested this facility in Guardian, but this is what I do via the BA API, using Auto-It - which I know a few people on here use

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




Thanks for posting this. I've been experimenting with different solutions to the same problem. One partial solution for some situations is to just load up different instances of BA and spreading the load that way.

Why do you need to switch to polling?

I exchange prices and other data between the football markets I load, so I have 6 markets per match. To split matches between instances would then be a pain. Plus working with all the multiple windows I find annoying.

There's a 1000 market limit using streaming, so going over that with 3000 markets isn't possible in one instance.

Using this script, combined with restricted refresh, is neat way of solving that issue. With the strats I use I can get rid of most markets immediately after KO
Ah, thanks. I wasnt aware that you could process more than 1000 markets using polling.

Your autoit script solution is obviously working for you, so I was just commenting for other people on the off chance that the script system isnt for them!

In the same vain, I've found that I can get around the shared market thing by loading up one region in one instance, and another region in another etc.

I agree with the multiple windows be annoying. I've a few kludges for that too - but still searching for a better process.
sniffer66
Posts: 1681
Joined: Thu May 02, 2019 8:37 am

To be honest, it's also a good way to keep things neat in Guardian even when you have less than 1000 markets, say on a Thursday - removing Closed matches, matches that don't qualify for an entry etc, without having to manually remove them. I know when I look at a Watch List (which I now sort using SV's with entered markets at the top) that all I'm looking at is matches I'm interested in. No having to get rid of them manually in Guardian - it's fully automatic
Anbell
Posts: 2062
Joined: Fri Apr 05, 2019 2:31 am

sniffer66 wrote:
Thu Nov 09, 2023 6:17 am
To be honest, it's also a good way to keep things neat in Guardian even when you have less than 1000 markets, say on a Thursday - removing Closed matches, matches that don't qualify for an entry etc, without having to manually remove them. I know when I look at a Watch List (which I now sort using SV's with entered markets at the top) that all I'm looking at is matches I'm interested in. No having to get rid of them manually in Guardian - it's fully automatic
Good point. Are you no-touch at the front end as well?
sniffer66
Posts: 1681
Joined: Thu May 02, 2019 8:37 am

Anbell wrote:
Thu Nov 09, 2023 6:32 am
sniffer66 wrote:
Thu Nov 09, 2023 6:17 am
To be honest, it's also a good way to keep things neat in Guardian even when you have less than 1000 markets, say on a Thursday - removing Closed matches, matches that don't qualify for an entry etc, without having to manually remove them. I know when I look at a Watch List (which I now sort using SV's with entered markets at the top) that all I'm looking at is matches I'm interested in. No having to get rid of them manually in Guardian - it's fully automatic
Good point. Are you no-touch at the front end as well?
Probably about 80% hands free, so it does help having an instant view of the other 20%
Anbell
Posts: 2062
Joined: Fri Apr 05, 2019 2:31 am

sniffer66 wrote:
Thu Nov 09, 2023 6:35 am
Anbell wrote:
Thu Nov 09, 2023 6:32 am
sniffer66 wrote:
Thu Nov 09, 2023 6:17 am
To be honest, it's also a good way to keep things neat in Guardian even when you have less than 1000 markets, say on a Thursday - removing Closed matches, matches that don't qualify for an entry etc, without having to manually remove them. I know when I look at a Watch List (which I now sort using SV's with entered markets at the top) that all I'm looking at is matches I'm interested in. No having to get rid of them manually in Guardian - it's fully automatic
Good point. Are you no-touch at the front end as well?
Probably about 80% hands free, so it does help having an instant view of the other 20%
Nice work.

Have you posted a script for loading markets into guardian before? Every time I've tried to implement it I fail, but I have some spare time in the next few days.
sniffer66
Posts: 1681
Joined: Thu May 02, 2019 8:37 am

I don't think I've posted one, but I do have an API script that does it. I run it on a timed loop set for 5am, it will load a number of coupons, and assign the correct baf's , given the sport/market type etc. I'm completely hands free on Guardian if I need to be - no having to go in each morning and set everything up

In fact I could merge the unwanted markets one with the 5am load. At 5am it will set everything up, drop to the unwanted sub loop then break out at 5am (or any other time) to load new markets

Happy to share or walk you through it if it's going to be useful
Anbell
Posts: 2062
Joined: Fri Apr 05, 2019 2:31 am

sniffer66 wrote:
Thu Nov 09, 2023 6:44 am
I don't think I've posted one, but I do have an API script that does it. I run it on a timed loop set for 5am, it will load a number of coupons, and assign the correct baf's , given the sport/market type etc. I'm completely hands free on Guardian if I need to be - no having to go in each morning and set everything up

In fact I could merge the unwanted markets one with the 5am load. At 5am it will set everything up, drop to the unwanted sub loop then break out at 5am (or any other time) to load new markets

Happy to share or walk you through it if it's going to be useful
That's very generous of you! Should we do it in public so others can also learn?
sniffer66
Posts: 1681
Joined: Thu May 02, 2019 8:37 am

Yes, of course. Happy to share
Anbell
Posts: 2062
Joined: Fri Apr 05, 2019 2:31 am

Great! I've never used a betangel API. Do we need to buy a key or something? (I have a key on some of my other accounts already but dont really understand it)
sniffer66
Posts: 1681
Joined: Thu May 02, 2019 8:37 am

Anbell wrote:
Thu Nov 09, 2023 7:07 am
Great! I've never used a betangel API. Do we need to buy a key or something? (I have a key on some of my other accounts already but dont really understand it)
No, you have unrestricted access to the BA API as part of the license. All you need to do is turn it on via settings


Capture.JPG

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)
You do not have the required permissions to view the files attached to this post.
Last edited by sniffer66 on Thu Nov 09, 2023 7:15 am, edited 1 time in total.
Anbell
Posts: 2062
Joined: Fri Apr 05, 2019 2:31 am

sniffer66 wrote:
Thu Nov 09, 2023 7:10 am
Anbell wrote:
Thu Nov 09, 2023 7:07 am
Great! I've never used a betangel API. Do we need to buy a key or something? (I have a key on some of my other accounts already but dont really understand it)
No, you have unrestricted access to the BA API as part of the license. All you need to do is turn it on via settings

Capture.JPG
Done
Post Reply

Return to “Bet Angel - API”