2020-06-18 10:54:14 +00:00
|
|
|
package bbgo
|
|
|
|
|
|
|
|
import "strconv"
|
|
|
|
|
|
|
|
type Market struct {
|
|
|
|
Symbol string
|
|
|
|
PricePrecision int
|
|
|
|
VolumePrecision int
|
2020-06-18 16:07:05 +00:00
|
|
|
MinQuantity float64
|
|
|
|
MinAmount float64
|
2020-06-18 10:54:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m Market) FormatPrice(val float64) string {
|
|
|
|
return strconv.FormatFloat(val, 'f', m.PricePrecision, 64)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m Market) FormatVolume(val float64) string {
|
|
|
|
return strconv.FormatFloat(val, 'f', m.VolumePrecision, 64)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Binance Markets, this should be defined per exchange
|
2020-06-18 16:07:05 +00:00
|
|
|
|
|
|
|
var MarketBTCUSDT = Market{
|
2020-06-18 10:54:14 +00:00
|
|
|
Symbol: "BTCUSDT",
|
|
|
|
PricePrecision: 2,
|
2020-06-24 13:25:47 +00:00
|
|
|
VolumePrecision: 6,
|
2020-06-18 16:07:05 +00:00
|
|
|
MinQuantity: 0.00000100,
|
|
|
|
MinAmount: 10.0,
|
2020-06-18 10:54:14 +00:00
|
|
|
}
|
2020-06-18 16:07:05 +00:00
|
|
|
var MarketBNBUSDT = Market{
|
|
|
|
Symbol: "BNBUSDT",
|
|
|
|
PricePrecision: 4,
|
|
|
|
VolumePrecision: 2,
|
|
|
|
MinQuantity: 0.01,
|
|
|
|
MinAmount: 10.0,
|
2020-06-18 10:54:14 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 16:07:05 +00:00
|
|
|
var Markets = map[string]Market{
|
|
|
|
"BNBUSDT": MarketBNBUSDT,
|
|
|
|
"BTCUSDT": MarketBTCUSDT,
|
|
|
|
}
|
2020-06-18 10:54:14 +00:00
|
|
|
|
2020-06-18 16:07:05 +00:00
|
|
|
func FindMarket(symbol string) (m Market, ok bool) {
|
|
|
|
m, ok = Markets[symbol]
|
|
|
|
return m, ok
|
|
|
|
}
|