There are some previous threads on this subject that are worth reading
Here is a calculator that correctly deals with the UK matching rules
The author says it can cope with over 10,000 trades.