pkg/exchange: fix precision

This commit is contained in:
Edwin 2023-10-27 12:52:36 +08:00
parent c4f1af00d7
commit 2a85bbebf0
3 changed files with 6 additions and 7 deletions

View File

@ -16,8 +16,8 @@ func toGlobalMarket(m bybitapi.Instrument) types.Market {
return types.Market{ return types.Market{
Symbol: m.Symbol, Symbol: m.Symbol,
LocalSymbol: m.Symbol, LocalSymbol: m.Symbol,
PricePrecision: int(math.Log10(m.LotSizeFilter.QuotePrecision.Float64())), PricePrecision: -int(math.Log10(m.LotSizeFilter.QuotePrecision.Float64())),
VolumePrecision: int(math.Log10(m.LotSizeFilter.BasePrecision.Float64())), VolumePrecision: -int(math.Log10(m.LotSizeFilter.BasePrecision.Float64())),
QuoteCurrency: m.QuoteCoin, QuoteCurrency: m.QuoteCoin,
BaseCurrency: m.BaseCoin, BaseCurrency: m.BaseCoin,
MinNotional: m.LotSizeFilter.MinOrderAmt, MinNotional: m.LotSizeFilter.MinOrderAmt,

View File

@ -2,7 +2,6 @@ package bybit
import ( import (
"fmt" "fmt"
"math"
"strconv" "strconv"
"testing" "testing"
"time" "time"
@ -67,8 +66,8 @@ func TestToGlobalMarket(t *testing.T) {
exp := types.Market{ exp := types.Market{
Symbol: inst.Symbol, Symbol: inst.Symbol,
LocalSymbol: inst.Symbol, LocalSymbol: inst.Symbol,
PricePrecision: int(math.Log10(inst.LotSizeFilter.QuotePrecision.Float64())), PricePrecision: 8,
VolumePrecision: int(math.Log10(inst.LotSizeFilter.BasePrecision.Float64())), VolumePrecision: 6,
QuoteCurrency: inst.QuoteCoin, QuoteCurrency: inst.QuoteCoin,
BaseCurrency: inst.BaseCoin, BaseCurrency: inst.BaseCoin,
MinNotional: inst.LotSizeFilter.MinOrderAmt, MinNotional: inst.LotSizeFilter.MinOrderAmt,

View File

@ -39,8 +39,8 @@ func toGlobalMarket(m kucoinapi.Symbol) types.Market {
return types.Market{ return types.Market{
Symbol: symbol, Symbol: symbol,
LocalSymbol: m.Symbol, LocalSymbol: m.Symbol,
PricePrecision: int(math.Log10(m.PriceIncrement.Float64())), // convert 0.0001 to 4 PricePrecision: -int(math.Log10(m.PriceIncrement.Float64())), // convert 0.0001 to 4
VolumePrecision: int(math.Log10(m.BaseIncrement.Float64())), VolumePrecision: -int(math.Log10(m.BaseIncrement.Float64())),
QuoteCurrency: m.QuoteCurrency, QuoteCurrency: m.QuoteCurrency,
BaseCurrency: m.BaseCurrency, BaseCurrency: m.BaseCurrency,
MinNotional: m.QuoteMinSize, MinNotional: m.QuoteMinSize,