Skip to content

Commit

Permalink
fix common.Strategy.IsHalted
Browse files Browse the repository at this point in the history
  • Loading branch information
narumiruna committed Sep 28, 2023
1 parent 4b9c933 commit e34480a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
17 changes: 3 additions & 14 deletions config/fixedmaker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@
exchangeStrategies:
- on: max
fixedmaker:
interval: 5m
symbol: BTCUSDT
halfSpreadRatio: 0.05%
interval: 5m
halfSpread: 0.05%
quantity: 0.005
dryRun: false

- on: max
rebalance:
interval: 1h
quoteCurrency: USDT
targetWeights:
BTC: 50%
USDT: 50%
threshold: 2%
maxAmount: 200 # max amount to buy or sell per order
orderType: LIMIT_MAKER # LIMIT, LIMIT_MAKER or MARKET
orderType: LIMIT_MAKER
dryRun: false
3 changes: 3 additions & 0 deletions pkg/strategy/common/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,8 @@ func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, se
}

func (s *Strategy) IsHalted(t time.Time) bool {
if s.circuitBreakRiskControl == nil {
return false
}
return s.circuitBreakRiskControl.IsHalted(t)
}
4 changes: 2 additions & 2 deletions pkg/strategy/fixedmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ func (s *Strategy) generateSubmitOrders(ctx context.Context) ([]types.SubmitOrde
log.Infof("mid price: %+v", midPrice)

// calculate bid and ask price
// ask price = mid price * (1 + r))
// bid price = mid price * (1 - r))
// sell price = mid price * (1 + r))
// buy price = mid price * (1 - r))
sellPrice := midPrice.Mul(fixedpoint.One.Add(s.HalfSpread)).Round(s.Market.PricePrecision, fixedpoint.Up)
buyPrice := midPrice.Mul(fixedpoint.One.Sub(s.HalfSpread)).Round(s.Market.PricePrecision, fixedpoint.Down)
log.Infof("sell price: %s, buy price: %s", sellPrice.String(), buyPrice.String())
Expand Down

0 comments on commit e34480a

Please sign in to comment.