You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
887 B

package indicator
import (
"fmt"
"sig-pub/api/pb"
"sig-pub/pkg/types"
)
type RSI struct {
// types.IntervalWindow
window int // 窗口大小
}
func (ind *RSI) IntervalWindow() {
// 指标参数注入
}
func (ind *RSI) QueryRange(exchange pb.ExchangeType, instId string, interval types.Interval, rsi int) (query string, err error) {
var r types.MeticMatrix
_ = r
intervalAdder, ok := types.SupportedIntervals[interval]
if !ok {
err = fmt.Errorf("unsupport interval %s", interval)
return
}
minutes := intervalAdder(0, int64(rsi)) / 1000 / 60
query = fmt.Sprintf(`
100 - 100 / (1 + (
avg_over_time(clamp_min(delta(%s{kind="close", interval="%s", exchange="%s"}), 0)[%dm]) /
avg_over_time(abs(clamp_max(delta(%s{kind="close", interval="%s", exchange="%s"}), 0))[%dm])
))
`, instId, interval, exchange, minutes, instId, interval, exchange, minutes)
return
}