mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
fix common.Strategy.IsHalted
This commit is contained in:
parent
4b9c933df1
commit
c5cd6bc95e
|
@ -2,20 +2,9 @@
|
||||||
exchangeStrategies:
|
exchangeStrategies:
|
||||||
- on: max
|
- on: max
|
||||||
fixedmaker:
|
fixedmaker:
|
||||||
interval: 5m
|
|
||||||
symbol: BTCUSDT
|
symbol: BTCUSDT
|
||||||
halfSpreadRatio: 0.05%
|
interval: 5m
|
||||||
|
halfSpread: 0.05%
|
||||||
quantity: 0.005
|
quantity: 0.005
|
||||||
dryRun: false
|
orderType: LIMIT_MAKER
|
||||||
|
dryRun: true
|
||||||
- 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
|
|
||||||
|
|
|
@ -90,5 +90,8 @@ func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, se
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strategy) IsHalted(t time.Time) bool {
|
func (s *Strategy) IsHalted(t time.Time) bool {
|
||||||
|
if s.circuitBreakRiskControl == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return s.circuitBreakRiskControl.IsHalted(t)
|
return s.circuitBreakRiskControl.IsHalted(t)
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,8 @@ func (s *Strategy) generateSubmitOrders(ctx context.Context) ([]types.SubmitOrde
|
||||||
log.Infof("mid price: %+v", midPrice)
|
log.Infof("mid price: %+v", midPrice)
|
||||||
|
|
||||||
// calculate bid and ask price
|
// calculate bid and ask price
|
||||||
// ask price = mid price * (1 + r))
|
// sell price = mid price * (1 + r))
|
||||||
// bid 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)
|
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)
|
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())
|
log.Infof("sell price: %s, buy price: %s", sellPrice.String(), buyPrice.String())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user