// NewTemaForStream creates a Tripple Exponential Moving Average Indicator (Tema) for online usage with a source data stream
424127
func NewTemaForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int, selectData gotrade.DOHLCVDataSelectionFunc) (indicator *Tema, err error) {
	ind, err := NewTema(timePeriod, selectData)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
713565
func NewEmaForStreamWithSrcLen(sourceLength uint, priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int, selectData gotrade.DOHLCVDataSelectionFunc) (indicator *Ema, err error) {
	ind, err := NewEmaWithSrcLen(sourceLength, timePeriod, selectData)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
304001
func NewSarForStreamWithSrcLen(sourceLength uint, priceStream gotrade.DOHLCVStreamSubscriber, accelerationFactor float64, accelerationFactorMax float64) (indicator *Sar, err error) {
	ind, err := NewSarWithSrcLen(sourceLength, accelerationFactor, accelerationFactorMax)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
20504
func NewTransactionFromJSON(data string) (*Transaction, error) {
	tx := &Transaction{
		tx: new(types.Transaction),
	}
	if err := json.Unmarshal([]byte(data), tx.tx); err != nil {
		return nil, err
	}
	return tx, nil
}
1337758
func NewDefaultDemaForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Dema, err error) {
	ind, err := NewDefaultDema()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
1016183
func NewAdxForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int) (indicator *Adx, err error) {
	ind, err := NewAdx(timePeriod)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
230458
func NewTransaction(txID string, txValidationCode pb.TxValidationCode, headerType cb.HeaderType) *TxInfo {
	return &TxInfo{
		TxID:             txID,
		TxValidationCode: txValidationCode,
		HeaderType:       headerType,
	}
}
513228
func NewStdDevForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int, selectData gotrade.DOHLCVDataSelectionFunc) (indicator *StdDev, err error) {
	ind, err := NewStdDev(timePeriod, selectData)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
260374
func NewDefaultTrimaForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Trima, err error) {
	ind, err := NewDefaultTrima()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
940690
func NewTransport(provider StreamProvider) libchan.Transport {
	session := &Transport{
		provider:         provider,
		referenceCounter: 1,
		receiverChan:     make(chan *receiver),
		streamC:          sync.NewCond(new(sync.Mutex)),
		streams:          make(map[uint64]*stream),
	}

	go session.handleStreams()

	return session
}
1188202
func Tema(inReal []float64, inTimePeriod int) []float64 {

	outReal := make([]float64, len(inReal))
	firstEMA := Ema(inReal, inTimePeriod)
	secondEMA := Ema(firstEMA[inTimePeriod-1:], inTimePeriod)
	thirdEMA := Ema(secondEMA[inTimePeriod-1:], inTimePeriod)

	outIdx := (inTimePeriod * 3) - 3
	secondEMAIdx := (inTimePeriod * 2) - 2
	thirdEMAIdx := inTimePeriod - 1

	for outIdx < len(inReal) {
		outReal[outIdx] = thirdEMA[thirdEMAIdx] + ((3.0 * firstEMA[outIdx]) - (3.0 * secondEMA[secondEMAIdx]))
		outIdx++
		secondEMAIdx++
		thirdEMAIdx++
	}

	return outReal
}
489068
func NewTempFactory(path string) TempFactory {
	if path == "" {
		path = DefaultTempPath()
	}
	return TempFactory{path: path}
}
456579
func NewTransport(t http.RoundTripper) http.RoundTripper {
	return NewTransportWith(stats.DefaultEngine, t)
}
386707
func NewDefaultTemaForStreamWithSrcLen(sourceLength uint, priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Tema, err error) {
	ind, err := NewDefaultTemaWithSrcLen(sourceLength)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
371818
func NewTarExporter(is image.Store, ls layer.Store, rs reference.Store) hyperimage.Exporter {
	return &tarexporter{
		is: is,
		ls: ls,
		rs: rs,
	}
}
570027
func NewDefaultSmaForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Sma, err error) {
	ind, err := NewDefaultSma()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
615017
func NewTextFormatter(name string) *TextFormatter {
	timeLabel := KeyMap.Time + AssignmentChar
	levelLabel := Separator + KeyMap.Level + AssignmentChar
	messageLabel := Separator + KeyMap.Message + AssignmentChar
	nameLabel := Separator + KeyMap.Name + AssignmentChar
	pidLabel := Separator + KeyMap.PID + AssignmentChar

	var buildKV = func(level string) string {
		buf := pool.Get()
		defer pool.Put(buf)

		buf.WriteString(pidLabel)
		buf.WriteString(pidStr)

		//buf.WriteString(Separator)
		buf.WriteString(nameLabel)
		buf.WriteString(name)

		//buf.WriteString(Separator)
		buf.WriteString(levelLabel)
		buf.WriteString(level)

		//buf.WriteString(Separator)
		buf.WriteString(messageLabel)

		return buf.String()
	}
	itoaLevelMap := map[int]string{
		LevelDebug: buildKV(LevelMap[LevelDebug]),
		LevelWarn:  buildKV(LevelMap[LevelWarn]),
		LevelInfo:  buildKV(LevelMap[LevelInfo]),
		LevelError: buildKV(LevelMap[LevelError]),
		LevelFatal: buildKV(LevelMap[LevelFatal]),
	}
	return &TextFormatter{itoaLevelMap: itoaLevelMap, name: name, timeLabel: timeLabel}
}