go-tachart

module
v0.0.0-...-12052a3 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT

README

go-tachart

This is a fork and extension to the beautiful go-echarts project. Some of the go-echarts code is modified to tailor to the needs of TA charts. To keep iteration simple, go-echarts code is replicated in this repo. This is still a work-in-progress. More TA chart and event types will be added to support a wide-range of use cases.

How It Looks Like

Candlestick chart with moving average overlay on top

Screen Shot 2021-06-08 at 12 05 22 PM

Candlestick chart with moving average overlay on top + additional indicators

Screen Shot 2021-06-08 at 12 04 45 PM

Usage

In this example, a simple chart is created with a few lines of code. A complete code example can be found in the example folder.

package main

import (
	"github.com/iamjinlei/go-tachart/tachart"
)

func main() {
	cdls := []tachart.Candle{
		{Label: "2018/1/24", O: 2320.26, C: 2320.26, L: 2287.3, H: 2362.94, V: 149092},
		{Label: "2018/1/25", O: 2300, C: 2291.3, L: 2288.26, H: 2308.38, V: 189092},
		{Label: "2018/1/28", O: 2295.35, C: 2346.5, L: 2295.35, H: 2346.92, V: 159034},
		{Label: "2018/1/29", O: 2347.22, C: 2358.98, L: 2337.35, H: 2363.8, V: 249910},
		{Label: "2018/1/30", O: 2360.75, C: 2382.48, L: 2347.89, H: 2383.76, V: 119910},
		{Label: "2018/1/31", O: 2383.43, C: 2385.42, L: 2371.23, H: 2391.82, V: 89940},
                    ... // To fill more data
		{Label: "2018/6/13", O: 2190.1, C: 2148.35, L: 2126.22, H: 2190.1, V: 239510},
	}

	events := []tachart.Event{
		{
			Type:        tachart.Short,
			Label:       cdls[40].Label,
			Description: "This is a demo event description. Randomly pick this candle to go short on " + cdls[40].Label,
		},
	}

	cfg := tachart.NewConfig().
		SetWidth(1080).
		SetHeight(800).
		AddOverlay(
			tachart.NewSMA(5),
			tachart.NewSMA(20),
		).
		AddIndicator(
			tachart.NewMACD(12, 26, 9),
		).
		UseRepoAssets() // serving assets file from current repo, avoid network access

	c := tachart.New(*cfg)
	c.GenStatic(cdls, events, "/Volumes/tmpfs/tmp/kline.html")
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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