polygon

package
v1.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	UpcomingPath rawPath
)
View Source
const (
	UpcomingRatelimiter ratelimiter
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct{ http.Client }

Client is a wrapper for http.Client.

func NewClient

func NewClient(_ context.Context, roundtripper transport.T) (*Client, error)

NewClient will return a new HTTP client to interface with the polygon.io web API.

func (*Client) Upcoming

func (c *Client) Upcoming() (m []*Upcoming, _ error)

Upcoming gets market holidays and their open/close times.

source: https://polygon.io/docs/crypto/get_v1_marketstatus_upcoming

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/polygon"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	url := "https://api.polygon.io"
	apikey := os.Getenv("POLYGON_API_KEY")

	client, err := polygon.NewClient(context.TODO(), transport.NewAuth2().SetBearer(apikey).SetURL(url))
	if err != nil {
		log.Fatalf("error fetching client: %v", err)
	}

	upcoming, err := client.Upcoming()
	if err != nil {
		log.Fatalf("error fetching upcoming holidays: %v", err)
	}

	fmt.Printf("the next holiday is %q\n", upcoming[0].Name)
}
Output:

type Upcoming

type Upcoming struct {
	// Close is the market close time on the holiday (if it's not closed).
	Close string `json:"close" bson:"close"`

	// Date is the date of the holiday.
	Date string `json:"date" bson:"date"`

	// Exchange is market the record is for.
	Exchange string `json:"exchange" bson:"exchange"`

	// Name is the name of the holiday.
	Name string `json:"name" bson:"name"`

	// Open is the market open time on the holiday (if it's not closed).
	Open string `json:"open" bson:"open"`

	// Status is the status of the market on the holiday.
	Status string `json:"status" bson:"status"`
}

Upcoming returns information concerning market holidays and their open/close times.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL