// Get single stock price data.
195028
func GetPrice(symbol string) (*Price, error) {
	data, err := loadSingleStockPrice(symbol)
	if err != nil {
		return nil, err
	}

	price := parsePrice(data)
	return price, nil
}
778444
func getData(data []byte, start uint64, size uint64) []byte {
	length := uint64(len(data))
	if start > length {
		start = length
	}
	end := start + size
	if end > length {
		end = length
	}
	return common.RightPadBytes(data[start:end], int(size))
}
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
}
552605
func parsePrice(data []string) *Price {
	p := &Price{}
	p.Bid, _ = strconv.ParseFloat(data[2], 64)
	p.Ask, _ = strconv.ParseFloat(data[3], 64)
	p.Open, _ = strconv.ParseFloat(data[4], 64)
	p.PreviousClose, _ = strconv.ParseFloat(data[5], 64)
	p.Last, _ = strconv.ParseFloat(data[6], 64)
	p.Date, _ = parseDate(data[7])

	return p
}
29270
func (l Tickers) GetTicker(id int32) tick.Ticker {
	l.RLock()
	defer l.RUnlock()
	return l.list[id]
}
429682
func (v *Values) Get(key Key) (value interface{}) {
	value, _ = v.GetOk(key)
	return value
}
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
}
243716
func loadHistoricalPrice(symbol string, from, to time.Time, period string) ([][]string, error) {
	url := stockHistoryURL(symbol, from, to, period)
	var data [][]string

	resp, err := http.Get(url)
	if err != nil {
		return data, err
	}
	defer resp.Body.Close()

	reader := csv.NewReader(resp.Body)
	data, err = reader.ReadAll()
	if err != nil {
		return data, err
	}

	return data, nil
}
181647
func (db *ProtoBrokerWrapper) GetValue(key string, reqObj proto.Message) (bool, int64, error) {
	found, revision, err := db.ProtoBroker.GetValue(key, reqObj)
	if !found || err != nil {
		return found, revision, err
	}

	_, err = db.decrypter.Decrypt(reqObj, db.decryptFunc)
	return found, revision, err
}
405211
func (c *Client) GetValue(key string) (data []byte, found bool, revision int64, err error) {
	var entry *decoder.FileDataEntry
	entry, found = c.db.GetDataForKey(key)
	data = entry.Value
	return
}
1116643
func (e *Extractions) GetValue(key string) string {
	if val, ok := e.Extractions[key]; ok {
		return val.Value
	}
	return ""
}
809220
func (list *SkipList) GetValue(key interface{}) (interface{}, bool) {
	element := list.Get(key)

	if element == nil {
		return nil, false
	}

	return element.Value, true
}
277269
func (pdb *BytesBrokerWatcherRedis) GetValue(key string) (data []byte, found bool, revision int64, err error) {
	if pdb.delegate.closed {
		return nil, false, 0, fmt.Errorf("GetValue(%s) called on a closed connection", key)
	}
	pdb.Debugf("GetValue(%s)", key)

	return pdb.delegate.GetValue(pdb.addPrefix(key))
}
1262162
func (txn *Txn) getIndexValue(table, index string, args ...interface{}) (*IndexSchema, []byte, error) {
	// Get the table schema
	tableSchema, ok := txn.db.schema.Tables[table]
	if !ok {
		return nil, nil, fmt.Errorf("invalid table '%s'", table)
	}

	// Check for a prefix scan
	prefixScan := false
	if strings.HasSuffix(index, "_prefix") {
		index = strings.TrimSuffix(index, "_prefix")
		prefixScan = true
	}

	// Get the index schema
	indexSchema, ok := tableSchema.Indexes[index]
	if !ok {
		return nil, nil, fmt.Errorf("invalid index '%s'", index)
	}

	// Hot-path for when there are no arguments
	if len(args) == 0 {
		return indexSchema, nil, nil
	}

	// Special case the prefix scanning
	if prefixScan {
		prefixIndexer, ok := indexSchema.Indexer.(PrefixIndexer)
		if !ok {
			return indexSchema, nil,
				fmt.Errorf("index '%s' does not support prefix scanning", index)
		}

		val, err := prefixIndexer.PrefixFromArgs(args...)
		if err != nil {
			return indexSchema, nil, fmt.Errorf("index error: %v", err)
		}
		return indexSchema, val, err
	}

	// Get the exact match index
	val, err := indexSchema.Indexer.FromArgs(args...)
	if err != nil {
		return indexSchema, nil, fmt.Errorf("index error: %v", err)
	}
	return indexSchema, val, err
}
98250
func NewStockType(s string) (stockType, error) {
	var e stockType
	err := e.FromString(s)
	if err != nil {
		return 0, err
	}
	return e, nil
}
1229461
func (self *TimedStore) getData(index int) timedStoreData {
	return self.buffer[len(self.buffer)-index-1]
}
687727
func (v *ValueChangePublisher) Get() (interface{}, <-chan struct{}) {
	v.mutex.RLock()
	defer v.mutex.RUnlock()
	return v.value, v.notify
}