1 Star 4 Fork 11

王布衣 / pandas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
barssincen.go 481 Bytes
一键复制 编辑 原始数据 按行查看 历史
package formula
import (
"gitee.com/quant1x/pandas/stat"
)
// BARSSINCEN N周期内第一次S条件成立到现在的周期数,N为常量
func BARSSINCEN(S stat.Series, N any) stat.Series {
ret := S.Rolling(N).Apply(func(X stat.Series, M stat.DType) stat.DType {
x := X.DTypes()
n := int(M)
argMax := stat.ArgMax(x)
r := 0
if argMax != 0 || x[0] != 0 {
r = n - 1 - argMax
} else {
r = 0
}
return stat.DType(r)
})
r1 := ret.FillNa(0, true)
return r1
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/quant1x/pandas.git
git@gitee.com:quant1x/pandas.git
quant1x
pandas
pandas
v0.9.17

搜索帮助

344bd9b3 5694891 D2dac590 5694891