<commit_before>package main

import (
	"errors"
	"fmt"
	"log"
	"net/url"
	"strings"
	"time"
)

type Rate struct {
	Id   string  `json:"id"`
	Name string  `json:"Name"`
	Rate float64 `json:",string"`
	Date string  `json:"Date"`
	Time string  `json:"Time"`
	Ask  float64 `json:",string"`
	Bid  float64 `json:",string"`
}

type YahooJSONResponseInfo struct {
	Count   int       `json:"count"`
	Created time.Time `json:"created"`
	Lang    string    `json:"lang"`
}

type YahooJSONResponse struct {
	Query struct {
		YahooJSONResponseInfo
		Results struct {
			Rate []Rate `json:"rate"`
		}
	}
}

const (
	YAHOO_YQL_URL      = "http://query.yahooapis.com/v1/public/yql"
	YAHOO_DATABASE     = "store://datatables.org/alltableswithkeys"
	DEFAULT_CURRENCIES = "USD,AUD,EUR,CNY"
)

var (
	CurrencyStore             YahooJSONResponse
	ErrCurrencyDataNotFetched = errors.New("Yahoo currency data has not been fetched yet.")
	ErrCurrencyNotFound       = errors.New("Unable to find specified currency.")
	ErrQueryingYahoo          = errors.New("Unable to query Yahoo currency values.")
)

func RetrieveConfigCurrencyPairs(config Config) error {
	currencyPairs := ""
	for _, exchange := range config.Exchanges {
		if exchange.Enabled {
			var result []string
			if StringContains(exchange.BaseCurrencies, ",") {
				result = SplitStrings(exchange.BaseCurrencies, ",")
			} else {
				if StringContains(DEFAULT_CURRENCIES, exchange.BaseCurrencies) {
					result = SplitStrings(DEFAULT_CURRENCIES, ",")
				} else {
					result = SplitStrings(exchange.BaseCurrencies+","+DEFAULT_CURRENCIES, ",")
				}
			}
			for _, s := range result {
				if !StringContains(currencyPairs, s) {
					currencyPairs += s + ","
				}
			}
		}
	}
	currencyPairs = currencyPairs[0 : len(currencyPairs)-1]
	err := QueryYahooCurrencyValues(currencyPairs)

	if err != nil {
		return ErrQueryingYahoo
	}

	log.Println("Fetched currency value data.")
	return nil
}

func MakecurrencyPairs(supportedCurrencies string) string {
	currencies := SplitStrings(supportedCurrencies, ",")<commit_msg>Added IsFiatCurrency function.<commit_after>package main

import (
	"errors"
	"fmt"
	"log"
	"net/url"
	"strings"
	"time"
)

type Rate struct {
	Id   string  `json:"id"`
	Name string  `json:"Name"`
	Rate float64 `json:",string"`
	Date string  `json:"Date"`
	Time string  `json:"Time"`
	Ask  float64 `json:",string"`
	Bid  float64 `json:",string"`
}

type YahooJSONResponseInfo struct {
	Count   int       `json:"count"`
	Created time.Time `json:"created"`
	Lang    string    `json:"lang"`
}

type YahooJSONResponse struct {
	Query struct {
		YahooJSONResponseInfo
		Results struct {
			Rate []Rate `json:"rate"`
		}
	}
}

const (
	YAHOO_YQL_URL      = "http://query.yahooapis.com/v1/public/yql"
	YAHOO_DATABASE     = "store://datatables.org/alltableswithkeys"
	DEFAULT_CURRENCIES = "USD,AUD,EUR,CNY"
)

var (
	CurrencyStore             YahooJSONResponse
	BaseCurrencies            string
	ErrCurrencyDataNotFetched = errors.New("Yahoo currency data has not been fetched yet.")
	ErrCurrencyNotFound       = errors.New("Unable to find specified currency.")
	ErrQueryingYahoo          = errors.New("Unable to query Yahoo currency values.")
)

func IsFiatCurrency(currency string) bool {
	if StringContains(BaseCurrencies, StringToUpper(currency)) {
		return true
	}
	return false
}

func RetrieveConfigCurrencyPairs(config Config) error {
	currencyPairs := ""
	for _, exchange := range config.Exchanges {
		if exchange.Enabled {
			var result []string
			if StringContains(exchange.BaseCurrencies, ",") {
				result = SplitStrings(exchange.BaseCurrencies, ",")
			} else {
				if StringContains(DEFAULT_CURRENCIES, exchange.BaseCurrencies) {
					result = SplitStrings(DEFAULT_CURRENCIES, ",")
				} else {
					result = SplitStrings(exchange.BaseCurrencies+","+DEFAULT_CURRENCIES, ",")
				}
			}
			for _, s := range result {
				if !StringContains(currencyPairs, s) {
					currencyPairs += s + ","
				}
			}
		}
	}
	currencyPairs = currencyPairs[0 : len(currencyPairs)-1]
	BaseCurrencies = currencyPairs
	err := QueryYahooCurrencyValues(currencyPairs)

	if err != nil {
		return ErrQueryingYahoo
	}

	log.Println("Fetched currency value data.")
	return nil
}

func MakecurrencyPairs(supportedCurrencies string) string {
	currencies := SplitStrings(supportedCurrencies, ",")
{'fraction_non_alphanumeric': 0.12051815868609762, 'fraction_numerical': 0.004163775156141568, 'mean_word_length': 3.9758342922899885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3650978', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1429, 'n_words': 309}