// Get single stock price for certain date.
773044
func GetPriceForDate(symbol string, date time.Time) (PriceH, error) {
	var price PriceH
	// We need to get price information for single date, so date passed to
	// this function will be used both for "from" and "to" arguments.
	data, err := loadHistoricalPrice(symbol, date, date, Daily)
	if err != nil {
		return price, err
	}

	prices, err := parseHistorical(data)
	if err != nil {
		return PriceH{}, err
	}
	price = prices[0]

	// Return single price.
	return price, nil
}
3476
func (m *MarketplacePlan) GetYearlyPriceInCents() int {
	if m == nil || m.YearlyPriceInCents == nil {
		return 0
	}
	return *m.YearlyPriceInCents
}
382935
func (c *CommitAuthor) GetDate() time.Time {
	if c == nil || c.Date == nil {
		return time.Time{}
	}
	return *c.Date
}
996008
func (r Billing_Currency_ExchangeRate) GetExchangeRate(to *string, from *string, effectiveDate *datatypes.Time) (resp datatypes.Billing_Currency_ExchangeRate, err error) {
	params := []interface{}{
		to,
		from,
		effectiveDate,
	}
	err = r.Session.DoRequest("SoftLayer_Billing_Currency_ExchangeRate", "getExchangeRate", params, &r.Options, &resp)
	return
}
1219457
func stockHistoryURL(symbol string, from, to time.Time, frequency string) string {
	// From date
	fMonth := (from.Month() - 1) // Need to subtract 1 because months in query is 0 based.
	fDay := from.Day()
	fYear := from.Year()
	// To date
	tMonth := (to.Month() - 1)
	tDay := to.Day()
	tYear := to.Year()

	url := fmt.Sprintf(
		YURL_H,
		symbol,
		fMonth,
		fDay,
		fYear,
		tMonth,
		tDay,
		tYear,
		frequency)

	return url
}
1366534
func MidPrice(inHigh []float64, inLow []float64, inTimePeriod int) []float64 {

	outReal := make([]float64, len(inHigh))

	nbInitialElementNeeded := inTimePeriod - 1
	startIdx := nbInitialElementNeeded
	outIdx := inTimePeriod - 1
	today := startIdx
	trailingIdx := startIdx - nbInitialElementNeeded
	for today < len(inHigh) {
		lowest := inLow[trailingIdx]
		highest := inHigh[trailingIdx]
		trailingIdx++
		for i := trailingIdx; i <= today; i++ {
			tmp := inLow[i]
			if tmp < lowest {
				lowest = tmp
			}
			tmp = inHigh[i]
			if tmp > highest {
				highest = tmp
			}
		}
		outReal[outIdx] = (highest + lowest) / 2.0
		outIdx++
		today++
	}
	return outReal
}
211513
func (e *Event) GetPreviousValue(keys ...string) string {
	return getValue(e.Data.PreviousAttributes, keys)
}
800394
func (d *Datum) GetValue() interface{} {
	switch d.k {
	case KindInt64:
		return d.GetInt64()
	case KindUint64:
		return d.GetUint64()
	case KindFloat32:
		return d.GetFloat32()
	case KindFloat64:
		return d.GetFloat64()
	case KindString:
		return d.GetString()
	case KindBytes:
		return d.GetBytes()
	case KindMysqlDecimal:
		return d.GetMysqlDecimal()
	case KindMysqlDuration:
		return d.GetMysqlDuration()
	case KindMysqlEnum:
		return d.GetMysqlEnum()
	case KindBinaryLiteral, KindMysqlBit:
		return d.GetBinaryLiteral()
	case KindMysqlSet:
		return d.GetMysqlSet()
	case KindMysqlJSON:
		return d.GetMysqlJSON()
	case KindMysqlTime:
		return d.GetMysqlTime()
	default:
		return d.GetInterface()
	}
}
650782
func GetVariantDate(value uint64) (time.Time, error) {
	var st syscall.Systemtime
	r, _, _ := procVariantTimeToSystemTime.Call(uintptr(value), uintptr(unsafe.Pointer(&st)))
	if r != 0 {
		return time.Date(int(st.Year), time.Month(st.Month), int(st.Day), int(st.Hour), int(st.Minute), int(st.Second), int(st.Milliseconds/1000), time.UTC), nil
	}
	return time.Now(), errors.New("Could not convert to time, passing current time.")
}
1096502
func parseHistoricalRow(data []string) (PriceH, error) {
	p := PriceH{}

	// Parse date.
	d, err := time.Parse("2006-01-02", data[0])
	if err != nil {
		return p, err
	}

	p.Date = d
	p.Open, _ = strconv.ParseFloat(data[1], 64)
	p.High, _ = strconv.ParseFloat(data[2], 64)
	p.Low, _ = strconv.ParseFloat(data[3], 64)
	p.Close, _ = strconv.ParseFloat(data[4], 64)
	p.Volume, _ = strconv.ParseFloat(data[5], 64)
	p.AdjClose, _ = strconv.ParseFloat(data[6], 64)

	return p, nil
}
98250
func NewStockType(s string) (stockType, error) {
	var e stockType
	err := e.FromString(s)
	if err != nil {
		return 0, err
	}
	return e, nil
}
293012
func (m *MarketplacePurchaseEvent) GetEffectiveDate() Timestamp {
	if m == nil || m.EffectiveDate == nil {
		return Timestamp{}
	}
	return *m.EffectiveDate
}
957760
func GetTimeValue(ctx context.Context, v interface{}, tp byte, fsp int) (types.Datum, error) {
	return getTimeValue(ctx, v, tp, fsp)
}
1116643
func (e *Extractions) GetValue(key string) string {
	if val, ok := e.Extractions[key]; ok {
		return val.Value
	}
	return ""
}
1105488
func (b *LRUCache) GetStale(key string) (value interface{}, ok, expired bool) {
	return b.GetStaleNow(key, time.Now())
}
1258379
func (s *RatesService) Single(code string) (*float64, error) {
	// No base currency provided, let them know!
	if baseCurrency == "" || code == "" {
		return nil, errors.New("Both the base currency and requested currency values must be set")
	}

	// If we have cached results, use them.
	results := s.client.Cache.Get(baseCurrency)
	if results != nil {
		single := results.Rates[code]
		return &single, nil
	}

	// No cached results, go and fetch them.
	err := s.client.Update.LatestRates(baseCurrency)
	if err != nil {
		return nil, err
	}

	return s.Single(code)
}
476089
func GetDailyHistory(symbol string, from, to time.Time) ([]PriceH, error) {
	var prices []PriceH
	// Create URL with daily frequency of data.
	data, err := loadHistoricalPrice(symbol, from, to, Daily)
	if err != nil {
		return prices, err
	}

	prices, err = parseHistorical(data)
	if err != nil {
		return prices, err
	}

	return prices, nil
}