예제 #1
0
// GetDateList 取出資料時間序列
func (d *Data) GetDateList() []time.Time {
	if d.datelist == nil {
		datelistdata := d.getColsList(0)
		d.datelist = make([]time.Time, len(datelistdata))
		for i, v := range datelistdata {
			d.datelist[i] = utils.ParseDate(v)
		}
	}
	return d.datelist
}
예제 #2
0
// GetByTimeMap return a map by key of time.Time
func (d Data) GetByTimeMap() map[time.Time]interface{} {
	var (
		dailyData [][]string
		data      map[time.Time]interface{}
		err       error
	)
	if dailyData, err = d.Get(); err == nil {
		data = make(map[time.Time]interface{})
		for _, v := range dailyData {
			data[utils.ParseDate(v[0])] = v
		}
	}
	return data
}
예제 #3
0
// FormatData is format daily data.
func (d Data) FormatData() []FmtData {
	var (
		loopd  FmtData
		result []FmtData
	)
	result = make([]FmtData, len(d.RawData))
	for i, v := range d.RawData {
		loopd.Date = utils.ParseDate(v[0])
		loopd.Volume, _ = strconv.ParseUint(strings.Replace(v[1], ",", "", -1), 10, 64)
		loopd.TotalPrice, _ = strconv.ParseUint(strings.Replace(v[2], ",", "", -1), 10, 64)
		loopd.Open, _ = strconv.ParseFloat(v[3], 64)
		loopd.High, _ = strconv.ParseFloat(v[4], 64)
		loopd.Low, _ = strconv.ParseFloat(v[5], 64)
		loopd.Price, _ = strconv.ParseFloat(v[6], 64)
		loopd.Range, _ = strconv.ParseFloat(v[7], 64)
		loopd.Totalsale, _ = strconv.ParseUint(strings.Replace(v[8], ",", "", -1), 10, 64)
		result[i] = loopd
	}
	return result
}