yahoofin

package module
v0.0.0-...-80adfb5 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 10 Imported by: 0

README

yahoofin

Go Report Card Travis CI

A client for the yahoo finance api written in go.

Installation

go get github.com/sklarsa/yahoofin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a struct that represents a Yahoo Finance client

func NewClient

func NewClient() (*Client, error)

NewClient creates a new Yahoo Finance client

func (*Client) GetSecurityData

func (c *Client) GetSecurityData(ticker string, startDate, endDate time.Time, field Field) ([]*Price, error)

GetSecurityData returns a slice of pointers to Price structs, based on the data received from yahoo

func (*Client) GetSecurityDataString

func (c *Client) GetSecurityDataString(ticker string, startDate, endDate time.Time, field Field) (string, error)

GetSecurityDataString returns the raw response data from the yahoo endpoint. This string will be CSV formatted if the request succeeds. In the event of a failed request, this string will be JSON-formatted

type DateTime

type DateTime struct {
	time.Time
}

DateTime is a custom implementation of time.Time used to unmarshal yahoo csv data

func (*DateTime) UnmarshalCSV

func (date *DateTime) UnmarshalCSV(csv string) (err error)

UnmarshalCSV converts the CSV string as internal date

type ErrorDescription

type ErrorDescription struct {
	Code        string `json:"code"`
	Description string `json:"description"`
}

ErrorDescription is used to deserialize additional error information from yahoo's server

type Field

type Field string

Field represents the type of data that is being requested from the yahoo api

const (
	// History will return historical prices
	History Field = "history"
	// Dividend will return dividend payment history
	Dividend Field = "dividend"
	// Split will return stock split data
	Split Field = "split"
)

type Price

type Price struct {
	Date     DateTime `csv:"Date"`
	Open     float64  `csv:"Open"`
	High     float64  `csv:"High"`
	Low      float64  `csv:"Low"`
	Close    float64  `csv:"Close"`
	AdjClose float64  `csv:"Adj Close"`
	Volume   float64  `csv:"Volume"`
}

Price represents a single datapoint returned by the yahoo api

type ServerError

type ServerError struct {
	Result interface{}      `json:"result"`
	Error  ErrorDescription `json:"error"`
}

ServerError is used to deserialize non-200 responses from yahoo's server

type ServerErrorRoot

type ServerErrorRoot struct {
	Chart ServerError `json:"chart"`
}

ServerErrorRoot is the root object returned by yahoo's server on errors

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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