mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-16 15:09:57 +00:00
Quick bug fix (#112)
* Added verbosity to returned error in currency.go * Fixed bug with request handler init in okcoin.
This commit is contained in:
committed by
Adrian Gallagher
parent
7fc9d20fd7
commit
5f25fd8be7
@@ -66,7 +66,7 @@ var (
|
||||
BaseCurrencies []string
|
||||
CryptoCurrencies []string
|
||||
ErrCurrencyDataNotFetched = errors.New("yahoo currency data has not been fetched yet")
|
||||
ErrCurrencyNotFound = errors.New("unable to find specified currency")
|
||||
ErrCurrencyNotFound = "unable to find specified currency"
|
||||
ErrQueryingYahoo = errors.New("unable to query Yahoo currency values")
|
||||
ErrQueryingYahooZeroCount = errors.New("yahoo returned zero currency data")
|
||||
YahooEnabled = false
|
||||
@@ -227,7 +227,7 @@ func ConvertCurrency(amount float64, from, to string) (float64, error) {
|
||||
|
||||
result, ok := CurrencyStore[currency]
|
||||
if !ok {
|
||||
return 0, ErrCurrencyNotFound
|
||||
return 0, errors.New(ErrCurrencyNotFound + " currency not found in CurrencyStore " + currency)
|
||||
}
|
||||
return amount * result.Rate, nil
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func ConvertCurrency(amount float64, from, to string) (float64, error) {
|
||||
if to == "USD" {
|
||||
resultFrom, ok := CurrencyStoreFixer[from]
|
||||
if !ok {
|
||||
return 0, ErrCurrencyNotFound
|
||||
return 0, errors.New(ErrCurrencyNotFound + " " + from + " in CurrencyStoreFixer with pair " + from + to)
|
||||
}
|
||||
return amount / resultFrom, nil
|
||||
}
|
||||
@@ -255,7 +255,7 @@ func ConvertCurrency(amount float64, from, to string) (float64, error) {
|
||||
if from == "USD" {
|
||||
resultTo, ok := CurrencyStoreFixer[to]
|
||||
if !ok {
|
||||
return 0, ErrCurrencyNotFound
|
||||
return 0, errors.New(ErrCurrencyNotFound + " " + to + " in CurrencyStoreFixer with pair " + from + to)
|
||||
}
|
||||
return resultTo * amount, nil
|
||||
}
|
||||
@@ -263,13 +263,13 @@ func ConvertCurrency(amount float64, from, to string) (float64, error) {
|
||||
// Otherwise convert to USD, then to the target currency
|
||||
resultFrom, ok := CurrencyStoreFixer[from]
|
||||
if !ok {
|
||||
return 0, ErrCurrencyNotFound
|
||||
return 0, errors.New(ErrCurrencyNotFound + " " + from + " in CurrencyStoreFixer with pair " + from + to)
|
||||
}
|
||||
|
||||
converted := amount / resultFrom
|
||||
resultTo, ok = CurrencyStoreFixer[to]
|
||||
if !ok {
|
||||
return 0, ErrCurrencyNotFound
|
||||
return 0, errors.New(ErrCurrencyNotFound + " " + to + " in CurrencyStoreFixer with pair " + from + to)
|
||||
}
|
||||
|
||||
return converted * resultTo, nil
|
||||
|
||||
@@ -106,7 +106,6 @@ func (o *OKCoin) SetDefaults() {
|
||||
o.AssetTypes = []string{ticker.Spot}
|
||||
o.SupportsAutoPairUpdating = false
|
||||
o.Handler = new(request.Handler)
|
||||
o.SetRequestHandler(o.Name, okcoinAuthRate, okcoinUnauthRate, new(http.Client))
|
||||
|
||||
if okcoinDefaultsSet {
|
||||
o.AssetTypes = append(o.AssetTypes, o.FuturesValues...)
|
||||
@@ -114,12 +113,14 @@ func (o *OKCoin) SetDefaults() {
|
||||
o.Name = "OKCOIN International"
|
||||
o.WebsocketURL = okcoinWebsocketURL
|
||||
o.setCurrencyPairFormats()
|
||||
o.SetRequestHandler(o.Name, okcoinAuthRate, okcoinUnauthRate, new(http.Client))
|
||||
} else {
|
||||
o.APIUrl = okcoinAPIURLChina
|
||||
o.Name = "OKCOIN China"
|
||||
o.WebsocketURL = okcoinWebsocketURLChina
|
||||
okcoinDefaultsSet = true
|
||||
o.setCurrencyPairFormats()
|
||||
o.SetRequestHandler(o.Name, okcoinAuthRate, okcoinUnauthRate, new(http.Client))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user