mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
move currency formatter to market struct
This commit is contained in:
parent
790b3357d7
commit
952bdf8218
|
@ -6,7 +6,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/c9s/bbgo/pkg/exchange/binance"
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
"github.com/leekchan/accounting"
|
||||
"github.com/sirupsen/logrus"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -198,11 +197,8 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
return
|
||||
}
|
||||
|
||||
prettyBaseVolume := accounting.DefaultAccounting(s.Market.BaseCurrency, s.Market.VolumePrecision)
|
||||
prettyBaseVolume.Format = "%v %s"
|
||||
|
||||
prettyQuoteVolume := accounting.DefaultAccounting(s.Market.QuoteCurrency, 0)
|
||||
prettyQuoteVolume.Format = "%v %s"
|
||||
prettyBaseVolume := s.Market.BaseCurrencyFormatter()
|
||||
prettyQuoteVolume := s.Market.QuoteCurrencyFormatter()
|
||||
|
||||
if detection.MinVolume > 0 && kline.Volume > detection.MinVolume.Float64() {
|
||||
s.Notifiability.Notify("Detected %s %s support base volume %s > min base volume %s, quote volume %s",
|
||||
|
|
|
@ -3,6 +3,7 @@ package types
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/leekchan/accounting"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -70,6 +71,18 @@ type Market struct {
|
|||
TickSize float64
|
||||
}
|
||||
|
||||
func (m Market) BaseCurrencyFormatter() *accounting.Accounting {
|
||||
a := accounting.DefaultAccounting(m.BaseCurrency, m.VolumePrecision)
|
||||
a.Format = "%v %s"
|
||||
return a
|
||||
}
|
||||
|
||||
func (m Market) QuoteCurrencyFormatter() *accounting.Accounting {
|
||||
a := accounting.DefaultAccounting(m.QuoteCurrency, m.PricePrecision)
|
||||
a.Format = "%v %s"
|
||||
return a
|
||||
}
|
||||
|
||||
func (m Market) FormatPriceCurrency(val float64) string {
|
||||
switch m.QuoteCurrency {
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user