package servicemanager import ( "github.com/shopspring/decimal" "os" "wss-pool/cmd/selfContract" "wss-pool/config" "wss-pool/internal/data" red "wss-pool/internal/redis" "wss-pool/logging/applogger" ) // Gather func SelfContract(checkStr, ipServer, addrServer, contractCode string) { red.RedisClient = red.RedisInit(config.Config.Redis.DbEleven) data.Mgo_init(config.Config.Mongodb) data.InitGorm(config.Config.Bourse) if contractCode == "" { applogger.Error("Lack of contract code") os.Exit(400) } //初始价格优先数据库 res := selfContract.GetNewPrice(contractCode) if len(res) > 0 { selfContract.InitialPrice = decimal.RequireFromString(res[0].Close) } if selfContract.InitialPrice.IsZero() { selfContract.InitialPrice, _ = decimal.NewFromString(checkStr) } if selfContract.InitialPrice.IsZero() { applogger.Error("Lack of initial price") os.Exit(400) } selfContract.SelfContractCode = contractCode applogger.Info("合约", selfContract.SelfContractCode, "初始价格", selfContract.InitialPrice) // Enable collaborative data collection selfContract.NewSelfContract() }