mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
scmaker: truncate price with price precision
This commit is contained in:
parent
68c3c96b10
commit
372028ebe6
|
@ -280,19 +280,24 @@ func (s *Strategy) placeLiquidityOrders(ctx context.Context) {
|
|||
// calculate and collect prices
|
||||
for i := 0; i <= s.NumOfLiquidityLayers; i++ {
|
||||
fi := fixedpoint.NewFromInt(int64(i))
|
||||
if i == 0 {
|
||||
bidPrices = append(bidPrices, ticker.Buy)
|
||||
askPrices = append(askPrices, ticker.Sell)
|
||||
} else if i == s.NumOfLiquidityLayers {
|
||||
|
||||
bidPrice := ticker.Buy
|
||||
askPrice := ticker.Sell
|
||||
|
||||
if i == s.NumOfLiquidityLayers {
|
||||
bwf := fixedpoint.NewFromFloat(bandWidth)
|
||||
bidPrices = append(bidPrices, midPrice.Add(-bwf))
|
||||
askPrices = append(askPrices, midPrice.Add(bwf))
|
||||
} else {
|
||||
bidPrice := midPrice.Sub(tickSize.Mul(fi))
|
||||
askPrice := midPrice.Add(tickSize.Mul(fi))
|
||||
bidPrices = append(bidPrices, bidPrice)
|
||||
askPrices = append(askPrices, askPrice)
|
||||
bidPrice = midPrice.Add(-bwf)
|
||||
askPrice = midPrice.Add(bwf)
|
||||
} else if i > 0 {
|
||||
bidPrice = midPrice.Sub(tickSize.Mul(fi))
|
||||
askPrice = midPrice.Add(tickSize.Mul(fi))
|
||||
}
|
||||
|
||||
bidPrice = s.Market.TruncatePrice(bidPrice)
|
||||
askPrice = s.Market.TruncatePrice(askPrice)
|
||||
|
||||
bidPrices = append(bidPrices, bidPrice)
|
||||
askPrices = append(askPrices, askPrice)
|
||||
}
|
||||
|
||||
availableBase := baseBal.Available
|
||||
|
|
Loading…
Reference in New Issue
Block a user