common/math: Add math.Abs to PercentageDifference calculation (#1617)

* fix bug and add decimal calc

* pew pew

* Update common/math/math.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

* nits: plus change name convention

* gk: nits and splits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2024-11-27 10:27:15 +11:00
committed by GitHub
parent 0fb27542fe
commit a0d82f2a7d
5 changed files with 78 additions and 44 deletions

View File

@@ -1049,10 +1049,10 @@ func (m *DataHistoryManager) CheckCandleIssue(job *DataHistoryJob, multiplier in
}
if apiData != dbData {
var diff float64
if apiData > dbData {
diff = gctmath.CalculatePercentageGainOrLoss(apiData, dbData)
if apiData < dbData {
diff = gctmath.PercentageChange(apiData, dbData)
} else {
diff = gctmath.CalculatePercentageGainOrLoss(dbData, apiData)
diff = gctmath.PercentageChange(dbData, apiData)
}
if diff > job.IssueTolerancePercentage {
issue = fmt.Sprintf("%s api: %v db: %v diff: %v %%", candleField, apiData, dbData, diff)