Koinly has this tax basis method already, as per below: Optimized HIFO is a special cost-basis method that incorporates specific lot identification in order to prioritize long-term gains over short-term gains. Optimized HIFO is very similar to regular HIFO, with the main difference being that Optimized HIFO will consider the holding period of the lot being sold, while regular HIFO will only consider the cost-basis of the lot. This is the exact order in which Optimized HIFO will prioritize your holdings: - Any lots resulting in a short-term loss will be selected first - Any lots resulting in a long-term loss will be selected second - Any lots resulting in a long-term profit will be selected third - Any lots resulting in a short-term profit will be selected last This means that Optimized HIFO will prioritize short-term losses over long-term losses, and will only generate short-term profit if there are no other lots to select from.