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

Update igmarkets.go #3

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions igmarkets.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,17 +528,22 @@ func (ig *IGMarkets) GetTransactions(transactionType string, from time.Time) (*H
func (ig *IGMarkets) GetPriceHistory(epic, resolution string, max int, from, to time.Time) (*PriceResponse, error) {
bodyReq := new(bytes.Buffer)

fmt.Println(from, to)

limitStr := ""
if !to.IsZero() && !from.IsZero() {
fromStr := from.Format("2006-01-02T15:04:05")
toStr := to.Format("2006-01-02T15:04:05")
limitStr = fmt.Sprintf("&from=%s&to=%s", fromStr, toStr)
} else if max > 0 {
}
if max > 0 {
limitStr = fmt.Sprintf("&max=%d", max)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max is set only when "to" or "from" has no time.Time value.

GetPriceHistory requires time.Time so it will never set "max" in the "else if" to 1.
Setting max is required to not get the default of i think 10.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is: If max > 0, we set max twice. In page and in limitStr. This is wrong IMO because both are used to assemble the URL. I think we need to removed it from page and leave limitStr empty if max is zero.

}

page := "&max=100&pageSize=100"

page := "&pageSize=1000"

fmt.Println(limitStr)

req, err := http.NewRequest("GET", fmt.Sprintf("%s/gateway/deal/prices/%s?resolution=%s",
ig.APIURL, epic, resolution)+limitStr+page, bodyReq)
if err != nil {
Expand Down