fix common.Strategy.IsHalted

This commit is contained in:
narumi 2023-09-29 01:12:53 +08:00
parent 4b9c933df1
commit c5cd6bc95e
3 changed files with 9 additions and 17 deletions

View File

@ -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
dryRun: false
orderType: LIMIT_MAKER
dryRun: true

View File

@ -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)
}

View File

@ -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())