GithubHelp home page GithubHelp logo

go-tart's Introduction

go-tart (go-TA RealTime)

Build Status Go Report Card License: MIT Go Reference

Intro

go-talib project provides a nice port of the C-implementation TA-Lib. However, its code is very verbose and hard to read due to the straight translation from the "C" code of TA-Lib. More often, streaming incremental updates to indicators is desirable. We don't want to recalculate the full result if the sliding window only moves forward a single value while history values are not changed at all. Recalculation of the history for every new value is expensive. With those in mind, go-tart intends to support streaming updates of new values with a concise implementation. Most of the indicators from go-talib are realized except a few trivial ones and those involves Hilbert Transform. Results are verified using TA-Lib's output. MACD's "stability" issue from go-talib is fixed.

Performance

A benchmark is written to compare the performance for the set of indicators from both go-talib and go-talib. This is not a scientific evaluation but gives a sense of how they perform in case of a full recalculation. As shown below, go-tart is about 3X slower in full recalculation, which is due to function call to Update in each iteration. go-talib holds advantage because its code is inlined.

gotest -run ^$ -bench=.
BenchmarkTart-4             2019            496703 ns/op
BenchmarkTalib-4            7944            150311 ns/op

After the initial full calculation, go-tart should perform better as it only needs a single iteration cost to compute a new update.

Install

Install the package with:

go get github.com/iamjinlei/go-tart

Import it with:

import "github.com/iamjinlei/go-tart"

and use tart as the package name

Exmaple

package main

import (
	"fmt"

	"github.com/iamjinlei/go-tart"
)

func main() {
	sma := tart.NewSma(5)
	for i := 0; i < 20; i++ {
		fmt.Printf("sma[%v] = %.4f\n", i, sma.Update(float64(i%7)))
	}
}

go-tart's People

Contributors

iamjinlei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.