finance-go icon indicating copy to clipboard operation
finance-go copied to clipboard

Only 1 candle for day interval

Open DestroyerMB opened this issue 4 years ago • 1 comments

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

DestroyerMB avatar Jan 11 '21 17:01 DestroyerMB

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.

AmIJesse avatar Jan 28 '21 02:01 AmIJesse