Author Topic: lay formula  (Read 2403 times)

Tags:
  • All members
  • Posts: 57
lay formula
« on: 21 Mar 2016, 10:33 »
Hi all

I have been playing around with a lay formula in place of using the distribute loss feature .The distribute loss didn't seem to work successfully (I get regular comments in the log file that suggest that selections are not available for loss distribution despite there being a clear loss position on runners where back matched are greater than 0 but that's another conversation).I am laying at lay_price2 which has helped me minimise unmatched bets.I found this formula on the boards here and tried to modify it for lay_price 2 :    ((bm_backa*(bm_backp-1))*((100-sl1)/100))/(lay_price2-1)
-sl1 is 0.01
This works well on some races but for reasons I can't explain it will fail to work on a number of races randomly with the following errors logged for the trigger:
"Error in the trigger expression of price or amount for selection
All bets will be discarded"

This error occurs in time machine as well as on live races (test or real). Lay_price2 appears to be available on the market for the relevant selection at the time the bet is placed and there are a number of errors -1 for each time the formula is run as it seems to retry over and over again while the conditions are true.I have noted however that the (lay_price2-1) portion of the formula in the log shows as (0-1) when it calculates values -- when there is an error which led me to make sure that the lay_price2 amount is available.It is almost as though there is a small time gap where there is no lay_price2 amount available at the time of calculation and this is remembered and not renewed for each retry? Anyway, my questions are: is there a problem with the formula? If so, why does it only work sometimes? -or is it because lay_price2 is not available at that instant and that 0 amount is remembered for each retry? Is there another more elegant way to distribute the loss for a back bet other than using the distribute loss function (which fails as per above).Thanks in advance

  • Moderator
  • Posts: 3597
*
Re: lay formula
« Reply #1 on: 21 Mar 2016, 18:32 »
Hi
The standard amount formula to green or red a back bet is (bm_backp*bm_backa)/lay_price

I think lay_price2 is too close, especially inplay, can be gone in millisecs.

Try this which will submit a lay bet 10 ticks above the current best lay price (replace 10 with any amount of ticks):
LAY
Price: r_ticks(lay_price,10)
Amount: (bm_backp*bm_backa)/lay_price
Conditions:
selections back matched is greater than 0
....plus any further conditions to confirm the selection is running a loss

Now, this will always work smoothly in test mode, because it will use lay_price and distribute evenly. You will have to try with small stakes in real mode because Betfair will match your lay bet which is submitted 10 ticks above lay_price, at the best available price, if there is sufficient unmatched volume, and then move to the next best price etc.

Hope that makes sense. 
Please read the following disclaimer with regards to the information you may request and obtain on our forum. This specifically concerns trigger files and various instructions as to how to implement a strategy.

  • All members
  • Posts: 57
Re: lay formula
« Reply #2 on: 21 Mar 2016, 21:03 »
Thanks very much MarkV.That makes sense. I'll give it a go

  • All members
  • Posts: 57
Re: lay formula
« Reply #3 on: 23 Mar 2016, 08:16 »
Hi MarkV

Just a quick update. I am getting just one part of the error now "Äll bets will be discarded". The lay price is showing as 0 in the formula which I will monitor ongoing in terms of availability vs race time. I also noticed a strange anomaly in a live race overnight (still in test) where my back matched condition seemed to be fulfilled by the legitimate back matched and a runner where I hadn't backed (or even tried to). I had the lay trigger set to execute once per market so the lay executed against the runner which hadn't been backed so it lay'd at 1.02 (not ideal  :o) Not sure of this is a Betfair API error and I have only seen this once over hundreds of bets but mention it for interest sake . I am trying running the trigger a specific number of times (4) to see if that resolves the issue.I'll update this post as I progress.Cheers

  • Moderator
  • Posts: 3597
*
Re: lay formula
« Reply #4 on: 23 Mar 2016, 10:31 »
Hi
Thanks for your update. Depending on how your trigger is constructed, it is possible your conditions or formulae not specific enough, e.g. (s_1_bm_backp*s_1_bm_backa)/s_1_lay_price refers explicitly to the variables for selection index 1.

Have you tried test laying at "best" price, and also check your settings for this option are as you want them Settings > Betting Options > When laying at "best" price...
Also in case you have not seen it, there is a very good description of "best" in the manual which might be useful to you.
Please read the following disclaimer with regards to the information you may request and obtain on our forum. This specifically concerns trigger files and various instructions as to how to implement a strategy.

  • All members
  • Posts: 57
Re: lay formula
« Reply #5 on: 24 Mar 2016, 08:30 »
Thanks for that MarkV. It would be difficult to specify the index as I am looking for criteria that vary in the original back selection. The specific number of times option failed.I will try the 'best' option.Had forgotten about that,cheers
Will let you know

  • All members
  • Posts: 57
Re: lay formula
« Reply #6 on: 27 Mar 2016, 07:13 »
Hi
Update: Wasn't able to get around this. I think it was due to in play betting and the lay price not being available. I am not entirely sure as the lay amounts looked to be available but could be due to betfair queues etc. I changed the trigger timing and it is not 100% but looks to be working better now.Thanks for the help and advice MarkV

 

Please note, BetFair is seems to be currently OFFLINE