In Go, I'm using this function bars, err := custplotter.NewCandlesticks(data)
from here:
https://github.com/pplcc/plotext/tree/master/custplotter
It's expecting this shape for data:
[{2 16435 16458 16435 16446 1} {3 16446 16458 16435.04 16455 1} .....]
But my code below is creating my data in this shape instead:
[[2 16435 16458 16435 16446 1] [3 16446 16458 16435.04 16455 1] .....]
Which gives me this error message:
cannot use data (type [ ][ ]string
) as type custplotter.TOHLCVer
in argument to custplotter.NewCandlesticks
:
[ ][ ]string does not implement custplotter.TOHLCVer (missing Len method)
I believe the problem is the data shape. How can i change my code to create the required data shape (with { } instead of [ ]) ?
//read excel file******************************************
xlsx, err := excelize.OpenFile("/media/Snaps/test snaps.xlsm")
if err != nil {
fmt.Println(err)
return
}
//read all rows into df
df := xlsx.GetRows("ticker_2")
//get only TOHLCV columns and 60 rows
df3 := make([][]string, 60) // create slice for 60 rows
idx := 0
for _, row := range df[1:61] { // read 60 rows
df3row := make([]string, 6) // create slice for 6 columns
copy(df3row, row[28:34]) // copy desired columns to new row slice
df3[idx] = df3row
idx++
}
All examples of slices i found in Go litterature uses only [ [ ], [ ] ]