2 Star 15 Fork 17

王布衣/engine

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
sector_snapshot.go 1.32 KB
Copy Edit Raw Blame History
package tracker
import (
"fmt"
"gitee.com/quant1x/engine/factors"
"gitee.com/quant1x/engine/models"
"gitee.com/quant1x/gotdx/securities"
"gitee.com/quant1x/gox/api"
"gitee.com/quant1x/gox/progressbar"
"gitee.com/quant1x/num"
)
// 板块扫描
func scanSectorSnapshots(pbarIndex *int, blockType securities.BlockType, isHead bool) (list []factors.QuoteSnapshot) {
// 执行板块指数的检测
blockInfos := securities.BlockList()
// 获取指定类型的板块代码列表
var blockCodes []string
for _, v := range blockInfos {
if v.Type != blockType {
continue
}
blockCode := v.Code
blockCodes = append(blockCodes, blockCode)
blockTypeName, _ := securities.BlockTypeNameByTypeCode(v.Type)
__mapBlockTypeName[blockCode] = blockTypeName
}
blockCount := len(blockCodes)
fmt.Println()
btn, ok := securities.BlockTypeNameByTypeCode(blockType)
if !ok {
btn = num.AnyToString(blockType)
}
bar := progressbar.NewBar(*pbarIndex, "执行[扫描"+btn+"板块指数]", blockCount)
*pbarIndex++
for i := 0; i < blockCount; i++ {
bar.Add(1)
blockCode := blockCodes[i]
snapshot := models.GetStrategySnapshot(blockCode)
if snapshot == nil {
continue
}
list = append(list, *snapshot)
}
if isHead {
api.SliceSort(list, SectorSortForHead)
} else {
api.SliceSort(list, SectorSortForTick)
}
return list
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v1.8.38

Search