Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 2.06 KB

README.md

File metadata and controls

65 lines (48 loc) · 2.06 KB

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