mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
xalign: fix tick size calculation
This commit is contained in:
parent
dadf22e48f
commit
64dcef3429
|
@ -118,6 +118,8 @@ func (s *Strategy) selectSessionForCurrency(ctx context.Context, sessions map[st
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spread := ticker.Sell.Sub(ticker.Buy)
|
||||||
|
|
||||||
// changeQuantity > 0 = buy
|
// changeQuantity > 0 = buy
|
||||||
// changeQuantity < 0 = sell
|
// changeQuantity < 0 = sell
|
||||||
q := changeQuantity.Abs()
|
q := changeQuantity.Abs()
|
||||||
|
@ -135,8 +137,8 @@ func (s *Strategy) selectSessionForCurrency(ctx context.Context, sessions map[st
|
||||||
price := ticker.Sell
|
price := ticker.Sell
|
||||||
if taker {
|
if taker {
|
||||||
price = ticker.Sell
|
price = ticker.Sell
|
||||||
} else if ticker.Buy.Add(market.TickSize).Compare(ticker.Sell) < 0 {
|
} else if spread.Compare(market.TickSize) > 0 {
|
||||||
price = ticker.Buy.Add(market.TickSize)
|
price = ticker.Sell.Sub(market.TickSize)
|
||||||
} else {
|
} else {
|
||||||
price = ticker.Buy
|
price = ticker.Buy
|
||||||
}
|
}
|
||||||
|
@ -174,14 +176,14 @@ func (s *Strategy) selectSessionForCurrency(ctx context.Context, sessions map[st
|
||||||
price := ticker.Buy
|
price := ticker.Buy
|
||||||
if taker {
|
if taker {
|
||||||
price = ticker.Buy
|
price = ticker.Buy
|
||||||
} else if ticker.Sell.Add(market.TickSize.Neg()).Compare(ticker.Buy) < 0 {
|
} else if spread.Compare(market.TickSize) > 0 {
|
||||||
price = ticker.Sell.Add(market.TickSize.Neg())
|
price = ticker.Buy.Add(market.TickSize)
|
||||||
} else {
|
} else {
|
||||||
price = ticker.Sell
|
price = ticker.Sell
|
||||||
}
|
}
|
||||||
|
|
||||||
if market.IsDustQuantity(q, price) {
|
if market.IsDustQuantity(q, price) {
|
||||||
log.Infof("%s dust quantity: %f", currency, q.Float64())
|
log.Infof("%s ignore dust quantity: %f", currency, q.Float64())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user