Categorygithub.com/ranjanrak/go-sqlcandlestick
modulepackage
0.1.0
Repository: https://github.com/ranjanrak/go-sqlcandlestick.git
Documentation: pkg.go.dev

# README

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

# Packages

No description provided by the author

# Functions

New creates new data-base connection interface.

# Constants

Supported database drivers.
Supported database drivers.
Supported database drivers.

# Structs

AxisValues represents X and Y-axis values.
Client represents database driver client.
ClientParam represents interface to connect to sqldb.
HttpInput represents input data for rendering candle stick chart.