Beispiel #1
0
func prettyprint(stock *twse.Data, check filter.CheckGroup) string {
	var (
		Open        = stock.GetOpenList()[len(stock.GetOpenList())-1]
		Price       = stock.GetPriceList()[len(stock.GetPriceList())-1]
		RangeValue  = stock.GetDailyRangeList()[len(stock.GetDailyRangeList())-1]
		Volume      = stock.GetVolumeList()[len(stock.GetVolumeList())-1] / 1000
		outputcolor func(string, ...interface{}) string
	)

	switch {
	case RangeValue > 0:
		outputcolor = red
	case RangeValue < 0:
		outputcolor = green
	default:
		outputcolor = white
	}

	return fmt.Sprintf("%s %s %s %s%s %s %s",
		yellow("[%s]", check),
		blue("%s", stock.RawData[stock.Len()-1][0]),
		outputcolor("%s %s", stock.No, stock.Name),
		outputcolor("$%.2f", Price),
		outputcolor("(%.2f)", RangeValue),
		outputcolor("%.2f%%", RangeValue/Open*100),
		outputcolor("%d", Volume),
	)
}
Beispiel #2
0
// ShowAll is lazy to show all XD.
func ShowAll(stock *twse.Data) {
	fmt.Println(stock.RawData)
	fmt.Println(stock.MA(6))
	fmt.Println(stock.MAV(6))
	fmt.Println(stock.GetPriceList())
	fmt.Println(utils.ThanPastFloat64(stock.GetPriceList(), 3, true))
	fmt.Println(utils.ThanPastFloat64(stock.GetPriceList(), 3, false))
	fmt.Println(stock.GetVolumeList())
	fmt.Println(utils.ThanPastUint64(stock.GetVolumeList(), 3, true))
	fmt.Println(utils.ThanPastUint64(stock.GetVolumeList(), 3, false))
	fmt.Println(stock.GetRangeList())
	fmt.Println(stock.IsRed())
}