mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* Initial currency overhaul before service system implementation * Remove redundant currency string in orderbook.Base Unexport lastupdated field in orderbook.Base as it was being instantiated multiple times Add error handling for process orderbook * Remove redundant currency string in ticker.Price Unexport lastupdated field in ticker.Price Add error handling for process ticker function and fix tests * Phase Two Update * Update translations to use map type - thankyou to kempeng for spotting this * Change pair method name from Display -> Format for better readability * Fixes misspelling and tests * Implement requested changes from GloriousCode * Remove reduntant function and streamlined return in currency_translation.go * Revert pair method naming conventions * Change currency naming conventions * Changed code type to exported Item type with underlying string to reduce complexity * Added interim orderbook process method to orderbook.Base type * Changed feebuilder struct field to currency.Pair * Adds fall over system for backup fx providers * deprecate function and children and fix linter issue with btcmarkets * Fixed requested changes * Fix bug and move mtx for rates * Fixed after rebase oopsies * Fix linter issues * Fixes race conditions in testing functions * Final phase coinmarketcap update * fix linter issues * Implement requested changes * Adds configuration variables to increase/decrease time durations between updating currency file and fetching new currency rates * Add a collection of tests to improve codecov * After rebase oopsy fixes for btse * Fix requested changes * fix after rebase oopsies and add more efficient comparison checks within currency pair * Fix linter issues
128 lines
2.3 KiB
Go
128 lines
2.3 KiB
Go
package currency
|
|
|
|
import "errors"
|
|
|
|
// symbols map holds the currency name and symbol mappings
|
|
var symbols = map[*Item]string{
|
|
ALL.Item: "Lek",
|
|
AFN.Item: "؋",
|
|
ARS.Item: "$",
|
|
AWG.Item: "ƒ",
|
|
AUD.Item: "$",
|
|
AZN.Item: "ман",
|
|
BSD.Item: "$",
|
|
BBD.Item: "$",
|
|
BYN.Item: "Br",
|
|
BZD.Item: "BZ$",
|
|
BMD.Item: "$",
|
|
BOB.Item: "$b",
|
|
BAM.Item: "KM",
|
|
BWP.Item: "P",
|
|
BGN.Item: "лв",
|
|
BRL.Item: "R$",
|
|
BND.Item: "$",
|
|
KHR.Item: "៛",
|
|
CAD.Item: "$",
|
|
KYD.Item: "$",
|
|
CLP.Item: "$",
|
|
CNY.Item: "¥",
|
|
COP.Item: "$",
|
|
CRC.Item: "₡",
|
|
HRK.Item: "kn",
|
|
CUP.Item: "₱",
|
|
CZK.Item: "Kč",
|
|
DKK.Item: "kr",
|
|
DOP.Item: "RD$",
|
|
XCD.Item: "$",
|
|
EGP.Item: "£",
|
|
SVC.Item: "$",
|
|
EUR.Item: "€",
|
|
FKP.Item: "£",
|
|
FJD.Item: "$",
|
|
GHS.Item: "¢",
|
|
GIP.Item: "£",
|
|
GTQ.Item: "Q",
|
|
GGP.Item: "£",
|
|
GYD.Item: "$",
|
|
HNL.Item: "L",
|
|
HKD.Item: "$",
|
|
HUF.Item: "Ft",
|
|
ISK.Item: "kr",
|
|
INR.Item: "₹",
|
|
IDR.Item: "Rp",
|
|
IRR.Item: "﷼",
|
|
IMP.Item: "£",
|
|
ILS.Item: "₪",
|
|
JMD.Item: "J$",
|
|
JPY.Item: "¥",
|
|
JEP.Item: "£",
|
|
KZT.Item: "лв",
|
|
KPW.Item: "₩",
|
|
KRW.Item: "₩",
|
|
KGS.Item: "лв",
|
|
LAK.Item: "₭",
|
|
LBP.Item: "£",
|
|
LRD.Item: "$",
|
|
MKD.Item: "ден",
|
|
MYR.Item: "RM",
|
|
MUR.Item: "₨",
|
|
MXN.Item: "$",
|
|
MNT.Item: "₮",
|
|
MZN.Item: "MT",
|
|
NAD.Item: "$",
|
|
NPR.Item: "₨",
|
|
ANG.Item: "ƒ",
|
|
NZD.Item: "$",
|
|
NIO.Item: "C$",
|
|
NGN.Item: "₦",
|
|
NOK.Item: "kr",
|
|
OMR.Item: "﷼",
|
|
PKR.Item: "₨",
|
|
PAB.Item: "B/.",
|
|
PYG.Item: "Gs",
|
|
PEN.Item: "S/.",
|
|
PHP.Item: "₱",
|
|
PLN.Item: "zł",
|
|
QAR.Item: "﷼",
|
|
RON.Item: "lei",
|
|
RUB.Item: "₽",
|
|
RUR.Item: "₽",
|
|
SHP.Item: "£",
|
|
SAR.Item: "﷼",
|
|
RSD.Item: "Дин.",
|
|
SCR.Item: "₨",
|
|
SGD.Item: "$",
|
|
SBD.Item: "$",
|
|
SOS.Item: "S",
|
|
ZAR.Item: "R",
|
|
LKR.Item: "₨",
|
|
SEK.Item: "kr",
|
|
CHF.Item: "CHF",
|
|
SRD.Item: "$",
|
|
SYP.Item: "£",
|
|
TWD.Item: "NT$",
|
|
THB.Item: "฿",
|
|
TTD.Item: "TT$",
|
|
TRY.Item: "₺",
|
|
TVD.Item: "$",
|
|
UAH.Item: "₴",
|
|
GBP.Item: "£",
|
|
USD.Item: "$",
|
|
USDT.Item: "$",
|
|
UYU.Item: "$U",
|
|
UZS.Item: "лв",
|
|
VEF.Item: "Bs",
|
|
VND.Item: "₫",
|
|
YER.Item: "﷼",
|
|
ZWD.Item: "Z$",
|
|
}
|
|
|
|
// GetSymbolByCurrencyName returns a currency symbol
|
|
func GetSymbolByCurrencyName(currency Code) (string, error) {
|
|
result, ok := symbols[currency.Item]
|
|
if !ok {
|
|
return "", errors.New("currency symbol not found")
|
|
}
|
|
return result, nil
|
|
}
|