mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
refactor volume calculator
This commit is contained in:
parent
cb4afca815
commit
577caab3f5
|
@ -97,6 +97,11 @@ func toLocalOrderType(orderType types.OrderType) (binance.OrderType, error) {
|
|||
}
|
||||
|
||||
func (e *Exchange) QueryKLines(ctx context.Context, symbol, interval string, limit int) ([]types.KLine, error) {
|
||||
if limit == 0 {
|
||||
// default limit == 500
|
||||
limit = 500
|
||||
}
|
||||
|
||||
logrus.Infof("[binance] querying kline %s %s limit %d", symbol, interval, limit)
|
||||
|
||||
resp, err := e.Client.NewKlinesService().Symbol(symbol).Interval(interval).Limit(limit).Do(ctx)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package bbgo
|
||||
|
||||
import "strconv"
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Market struct {
|
||||
Symbol string
|
||||
|
@ -20,6 +23,11 @@ func (m Market) FormatVolume(val float64) string {
|
|||
return strconv.FormatFloat(val, 'f', m.VolumePrecision, 64)
|
||||
}
|
||||
|
||||
func (m Market) CanonicalizeVolume(val float64) float64 {
|
||||
p := math.Pow10(m.VolumePrecision)
|
||||
return math.Trunc(p * val) / p
|
||||
}
|
||||
|
||||
// Binance Markets, this should be defined per exchange
|
||||
|
||||
var MarketBTCUSDT = Market{
|
||||
|
|
Loading…
Reference in New Issue
Block a user