Documentation ¶
Index ¶
- Constants
- Variables
- func CountPrecision(value int) (int, error)
- func MustCountPrecision(value int) int
- type BTC
- func (btc BTC) Add(toAdd BTC) BTC
- func (btc BTC) Equal(other BTC) bool
- func (btc BTC) IsZero() bool
- func (btc BTC) LessThan(other BTC) bool
- func (btc BTC) String() string
- func (btc BTC) Sub(toSubtract BTC) (BTC, error)
- func (btc BTC) ToFloat() *big.Float
- func (btc BTC) ToFloat64() float64
- func (btc BTC) ToUSD(price BTCPrice) USD
- type BTCAction
- type BTCPrice
- type BTCRepository
- type USD
- type USDAction
Constants ¶
View Source
const ( SatoshiInBitcoin = 100_000_000 BTCSuffix = "BTC" )
View Source
const ( CentInUSD = 100 USDPrefix = "$" )
View Source
const MinimalPrecision = 10
Variables ¶
View Source
var ( DepositUSDAction = USDAction{"deposit"} WithdrawUSDAction = USDAction{"withdraw"} BuyBTCAction = BTCAction{"buy"} SellBTCAction = BTCAction{"sell"} )
View Source
var ErrInvalidAction = errors.New("invalid action")
View Source
var ErrPrecisionInvalidFormat = errors.New("invalid format to get precision")
View Source
var ErrSubtractMoreBTCThanHave = errors.New("can't subtract more btc than available")
View Source
var ErrSubtractMoreUSDThanHave = errors.New("can't subtract more usd than available")
Functions ¶
func CountPrecision ¶
CountPrecision counts float numbers precision From integer in format like 1 (one) with some amount of zeroes It uses math.Log10 to count the number of digits It is used for formatting (satoshi -> btc, cent -> dollar) See BTC.String and USD.String for example of usage
func MustCountPrecision ¶
Types ¶
type BTCPrice ¶
type BTCPrice struct {
// contains filtered or unexported fields
}
func (BTCPrice) GetUpdatedAt ¶
type BTCRepository ¶
Click to show internal directories.
Click to hide internal directories.