Tiny go package for serving candlestick chart for relational database.
go get -u github.com/ranjanrak/go-sqlcandlestick
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)
}
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.
go test -v