Skip to content

Commit 057580b

Browse files
Adds IPOs, Short Interest/Volume, and Treasury Yields (#529)
1 parent a2fb53b commit 057580b

File tree

7 files changed

+651
-2
lines changed

7 files changed

+651
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"log"
6+
"os"
7+
8+
polygon "github.com/polygon-io/client-go/rest"
9+
"github.com/polygon-io/client-go/rest/models"
10+
)
11+
12+
func main() {
13+
// Initialize client
14+
c := polygon.New(os.Getenv("POLYGON_API_KEY"))
15+
16+
// Set parameters
17+
params := models.ListTreasuryYieldsParams{}.
18+
WithDate(models.GTE, "2024-12-15").
19+
WithDate(models.LTE, "2024-12-31").
20+
WithOrder(models.Asc).
21+
WithLimit(50000)
22+
23+
// Make request
24+
iter := c.VX.ListTreasuryYields(context.Background(), params)
25+
26+
// Process results
27+
for iter.Next() {
28+
log.Print(iter.Item())
29+
}
30+
if iter.Err() != nil {
31+
log.Fatal(iter.Err())
32+
}
33+
}

rest/example/stocks/ipos/main.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"log"
6+
"os"
7+
8+
polygon "github.com/polygon-io/client-go/rest"
9+
"github.com/polygon-io/client-go/rest/models"
10+
)
11+
12+
func main() {
13+
// Initialize client
14+
c := polygon.New(os.Getenv("POLYGON_API_KEY"))
15+
16+
// Set parameters
17+
params := models.ListIPOsParams{}.
18+
WithTicker("RAPP").
19+
WithListingDate(models.EQ, "2024-06-07").
20+
WithOrder(models.Desc).
21+
WithLimit(1000)
22+
23+
// Make request
24+
iter := c.VX.ListIPOs(context.Background(), params)
25+
26+
// Process results
27+
for iter.Next() {
28+
log.Print(iter.Item())
29+
}
30+
if iter.Err() != nil {
31+
log.Fatal(iter.Err())
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"log"
6+
"os"
7+
8+
polygon "github.com/polygon-io/client-go/rest"
9+
"github.com/polygon-io/client-go/rest/models"
10+
)
11+
12+
func main() {
13+
// Initialize client
14+
c := polygon.New(os.Getenv("POLYGON_API_KEY"))
15+
16+
// Set parameters
17+
params := models.ListShortInterestParams{}.
18+
WithTicker(models.EQ, "A").
19+
WithSettlementDate(models.EQ, "2025-03-14").
20+
WithOrder(models.Asc).
21+
WithLimit(50000)
22+
23+
// Make request
24+
iter := c.VX.ListShortInterest(context.Background(), params)
25+
26+
// Process results
27+
for iter.Next() {
28+
log.Print(iter.Item())
29+
}
30+
if iter.Err() != nil {
31+
log.Fatal(iter.Err())
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"log"
6+
"os"
7+
8+
polygon "github.com/polygon-io/client-go/rest"
9+
"github.com/polygon-io/client-go/rest/models"
10+
)
11+
12+
func main() {
13+
// Initialize client
14+
c := polygon.New(os.Getenv("POLYGON_API_KEY"))
15+
16+
// Set parameters
17+
params := models.ListShortVolumeParams{}.
18+
WithTicker(models.EQ, "A").
19+
WithDate(models.EQ, "2025-03-25").
20+
WithOrder(models.Asc).
21+
WithLimit(50000)
22+
23+
// Make request
24+
iter := c.VX.ListShortVolume(context.Background(), params)
25+
26+
// Process results
27+
for iter.Next() {
28+
log.Print(iter.Item())
29+
}
30+
if iter.Err() != nil {
31+
log.Fatal(iter.Err())
32+
}
33+
}

rest/models/economy.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package models
2+
3+
// ListTreasuryYieldsParams is the set of parameters for the ListTreasuryYields method.
4+
type ListTreasuryYieldsParams struct {
5+
// Calendar date of the yield observation (YYYY-MM-DD).
6+
DateEQ *string `query:"date"`
7+
DateLT *string `query:"date.lt"`
8+
DateLTE *string `query:"date.lte"`
9+
DateGT *string `query:"date.gt"`
10+
DateGTE *string `query:"date.gte"`
11+
12+
// Sort field used for ordering. Default is date.
13+
Sort *Sort `query:"sort"`
14+
15+
// Order results based on the sort field. Default is asc.
16+
Order *Order `query:"order"`
17+
18+
// Limit the number of results returned, default is 100 and max is 50000.
19+
Limit *int `query:"limit"`
20+
}
21+
22+
func (p ListTreasuryYieldsParams) WithDate(c Comparator, q string) *ListTreasuryYieldsParams {
23+
switch c {
24+
case EQ:
25+
p.DateEQ = &q
26+
case LT:
27+
p.DateLT = &q
28+
case LTE:
29+
p.DateLTE = &q
30+
case GT:
31+
p.DateGT = &q
32+
case GTE:
33+
p.DateGTE = &q
34+
}
35+
return &p
36+
}
37+
38+
func (p ListTreasuryYieldsParams) WithSort(q Sort) *ListTreasuryYieldsParams {
39+
p.Sort = &q
40+
return &p
41+
}
42+
43+
func (p ListTreasuryYieldsParams) WithOrder(q Order) *ListTreasuryYieldsParams {
44+
p.Order = &q
45+
return &p
46+
}
47+
48+
func (p ListTreasuryYieldsParams) WithLimit(q int) *ListTreasuryYieldsParams {
49+
p.Limit = &q
50+
return &p
51+
}
52+
53+
// ListTreasuryYieldsResponse is the response returned by the ListTreasuryYields method.
54+
type ListTreasuryYieldsResponse struct {
55+
BaseResponse
56+
57+
// An array of treasury yields that match your query.
58+
Results []TreasuryYield `json:"results,omitempty"`
59+
}
60+
61+
// TreasuryYield contains treasury yield data for a specific date.
62+
type TreasuryYield struct {
63+
Date string `json:"date,omitempty"`
64+
Yield1Month *float64 `json:"yield_1_month,omitempty"`
65+
Yield3Month *float64 `json:"yield_3_month,omitempty"`
66+
Yield6Month *float64 `json:"yield_6_month,omitempty"`
67+
Yield1Year *float64 `json:"yield_1_year,omitempty"`
68+
Yield2Year *float64 `json:"yield_2_year,omitempty"`
69+
Yield3Year *float64 `json:"yield_3_year,omitempty"`
70+
Yield5Year *float64 `json:"yield_5_year,omitempty"`
71+
Yield7Year *float64 `json:"yield_7_year,omitempty"`
72+
Yield10Year *float64 `json:"yield_10_year,omitempty"`
73+
Yield20Year *float64 `json:"yield_20_year,omitempty"`
74+
Yield30Year *float64 `json:"yield_30_year,omitempty"`
75+
}

0 commit comments

Comments
 (0)