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

Issue #23254:fix gain/loss calculation