当前位置: 首页>>代码示例>>Golang>>正文


Golang Logger.Infof函数代码示例

本文整理汇总了Golang中Logger.Infof函数的典型用法代码示例。如果您正苦于以下问题:Golang Infof函数的具体用法?Golang Infof怎么用?Golang Infof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Infof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: checkThreshold

func (emaStrategy *EMAStrategy) checkThreshold(tradeType string, EMAdif float64) bool {
	if tradeType == "buy" {
		buyThreshold := toFloat(Option["buyThreshold"])

		if EMAdif > buyThreshold {
			logger.Infof("EMAdif(%0.04f) > buyThreshold(%0.04f), trigger to buy\n", EMAdif, buyThreshold)
			emaStrategy.LessBuyThreshold = false
			return true
		} else {
			if emaStrategy.LessBuyThreshold == false {
				logger.Infof("cross up, but EMAdif(%0.04f) <= buyThreshold(%0.04f)\n", EMAdif, buyThreshold)
				emaStrategy.LessBuyThreshold = true
			}
		}
	} else {
		sellThreshold := toFloat(Option["sellThreshold"])

		if sellThreshold > 0 {
			sellThreshold = -sellThreshold
		}

		if EMAdif < sellThreshold {
			logger.Infof("EMAdif(%0.04f) <  sellThreshold(%0.04f), trigger to sell\n", EMAdif, sellThreshold)
			emaStrategy.LessSellThreshold = false
			return true
		} else {
			if emaStrategy.LessSellThreshold == false {
				logger.Infof("cross down, but EMAdif(%0.04f) >= sellThreshold(%0.04f)\n", EMAdif, sellThreshold)
				emaStrategy.LessSellThreshold = true
			}
		}
	}

	return false
}
开发者ID:cnspot,项目名称:btcrobot,代码行数:35,代码来源:ema.go

示例2: RobotWorker

func RobotWorker() {
	ticker := time.NewTicker(1 * time.Second) // one second
	defer ticker.Stop()

	totalHour, _ := strconv.ParseInt(Option["totalHour"], 0, 64)
	if totalHour < 1 {
		totalHour = 1
	}

	fmt.Println("trade robot start working...")

	go func() {
		for _ = range ticker.C {
			peroid, _ := strconv.Atoi(Option["tick_interval"])
			strategyName := Option["strategy"]
			ret := true
			var records []Record
			if strategyName != "OPENORDER" {
				ret, records = marketAPI().GetKLine(peroid)
			}

			if ret != false {
				strategy.Tick(tradeAPI(), records)
			}
		}
	}()

	logger.Infof("程序将持续运行%d小时后停止", time.Duration(totalHour))

	time.Sleep(time.Duration(totalHour) * time.Hour)

	logger.Infof("程序到达设定时长%d小时,停止运行。", time.Duration(totalHour))
}
开发者ID:philsong,项目名称:btcrobot,代码行数:33,代码来源:monitor.go

示例3: Login

// 登录;成功返回用户登录信息(user_login)
func Login(username, passwd string) (*model.UserLogin, error) {
	userLogin := model.NewUserLogin()
	err := userLogin.Where("username=" + username + " OR email=" + username).Find()
	if err != nil {
		logger.Errorf("用户 %s 登录错误:%s", username, err)
		return nil, errors.New("内部错误,请稍后再试!")
	}
	// 校验用户
	if userLogin.Uid == 0 {
		logger.Infof("用户名 %s 不存在", username)
		return nil, ErrUsername
	}
	passcode := userLogin.GetPasscode()
	md5Passwd := util.Md5(passwd + passcode)
	logger.Debugf("passwd: %s, passcode: %s, md5passwd: %s, dbpasswd: %s", passwd, passcode, md5Passwd, userLogin.Passwd)
	if md5Passwd != userLogin.Passwd {
		logger.Infof("用户名 %s 填写的密码错误", username)
		return nil, ErrPasswd
	}

	// 登录,活跃度+1
	go IncUserWeight("uid="+strconv.Itoa(userLogin.Uid), 1)

	return userLogin, nil
}
开发者ID:philsong,项目名称:studygolang,代码行数:26,代码来源:user.go

