ta

package
v0.0.0-...-85ff41b Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

README

TA

Technical analysis include kline pattern and indicators.

Technical Analysis 技术分析
Indicator Full Name Status
EMV Ease of Movement Value OK
KDJ K, D and J OK
SKDJ Slow Stochastic Oscillator OK
DMI Directional Movement Index OK
SOBV Standard On Balance Volume OK
VPT Volume Price Trend OK
OSC Oscillator OK
BOLL / BBANDS Bollinger Bands TODO
DEMA Double Exponential Moving Average TODO
EMA Exponential Moving Average TODO
HT_TRENDLINE Hilbert Transform - Instantaneous Trendline TODO
KAMA Kaufman Adaptive Moving Average TODO
MA Moving average TODO
MAMA MESA Adaptive Moving Average TODO
MAVP Moving average with variable period TODO
MIDPOINT MidPoint over period TODO
MIDPRICE Midpoint Price over period TODO
SAR Parabolic SAR TODO
SAREXT Parabolic SAR - Extended TODO
SMA Simple Moving Average TODO
T3 Triple Exponential Moving Average (T3) TODO
TEMA Triple Exponential Moving Average TODO
TRIMA Triangular Moving Average TODO
WMA Weighted Moving Average TODO
ADX Average Directional Movement Index TODO
ADXR Average Directional Movement Index Rating TODO
APO Absolute Price Oscillator TODO
AROON Aroon TODO
AROONOSC Aroon Oscillator TODO
BOP Balance Of Power TODO
CCI Commodity Channel Index TODO
CMO Chande Momentum Oscillator TODO
DX Directional Movement Index TODO
MACD Moving Average Convergence/Divergence TODO
MACDEXT MACD with controllable MA type TODO
MACDFIX Moving Average Convergence/Divergence Fix 12/26 TODO
MFI Money Flow Index TODO
MINUS_DI Minus Directional Indicator TODO
MINUS_DM Minus Directional Movement TODO
MOM Momentum TODO
PLUS_DI Plus Directional Indicator TODO
PLUS_DM Plus Directional Movement TODO
PPO Percentage Price Oscillator TODO
ROC Rate of change TODO
ROCP Rate of change Percentage TODO
ROCR Rate of change ratio TODO
ROCR100 Rate of change ratio 100 scale TODO
RSI Relative Strength Index TODO
STOCH Stochastic TODO
STOCHF Stochastic Fast TODO
STOCHRSI Stochastic Relative Strength Index TODO
TRIX Triple Exponentially Smoothed Average TODO
ULTOSC Ultimate Oscillator TODO
WR / WILLR Williams' %R TODO
AD Chaikin A/D Line TODO
ADOSC Chaikin A/D Oscillator TODO
OBV On Balance Volume TODO
HT_DCPERIOD Hilbert Transform - Dominant Cycle Period TODO
HT_DCPHASE Hilbert Transform - Dominant Cycle Phase TODO
HT_PHASOR Hilbert Transform - Phasor Components TODO
HT_SINE Hilbert Transform - SineWave TODO
HT_TRENDMODE Hilbert Transform - Trend vs Cycle Mode TODO
ATR Average True Range TODO
NATR Normalized Average True Range TODO
TR / TRANGE True Range TODO

Documentation

Index

Constants

View Source
const (
	IndSeriesUnknown = ""
	IndSeriesPrice   = "price"
	IndSeriesVolume  = "volume"
	IndSeriesUnique  = "unique"

	IndStyleUnknown = ""
	IndStyleLine    = "line"
	IndStyleBar     = "bar"
)

Variables

View Source
var (
	AllIndicators []Indicator

	IndicatorError = registerIndicator("", "")

	// price indicator
	IndicatorMA         = registerIndicator("MA", "C(T)[PL]") // MA is SMA in fact
	IndicatorEMA        = registerIndicator("EMA", "C(T)[PL]")
	IndicatorMACD       = registerIndicator("MACD", "C(TTT)[UL]{Hist:B}") // Hist成员是特殊情况,是Bar,其余都是L(Line)
	IndicatorKDJ        = registerIndicator("KDJ", "LHC(TPP)[UL]")        // mask可能不严谨
	IndicatorSKDJ       = registerIndicator("SKDJ", "LHC(TP)[UL]")
	IndicatorBOLL       = registerIndicator("BOLL", "C(TP)[PL]")
	IndicatorDUALTHRUST = registerIndicator("DUALTHRUST", "OHLC(TPP)[PL]")
	IndicatorATR        = registerIndicator("ATR", "HLC(T)[UL]")
	IndicatorATRK       = registerIndicator("ATRK", "HLC(TP)[UL]")
	IndicatorDC         = registerIndicator("DC", "LH(T)[PL]")

	// volume price indicator
	IndicatorAD    = registerIndicator("AD", "HLCV()[UL]") // Chaikin A/D Line
	IndicatorADOSC = registerIndicator("ADOSC", "HLCV(TT)[UL]")
	IndicatorEMV   = registerIndicator("EMV", "HLV(T)[UL]")
	IndicatorMFI   = registerIndicator("MFI", "HLCV(T)[UL]") // 1in 1out
	IndicatorOBV   = registerIndicator("OBV", "CV()[UL]")    // OBV使用的是Close价。很多工具中的OBV有1个参数,这个参数其实就是对OBV做的MA需要的参数
	IndicatorVPT   = registerIndicator("VPT", "CV()[UL]")

	IndicatorVAR      = registerIndicator("VAR", "C(T)[UL]")
	IndicatorSTOCKRSI = registerIndicator("StockRSI", "C(TTT)[UL]") // 最后一个参数是给MA的,出2条线
	IndicatorRSI      = registerIndicator("RSI", "C(TTT)[UL]")      // 3个参数出3条线,一起用才行
	IndicatorSAR      = registerIndicator("SAR", "HL(PP)[UL]")
	IndicatorTRIX     = registerIndicator("TRIX", "C(T)[UL]") // 2个参数,1个给TRIX,1个给MA,出2条线(TRIX, TRIX+MA)
	IndicatorWR       = registerIndicator("WR", "HLC(T)[UL]") // 用2个参数画出2条线,一起用
	IndicatorROC      = registerIndicator("ROC", "C(T)[UL]")
	IndicatorDMI      = registerIndicator("DMI", "HLC(T)[UL]") // DMI指标包含4条线:PDI、MDI、ADX和ADXR

	IndicatorZIGZAG = registerIndicator("ZIGZAG", "OC(PP)[PZ]")
	IndicatorK      = registerIndicator("Id", "(P)[]")
)

