// getLocalCurrencyAndExchangeRate gets display currency setting
// for accountID and fetches exchange rate is set.
//
// Arguments `account` and `exchangeRates` may end up mutated.
178062
func getLocalCurrencyAndExchangeRate(mctx libkb.MetaContext, remoter remote.Remoter, account *stellar1.OwnAccountCLILocal, exchangeRates exchangeRateMap) error {
	displayCurrency, err := stellar.GetAccountDisplayCurrency(mctx, account.AccountID)
	if err != nil {
		return err
	}
	rate, ok := exchangeRates[displayCurrency]
	if !ok {
		var err error
		rate, err = remoter.ExchangeRate(mctx.Ctx(), displayCurrency)
		if err != nil {
			return err
		}
		exchangeRates[displayCurrency] = rate
	}
	account.ExchangeRate = &rate
	return nil
}
555550
func (poloniex *PoloniexExchange) Refresh() {
	poloniex.LogRequest()

	var response map[string]*PoloniexPair
	err := poloniex.fetch(poloniex.requests.price, &response)
	if err != nil {
		poloniex.fail("Fetch", err)
		return
	}
	market, ok := response[poloniex.CurrencyPair]
	if !ok {
		poloniex.fail("Market not in response", fmt.Errorf("Response did not have expected CurrencyPair %s", poloniex.CurrencyPair))
		return
	}
	price, err := strconv.ParseFloat(market.Last, 64)
	if err != nil {
		poloniex.fail(fmt.Sprintf("Failed to parse float from Last=%s", market.Last), err)
		return
	}
	baseVolume, err := strconv.ParseFloat(market.BaseVolume, 64)
	if err != nil {
		poloniex.fail(fmt.Sprintf("Failed to parse float from BaseVolume=%s", market.BaseVolume), err)
		return
	}
	volume, err := strconv.ParseFloat(market.QuoteVolume, 64)
	if err != nil {
		poloniex.fail(fmt.Sprintf("Failed to parse float from QuoteVolume=%s", market.QuoteVolume), err)
		return
	}
	percentChange, err := strconv.ParseFloat(market.PercentChange, 64)
	if err != nil {
		poloniex.fail(fmt.Sprintf("Failed to parse float from PercentChange=%s", market.PercentChange), err)
		return
	}
	oldPrice := price / (1 + percentChange)

	// Depth chart
	// Check to see if the websocket has been initialized
	var skipHttp, skipBotUpdate bool
	var depth *DepthData
	if !poloniex.wsListening() {
		if poloniex.wsFailed() {
			errCount := poloniex.wsErrorCount()
			if errCount < poloniexMaxErrors {
				// Try to connect, but don't wait for the response. Grab the order
				// book over HTTP anyway.
				poloniex.connectWs()
			} else if errCount == poloniexMaxErrors {
				log.Errorf("Poloniex websocket being disabled. Too many errors")
			}
		} else {
			// Connection has not been initialized. Trigger a silent update, since an
			// update will be triggered on initial websocket message, which contains
			// the full orderbook.
			skipHttp = true
			skipBotUpdate = true
			log.Tracef("Initializing websocket connection for poloniex")
		}
	} else { // Websocket is listening
		depth = poloniex.wsDepths()
		skipHttp = true
	}

	// If not expecting depth data from the websocket, grab it from HTTP
	if !skipHttp {
		depthResponse := new(PoloniexDepthResponse)
		err = poloniex.fetch(poloniex.requests.depth, depthResponse)
		if err != nil {
			log.Errorf("Poloniex depth chart fetch error: %v", err)
		}
		depth = depthResponse.translate()
	}

	// Candlesticks
	state := poloniex.state()

	candlesticks := map[candlestickKey]Candlesticks{}
	for bin, req := range poloniex.requests.candlesticks {
		oldSticks, found := state.Candlesticks[bin]
		if !found || oldSticks.needsUpdate(bin) {
			log.Tracef("Signalling candlestick update for %s, bin size %s", poloniex.token, bin)
			response := new(PoloniexCandlestickResponse)
			err := poloniex.fetch(req, response)
			if err != nil {
				log.Errorf("Error retrieving candlestick data from poloniex for bin size %s: %v", string(bin), err)
				continue
			}

			sticks := response.translate()
			if !found || sticks.time().After(oldSticks.time()) {
				candlesticks[bin] = sticks
			}
		}
	}

	update := &ExchangeState{
		Price:        price,
		BaseVolume:   baseVolume,
		Volume:       volume,
		Change:       price - oldPrice,
		Depth:        depth,
		Candlesticks: candlesticks,
	}
	if skipBotUpdate {
		poloniex.SilentUpdate(update)
		poloniex.connectWs()
	} else {
		poloniex.Update(update)
	}

}
1065157
func (api *Client) GetAccountTransactions() ([]*AccountTransaction, error) {
	result, _, err := api.makeRequest(http.MethodGet, fmt.Sprintf("%s/%s", api.concatUserPath(accountPath), "transactions"), &[]*AccountTransaction{})
	if err != nil {
		return nil, err
	}
	return *(result.(*[]*AccountTransaction)), nil
}
1233610
func (m *MarketplacePendingChange) GetUnitCount() int {
	if m == nil || m.UnitCount == nil {
		return 0
	}
	return *m.UnitCount
}
411893
func FormatCurrencyWithCodeSuffix(mctx libkb.MetaContext, amount string, code stellar1.OutsideCurrencyCode, rounding stellarnet.FmtRoundingBehavior) (string, error) {
	conf, err := mctx.G().GetStellar().GetServerDefinitions(mctx.Ctx())
	if err != nil {
		return "", err
	}
	currency, ok := conf.Currencies[code]
	if !ok {
		return "", fmt.Errorf("FormatCurrencyWithCodeSuffix error: cannot find curency code %q", code)
	}
	return stellarnet.FmtCurrencyWithCodeSuffix(amount, rounding, string(code), currency.Symbol.Symbol, currency.Symbol.Postfix)
}
856863
func (s *Reservation) SetCurrencyCode(v string) *Reservation {
	s.CurrencyCode = &v
	return s
}
679264
func RetrieveExchangeTokenCtx(r *http.Request) string {
	token, ok := r.Context().Value(ctxXcToken).(string)
	if !ok {
		apiLog.Error("non-string encountered in exchange token context")
		return ""
	}
	return token
}
1179338
func (obj *Doc) GetLocaleInfo(ctx context.Context) (*LocaleInfo, error) {
	result := &struct {
		Return *LocaleInfo	`json:"qReturn"`
	} {}
	err := obj.rpc(ctx, "GetLocaleInfo", result)
	return result.Return, err 
}
965133
func GetLocale(locale string) (*Locale, bool) {
	l, ok := locales[locale]
	return l, ok
}
451317
func (s *ReservationPurchaseRecommendationSummary) SetCurrencyCode(v string) *ReservationPurchaseRecommendationSummary {
	s.CurrencyCode = &v
	return s
}
574354
func (s *LocalStore) GetAccount() (*Account, error) {
	storedData, err := s.get()
	if err != nil {
		return nil, err
	}

	return storedData.Account, nil
}
1330893
func (s *RatesService) All() (*RatesStore, error) {
	// No base currency provided, let them know!
	if baseCurrency == "" {
		return nil, errors.New("Please set a base currency.")
	}

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

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

	return s.All()
}
371499
func getLocal(url string, fs afero.Fs, cfg config.Provider) ([]byte, error) {
	filename := filepath.Join(cfg.GetString("workingDir"), url)
	if e, err := helpers.Exists(filename, fs); !e {
		return nil, err
	}

	return afero.ReadFile(fs, filename)

}
1138879
func (s *DescribeReservationOutput) SetCurrencyCode(v string) *DescribeReservationOutput {
	s.CurrencyCode = &v
	return s
}
328522
func (tm *transferManager) SetConcurrency(concurrency int) {
	tm.mu.Lock()
	tm.concurrencyLimit = concurrency
	tm.mu.Unlock()
}
452107
func ExtractCurrency(s string) (int64, error) {
	s = regexCurrency.FindString(s)
	if len(s) == 0 {
		return 0, ErrNotFound
	}
	val, err := strconv.ParseFloat(s, 64)
	if err != nil {
		return 0, err
	}
	log.Debug("found value", val)
	// Convert parsed float into an int64 with precision of 2 decimal places
	return int64(val * 100), nil
}
31145
func getCurrent(l, u, lang string) (*owm.CurrentWeatherData, error) {
	w, err := owm.NewCurrent(u, lang, os.Getenv("OWM_API_KEY")) // Create the instance with the given unit
	if err != nil {
		return nil, err
	}
	w.CurrentByName(l) // Get the actual data for the given location
	return w, nil
}