示例4: RobotWorker

func RobotWorker() {
	fmt.Println("env", Config["env"])
	if Config["env"] == "dev" {
		fmt.Println("test working...")
		var tradeAPI common.TradeAPI
		tradeAPI = huobi.NewHuobi()
		tradeAPI.Get_account_info()
		symbol := "btc_cny"
		tradeAPI.GetOrderBook(symbol)

		//testHuobiAPI()
		//testOkcoinLTCAPI()
		return
	}

	ticker := time.NewTicker(2 * time.Second) //2s
	defer ticker.Stop()

	var tradeAPI common.TradeAPI
	tradeAPI = huobi.NewHuobi()
	tradeAPI.Get_account_info()

	tradeAPI = okcoin.NewOkcoin()
	tradeAPI.Get_account_info()

	if Option["tradecenter"] == "huobi" {
		tradeAPI = huobi.NewHuobi()
	} else if Option["tradecenter"] == "okcoin" {
		tradeAPI = okcoin.NewOkcoin()
	} else {
		logger.Fatalln("Please config the tradecenter firstly...")
		return
	}
	peroid, _ := strconv.Atoi(Option["tick_interval"])
	totalHour, _ := strconv.ParseInt(Option["totalHour"], 0, 64)
	if totalHour < 1 {
		totalHour = 1
	}

	fmt.Println("robot working...")

	go func() {
		for _ = range ticker.C {
			tradeAPI.AnalyzeKLine(peroid)
		}
	}()

	logger.Infof("程序将持续运行%d小时后停止", time.Duration(totalHour))

	time.Sleep(time.Duration(totalHour) * time.Hour)

	logger.Infof("程序到达设定时长%d小时,停止运行。", time.Duration(totalHour))
}
开发者ID:kewinwang,项目名称:btcrobot,代码行数:53,代码来源:entry.go

示例5: RobotWorker

func RobotWorker() {
	fmt.Println("env", Config["env"])
	if DebugEnv || Config["env"] == "dev" {
		fmt.Println("test working...")

		// var tradeAPI TradeAPI
		// tradeAPI = okcoin.NewOkcoin()
		// tradeAPI.GetAccount()
		// tradeAPI.GetOrderBook()

		// tradeAPI = huobi.NewHuobi()
		// accout_info, ret := tradeAPI.GetAccount()
		// fmt.Println(ret, accout_info)

		// ret, orderbook := tradeAPI.GetOrderBook()
		// fmt.Println(ret, orderbook)

		testHuobiAPI()
		//testOkcoinLTCAPI()
		return
	}

	ticker := time.NewTicker(8 * time.Second) //2s
	defer ticker.Stop()

	totalHour, _ := strconv.ParseInt(Option["totalHour"], 0, 64)
	if totalHour < 1 {
		totalHour = 1
	}

	fmt.Println("robot working...")

	go func() {
		for _ = range ticker.C {

			records := []Record{}
			strategy.Tick(tradeAPI(), records)

			// peroid, _ := strconv.Atoi(Option["tick_interval"])
			// ret, records := marketAPI().GetKLine(peroid)
			// if ret != false {
			// 	strategy.Tick(tradeAPI(), records)
			// }
		}
	}()

	logger.Infof("程序将持续运行%d小时后停止", time.Duration(totalHour))

	time.Sleep(time.Duration(totalHour) * time.Hour)

	logger.Infof("程序到达设定时长%d小时,停止运行。", time.Duration(totalHour))
}
开发者ID:jiedo,项目名称:btcrobot,代码行数:52,代码来源:monitor.go

示例6: RobotWorker

