You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

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