The updated OPTI method calculation (August 2020) offers the choice of two options depending on the treatment of long-term coins in your country. You can select them in the Tax Report Settings:
If you choose option one, where the sale of long-term coins is completely tax free (for example Austria), the method calculates the optimal result (= lowest tax to pay) as follows:
Every single sale gets compared individually against all purchases and the match is picked according to the following priority:
first take highest to lowest GAIN from long coins, then take highest to lowest LOSS from short coins, then take lowest to highest LOSS from Long coins and finally (if not avoidable) take lowest to highest GAIN from short coins.
If you choose option two, where the long-term coins have only a reduced tax rate (for example the US), the method calculates the optimal result as follows:
first take highest to lowest LOSS for short coins, then highest to lowest LOSS for long coins, then lowest to highest gain for LONG coins and finally lowest to highest gain for SHORT coins.