missed a couple series validations
This commit is contained in:
parent
046daf94fb
commit
68cc6a95d3
1 changed files with 47 additions and 8 deletions
|
@ -27,6 +27,24 @@ type MACDSeries struct {
|
||||||
macdl *MACDLineSeries
|
macdl *MACDLineSeries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate validates the series.
|
||||||
|
func (macd MACDSeries) Validate() error {
|
||||||
|
var err error
|
||||||
|
if macd.signal != nil {
|
||||||
|
err = macd.signal.Validate()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if macd.macdl != nil {
|
||||||
|
err = macd.macdl.Validate()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetPeriods returns the primary and secondary periods.
|
// GetPeriods returns the primary and secondary periods.
|
||||||
func (macd MACDSeries) GetPeriods() (w1, w2, sig int) {
|
func (macd MACDSeries) GetPeriods() (w1, w2, sig int) {
|
||||||
if macd.PrimaryPeriod == 0 {
|
if macd.PrimaryPeriod == 0 {
|
||||||
|
@ -121,6 +139,14 @@ type MACDSignalSeries struct {
|
||||||
signal *EMASeries
|
signal *EMASeries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate validates the series.
|
||||||
|
func (macds MACDSignalSeries) Validate() error {
|
||||||
|
if macds.signal != nil {
|
||||||
|
return macds.signal.Validate()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetPeriods returns the primary and secondary periods.
|
// GetPeriods returns the primary and secondary periods.
|
||||||
func (macds MACDSignalSeries) GetPeriods() (w1, w2, sig int) {
|
func (macds MACDSignalSeries) GetPeriods() (w1, w2, sig int) {
|
||||||
if macds.PrimaryPeriod == 0 {
|
if macds.PrimaryPeriod == 0 {
|
||||||
|
@ -214,6 +240,27 @@ type MACDLineSeries struct {
|
||||||
Sigma float64
|
Sigma float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate validates the series.
|
||||||
|
func (macdl MACDLineSeries) Validate() error {
|
||||||
|
var err error
|
||||||
|
if macdl.ema1 != nil {
|
||||||
|
err = macdl.ema1.Validate()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if macdl.ema2 != nil {
|
||||||
|
err = macdl.ema2.Validate()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if macdl.InnerSeries == nil {
|
||||||
|
return fmt.Errorf("MACDLineSeries: must provide an inner series")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetName returns the name of the time series.
|
// GetName returns the name of the time series.
|
||||||
func (macdl MACDLineSeries) GetName() string {
|
func (macdl MACDLineSeries) GetName() string {
|
||||||
return macdl.Name
|
return macdl.Name
|
||||||
|
@ -289,11 +336,3 @@ func (macdl *MACDLineSeries) Render(r Renderer, canvasBox Box, xrange, yrange Ra
|
||||||
style := macdl.Style.InheritFrom(defaults)
|
style := macdl.Style.InheritFrom(defaults)
|
||||||
Draw.LineSeries(r, canvasBox, xrange, yrange, style, macdl)
|
Draw.LineSeries(r, canvasBox, xrange, yrange, style, macdl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates the series.
|
|
||||||
func (macdl *MACDLineSeries) Validate() error {
|
|
||||||
if macdl.InnerSeries == nil {
|
|
||||||
return fmt.Errorf("macd line series requires InnerSeries to be set")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue