From 2b9ac9f235829a1b513c352d715ddf1643f0a61e Mon Sep 17 00:00:00 2001 From: r4stl1n Date: Thu, 15 Feb 2024 23:46:11 -0800 Subject: [PATCH 1/2] added exchange schedule endpoint --- exchange.go | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ exchange_test.go | 11 ++++++++++ 2 files changed, 67 insertions(+) diff --git a/exchange.go b/exchange.go index 6b8c121..ea26f6d 100644 --- a/exchange.go +++ b/exchange.go @@ -9,6 +9,47 @@ type ExchangeStatusResponse struct { TradingActive bool `json:"trading_active,omitempty"` } +// ExchangeScheduleResponse is described here: +// https://trading-api.readme.io/reference/getexchangeschedule. +type ExchangeScheduleResponse struct { + Schedule struct { + StandardHours struct { + Monday struct { + OpenTime string `json:"open_time"` + CloseTime string `json:"close_time"` + } `json:"monday"` + Tuesday struct { + OpenTime string `json:"open_time"` + CloseTime string `json:"close_time"` + } `json:"tuesday"` + Wednesday struct { + OpenTime string `json:"open_time"` + CloseTime string `json:"close_time"` + } `json:"wednesday"` + Thursday struct { + OpenTime string `json:"open_time"` + CloseTime string `json:"close_time"` + } `json:"thursday"` + Friday struct { + OpenTime string `json:"open_time"` + CloseTime string `json:"close_time"` + } `json:"friday"` + Saturday struct { + OpenTime string `json:"open_time"` + CloseTime string `json:"close_time"` + } `json:"saturday"` + Sunday struct { + OpenTime string `json:"open_time"` + CloseTime string `json:"close_time"` + } `json:"sunday"` + } `json:"standard_hours"` + MaintenanceWindows []struct { + EndDatetime string `json:"end_datetime"` + StartDatetime string `json:"start_datetime"` + } `json:"maintenance_windows,omitempty"` + } `json:"schedule"` +} + // ExchangeStatus is described here: // https://trading-api.readme.io/reference/getexchangestatus. func (c *Client) ExchangeStatus(ctx context.Context) (*ExchangeStatusResponse, error) { @@ -23,3 +64,18 @@ func (c *Client) ExchangeStatus(ctx context.Context) (*ExchangeStatusResponse, e } return &resp, nil } + +// ExchangeSchedule is described here: +// https://trading-api.readme.io/reference/getexchangeschedule. +func (c *Client) ExchangeSchedule(ctx context.Context) (*ExchangeScheduleResponse, error) { + var resp ExchangeScheduleResponse + err := c.request(ctx, request{ + Method: "GET", + Endpoint: "exchange/schedule", + JSONResponse: &resp, + }) + if err != nil { + return nil, err + } + return &resp, nil +} diff --git a/exchange_test.go b/exchange_test.go index 5fe427f..2b24263 100644 --- a/exchange_test.go +++ b/exchange_test.go @@ -18,3 +18,14 @@ func TestExchangeStatus(t *testing.T) { require.True(t, s.ExchangeActive) require.True(t, s.TradingActive) } + +func TestExchangeSchedule(t *testing.T) { + t.Parallel() + + client := testClient(t) + + _, err := client.ExchangeSchedule(context.Background()) + + require.NoError(t, err) + +} From 4f38723025e8b41e2dc01055212d4eda21fdb6a3 Mon Sep 17 00:00:00 2001 From: r4stl1n Date: Thu, 15 Feb 2024 23:51:28 -0800 Subject: [PATCH 2/2] Updated the readme to include the supported endpoint --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9819238..8a45d68 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,10 @@ func main() { ### Exchange `kalshi` supports all Exchange endpoints. -| Endpoint | Support Status | -| ----------------- | -------------- | -| GetExchangeStatus | ✅ | +| Endpoint | Support Status | +|---------------------| -------------- | +| GetExchangeSchedule | ✅ | +| GetExchangeStatus | ✅ | ### Auth