talib

package module
v0.0.0-...-cd53a92 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2019 License: MIT Imports: 2 Imported by: 182

README

go-talib

GoDoc

A pure Go port of TA-Lib

Install

Install the package with:

go get github.com/markcheno/go-talib

Import it with:

import "github.com/markcheno/go-talib"

and use talib as the package name inside the code.

Example

package main

import (
	"fmt"
	"github.com/markcheno/go-quote"
	"github.com/markcheno/go-talib"
)

func main() {
	spy, _ := quote.NewQuoteFromYahoo("spy", "2016-01-01", "2016-04-01", quote.Daily, true)
	fmt.Print(spy.CSV())
	rsi2 := talib.Rsi(spy.Close, 2)
	fmt.Println(rsi2)
}

License

MIT License - see LICENSE for more details

Contributors

Documentation

Overview

Package talib is a pure Go port of TA-Lib (http://ta-lib.org) Technical Analysis Library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Acos

func Acos(inReal []float64) []float64

Acos - Vector Trigonometric ACOS

func Ad(inHigh []float64, inLow []float64, inClose []float64, inVolume []float64) []float64

Ad - Chaikin A/D Line

func AdOsc

func AdOsc(inHigh []float64, inLow []float64, inClose []float64, inVolume []float64, inFastPeriod int, inSlowPeriod int) []float64

AdOsc - Chaikin A/D Oscillator

func Add

func Add(inReal0 []float64, inReal1 []float64) []float64

Add - Vector arithmetic addition

func Adx

func Adx(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

Adx - Average Directional Movement Index

func AdxR

func AdxR(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

AdxR - Average Directional Movement Index Rating

func Apo

func Apo(inReal []float64, inFastPeriod int, inSlowPeriod int, inMAType MaType) []float64

Apo - Absolute Price Oscillator

func Aroon

func Aroon(inHigh []float64, inLow []float64, inTimePeriod int) ([]float64, []float64)

Aroon - Aroon aroondown, aroonup = AROON(high, low, timeperiod=14)

func AroonOsc

func AroonOsc(inHigh []float64, inLow []float64, inTimePeriod int) []float64

AroonOsc - Aroon Oscillator

func Asin

func Asin(inReal []float64) []float64

Asin - Vector Trigonometric ASIN

func Atan

func Atan(inReal []float64) []float64

Atan - Vector Trigonometric ATAN

func Atr

func Atr(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

Atr - Average True Range

func AvgPrice

func AvgPrice(inOpen []float64, inHigh []float64, inLow []float64, inClose []float64) []float64

AvgPrice - Average Price (o+h+l+c)/4

func BBands

func BBands(inReal []float64, inTimePeriod int, inNbDevUp float64, inNbDevDn float64, inMAType MaType) ([]float64, []float64, []float64)

BBands - Bollinger Bands upperband, middleband, lowerband = BBands(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)

func Beta

func Beta(inReal0 []float64, inReal1 []float64, inTimePeriod int) []float64

Beta - Beta

func Bop

func Bop(inOpen []float64, inHigh []float64, inLow []float64, inClose []float64) []float64

Bop - Balance Of Power

func Cci

func Cci(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

Cci - Commodity Channel Index

func Ceil

func Ceil(inReal []float64) []float64

Ceil - Vector CEIL

func Cmo

func Cmo(inReal []float64, inTimePeriod int) []float64

Cmo - Chande Momentum Oscillator

func Correl

func Correl(inReal0 []float64, inReal1 []float64, inTimePeriod int) []float64

Correl - Pearson's Correlation Coefficient (r)

func Cos

func Cos(inReal []float64) []float64

Cos - Vector Trigonometric COS

func Cosh

func Cosh(inReal []float64) []float64

Cosh - Vector Trigonometric COSH

func Crossover

func Crossover(series1 []float64, series2 []float64) bool

Crossover returns true if series1 is crossing over series2.

NOTE: Usually this is used with Media Average Series to check if it crosses for buy signals.
      It assumes first values are the most recent.
      The crossover function does not use most recent value, since usually it's not a complete candle.
      The second recent values and the previous are used, instead.

func Crossunder

func Crossunder(series1 []float64, series2 []float64) bool

Crossunder returns true if series1 is crossing under series2.

NOTE: Usually this is used with Media Average Series to check if it crosses for sell signals.

func Dema

func Dema(inReal []float64, inTimePeriod int) []float64

Dema - Double Exponential Moving Average

func Div

func Div(inReal0 []float64, inReal1 []float64) []float64

Div - Vector arithmetic division

func Dx

func Dx(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

Dx - Directional Movement Index

func Ema

func Ema(inReal []float64, inTimePeriod int) []float64

Ema - Exponential Moving Average

func Exp

func Exp(inReal []float64) []float64

Exp - Vector atrithmetic EXP

func Floor

func Floor(inReal []float64) []float64

Floor - Vector FLOOR

func GroupCandles

func GroupCandles(highs []float64, opens []float64, closes []float64, lows []float64, groupingFactor int) ([]float64, []float64, []float64, []float64, error)

GroupCandles groups a set of candles in another set of candles, basing on a grouping factor.

This is pretty useful if you want to transform, for example, 15min candles into 1h candles using same data.

This avoid calling multiple times the exchange for multiple contexts.

Example:

To transform 15 minute candles in 30 minutes candles you have a grouping factor = 2

To transform 15 minute candles in 1 hour candles you have a grouping factor = 4

To transform 30 minute candles in 1 hour candles you have a grouping factor = 2

func HeikinashiCandles

func HeikinashiCandles(highs []float64, opens []float64, closes []float64, lows []float64) ([]float64, []float64, []float64, []float64)

HeikinashiCandles - from candle values extracts heikinashi candle values.

Returns highs, opens, closes and lows of the heikinashi candles (in this order).

NOTE: The number of Heikin-Ashi candles will always be one less than the number of provided candles, due to the fact
      that a previous candle is necessary to calculate the Heikin-Ashi candle, therefore the first provided candle is not considered
      as "current candle" in the algorithm, but only as "previous candle".

func Hlc3

func Hlc3(highs []float64, lows []float64, closes []float64) []float64

Hlc3 returns the Hlc3 values

NOTE: Every Hlc item is defined as follows : (high + low + close) / 3
      It is used as AvgPrice candle.

func HtDcPeriod

func HtDcPeriod(inReal []float64) []float64

HtDcPeriod - Hilbert Transform - Dominant Cycle Period (lookback=32)

func HtDcPhase

func HtDcPhase(inReal []float64) []float64

HtDcPhase - Hilbert Transform - Dominant Cycle Phase (lookback=63)

func HtPhasor

func HtPhasor(inReal []float64) ([]float64, []float64)

HtPhasor - Hibert Transform - Phasor Components (lookback=32)

func HtSine

func HtSine(inReal []float64) ([]float64, []float64)

HtSine - Hilbert Transform - SineWave (lookback=63)

func HtTrendMode

func HtTrendMode(inReal []float64) []float64

HtTrendMode - Hilbert Transform - Trend vs Cycle Mode (lookback=63)

func HtTrendline

func HtTrendline(inReal []float64) []float64

HtTrendline - Hilbert Transform - Instantaneous Trendline (lookback=63)

func Kama

func Kama(inReal []float64, inTimePeriod int) []float64

Kama - Kaufman Adaptive Moving Average

func LinearReg

func LinearReg(inReal []float64, inTimePeriod int) []float64

LinearReg - Linear Regression

func LinearRegAngle

func LinearRegAngle(inReal []float64, inTimePeriod int) []float64

LinearRegAngle - Linear Regression Angle

func LinearRegIntercept

func LinearRegIntercept(inReal []float64, inTimePeriod int) []float64

LinearRegIntercept - Linear Regression Intercept

func LinearRegSlope

func LinearRegSlope(inReal []float64, inTimePeriod int) []float64

LinearRegSlope - Linear Regression Slope

func Ln

func Ln(inReal []float64) []float64

Ln - Vector natural log LN

func Log10

func Log10(inReal []float64) []float64

Log10 - Vector LOG10

func Ma

func Ma(inReal []float64, inTimePeriod int, inMAType MaType) []float64

Ma - Moving average

func MaVp

func MaVp(inReal []float64, inPeriods []float64, inMinPeriod int, inMaxPeriod int, inMAType MaType) []float64

MaVp - Moving average with variable period

func Macd

func Macd(inReal []float64, inFastPeriod int, inSlowPeriod int, inSignalPeriod int) ([]float64, []float64, []float64)

Macd - Moving Average Convergence/Divergence unstable period ~= 100

func MacdExt

func MacdExt(inReal []float64, inFastPeriod int, inFastMAType MaType, inSlowPeriod int, inSlowMAType MaType, inSignalPeriod int, inSignalMAType MaType) ([]float64, []float64, []float64)

MacdExt - MACD with controllable MA type unstable period ~= 100

func MacdFix

func MacdFix(inReal []float64, inSignalPeriod int) ([]float64, []float64, []float64)

MacdFix - MACD Fix 12/26 unstable period ~= 100

func Mama

func Mama(inReal []float64, inFastLimit float64, inSlowLimit float64) ([]float64, []float64)

Mama - MESA Adaptive Moving Average (lookback=32)

func Max

func Max(inReal []float64, inTimePeriod int) []float64

Max - Highest value over a period

func MaxIndex

func MaxIndex(inReal []float64, inTimePeriod int) []float64

MaxIndex - Index of highest value over a specified period

func MedPrice

func MedPrice(inHigh []float64, inLow []float64) []float64

MedPrice - Median Price (h+l)/2

func Mfi

func Mfi(inHigh []float64, inLow []float64, inClose []float64, inVolume []float64, inTimePeriod int) []float64

Mfi - Money Flow Index

func MidPoint

func MidPoint(inReal []float64, inTimePeriod int) []float64

MidPoint - MidPoint over period

func MidPrice

func MidPrice(inHigh []float64, inLow []float64, inTimePeriod int) []float64

MidPrice - Midpoint Price over period

func Min

func Min(inReal []float64, inTimePeriod int) []float64

Min - Lowest value over a period

func MinIndex

func MinIndex(inReal []float64, inTimePeriod int) []float64

MinIndex - Index of lowest value over a specified period

func MinMax

func MinMax(inReal []float64, inTimePeriod int) ([]float64, []float64)

MinMax - Lowest and highest values over a specified period

func MinMaxIndex

func MinMaxIndex(inReal []float64, inTimePeriod int) ([]float64, []float64)

MinMaxIndex - Indexes of lowest and highest values over a specified period

func MinusDI

func MinusDI(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

MinusDI - Minus Directional Indicator

func MinusDM

func MinusDM(inHigh []float64, inLow []float64, inTimePeriod int) []float64

MinusDM - Minus Directional Movement

func Mom

func Mom(inReal []float64, inTimePeriod int) []float64

Mom - Momentum

func Mult

func Mult(inReal0 []float64, inReal1 []float64) []float64

Mult - Vector arithmetic multiply

func Natr

func Natr(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

Natr - Normalized Average True Range

func Obv

func Obv(inReal []float64, inVolume []float64) []float64

Obv - On Balance Volume

func PlusDI

func PlusDI(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

PlusDI - Plus Directional Indicator

func PlusDM

func PlusDM(inHigh []float64, inLow []float64, inTimePeriod int) []float64

PlusDM - Plus Directional Movement

func Ppo

func Ppo(inReal []float64, inFastPeriod int, inSlowPeriod int, inMAType MaType) []float64

Ppo - Percentage Price Oscillator

func Roc

func Roc(inReal []float64, inTimePeriod int) []float64

Roc - Rate of change : ((price/prevPrice)-1)*100

func Rocp

func Rocp(inReal []float64, inTimePeriod int) []float64

Rocp - Rate of change Percentage: (price-prevPrice)/prevPrice

func Rocr

func Rocr(inReal []float64, inTimePeriod int) []float64

Rocr - Rate of change ratio: (price/prevPrice)

func Rocr100

func Rocr100(inReal []float64, inTimePeriod int) []float64

Rocr100 - Rate of change ratio 100 scale: (price/prevPrice)*100

func Rsi

func Rsi(inReal []float64, inTimePeriod int) []float64

Rsi - Relative strength index

func Sar

func Sar(inHigh []float64, inLow []float64, inAcceleration float64, inMaximum float64) []float64

Sar - Parabolic SAR real = Sar(high, low, acceleration=0, maximum=0)

func SarExt

func SarExt(inHigh []float64, inLow []float64,
	inStartValue float64,
	inOffsetOnReverse float64,
	inAccelerationInitLong float64,
	inAccelerationLong float64,
	inAccelerationMaxLong float64,
	inAccelerationInitShort float64,
	inAccelerationShort float64,
	inAccelerationMaxShort float64) []float64

SarExt - Parabolic SAR - Extended real = SAREXT(high, low, startvalue=0, offsetonreverse=0, accelerationinitlong=0, accelerationlong=0, accelerationmaxlong=0, accelerationinitshort=0, accelerationshort=0, accelerationmaxshort=0)

func Sin

func Sin(inReal []float64) []float64

Sin - Vector Trigonometric SIN

func Sinh

func Sinh(inReal []float64) []float64

Sinh - Vector Trigonometric SINH

func Sma

func Sma(inReal []float64, inTimePeriod int) []float64

Sma - Simple Moving Average

func Sqrt

func Sqrt(inReal []float64) []float64

Sqrt - Vector SQRT

func StdDev

func StdDev(inReal []float64, inTimePeriod int, inNbDev float64) []float64

StdDev - Standard Deviation

func Stoch

func Stoch(inHigh []float64, inLow []float64, inClose []float64, inFastKPeriod int, inSlowKPeriod int, inSlowKMAType MaType, inSlowDPeriod int, inSlowDMAType MaType) ([]float64, []float64)

Stoch - Stochastic

func StochF

func StochF(inHigh []float64, inLow []float64, inClose []float64, inFastKPeriod int, inFastDPeriod int, inFastDMAType MaType) ([]float64, []float64)

StochF - Stochastic Fast

func StochRsi

func StochRsi(inReal []float64, inTimePeriod int, inFastKPeriod int, inFastDPeriod int, inFastDMAType MaType) ([]float64, []float64)

StochRsi - Stochastic Relative Strength Index

func Sub

func Sub(inReal0 []float64, inReal1 []float64) []float64

Sub - Vector arithmetic subtraction

func Sum

func Sum(inReal []float64, inTimePeriod int) []float64

Sum - Vector summation

func T3

func T3(inReal []float64, inTimePeriod int, inVFactor float64) []float64

T3 - Triple Exponential Moving Average (T3) (lookback=6*inTimePeriod)

func TRange

func TRange(inHigh []float64, inLow []float64, inClose []float64) []float64

TRange - True Range

func Tan

func Tan(inReal []float64) []float64

Tan - Vector Trigonometric TAN

func Tanh

func Tanh(inReal []float64) []float64

Tanh - Vector Trigonometric TANH

func Tema

func Tema(inReal []float64, inTimePeriod int) []float64

Tema - Triple Exponential Moving Average

func Trima

func Trima(inReal []float64, inTimePeriod int) []float64

Trima - Triangular Moving Average

func Trix

func Trix(inReal []float64, inTimePeriod int) []float64

Trix - 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA

func Tsf

func Tsf(inReal []float64, inTimePeriod int) []float64

Tsf - Time Series Forecast

func TypPrice

func TypPrice(inHigh []float64, inLow []float64, inClose []float64) []float64

TypPrice - Typical Price (h+l+c)/3

func UltOsc

func UltOsc(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod1 int, inTimePeriod2 int, inTimePeriod3 int) []float64

UltOsc - Ultimate Oscillator

func Var

func Var(inReal []float64, inTimePeriod int) []float64

Var - Variance

func WclPrice

func WclPrice(inHigh []float64, inLow []float64, inClose []float64) []float64

WclPrice - Weighted Close Price

func WillR

func WillR(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int) []float64

WillR - Williams' %R

func Wma

func Wma(inReal []float64, inTimePeriod int) []float64

Wma - Weighted Moving Average

Types

type MaType

type MaType int

MaType - Moving average type

const (
	SMA MaType = iota
	EMA
	WMA
	DEMA
	TEMA
	TRIMA
	KAMA
	MAMA
	T3MA
)

Kinds of moving averages

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL