Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only 1 candle for day interval #16

Open
DestroyerMB opened this issue Jan 11, 2021 · 1 comment
Open

Only 1 candle for day interval #16

DestroyerMB opened this issue Jan 11, 2021 · 1 comment

Comments

@DestroyerMB
Copy link

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

@AmIJesse
Copy link

AmIJesse commented Jan 28, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants