model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package model contains code for the model in the MVC pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chart added in v1.1.0

type Chart struct {
	Quote                  *Quote
	Range                  Range
	TradingSessionSeries   *TradingSessionSeries
	MovingAverageSeries25  *MovingAverageSeries
	MovingAverageSeries50  *MovingAverageSeries
	MovingAverageSeries200 *MovingAverageSeries
	DailyStochasticSeries  *StochasticSeries
	WeeklyStochasticSeries *StochasticSeries
	LastUpdateTime         time.Time
}

Chart has multiple series of data to be graphed.

type Model

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

Model models the app's state.

func New

func New() *Model

New creates a new Model.

func (*Model) AddSidebarSymbol added in v1.1.0

func (m *Model) AddSidebarSymbol(symbol string) (added bool, err error)

AddSidebarSymbol adds a symbol to the sidebar and returns true if the stock was newly added.

func (*Model) CurrentSymbol added in v1.1.0

func (m *Model) CurrentSymbol() string

CurrentSymbol returns the current symbol or empty string if no stock is set.

func (*Model) RemoveSidebarSymbol added in v1.1.0

func (m *Model) RemoveSidebarSymbol(symbol string) (removed bool, err error)

RemoveSidebarSymbol removes a symbol from the sidebar and returns true if removed.

func (*Model) SetCurrentSymbol added in v1.1.0

func (m *Model) SetCurrentSymbol(symbol string) (changed bool, err error)

SetCurrentSymbol sets the current stock symbol and returns true if the current symbol changed.

func (*Model) SidebarSymbols added in v1.1.0

func (m *Model) SidebarSymbols() []string

SidebarSymbols returns the sidebar's symbols.

func (*Model) Stock added in v1.1.0

func (m *Model) Stock(symbol string) (*Stock, error)

Stock returns the stock for the symbol if it is in the model. Nil otherwise.

func (*Model) UpdateStockChart added in v1.1.0

func (m *Model) UpdateStockChart(symbol string, chart *Chart) error

UpdateStockChart inserts or updates the chart for a stock if it is in the model.

type MovingAverage

type MovingAverage struct {
	// Date is the start date of the data point.
	Date time.Time

	// Value is the moving average value.
	Value float32
}

MovingAverage is a single data point in a MovingAverageSeries.

type MovingAverageSeries

type MovingAverageSeries struct {
	// MovingAverages are sorted by date in ascending order.
	MovingAverages []*MovingAverage
}

MovingAverageSeries is a time series of moving average values.

type Quote

type Quote struct {
	CompanyName   string
	LatestPrice   float32
	LatestSource  Source
	LatestTime    time.Time
	LatestUpdate  time.Time
	LatestVolume  int
	Open          float32
	High          float32
	Low           float32
	Close         float32
	Change        float32
	ChangePercent float32
}

Quote is the latest quote for the stock.

type Range added in v1.1.0

type Range int

Range is the range to specify in the request.

const (
	RangeUnspecified Range = iota
	OneDay
	OneYear
)

Range values.

func (Range) String added in v1.1.0

func (i Range) String() string

type Source

type Source int

Source is the quote data source.

const (
	SourceUnspecified Source = iota
	IEXRealTimePrice
	FifteenMinuteDelayedPrice
	Close
	PreviousClose
)

Source values.

func (Source) String

func (i Source) String() string

type Stochastic

type Stochastic struct {
	// Date is the start date of the data point.
	Date time.Time

	// K measures the stock's momentum.
	K float32

	// D is some moving average of K.
	D float32
}

Stochastic is a single data point in a StochasticSeries.

type StochasticSeries

type StochasticSeries struct {
	// Stochastics are sorted by date in ascending order.
	Stochastics []*Stochastic
}

StochasticSeries is a time series of stochastic values.

type Stock

type Stock struct {
	// Symbol is the stock's non-empty symbol.
	Symbol string

	// Charts are the stock's unsorted charts. Nil initially.
	Charts []*Chart
}

Stock has a stock's symbol and charts.

type TradingSession

type TradingSession struct {
	Date          time.Time
	Open          float32
	High          float32
	Low           float32
	Close         float32
	Volume        int
	Change        float32
	PercentChange float32
}

TradingSession models a single trading session.

func (*TradingSession) Empty added in v1.1.0

func (s *TradingSession) Empty() bool

Empty returns whether the TradingSession has any data to report.

type TradingSessionSeries

type TradingSessionSeries struct {
	// TradingSessions are sorted by date in ascending order.
	TradingSessions []*TradingSession
}

TradingSessionSeries is a time series of trading sessions.

Jump to

Keyboard shortcuts

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