func RobotWorker() {
	fmt.Println("env", Config["env"])
	if DebugEnv || Config["env"] == "dev" {
		fmt.Println("test working...")

		var tradeAPI TradeAPI
		tradeAPI = okcoin.NewOkcoin()
		tradeAPI.GetAccount()
		tradeAPI.GetOrderBook()

		tradeAPI = huobi.NewHuobi()
		tradeAPI.GetAccount()
		ret, orderbook := tradeAPI.GetOrderBook()
		fmt.Println(ret, orderbook)

		//testHuobiAPI()
		//testOkcoinLTCAPI()
		return
	}

	ticker := time.NewTicker(1 * time.Second) //2s
	defer ticker.Stop()

	totalHour, _ := strconv.ParseInt(Option["totalHour"], 0, 64)
	if totalHour < 1 {
		totalHour = 1
	}

	fmt.Println("robot working...")

	go func() {
		for _ = range ticker.C {
			peroid, _ := strconv.Atoi(Option["tick_interval"])
			strategyName := Option["strategy"]
			ret := true
			var records []Record
			if strategyName != "OPENORDER" {
				ret, records = marketAPI().GetKLine(peroid)
			}

			if ret != false {
				strategy.Tick(tradeAPI(), records)
			}
		}
	}()

	logger.Infof("程序将持续运行%d小时后停止", time.Duration(totalHour))

	time.Sleep(time.Duration(totalHour) * time.Hour)

	logger.Infof("程序到达设定时长%d小时,停止运行。", time.Duration(totalHour))
}
开发者ID:jmliu88,项目名称:btcrobot,代码行数:52,代码来源:monitor.go

示例7: Tick

// the3crow strategy
func (the3crow *the3crowStrategy) Tick(records []Record) bool {
	if the3crow.PrevClosePrice == lastPrice {
		return false
	}

	the3crow.PrevClosePrice = lastPrice

	logger.Infof("lastPrice %0.02f\n", lastPrice)
	logger.Infof("3 open %0.02f close %0.02f\n", records[length-2].Open, records[length-2].Close)
	logger.Infof("2 open %0.02f close %0.02f\n", records[length-3].Open, records[length-3].Close)
	logger.Infof("1 open %0.02f close %0.02f\n", records[length-4].Open, records[length-4].Close)

	if records[length-2].Close > records[length-2].Open {
		logger.Infof("3阳")
	} else {
		logger.Infof("3阴")
	}

	if records[length-3].Close > records[length-3].Open {
		logger.Infof("2阳")
	} else {
		logger.Infof("2阴")
	}
	if records[length-4].Close > records[length-4].Open {
		logger.Infof("1阳")
	} else {
		logger.Infof("1阴")
	}
	logger.Infoln("---------")

	// the3crow cross
	if records[length-2].Close > records[length-2].Open &&
		records[length-3].Close > records[length-3].Open &&
		records[length-4].Close > records[length-4].Open {
		Buy()
	} else if records[length-2].Close < records[length-2].Open &&
		records[length-3].Close < records[length-3].Open &&
		records[length-4].Close < records[length-4].Open {
		Sell()
	}

	// do sell when price is below stoploss point
	processStoploss(lastPrice)

	processTimeout()

	return true
}
开发者ID:cnspot,项目名称:btcrobot,代码行数:49,代码来源:3crow.go

示例8: GetAccount

