finance-go
finance-go copied to clipboard
Only 1 candle for day interval
Hello,
I noticed when I'm asking for chart with Interval: datetime.OneDay I always got only 1 candle which is strange... :(
I tried this: params := &chart.Params{ Symbol: "AAPL", Interval: datetime.OneDay, } iter := chart.Get(params) for iter.Next() { b := iter.Bar() fmt.Printf("%+v %s\n", b, datetime.FromUnix(b.Timestamp).Time().Format("02.01.2006 15:04:05")) }
What I do wrong, please?
Regards, Max
Interval is the bar frequency, one day will give you one bar per day.
package main
import (
"fmt"
"github.com/piquette/finance-go/chart"
"github.com/piquette/finance-go/datetime"
)
func main() {
params := &chart.Params{
Symbol: "AAPL",
Interval: datetime.OneMin,
}
iter := chart.Get(params)
for iter.Next() {
b := iter.Bar()
fmt.Printf("%+v %s\n", b, datetime.FromUnix(b.Timestamp).Time().Format("02.01.2006 15:04:05"))
}
}
will give you one bar per minute, over the last day. You can adjust the start/stop times with the
Start
and End
chart parameters respectively.