Hi
I'm sorry, but I don't think what you ask is possible to do. The reason is the same as in Reply 13 in this topic. I have spent some more time today looking at it, but have not been able to come up with something that works. Below is a brief explanation.
Because the lay bets are in 2x different markets (win and place), the statement and win/lose history variables cannot be linked to those specific markets. We can only identify the last settled market overall, or the second last settled market etc.
Now if for whatever reason, Betfair settle a win market, but there is a delay on the settlement of the place market, the win/lose variables are no longer accurate, and the loss recoupment will not work correctly.
Add to that, if the next event’s two markets are settled before the previously delayed market is settled, the win/lose variables become a real mess.
Ideally, what is needed is the market_id to be included in the statement entries and relating win/lose variables. Hopefully we will get this in a future update.
Sorry I could not help you on this at the moment.