Skip to content

Commit

Permalink
Set historical data bar size
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlister committed Jan 11, 2021
1 parent c129308 commit b6a6633
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions data.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ const (
)

// Historical retrieves historical market data for a security.
func (s Security) Historical(period int, unit TimeUnit) Historical {
func (s Security) Historical(period int, unit TimeUnit, barSize int, barUnit TimeUnit) Historical {
client := resty.New()
client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
resp, err := client.R().Get(base + "/api/iserver/marketdata/history?conid=" + strconv.Itoa(s.Conid) + "&period=" + strconv.Itoa(period) + string(unit))
resp, err := client.R().Get(base + "/api/iserver/marketdata/history?conid=" + strconv.Itoa(s.Conid) + "&period=" + strconv.Itoa(period) + string(unit) + "&bar=" + strconv.Itoa(barSize) + string(barUnit))
if err != nil {
log.Panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/historical/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {
// Create a new reference to a security from a position
sec := broker.Security(p)
// Retrieve the historical data for that security
historical := sec.Historical(30, ib.Min)
historical := sec.Historical(2, ib.Day, 1, ib.Hour)
fmt.Println(historical)
}
}

0 comments on commit b6a6633

Please sign in to comment.