stock

package
v0.0.0-...-c5d5a31 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package stock fetches stock quote data

Index

Constants

View Source
const NASDAQ exchange = "NASDAQ"

NASDAQ is the NASDAQ Stock Exchange

View Source
const NYSE exchange = "NYSE"

NYSE is the New York Stock Exchange

Variables

View Source
var ErrInvalidTicker = fmt.Errorf("invalid ticker")

ErrInvalidTicker indicates the ticker was invalid

View Source
var IEXProvider provider = "IEX"

IEXProvider is a stock quote provider

Functions

This section is empty.

Types

type EOD

type EOD struct {
	Date   time.Time `json:"date"`
	Open   float64   `json:"open"`
	Close  float64   `json:"close"`
	High   float64   `json:"high"`
	Low    float64   `json:"low"`
	Volume int       `json:"volume"`
}

EOD is an end of day stock quote

type Fetcher

type Fetcher interface {
	Fetch(ticker string) (*Quote, error)
}

Fetcher retrieves stock quotes

type IEX

type IEX struct {
	HTTPClient *http.Client
}

IEX retrieves information from the IEX API

func (*IEX) Fetch

func (i *IEX) Fetch(ticker string) (*Quote, error)

Fetch retrieves from the IEX api

type Last

type Last struct {
	Price         float64
	Time          time.Time
	Change        float64
	ChangePercent float64
}

Last is the latest quote

type Quote

type Quote struct {
	Ticker   string
	Name     string
	Exchange exchange
	Last
	History  []EOD
	Provider provider
}

Quote includes the current and historical quotes

func (*Quote) SortHistorical

func (q *Quote) SortHistorical() *Quote

SortHistorical sorts the historical quotes in ascending order

Jump to

Keyboard shortcuts

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