Functions

func ADR

func ADR()

https://www.zhihu.com/question/56068713/answer/903382369 Average Daily Range (ADR)

func ATRK

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

func BOLL

func BOLL(inClose []float64, inN, inK int) (basis []float64, upper []float64, lower []float64, err error)

func DC

func DC(inLow, inHigh []float64, nPeriod int) (outLow, outHigh []float64)

TODO test required Donchian Channel

func DMI

func DMI(inHigh, inLow, inClose []float64, inTimePeriod int) (PDI, MDI, ADX, ADXR []float64)

DMI指标包含4条线:PDI、MDI、ADX和ADXR

func DualThrust

func DualThrust(inOpen, inHigh, inLow, inClose []float64, n int, k1, k2 float64) (buyLine, sellLine []float64)

N日High的最高价HH N日Close的最低价LC N日Close的最高价HC N日Low的最低价LL Range = Max(HH-LC,HC-LL) BuyLine = O + K1×Range SellLine = O + K2×Range

func EMA

func EMA(inReal []float64, inTimePeriod int) ([]float64, error)

func EMV

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

func HHV

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

Highest value over a period

func KDJ

func KDJ(inLow, inHigh, inClose []float64, inN1, inN2, inN3 int) (k, d, j []float64, err error)

func LLV

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

Lowest value over a period

func MAOCV

func MAOCV(inOpen, inClose, inVolume []float64, inTimePeriod int) []float64

把成交量的影响加权方式算进去

func OSC

func OSC(inOpen, inLow, inHigh, inClose []float64) ([]float64, error)

func SMA

func SMA(inReal []float64, inTimePeriod int) ([]float64, error)

func SOBV

func SOBV(inOpen, inClose, inVolume []float64) []float64

SOBV - On Balance V

func ZIGZAG

func ZIGZAG(inOpen, inClose []float64, minTrendLen int, minShockScale float64) []float64

获取所有转折点的价格,非转折点填0

func ZigZagLastForm

func ZigZagLastForm(inOpen, inClose []float64, minTrendLen int, minShockScale float64) string

从尾巴上识别zigzag形态 return M_TOP / W_BOTTOM / UNKNOWN

func ZigZagPoints

func ZigZagPoints(inOpen, inClose []float64, minTrendLen int, minShockScale float64) []float64

FIXME: error implement 获取所有转折点,非转折点填0,-1表示下拐,1表示上扬 minTrendLen = 2, minShockScale = 0.03: 至少2根线,且累计震幅达到最小要求3%,才能算形成趋势,否则只能算趋势上的震荡 return dots: -1 down knee point, 0 in the trend of last dot, 1 up knee point

Types

type IndExpr

type IndExpr string

dataSource.Indicator(params...).NextIndicator(params...) EMA(10).MA(30) MFI(default,5).EMA(30) OBV(default).MA(30)

func (IndExpr) MaxTimePeriod

func (ie IndExpr) MaxTimePeriod() *int

if returns nil, means time period is infinite or not sure

func (IndExpr) Parse

func (ie IndExpr) Parse() (indicator Indicator, params []gdecimal.Decimal, err error)

EMA(10) -> EMA, 10 MACD(6, 30, 3) -> MACD, [6, 30, 3]

func (IndExpr) String

func (ie IndExpr) String() string

type IndSeries

type IndSeries string

type IndStyle

type IndStyle string

func ValExprStyle

func ValExprStyle(ve string) (IndStyle, error)

MACD(12,9,3.5).Hist => Bar

type Indicator

type Indicator struct {
	// contains filtered or unexported fields
}

func ParseIndicator

func ParseIndicator(s string) Indicator

func (*Indicator) Name

func (i *Indicator) Name() string

func (*Indicator) ParamCount

func (i *Indicator) ParamCount() int

func (*Indicator) Series

func (i *Indicator) Series() IndSeries

func (*Indicator) TimePeriodParamIndex

func (i *Indicator) TimePeriodParamIndex() []int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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