Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GetShortInterest and ListIPOs support #453

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

justinpolygon
Copy link
Contributor

@justinpolygon justinpolygon commented Oct 9, 2024

Update client with Short Interest and IPOs support. This PR adds GetShortInterest and ListIPOs functions, params, responses, tests, and a working examples.

Short Interest

// Stocks - Short Interest
// https://polygon.io/docs/stocks/get_v1_reference_short-interest__identifierType___identifier
package main

import (
	"context"
	"log"
	"os"
	"time"

	polygon "github.com/polygon-io/client-go/rest"
	"github.com/polygon-io/client-go/rest/models"
)

func main() {

	// Initialize client
	c := polygon.New(os.Getenv("POLYGON_API_KEY"))

	// Set parameters
	params := models.ListShortInterestParams{
		IdentifierType: "ticker",
		Identifier:     "AMD",
	}.WithDay(models.GTE, 2024, time.October, 1).
		WithDay(models.LTE, 2024, time.October, 10).
		WithLimit(10)

	// Make request
	iter := c.ListShortInterest(context.Background(), params)

	// Do something with the result
	for iter.Next() {
		log.Print(iter.Item())
	}
	if iter.Err() != nil {
		log.Fatal(iter.Err())
	}

}
$ go run rest/example/stocks/short-interest/main.go
2024/10/10 23:07:38 {USD 2024-10-01 US0079031078 Advanced Micro Devices Inc. Ordinary Shares 7557448 32411 AMD 007903107}
2024/10/10 23:07:38 {USD 2024-10-02 US0079031078 Advanced Micro Devices Inc. Ordinary Shares 5921961 20324 AMD 007903107}
2024/10/10 23:07:38 {USD 2024-10-03 US0079031078 Advanced Micro Devices Inc. Ordinary Shares 6591389 29014 AMD 007903107}
2024/10/10 23:07:38 {USD 2024-10-04 US0079031078 Advanced Micro Devices Inc. Ordinary Shares 10902497 61664 AMD 007903107}
2024/10/10 23:07:38 {USD 2024-10-07 US0079031078 Advanced Micro Devices Inc. Ordinary Shares 9180696 48277 AMD 007903107}
2024/10/10 23:07:38 {USD 2024-10-08 US0079031078 Advanced Micro Devices Inc. Ordinary Shares 9587451 56876 AMD 007903107}

Company IPOs

// Stocks - Company IPOs
// https://polygon.io/docs/stocks/get_v1_reference_ipos
package main

import (
	"context"
	"log"
	"os"

	polygon "github.com/polygon-io/client-go/rest"
	"github.com/polygon-io/client-go/rest/models"
)

func main() {

	// Initialize client
	c := polygon.New(os.Getenv("POLYGON_API_KEY"))

	// Set parameters
	params := models.ListIPOsParams{}.WithTicker("RDDT")

	// make request
	iter := c.ListIPOs(context.Background(), params)

	// do something with the result
	for iter.Next() {
		log.Print(iter.Item())
	}
	if iter.Err() != nil {
		log.Fatal(iter.Err())
	}

}
$ go run rest/example/stocks/ipos/main.go
2024/10/10 23:07:03 {USD 34 34 history US75734B1008   Reddit Inc. 2024-03-26 2024-03-21 0 0 31 22000000 0 XNYS Ordinary Shares - Class A CS 36871367 RDDT 5.19401918e+08 75734B100}

ListingDateLTE *Nanos `query:"listing_date.lte"`
ListingDateGT *Nanos `query:"listing_date.gt"`
ListingDateGTE *Nanos `query:"listing_date.gte"`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we actually added an ipo_status param so users can filter by ipo_status as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants