quotes

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// YahooNotFoundCode define errors raised by yahoo finace on code not found
	YahooNotFoundCode = "Not Found"
	// ErrYahooSymbolNotFound define errors raised by yahoo finace on symblo not found
	ErrYahooSymbolNotFound = errors.New("symbol not foud")
	// ErrYahooInvalidTradingPeroid define errors raised by yahoo invalid trading peroid
	ErrYahooInvalidTradingPeroid = errors.New("invalid trading peroid")
)

Functions

This section is empty.

Types

type Company

type Company struct {
	Name string
	Code string // symbol
}

Company define company

func (*Company) Decode

func (c *Company) Decode(r io.Reader) error

Decode decode company from io.Reader

func (Company) Encode

func (c Company) Encode(w io.Writer) error

Encode encode company to io.Writer

func (Company) Equal

func (c Company) Equal(s Company) error

Equal check company is equal

type CompanyDailyQuote added in v0.3.0

type CompanyDailyQuote struct {
	Company  *Company
	Dividend *Dividend
	Split    *Split
	Pre      *Serial
	Regular  *Serial
	Post     *Serial
}

CompanyDailyQuote define company daily quote

func (*CompanyDailyQuote) Decode added in v0.3.0

func (q *CompanyDailyQuote) Decode(r io.Reader) error

Decode decode company daily quote from io.Reader

func (CompanyDailyQuote) Encode added in v0.3.0

func (q CompanyDailyQuote) Encode(w io.Writer) error

Encode encode company daily quote to io.Writer

func (CompanyDailyQuote) Equal added in v0.3.0

Equal check company daily quote is equal

func (CompanyDailyQuote) IsEmpty added in v0.3.2

func (q CompanyDailyQuote) IsEmpty() bool

IsEmpty check if company daily quote is empty

type CompanyMap added in v0.3.1

type CompanyMap map[string]*Company

CompanyMap define company map

func (*CompanyMap) Decode added in v0.3.1

func (m *CompanyMap) Decode(r io.Reader) error

Decode decode company map from io.Reader

func (CompanyMap) Encode added in v0.3.1

func (m CompanyMap) Encode(w io.Writer) error

Encode encode company map to io.Writer

type CompanyQuote added in v0.6.5

type CompanyQuote struct {
	Exchange string
	*Company
	Type   QuoteType
	Peroid int64
	*Quote
}

type Decoder

type Decoder interface {
	Decode(r io.Reader) error
}

Decoder define types can be decode from io.Reader

type Dividend

type Dividend struct {
	Enable    bool
	Timestamp uint64
	Amount    float32
}

Dividend define stock dividend

func (*Dividend) Decode

func (d *Dividend) Decode(r io.Reader) error

Decode decode dividend from io.Reader

func (Dividend) Encode

func (d Dividend) Encode(w io.Writer) error

Encode encode dividend to io.Writer

func (Dividend) Equal

func (d Dividend) Equal(s Dividend) error

Equal check dividend is equal

type Encoder

type Encoder interface {
	Encode(w io.Writer) error
}

Encoder define types can be encode to io.Writer

type ExchangeDailyQuote

type ExchangeDailyQuote struct {
	Exchange  string
	Date      time.Time
	Companies map[string]*Company
	Quotes    map[string]*CompanyDailyQuote
}

ExchangeDailyQuote define exchange daily quote

func (*ExchangeDailyQuote) Decode

func (q *ExchangeDailyQuote) Decode(r io.Reader) error

Decode decode exchange daily quote from io.Reader

func (ExchangeDailyQuote) Encode

func (q ExchangeDailyQuote) Encode(w io.Writer) error

Encode encode exchange daily quote to io.Writer

func (ExchangeDailyQuote) Equal

Equal check exchange daily quote is equal

func (ExchangeDailyQuote) IsEmpty added in v0.3.2

func (q ExchangeDailyQuote) IsEmpty() bool

IsEmpty check if exchange daily quote is empty

type Quote

type Quote struct {
	Timestamp uint64
	Open      float32
	Close     float32
	High      float32
	Low       float32
	Volume    uint64
}

Quote define stock quote

func (*Quote) Decode

func (q *Quote) Decode(r io.Reader) error

Decode decode quote from io.Reader

func (Quote) Encode

func (q Quote) Encode(w io.Writer) error

Encode encode quote to io.Writer

func (Quote) Equal

func (q Quote) Equal(s Quote) error

Equal check quote is equal

type QuoteType added in v0.6.5

type QuoteType string

QuoteType quote type

const (
	TypeDaily QuoteType = "daily"
)

type Serial

type Serial []Quote

Serial define quotes

func (*Serial) Decode

func (s *Serial) Decode(r io.Reader) error

Decode decode quotes from io.Reader

func (Serial) Encode

func (s Serial) Encode(w io.Writer) error

Encode encode quotes to io.Writer

func (Serial) Equal

func (s Serial) Equal(q Serial) error

Equal check quotes is equal

func (Serial) Len

func (s Serial) Len() int

func (Serial) Less

func (s Serial) Less(i, j int) bool

func (Serial) Rollup

func (s Serial) Rollup() *Quote

Rollup rollup quotes to a summary

func (Serial) Swap

func (s Serial) Swap(i, j int)

type SerialType

type SerialType int

SerialType define quotes type

const (
	// SerialTypePre before trading peroid
	SerialTypePre SerialType = iota + 1
	// SerialTypeRegular in the trading peroid
	SerialTypeRegular
	// SerialTypePost after trading peroid
	SerialTypePost
)

func (SerialType) String

func (t SerialType) String() string

type Split

type Split struct {
	Enable      bool
	Timestamp   uint64
	Numerator   float32
	Denominator float32
}

Split define stock split

func (*Split) Decode

func (s *Split) Decode(r io.Reader) error

Decode decode split from io.Reader

func (Split) Encode

func (s Split) Encode(w io.Writer) error

Encode encode split to io.Writer

func (Split) Equal

func (s Split) Equal(t Split) error

Equal check split is equal

type TradingPeroid1 added in v0.6.2

type TradingPeroid1 [][]YahooPeroid

TradingPeroid1 define trading peroid

type TradingPeroid2 added in v0.6.2

type TradingPeroid2 struct {
	Pre     [][]YahooPeroid `json:"pre"`
	Regular [][]YahooPeroid `json:"regular"`
	Post    [][]YahooPeroid `json:"post"`
}

TradingPeroid2 define trading peroid

type YahooDividend

type YahooDividend struct {
	Amount float32 `json:"amount"`
	Date   uint64  `json:"date"`
}

YahooDividend define stock dividend

type YahooPeroid

type YahooPeroid struct {
	Timezone  string `json:"timezone"`
	Start     uint64 `json:"start"`
	End       uint64 `json:"end"`
	GMTOffset int64  `json:"gmtoffset"`
}

YahooPeroid define trading peroid

type YahooQuote

type YahooQuote struct {
	Chart struct {
		Result []struct {
			Meta struct {
				Currency             string  `json:"currency"`
				Symbol               string  `json:"symbol"`
				ExchangeName         string  `json:"exchangeName"`
				InstrumentType       string  `json:"instrumentType"`
				FirstTradeDate       int64   `json:"firstTradeDate"`
				GMTOffset            int64   `json:"gmtoffset"`
				Timezone             string  `json:"timezone"`
				PreviousClose        float32 `json:"previousClose"`
				Scale                int     `json:"scale"`
				CurrentTradingPeriod struct {
					Pre     YahooPeroid `json:"pre"`
					Regular YahooPeroid `json:"regular"`
					Post    YahooPeroid `json:"post"`
				} `json:"currentTradingPeriod"`
				TradingPeriods  json.RawMessage `json:"tradingPeriods"`
				DataGranularity string          `json:"dataGranularity"`
				ValidRanges     []string        `json:"validRanges"`
			} `json:"meta"`
			Timestamp []uint64 `json:"timestamp"`
			Events    struct {
				Dividends map[uint64]YahooDividend `json:"dividends"`
				Splits    map[uint64]YahooSplits   `json:"splits"`
			} `json:"events"`
			Indicators struct {
				Quotes []struct {
					Open   []float32 `json:"open"`
					Close  []float32 `json:"close"`
					High   []float32 `json:"high"`
					Low    []float32 `json:"low"`
					Volume []uint64  `json:"volume"`
				} `json:"quote"`
			} `json:"indicators"`
		} `json:"result"`
		Err *struct {
			Code        string `json:"code"`
			Description string `json:"description"`
		} `json:"error"`
	} `json:"chart"`
}

YahooQuote define yahoo finace response structure

func (YahooQuote) ToCompanyDailyQuote

func (q YahooQuote) ToCompanyDailyQuote(company *Company, start, end uint64) *CompanyDailyQuote

ToCompanyDailyQuote convert yahoo finance response to company daily quote

func (YahooQuote) Validate

func (q YahooQuote) Validate() error

Validate validate response is valid

type YahooSplits

type YahooSplits struct {
	Date        uint64 `json:"date"`
	Numerator   uint32 `json:"numerator"`
	Denominator uint32 `json:"denominator"`
	Ratio       string `json:"splitRatio"`
}

YahooSplits define stock split

Jump to

Keyboard shortcuts

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