func (w Okcoin) GetAccount() (account Account, ret bool) {
	tradeAPI := NewOkcoinTrade(SecretOption["ok_partner"], SecretOption["ok_secret_key"])

	userInfo, ret := tradeAPI.GetAccount()

	logger.Infoln("account:", userInfo)
	if !ret {
		logger.Traceln("okcoin GetAccount failed")
		return
	} else {
		logger.Traceln(userInfo)

		account.Available_cny = userInfo.Info.Funds.Free.CNY
		account.Available_btc = userInfo.Info.Funds.Free.BTC
		account.Available_ltc = userInfo.Info.Funds.Free.LTC

		account.Frozen_cny = userInfo.Info.Funds.Freezed.CNY
		account.Frozen_btc = userInfo.Info.Funds.Freezed.BTC
		account.Frozen_ltc = userInfo.Info.Funds.Freezed.LTC

		logger.Infof("okcoin资产: \n 可用cny:%-10s \tbtc:%-10s \tltc:%-10s \n 冻结cny:%-10s \tbtc:%-10s \tltc:%-10s\n",
			account.Available_cny,
			account.Available_btc,
			account.Available_ltc,
			account.Frozen_cny,
			account.Frozen_btc,
			account.Frozen_ltc)
		//logger.Infoln(Account)
		return
	}
}
开发者ID:9cat,项目名称:btcrobot,代码行数:31,代码来源:api.go

示例9: GetAccount

func (w Okcoin) GetAccount() (account Account, ret bool) {
	tradeAPI := w.tradeAPI

	userInfo, ret := tradeAPI.GetAccount()

	if !ret {
		logger.Traceln("okcoin GetAccount failed")
		return
	} else {
		logger.Traceln(userInfo)

		account.Available_cny = userInfo.Info.Funds.Free.CNY
		account.Available_btc = userInfo.Info.Funds.Free.BTC
		account.Available_ltc = userInfo.Info.Funds.Free.LTC

		account.Frozen_cny = userInfo.Info.Funds.Freezed.CNY
		account.Frozen_btc = userInfo.Info.Funds.Freezed.BTC
		account.Frozen_ltc = userInfo.Info.Funds.Freezed.LTC

		logger.Infof("okcoin资产: \n 可用cny:%-10s \tbtc:%-10s \tltc:%-10s \n 冻结cny:%-10s \tbtc:%-10s \tltc:%-10s\n",
			account.Available_cny,
			account.Available_btc,
			account.Available_ltc,
			account.Frozen_cny,
			account.Frozen_btc,
			account.Frozen_ltc)
		return
	}
}
开发者ID:ifzz,项目名称:btcrobot,代码行数:29,代码来源:api.go

示例10: Get_account_info

func (w Okcoin) Get_account_info() (userMoney common.UserMoney, ret bool) {
	tradeAPI := NewOkcoinTrade(SecretOption["ok_partner"], SecretOption["ok_secret_key"])

	userInfo, ret := tradeAPI.Get_account_info()

	if !ret {
		logger.Traceln("okcoin Get_account_info failed")
		return
	} else {
		logger.Traceln(userInfo)

		userMoney.Available_cny = userInfo.Info.Funds.Free.CNY
		userMoney.Available_btc = userInfo.Info.Funds.Free.BTC
		userMoney.Available_ltc = userInfo.Info.Funds.Free.LTC

		userMoney.Frozen_cny = userInfo.Info.Funds.Freezed.CNY
		userMoney.Frozen_btc = userInfo.Info.Funds.Freezed.BTC
		userMoney.Frozen_ltc = userInfo.Info.Funds.Freezed.LTC

		logger.Infof("okcoin资产: \n 可用cny:%-10s \tbtc:%-10s \tltc:%-10s \n 冻结cny:%-10s \tbtc:%-10s \tltc:%-10s\n",
			userMoney.Available_cny,
			userMoney.Available_btc,
			userMoney.Available_ltc,
			userMoney.Frozen_cny,
			userMoney.Frozen_btc,
			userMoney.Frozen_ltc)
		//logger.Infoln(userMoney)
		return
	}
}
开发者ID:kewinwang,项目名称:btcrobot,代码行数:30,代码来源:api.go

示例11: Tick

