So I am a bit curious on how Guardian processes rules in a baf file in terms of order and execution, as I keep seeing odd behaviour and weird log output, here is an example:
20/05/2021 13:00:10: [G_Auto 1] : Automation Signal for market: take_SP = 1
20/05/2021 13:00:10: [G_Auto 1] : Cancelling bets 233831620159
20/05/2021 13:00:10: [G_Auto 1] : An error occurred while updating bet persistence: The entire order has been rejected.
20/05/2021 13:00:10: [G_Auto 1] : Modify bet persistence 233831620124 from 'Cancel' to 'Take SP'
20/05/2021 13:00:10: [G_Auto 1] : Modify bet persistence 233831620159 from 'Cancel' to 'Take SP'
20/05/2021 13:00:10: [G_Auto 1] : Cancelling bets 233831620124
20/05/2021 13:00:10: [G_Auto 1] : £ 3.43 Lay bet placed on Azor Ahai at 1.05. Entirely unmatched when it initially reached the market. Ref: 233831641007
20/05/2021 13:00:10: [G_Auto 1] : £ 11.84 Back bet placed on Signal Twenty Nine at 100. Entirely unmatched when it initially reached the market. Ref: 233831641006
So the actual order of rules in the BAF file is:
- Cancel Orders
- Submit new orders
- Take SP all unmatched
But as you can see from the log it shows:
- First take_SP signal from the Take SP all unmatched rule
- Then Cancelling 1 bet msg
- Then Error msg from take SP (because it is trying to take_SP on cancelled orders)
- Then another Cancelling msg
- Then the 2 new bets
So totally different order to the BAF !?!
It sort of looks like maybe Guardian is asynchronously spawning threads for each rule regardless of order or completion of any previous rule?
BAF Rule ordering and execution?
I'm sort of thinking I need to put 1-2 seconds between each rule, so for example to allow time for the Cancel rule to execute, then the Back new bet, then the Take SP on the new Back bet. Without the extra "time" it seems the Take SP is selecting the Cancelled orders. Ideally i'd like to specify the bet ref for the Take SP, can you do that?
This is want I need I think: https://docs.developer.betfair.com/disp ... laceOrders
Each rule gets checked in the order they are in the file, 100s of rules can be checked in a fraction of a second
So depending what each is doing you may need to insert a gap between each one (or you could just arm it to trigger starting the same time but have it trigger 2-3 times)
ie, if placing a bet you'll need to allow enough milliseconds for it to travel to Betfairs servers over your internet connection then for them to place it into the market, then send back the bet reference etc, all this could all take 10ms
If the next rule is to react to that ie, take SP/Keep bets etc its needs to trigger on the next refresh cycle at the earliest
If you are setting a signal or stored value with a rule they are done locally so any subsequent rules can react to that even as part of the same refresh cycle
So depending what each is doing you may need to insert a gap between each one (or you could just arm it to trigger starting the same time but have it trigger 2-3 times)
ie, if placing a bet you'll need to allow enough milliseconds for it to travel to Betfairs servers over your internet connection then for them to place it into the market, then send back the bet reference etc, all this could all take 10ms
If the next rule is to react to that ie, take SP/Keep bets etc its needs to trigger on the next refresh cycle at the earliest
If you are setting a signal or stored value with a rule they are done locally so any subsequent rules can react to that even as part of the same refresh cycle
Thank you Dallas, that's really useful to know, I will ensure the dependent rules execute on the next refresh cycle via a signal increment or something.Dallas wrote: ↑Thu May 20, 2021 3:32 pmEach rule gets checked in the order they are in the file, 100s of rules can be checked in a fraction of a second
So depending what each is doing you may need to insert a gap between each one (or you could just arm it to trigger starting the same time but have it trigger 2-3 times)
ie, if placing a bet you'll need to allow enough milliseconds for it to travel to Betfairs servers over your internet connection then for them to place it into the market, then send back the bet reference etc, all this could all take 10ms
If the next rule is to react to that ie, take SP/Keep bets etc its needs to trigger on the next refresh cycle at the earliest
If you are setting a signal or stored value with a rule they are done locally so any subsequent rules can react to that even as part of the same refresh cycle
Cheers
G