mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
bbgo: update VWMA and add VWMA to the indicator method
This commit is contained in:
parent
469c6bfb28
commit
09cc91bab8
|
@ -74,6 +74,13 @@ func (s *StandardIndicatorSet) EWMA(iw types.IntervalWindow) *indicator.EWMA {
|
||||||
return inc.(*indicator.EWMA)
|
return inc.(*indicator.EWMA)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VWMA
|
||||||
|
func (s *StandardIndicatorSet) VWMA(iw types.IntervalWindow) *indicator.VWMA {
|
||||||
|
inc := s.allocateSimpleIndicator(&indicator.VWMA{IntervalWindow: iw}, iw)
|
||||||
|
return inc.(*indicator.VWMA)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s *StandardIndicatorSet) PivotLow(iw types.IntervalWindow) *indicator.PivotLow {
|
func (s *StandardIndicatorSet) PivotLow(iw types.IntervalWindow) *indicator.PivotLow {
|
||||||
inc := s.allocateSimpleIndicator(&indicator.PivotLow{IntervalWindow: iw}, iw)
|
inc := s.allocateSimpleIndicator(&indicator.PivotLow{IntervalWindow: iw}, iw)
|
||||||
return inc.(*indicator.PivotLow)
|
return inc.(*indicator.PivotLow)
|
||||||
|
|
|
@ -70,6 +70,15 @@ func (inc *VWMA) Update(price, volume float64) {
|
||||||
inc.Values.Push(vwma)
|
inc.Values.Push(vwma)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (inc *VWMA) PushK(k types.KLine) {
|
||||||
|
if inc.EndTime != zeroTime && k.EndTime.Before(inc.EndTime) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
inc.Update(k.Close.Float64(), k.Volume.Float64())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func (inc *VWMA) CalculateAndUpdate(allKLines []types.KLine) {
|
func (inc *VWMA) CalculateAndUpdate(allKLines []types.KLine) {
|
||||||
if len(allKLines) < inc.Window {
|
if len(allKLines) < inc.Window {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user