mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-17 07:26:48 +00:00
remove rounding from scripting TA (#591)
This commit is contained in:
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -87,7 +86,7 @@ func atr(args ...objects.Object) (objects.Object, error) {
|
||||
r.Period = inTimePeriod
|
||||
ret := indicators.ATR(ohlcvData[2], ohlcvData[3], ohlcvData[4], inTimePeriod)
|
||||
for x := range ret {
|
||||
r.Value = append(r.Value, &objects.Float{Value: math.Round(ret[x]*100) / 100})
|
||||
r.Value = append(r.Value, &objects.Float{Value: ret[x]})
|
||||
}
|
||||
|
||||
return r, nil
|
||||
|
||||
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -125,12 +124,12 @@ func bbands(args ...objects.Object) (objects.Object, error) {
|
||||
retUpper, retMiddle, retLower := indicators.BBANDS(ohlcvData[selector], inTimePeriod, inNbDevDn, inNbDevDn, MAType)
|
||||
for x := range retMiddle {
|
||||
temp := &objects.Array{}
|
||||
temp.Value = append(temp.Value, &objects.Float{Value: math.Round(retMiddle[x]*100) / 100})
|
||||
temp.Value = append(temp.Value, &objects.Float{Value: retMiddle[x]})
|
||||
if retUpper != nil {
|
||||
temp.Value = append(temp.Value, &objects.Float{Value: math.Round(retUpper[x]*100) / 100})
|
||||
temp.Value = append(temp.Value, &objects.Float{Value: retUpper[x]})
|
||||
}
|
||||
if retLower != nil {
|
||||
temp.Value = append(temp.Value, &objects.Float{Value: math.Round(retLower[x]*100) / 100})
|
||||
temp.Value = append(temp.Value, &objects.Float{Value: retLower[x]})
|
||||
}
|
||||
r.Value = append(r.Value, temp)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -84,7 +83,7 @@ func correlationCoefficient(args ...objects.Object) (objects.Object, error) {
|
||||
|
||||
ret := indicators.CorrelationCoefficient(closures1, closures2, inTimePeriod)
|
||||
for x := range ret {
|
||||
r.Value = append(r.Value, &objects.Float{Value: math.Round(ret[x]*100) / 100})
|
||||
r.Value = append(r.Value, &objects.Float{Value: ret[x]})
|
||||
}
|
||||
|
||||
return r, nil
|
||||
|
||||
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -72,7 +71,7 @@ func ema(args ...objects.Object) (objects.Object, error) {
|
||||
|
||||
ret := indicators.EMA(ohlcvClose, inTimePeriod)
|
||||
for x := range ret {
|
||||
r.Value = append(r.Value, &objects.Float{Value: math.Round(ret[x]*100) / 100})
|
||||
r.Value = append(r.Value, &objects.Float{Value: ret[x]})
|
||||
}
|
||||
|
||||
return r, nil
|
||||
|
||||
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -85,12 +84,12 @@ func macd(args ...objects.Object) (objects.Object, error) {
|
||||
macd, macdSignal, macdHist := indicators.MACD(ohlcvClose, inFastPeriod, inSlowPeriod, inTimePeriod)
|
||||
for x := range macdHist {
|
||||
tempMACD := &objects.Array{}
|
||||
tempMACD.Value = append(tempMACD.Value, &objects.Float{Value: math.Round(macdHist[x]*100) / 100})
|
||||
tempMACD.Value = append(tempMACD.Value, &objects.Float{Value: macdHist[x]})
|
||||
if macd != nil {
|
||||
tempMACD.Value = append(tempMACD.Value, &objects.Float{Value: math.Round(macd[x]*100) / 100})
|
||||
tempMACD.Value = append(tempMACD.Value, &objects.Float{Value: macd[x]})
|
||||
}
|
||||
if macdSignal != nil {
|
||||
tempMACD.Value = append(tempMACD.Value, &objects.Float{Value: math.Round(macdSignal[x]*100) / 100})
|
||||
tempMACD.Value = append(tempMACD.Value, &objects.Float{Value: macdSignal[x]})
|
||||
}
|
||||
r.Value = append(r.Value, tempMACD)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -87,7 +86,7 @@ func mfi(args ...objects.Object) (objects.Object, error) {
|
||||
|
||||
ret := indicators.MFI(ohlcvData[2], ohlcvData[3], ohlcvData[4], ohlcvData[5], inTimePeriod)
|
||||
for x := range ret {
|
||||
r.Value = append(r.Value, &objects.Float{Value: math.Round(ret[x]*100) / 100})
|
||||
r.Value = append(r.Value, &objects.Float{Value: ret[x]})
|
||||
}
|
||||
|
||||
return r, nil
|
||||
|
||||
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -81,7 +80,7 @@ func obv(args ...objects.Object) (objects.Object, error) {
|
||||
|
||||
ret := indicators.OBV(ohlcvData[4], ohlcvData[5])
|
||||
for x := range ret {
|
||||
temp := &objects.Float{Value: math.Round(ret[x]*100) / 100}
|
||||
temp := &objects.Float{Value: ret[x]}
|
||||
r.Value = append(r.Value, temp)
|
||||
}
|
||||
return r, nil
|
||||
|
||||
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -71,7 +70,7 @@ func rsi(args ...objects.Object) (objects.Object, error) {
|
||||
r.Period = inTimePeriod
|
||||
ret := indicators.RSI(ohlcvClose, inTimePeriod)
|
||||
for x := range ret {
|
||||
r.Value = append(r.Value, &objects.Float{Value: math.Round(ret[x]*100) / 100})
|
||||
r.Value = append(r.Value, &objects.Float{Value: ret[x]})
|
||||
}
|
||||
|
||||
return r, nil
|
||||
|
||||
@@ -3,7 +3,6 @@ package indicators
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
objects "github.com/d5/tengo/v2"
|
||||
@@ -69,7 +68,7 @@ func sma(args ...objects.Object) (objects.Object, error) {
|
||||
r.Period = inTimePeriod
|
||||
ret := indicators.SMA(ohlcvClose, inTimePeriod)
|
||||
for x := range ret {
|
||||
r.Value = append(r.Value, &objects.Float{Value: math.Round(ret[x]*100) / 100})
|
||||
r.Value = append(r.Value, &objects.Float{Value: ret[x]})
|
||||
}
|
||||
|
||||
return r, nil
|
||||
|
||||
Reference in New Issue
Block a user