Skip to content

Tiny go package for serving candlestick chart for any relational database.

License

Notifications You must be signed in to change notification settings

ranjanrak/go-sqlcandlestick

Repository files navigation

go-sqlcandlestick

Run Tests Go Reference

Tiny go package for serving candlestick chart for relational database.

Installation

go get -u github.com/ranjanrak/go-sqlcandlestick

Usage

package main
import (
	"log"

	sqlcandlestick "github.com/ranjanrak/go-sqlcandlestick"
)

func main() {
    client, err := sqlcandlestick.New(sqlcandlestick.ClientParam{
                    DriverName: sqlcandlestick.Clickhouse,
                    DSN: "tcp://127.0.0.1:9000?debug=true"})
    if err != nil {
        log.Fatalf("Error connecting to db: %v", err)
    }
    // Prepare sql statement
    queryStatement := `SELECT date,
                        open,
                        close
                        max(price) AS high,
                        min(price) AS low
                        FROM candle_data
                        GROUP BY date
                        ORDER BY date ASC`

    // Serve the candlestick chart
    client.ServeChart(queryStatement, "", nil)
}

Default candlestick chart

image

Create your own candlestick pattern

You can create your own candlestick chart types and pass the chart config to ServeChart(..., chart *charts.Kline). Few example chart config are shown under examples folder.

  1. Candlestick OCLH chart along with volume movement image

  2. Candlestick OCLH chart with EMA and SMA lines image

Run unit tests

go test -v

About

Tiny go package for serving candlestick chart for any relational database.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages