fix/supertrend-strategy: LinReg baseline slope wrongly calculated as reciprocal

This commit is contained in:
Andy Cheng 2022-10-07 13:48:16 +08:00
parent 1744281d0f
commit aa492a05a1

View File

@ -66,7 +66,7 @@ func (lr *LinReg) Update(kline types.KLine) {
average := sumY / length
endPrice := average - slope*sumX/length + slope
startPrice := endPrice + slope*(length-1)
lr.Values.Push((length - 1) / (endPrice - startPrice))
lr.Values.Push((endPrice - startPrice) / (length - 1))
log.Debugf("linear regression baseline slope: %f", lr.Last())
}