2 Star 7 Fork 10

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
executor.go 1009 Bytes
一键复制 编辑 原始数据 按行查看 历史
package models
import (
"fmt"
"gitee.com/quant1x/engine/market"
"gitee.com/quant1x/gox/progressbar"
"gitee.com/quant1x/gox/tags"
"gitee.com/quant1x/gox/util/treemap"
"github.com/olekukonko/tablewriter"
"os"
)
// ExecuteStrategy 执行策略
func ExecuteStrategy(model Strategy, barIndex *int) {
// 加载即时行情
GetAllSnapshots(barIndex)
fmt.Println()
// 执行策略
allCodes := market.GetCodeList()
count := len(allCodes)
bar := progressbar.NewBar(*barIndex, "执行["+model.Name()+"]", count)
results := treemap.NewWithStringComparator()
for _, securityCode := range allCodes {
// 此处可以增加过滤规则
model.Evaluate(securityCode, results)
bar.Add(1)
}
// 输出一个换行符, 结束上一个进度条
fmt.Println()
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader(tags.GetHeadersByTags(ResultInfo{}))
results.Each(func(key interface{}, value interface{}) {
row := value.(ResultInfo)
table.Append(tags.GetValuesByTags(row))
})
table.Render()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v0.4.7

搜索帮助