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

Issue #23254:fix gain/loss calculation