Skip to content

Commit

Permalink
Merge pull request #3 from r4stl1n/update-exchange-endpoints
Browse files Browse the repository at this point in the history
added exchange schedule endpoint
  • Loading branch information
ammario authored Feb 17, 2024
2 parents 15ea7b8 + 4f38723 commit c91ae7f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ func main() {
### Exchange
`kalshi` supports all Exchange endpoints.

| Endpoint | Support Status |
| ----------------- | -------------- |
| GetExchangeStatus ||
| Endpoint | Support Status |
|---------------------| -------------- |
| GetExchangeSchedule ||
| GetExchangeStatus ||

### Auth

Expand Down
56 changes: 56 additions & 0 deletions exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
11 changes: 11 additions & 0 deletions exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}

0 comments on commit c91ae7f

Please sign in to comment.