2 Star 14 Fork 16

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-10-19 17:25 +08:00 . 增加daemon服务命令字
package main
import (
"fmt"
"gitee.com/quant1x/engine/command"
"gitee.com/quant1x/engine/models"
"gitee.com/quant1x/engine/util/functions"
"gitee.com/quant1x/gox/logger"
cmder "github.com/spf13/cobra"
"log"
_ "net/http/pprof"
"os"
"runtime/debug"
"runtime/pprof"
"time"
)
var (
MinVersion = "1.0.0" // 版本号
strategyNumber = 0 // 策略编号
)
var (
cpuProfile = "./cpu.pprof"
memProfile = "./mem.pprof"
)
// 更新日线数据工具
func main() {
fCpu, err := os.Create(cpuProfile)
if err != nil {
log.Fatal(err)
}
_ = pprof.StartCPUProfile(fCpu)
defer pprof.StopCPUProfile()
//go func() {
// log.Println(http.ListenAndServe(":8000", nil))
//}()
mainStart := time.Now()
defer func() {
if err := recover(); err != nil {
s := string(debug.Stack())
fmt.Printf("\nerr=%v, stack=%s\n", err, s)
logger.Fatalf("%s 异常: %+v", command.Application, err)
}
elapsedTime := time.Since(mainStart) / time.Millisecond
fmt.Printf("\n总耗时: %.3fs\n", float64(elapsedTime)/1000)
}()
// stock模块内的更新版本号
command.UpdateApplicationVersion(MinVersion)
functions.GOMAXPROCS()
var rootCmd = &cmder.Command{
Use: command.Application,
Run: func(cmd *cmder.Command, args []string) {
//stat.SetAvx2Enabled(modules.CpuAvx2)
//runtime.GOMAXPROCS(modules.CpuNum)
var model models.Strategy
switch strategyNumber {
default:
model = new(models.ModelNo1)
}
fmt.Printf("策略模块: %s\n", model.Name())
// 执行策略
barIndex := 1
models.ExecuteStrategy(model, &barIndex)
},
}
rootCmd.Flags().IntVar(&strategyNumber, "strategy", models.DefaultStrategy, "策略编号")
command.Init()
rootCmd.AddCommand(command.CmdVersion, command.CmdPrint, command.CmdUpdate, command.CmdRepair, command.CmdService)
_ = rootCmd.Execute()
fMem, err := os.Create(memProfile)
if err != nil {
log.Fatal(err)
}
_ = pprof.WriteHeapProfile(fMem)
_ = fMem.Close()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v0.4.9

搜索帮助