stock

package
v0.0.0-...-d3c8f25 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MarketOpenHour    = 9
	MarketOpenMinute  = 30
	MarketCloseHour   = 15
	MarketCloseMinute = 59
)

Variables

This section is empty.

Functions

func DailyPriceHeader

func DailyPriceHeader() string

func GetSymbols

func GetSymbols() []string

func OneMinSaleHeader

func OneMinSaleHeader() string

func SortByLastPrice

func SortByLastPrice(stockList []*Stock)

func SortBySymbol

func SortBySymbol(stockList []*Stock)

Types

type DailyPrice

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

DailyPrice holds a single day's price and volume data for a security.

func NewDailyPrice

func NewDailyPrice(
	year, month, day int,
	open, close, high, low float64,
	volume int64,
) (dp DailyPrice, err error)

func (DailyPrice) Date

func (dp DailyPrice) Date() time.Time

func (DailyPrice) DateStr

func (dp DailyPrice) DateStr() string

DateStr returns the daily price date as "YYYY-MM-DD".

func (DailyPrice) HighLow

func (dp DailyPrice) HighLow() (float64, float64)

func (DailyPrice) OpenClose

func (dp DailyPrice) OpenClose() (float64, float64)

func (DailyPrice) String

func (dp DailyPrice) String() string

func (DailyPrice) ToGob

func (dp DailyPrice) ToGob() DailyPriceGob

func (DailyPrice) Validate

func (dp DailyPrice) Validate() error

func (DailyPrice) Volume

func (dp DailyPrice) Volume() int64

type DailyPriceGob

type DailyPriceGob struct {
	Year   int
	Month  int
	Day    int
	Open   float64
	Close  float64
	High   float64
	Low    float64
	Volume int64
}

DailyPriceGob is the type used to persist daily price data.

func (DailyPriceGob) ToDailyPrice

func (dpg DailyPriceGob) ToDailyPrice() (DailyPrice, error)

type OneMinSale

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

OneMinSale holds price and volume data for one minute of stock trading activity.

func NewOneMinSale

func NewOneMinSale(
	year, month, day, hour, min int,
	open, close, high, low float64,
	volume int64,
	vwap float64,
) (oms OneMinSale, err error)

func (OneMinSale) DateTimeStr

func (oms OneMinSale) DateTimeStr() string

DateTimeStr returns the one minute sales time as "YYYY-MM-DD HH:MM".

func (OneMinSale) HighLow

func (oms OneMinSale) HighLow() (float64, float64)

func (OneMinSale) OpenClose

func (oms OneMinSale) OpenClose() (float64, float64)

func (OneMinSale) StartTime

func (oms OneMinSale) StartTime() time.Time

func (OneMinSale) String

func (oms OneMinSale) String() string

func (OneMinSale) VWAP

func (oms OneMinSale) VWAP() float64

func (OneMinSale) Validate

func (oms OneMinSale) Validate() error

func (OneMinSale) Volume

func (oms OneMinSale) Volume() int64

type Stock

type Stock struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewStock

func NewStock(symbol string) *Stock

func (*Stock) AppendDailyPrices

func (s *Stock) AppendDailyPrices(dps []*DailyPrice) error

func (*Stock) AppendExpirations

func (s *Stock) AppendExpirations(exps []option.Expiration) error

func (*Stock) AppendOneMinSales

func (s *Stock) AppendOneMinSales(omss []OneMinSale) error

func (*Stock) LastPrice

func (s *Stock) LastPrice() float64

func (*Stock) Prices

func (s *Stock) Prices() []DailyPrice

func (*Stock) Quote

func (s *Stock) Quote() quote.Quote

func (*Stock) SetQuote

func (s *Stock) SetQuote(q quote.Quote)

func (*Stock) String

func (s *Stock) String() string

func (*Stock) Symbol

func (s *Stock) Symbol() string

Jump to

Keyboard shortcuts

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