2 Star 3 Fork 10

王布衣 / engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mod_sort.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
package tracker
import (
"gitee.com/quant1x/engine/factors"
"gitee.com/quant1x/num"
)
func tickWeight(snapshot factors.QuoteSnapshot) float64 {
// 1. 板块涨幅
weight1 := snapshot.ChangeRate
// 2. 涨速
weight2 := snapshot.Rate
return num.Mean([]float64{weight1, weight2})
}
// SectorSortForTick 板块排序, 盘中
func SectorSortForTick(a, b factors.QuoteSnapshot) bool {
aWeight := tickWeight(a)
bWeight := tickWeight(b)
return aWeight > bWeight
}
// SectorSortForHead 板块排序, 早盘
func SectorSortForHead(a, b factors.QuoteSnapshot) bool {
if a.OpeningChangeRate > b.OpeningChangeRate {
return true
}
if a.OpeningChangeRate == b.OpeningChangeRate && a.Amount > b.Amount {
return true
}
if a.OpeningChangeRate == b.OpeningChangeRate && a.Amount == b.Amount && a.OpenTurnZ > b.OpenTurnZ {
return true
}
return false
}
// StockSort 个股排序
func StockSort(a, b factors.QuoteSnapshot) bool {
if a.ChangeRate > b.ChangeRate {
return true
}
if a.ChangeRate == b.ChangeRate && a.OpenTurnZ > b.OpenTurnZ {
return true
}
return false
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v1.7.0

搜索帮助

344bd9b3 5694891 D2dac590 5694891