Issue #23254:fix gain/loss calculation
Merge pull request #436 from garyhgohoos/23254-3

Issue #23254:fix gain/loss calculation