// NewAdxrForStream creates an Average Directional Rating Index (Adxr) for online usage with a source data stream
11726
func NewAdxrForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int) (indicator *Adxr, err error) {
	ind, err := NewAdxr(timePeriod)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
1098477
func NewDefaultSarForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Sar, err error) {
	ind, err := NewDefaultSar()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
662336
func NewDefaultLinRegForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *LinReg, err error) {
	ind, err := NewDefaultLinReg()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
1115623
func NewAdxr(timePeriod int) (indicator *Adxr, err error) {
	ind := Adxr{}
	ind.AdxrWithoutStorage, err = NewAdxrWithoutStorage(timePeriod,
		func(dataItem float64, streamBarIndex int) {
			ind.Data = append(ind.Data, dataItem)
		})

	return &ind, err
}
1129789
func NewDxForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int) (indicator *Dx, err error) {
	ind, err := NewDx(timePeriod)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
894913
func NewDefaultVarForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Var, err error) {
	ind, err := NewDefaultVar()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
530413
func (s stream) NewDecoder(r io.Reader) *StreamDecoder {
	dec := NewDecoder(r)
	streamDec := &StreamDecoder{
		Decoder: dec,
		done:    make(chan struct{}, 1),
		mux:     sync.RWMutex{},
	}
	return streamDec
}
1084552
func NewAddrDialer(addrs []utils.NetAddr) DialContext {
	dialer := net.Dialer{
		Timeout:   defaults.DefaultDialTimeout,
		KeepAlive: defaults.ReverseTunnelAgentHeartbeatPeriod,
	}
	return func(in context.Context, network, _ string) (net.Conn, error) {
		var err error
		var conn net.Conn
		for _, addr := range addrs {
			conn, err = dialer.DialContext(in, network, addr.Addr)
			if err == nil {
				return conn, nil
			}
			log.Errorf("Failed to dial auth server %v: %v.", addr.Addr, err)
		}
		// not wrapping on purpose to preserve the original error
		return nil, err
	}
}
712846
func NewDefaultLinRegForStreamWithSrcLen(sourceLength uint, priceStream gotrade.DOHLCVStreamSubscriber) (indicator *LinReg, err error) {
	ind, err := NewDefaultLinRegWithSrcLen(sourceLength)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
1170040
func NewDefaultAtrForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Atr, err error) {
	ind, err := NewDefaultAtr()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
474419
func NewAdl() (indicator *Adl, err error) {
	ind := Adl{}
	ind.AdlWithoutStorage, err = NewAdlWithoutStorage(func(dataItem float64, streamBarIndex int) {
		ind.Data = append(ind.Data, dataItem)
	})

	return &ind, err
}
735369
func NewDefaultStochRsiForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *StochRsi, err error) {
	ind, err := NewDefaultStochRsi()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
148505
func NewDefaultTsfForStreamWithSrcLen(sourceLength uint, priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Tsf, err error) {
	ind, err := NewDefaultTsfWithSrcLen(sourceLength)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
335276
func NewWillRForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int) (indicator *WillR, err error) {
	ind, err := NewWillR(timePeriod)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
741864
func NewDefaultAdxWithSrcLen(sourceLength uint) (indicator *Adx, err error) {
	ind, err := NewDefaultAdx()

	// only initialise the storage if there is enough source data to require it
	if sourceLength-uint(ind.GetLookbackPeriod()) > 1 {
		ind.Data = make([]float64, 0, sourceLength-uint(ind.GetLookbackPeriod()))
	}

	return ind, err
}
286926
func NewDefaultPlusDiForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *PlusDi, err error) {
	ind, err := NewDefaultPlusDi()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
680558
func NewAtrForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int) (indicator *Atr, err error) {
	ind, err := NewAtr(timePeriod)
	priceStream.AddTickSubscription(ind)
	return ind, err
}