//circular strategy
func (circular *circularStrategy) Tick(records []Record) bool {
	if circular.PrevClosePrice == lastPrice {
		return false
	}

	basePrice, err := strconv.ParseFloat(Option["basePrice"], 64)
	if err != nil {
		logger.Debugln("config item basePrice is not float")
		return false
	}

	fluctuation, err := strconv.ParseFloat(Option["fluctuation"], 64)
	if err != nil {
		logger.Debugln("config item fluctuation is not float")
		return false
	}

	circular.PrevClosePrice = lastPrice

	logger.Infof("lastPrice %0.02f\n", lastPrice)
	if lastPrice >= basePrice+fluctuation {
		Sell()
	} else if lastPrice <= basePrice-fluctuation {
		Buy()
	}

	//do sell when price is below stoploss point
	processStoploss(lastPrice)

	processTimeout()

	return true
}
开发者ID:2yeslater,项目名称:btcrobot,代码行数:34,代码来源:circular.go

示例12: AnalyzePeroidLine

func (w *Huobi) AnalyzePeroidLine(filename string, content string) bool {
	//logger.Infoln(content)
	//logger.Infoln(filename)
	PeroidRecords := ParsePeroidCSV(filename)

	var xData []string
	var yData []float64
	for _, v := range PeroidRecords {
		xData = append(xData, v.Date+" "+v.Time)
		yData = append(yData, v.Close)
		//yData = append(yData, (v.Close+v.Open+v.High+v.Low)/4.0)
		//yData = append(yData, v.Low)
	}
	w.xData = xData
	w.yData = yData
	//rsi(yData)
	if Config["env"] == "test" {
		w.do2Percent(xData, yData)
		return true

		k, d, j := doKDJ(PeroidRecords)
		length := len(k)
		// Loop through the entire array.
		for i := 0; i < length; i++ {
			logger.Infof("[%s-%s]%d/%d/%d\n", PeroidRecords[i].Date, PeroidRecords[i].Time, int(k[i]), int(d[i]), int(j[i]))
		}
	} else {
		w.doEMA(xData, yData)
		return true
	}

	return true
}
开发者ID:kuainiao,项目名称:btcrobot,代码行数:33,代码来源:huobikline.go

示例13: FindCurrentUser

// 获取当前登录用户信息(常用信息)
func FindCurrentUser(username string) (user map[string]interface{}, err error) {
	userLogin := model.NewUserLogin()
	err = userLogin.Where("username=" + username).Find()
	if err != nil {
		logger.Errorf("获取用户 %s 信息失败:%s", username, err)
		return
	}
	if userLogin.Uid == 0 {
		logger.Infof("用户 %s 不存在!", username)
		return
	}
	user = map[string]interface{}{
		"uid":      userLogin.Uid,
		"username": userLogin.Username,
		"email":    userLogin.Email,
	}

	// 获取未读消息数
	user["msgnum"] = FindNotReadMsgNum(userLogin.Uid)

	// 获取角色信息
	userRoleList, err := model.NewUserRole().Where("uid=" + strconv.Itoa(userLogin.Uid)).FindAll()
	if err != nil {
		logger.Errorf("获取用户 %s 角色 信息失败:%s", username, err)
		return
	}
	for _, userRole := range userRoleList {
		if userRole.Roleid <= model.AdminMinRoleId {
			// 是管理员
			user["isadmin"] = true
		}
	}
	return
}
开发者ID:philsong,项目名称:studygolang,代码行数:35,代码来源:user.go

示例14: Tick

