Skip to content

Repository files navigation

Tango - (Trading Analysis & Go)

Go Reference Build Status Go Report Card

Features

Installation

go get github.com/jellydator/tango

Usage

All of the tools must be created using New* function. It performs parameters validation and returns an object that is capable of working with data slices.

The main calculations are done using Calc method. The return types varies based on the tool.

A simple use case could look like this:

func main() {
  sma, err := tango.NewSMA(3)
  if err != nil {
    // handle the error.
  }

  dataPoints := []decimal.Decimal{
    decimal.NewFromInt(2),
    decimal.NewFromInt(3),
    decimal.NewFromInt(4),
  }

  // the value is 3
  value, err := sma.Calc(dataPoints)
  if err != nil {
    // handle the error.
  }
}

For the calculation to be successful, the Calc method should receive only the information that it requires. In some scenarios, it might not be known how many data points is needed, for this, a Count method may be used.

func CalculateMA(ma tango.MA, values []decimal.Decimal) (decimal.Decimal, error) {
  requiredValues := ma.Count()

  if len(values) < requiredValues {
    return decimal.Zero, errors.New("invalid count of values")
  }

  return ma.Calc(values[:requiredValues])
}

Indicators that work with full candles instead of a single data points slice accept a []Candle (or a single Candle) ordered from the oldest to the newest.

Oscillators

Overlays

Volatility

Trend

Volume

Pivot Points

The PivotPoints indicator calculates the pivot point along with three resistance and three support levels from the candle of the preceding period. Supported calculation variants: classic, fibonacci and camarilla.

Candlestick Patterns

The CandlestickPattern type evaluates whether a series of candles matches a given pattern. Single candle patterns: hammer, hanging-man, inverted-hammer, shooting-star, long-legged-doji, dragonfly-doji, gravestone-doji, bullish-marubozu, bearish-marubozu and spinning-top. Double candle patterns: bullish-engulfing, bearish-engulfing, bullish-harami, bearish-harami, piercing-line, dark-cloud-cover, tweezer-top and tweezer-bottom. Triple candle patterns: morning-star, evening-star, three-white-soldiers and three-black-crows.

About

A lightweight technical analysis package

Topics

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages