Skip to content

Commit

Permalink
scmaker: fix the layer price
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jun 15, 2023
1 parent 472a9fd commit a7b2051
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config/scmaker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sessions:
exchangeStrategies:
- on: max
scmaker:
symbol: USDCUSDT
symbol: &symbol USDCUSDT

## adjustmentUpdateInterval is the interval for adjusting position
adjustmentUpdateInterval: 1m
Expand Down Expand Up @@ -45,7 +45,7 @@ backtest:
startTime: "2023-05-20"
endTime: "2023-06-01"
symbols:
- USDCUSDT
- *symbol
account:
max:
makerFeeRate: 0.0%
Expand Down
14 changes: 7 additions & 7 deletions pkg/strategy/scmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ func (s *Strategy) placeLiquidityOrders(ctx context.Context) {
// calculate and collect prices
for i := 0; i <= s.NumOfLiquidityLayers; i++ {
fi := fixedpoint.NewFromInt(int64(i))
sp := tickSize.Mul(fi)

bidPrice := ticker.Buy
askPrice := ticker.Sell
Expand All @@ -289,17 +290,16 @@ func (s *Strategy) placeLiquidityOrders(ctx context.Context) {
bidPrice = midPrice.Add(bwf.Neg())
askPrice = midPrice.Add(bwf)
} else if i > 0 {
sp := tickSize.Mul(fi)
bidPrice = midPrice.Sub(sp)
askPrice = midPrice.Add(sp)
}

if bidPrice.Compare(ticker.Buy) < 0 {
bidPrice = ticker.Buy.Sub(sp)
}
if i > 0 && bidPrice.Compare(ticker.Buy) < 0 {
bidPrice = ticker.Buy.Sub(sp)
}

if askPrice.Compare(ticker.Sell) > 0 {
askPrice = ticker.Sell.Add(sp)
}
if i > 0 && askPrice.Compare(ticker.Sell) > 0 {
askPrice = ticker.Sell.Add(sp)
}

bidPrice = s.Market.TruncatePrice(bidPrice)
Expand Down

0 comments on commit a7b2051

Please sign in to comment.