-
-
Notifications
You must be signed in to change notification settings - Fork 277
/
currencies.go
47 lines (36 loc) · 967 Bytes
/
currencies.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package types
import (
"math/big"
"github.com/leekchan/accounting"
"github.com/c9s/bbgo/pkg/fixedpoint"
)
type Acc = accounting.Accounting
type wrapper struct {
Acc
}
func (w *wrapper) FormatMoney(v fixedpoint.Value) string {
f := new(big.Float)
f.SetString(v.String())
return w.Acc.FormatMoneyBigFloat(f)
}
var USD = wrapper{accounting.Accounting{Symbol: "$ ", Precision: 2}}
var BTC = wrapper{accounting.Accounting{Symbol: "BTC ", Precision: 8}}
var BNB = wrapper{accounting.Accounting{Symbol: "BNB ", Precision: 4}}
var FiatCurrencies = []string{"USDC", "USDT", "USD", "TWD", "EUR", "GBP", "BUSD"}
var USDFiatCurrencies = []string{"USDT", "USDC", "USD", "BUSD"}
func IsUSDFiatCurrency(currency string) bool {
for _, c := range USDFiatCurrencies {
if c == currency {
return true
}
}
return false
}
func IsFiatCurrency(currency string) bool {
for _, c := range FiatCurrencies {
if c == currency {
return true
}
}
return false
}