mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
pivotshort: rename pivotBuffer to pivotLowPrices
This commit is contained in:
parent
32f324761e
commit
74ee92832b
|
@ -66,8 +66,8 @@ type Strategy struct {
|
||||||
|
|
||||||
session *bbgo.ExchangeSession
|
session *bbgo.ExchangeSession
|
||||||
|
|
||||||
pivot *indicator.Pivot
|
pivot *indicator.Pivot
|
||||||
pivotBuffer []fixedpoint.Value
|
pivotLowPrices []fixedpoint.Value
|
||||||
|
|
||||||
// StrategyController
|
// StrategyController
|
||||||
bbgo.StrategyController
|
bbgo.StrategyController
|
||||||
|
@ -187,9 +187,9 @@ func canClosePosition(position *types.Position, signal fixedpoint.Value, price f
|
||||||
|
|
||||||
// get last available pivot low, the most recent pivot point higher than current price
|
// get last available pivot low, the most recent pivot point higher than current price
|
||||||
func (s *Strategy) getValidPivotLow(price fixedpoint.Value) fixedpoint.Value {
|
func (s *Strategy) getValidPivotLow(price fixedpoint.Value) fixedpoint.Value {
|
||||||
for l := len(s.pivotBuffer) - 1; l > 0; l-- {
|
for l := len(s.pivotLowPrices) - 1; l > 0; l-- {
|
||||||
if s.pivotBuffer[l].Compare(price) > 0 {
|
if s.pivotLowPrices[l].Compare(price) > 0 {
|
||||||
return s.pivotBuffer[l]
|
return s.pivotLowPrices[l]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return price
|
return price
|
||||||
|
@ -341,7 +341,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
|
|
||||||
if !s.LastLow.IsZero() {
|
if !s.LastLow.IsZero() {
|
||||||
|
|
||||||
s.pivotBuffer = append(s.pivotBuffer, s.LastLow)
|
s.pivotLowPrices = append(s.pivotLowPrices, s.LastLow)
|
||||||
|
|
||||||
if err := s.activeMakerOrders.GracefulCancel(ctx, s.session.Exchange); err != nil {
|
if err := s.activeMakerOrders.GracefulCancel(ctx, s.session.Exchange); err != nil {
|
||||||
log.WithError(err).Errorf("graceful cancel order error")
|
log.WithError(err).Errorf("graceful cancel order error")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user