// MACD strategy
func (macdStrategy *MACDStrategy) Tick(records []Record) bool {
	// read config
	shortEMA, _ := strconv.Atoi(Option["shortEMA"])
	longEMA, _ := strconv.Atoi(Option["longEMA"])

	signalPeriod, _ := strconv.Atoi(Option["signalPeriod"])
	/*
		MACDMinThreshold, err := strconv.ParseFloat(Option["MACDMinThreshold"], 64)
		if err != nil {
			logger.Debugln("config item MACDMinThreshold is not float")
			return false
		}
	*/

	MACDbuyThreshold, err := strconv.ParseFloat(Option["MACDbuyThreshold"], 64)
	if err != nil {
		logger.Errorln("config item MACDbuyThreshold is not float")
		return false
	}

	MACDsellThreshold, err := strconv.ParseFloat(Option["MACDsellThreshold"], 64)
	if err != nil {
		logger.Errorln("config item MACDsellThreshold is not float")
		return false
	}

	var Price []float64
	for _, v := range records {
		Price = append(Price, v.Close)
	}

	// compute the indictor
	emaShort := EMA(Price, shortEMA)
	emaLong := EMA(Price, longEMA)
	MACDdif := getMACDdif(emaShort, emaLong)
	MACDSignal := getMACDSignal(MACDdif, signalPeriod)
	MACDHistogram := getMACDHistogram(MACDdif, MACDSignal)

	if MACDdif[length-1] != macdStrategy.PrevMACDdif {
		macdStrategy.PrevMACDdif = MACDdif[length-1]
		logger.Infof("MACD:d%5.03f\ts%5.03f\tph%5.03f\th%5.03f\tPrice:%5.02f\n", MACDdif[length-1], MACDSignal[length-1], MACDHistogram[length-2], MACDHistogram[length-1], Price[length-1])
	}

	// macd cross
	if (MACDHistogram[length-2] < -0.000001 && MACDHistogram[length-1] > MACDbuyThreshold) ||
		(PrevTrade == "sell" && MACDHistogram[length-2] > 0.000001 && MACDHistogram[length-1] > MACDbuyThreshold) {
		Buy()
	} else if (MACDHistogram[length-2] > 0.000001 && MACDHistogram[length-1] < MACDsellThreshold) ||
		(PrevTrade == "buy" && MACDHistogram[length-2] < -0.000001 && MACDHistogram[length-1] < MACDsellThreshold) {
		Sell()
	}

	// do sell when price is below stoploss point
	processStoploss(lastPrice)
	processTimeout()

	return true
}
开发者ID:cnspot,项目名称:btcrobot,代码行数:59,代码来源:macd.go

示例15: checkThreshold

func (emaStrategy *EMAStrategy) checkThreshold(direction string, EMAdif float64) bool {
	if direction == "buy" {
		buyThreshold, err := strconv.ParseFloat(Option["buyThreshold"], 64)
		if err != nil {
			logger.Errorln("config item buyThreshold is not float")
			return false
		}

		if EMAdif > buyThreshold {
			logger.Infof("EMAdif(%0.04f) > buyThreshold(%0.04f), trigger to buy\n", EMAdif, buyThreshold)
			emaStrategy.LessBuyThreshold = false
			return true
		} else {
			if emaStrategy.LessBuyThreshold == false {
				logger.Infof("cross up, but EMAdif(%0.04f) <= buyThreshold(%0.04f)\n", EMAdif, buyThreshold)
				emaStrategy.LessBuyThreshold = true
			}
		}
	} else {
		sellThreshold, err := strconv.ParseFloat(Option["sellThreshold"], 64)
		if err != nil {
			logger.Errorln("config item sellThreshold is not float")
			return false
		}

		if sellThreshold > 0 {
			sellThreshold = -sellThreshold
		}

		if EMAdif < sellThreshold {
			logger.Infof("EMAdif(%0.04f) <  sellThreshold(%0.04f), trigger to sell\n", EMAdif, sellThreshold)
			emaStrategy.LessSellThreshold = false
			return true
		} else {
			if emaStrategy.LessSellThreshold == false {
				logger.Infof("cross down, but EMAdif(%0.04f) >= sellThreshold(%0.04f)\n", EMAdif, sellThreshold)
				emaStrategy.LessSellThreshold = true
			}
		}
	}

	return false
}
开发者ID:9cat,项目名称:btcrobot,代码行数:43,代码来源:ema.go


注:本文中的Logger.Infof函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。