mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
strategy/linregmaker: fix faster decrease logic
This commit is contained in:
parent
2ecdae6530
commit
2b8a5fe755
|
@ -374,14 +374,12 @@ func (s *Strategy) getOrderQuantities(askPrice fixedpoint.Value, bidPrice fixedp
|
|||
log.Infof("%s caculated buy qty %v, sell qty %v", s.Symbol, buyQuantity, sellQuantity)
|
||||
|
||||
// Faster position decrease
|
||||
if s.isAllowOppositePosition() {
|
||||
if s.mainTrendCurrent == types.DirectionUp {
|
||||
sellQuantity = sellQuantity.Mul(s.FasterDecreaseRatio)
|
||||
} else if s.mainTrendCurrent == types.DirectionDown {
|
||||
buyQuantity = buyQuantity.Mul(s.FasterDecreaseRatio)
|
||||
}
|
||||
log.Infof("%s faster position decrease: buy qty %v, sell qty %v", s.Symbol, buyQuantity, sellQuantity)
|
||||
if s.mainTrendCurrent == types.DirectionUp && s.SlowLinReg.Last() < 0 {
|
||||
sellQuantity = sellQuantity.Mul(s.FasterDecreaseRatio)
|
||||
} else if s.mainTrendCurrent == types.DirectionDown && s.SlowLinReg.Last() > 0 {
|
||||
buyQuantity = buyQuantity.Mul(s.FasterDecreaseRatio)
|
||||
}
|
||||
log.Infof("%s faster position decrease: buy qty %v, sell qty %v", s.Symbol, buyQuantity, sellQuantity)
|
||||
|
||||
// Reduce order qty to fit current position
|
||||
if !s.isAllowOppositePosition() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user