55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
|
package types
|
||
|
|
||
|
import (
|
||
|
"math/big"
|
||
|
|
||
|
"github.com/leekchan/accounting"
|
||
|
|
||
|
"git.qtrade.icu/lychiyu/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}}
|
||
|
|
||
|
const (
|
||
|
USDT = "USDT"
|
||
|
USDC = "USDC"
|
||
|
BUSD = "BUSD"
|
||
|
)
|
||
|
|
||
|
var FiatCurrencies = []string{"USDC", "USDT", "USD", "TWD", "EUR", "GBP", "BUSD"}
|
||
|
|
||
|
// USDFiatCurrencies lists the USD stable coins
|
||
|
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
|
||
|
}
|