Skip to content

Commit a205ba7

Browse files
committed
Extend the calendar day with session and settlement info
1 parent efb7598 commit a205ba7

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

alpaca/entities.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,12 @@ type Fundamental struct {
175175
}
176176

177177
type CalendarDay struct {
178-
Date string `json:"date"`
179-
Open string `json:"open"`
180-
Close string `json:"close"`
178+
Date string `json:"date"`
179+
Open string `json:"open"`
180+
Close string `json:"close"`
181+
SessionOpen string `json:"session_open"`
182+
SessionClose string `json:"session_close"`
183+
SettlementDate string `json:"settlement_date"`
181184
}
182185

183186
//easyjson:json

alpaca/entities_easyjson.go

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

alpaca/rest_test.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,26 +235,37 @@ func TestGetCalendar(t *testing.T) {
235235
c := DefaultClient
236236
// successful
237237
c.do = func(c *Client, req *http.Request) (*http.Response, error) {
238-
assert.Equal(t, "2018-01-01", req.URL.Query().Get("start"))
239-
assert.Equal(t, "2018-01-02", req.URL.Query().Get("end"))
240-
calendar := []CalendarDay{
238+
assert.Equal(t, "2023-01-01", req.URL.Query().Get("start"))
239+
assert.Equal(t, "2023-01-03", req.URL.Query().Get("end"))
240+
jsonResp := `[
241241
{
242-
Date: "2018-01-01",
243-
Open: time.Now().Format(time.RFC3339),
244-
Close: time.Now().Format(time.RFC3339),
245-
},
246-
}
242+
"date": "2023-01-03",
243+
"open": "09:30",
244+
"close": "16:00",
245+
"session_open": "0400",
246+
"session_close": "2000",
247+
"settlement_date": "2023-01-05"
248+
}
249+
]`
247250
return &http.Response{
248-
Body: genBody(calendar),
251+
Body: nopCloser{strings.NewReader(jsonResp)},
249252
}, nil
250253
}
251254

252255
calendar, err := c.GetCalendar(GetCalendarRequest{
253-
Start: time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC),
254-
End: time.Date(2018, 1, 2, 0, 0, 0, 0, time.UTC),
256+
Start: time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC),
257+
End: time.Date(2023, 1, 3, 0, 0, 0, 0, time.UTC),
255258
})
256259
require.NoError(t, err)
257260
assert.Len(t, calendar, 1)
261+
assert.Equal(t, CalendarDay{
262+
Date: "2023-01-03",
263+
Open: "09:30",
264+
Close: "16:00",
265+
SessionOpen: "0400",
266+
SessionClose: "2000",
267+
SettlementDate: "2023-01-05",
268+
}, calendar[0])
258269

259270
// api failure
260271
c.do = func(c *Client, req *http.Request) (*http.Response, error) {

0 commit comments

Comments
 (0)