Documentation ¶
Overview ¶
Package model contains code for the model in the MVC pattern.
Index ¶
- type Chart
- type Model
- func (m *Model) AddSidebarSymbol(symbol string) (added bool, err error)
- func (m *Model) CurrentSymbol() string
- func (m *Model) RemoveSidebarSymbol(symbol string) (removed bool, err error)
- func (m *Model) SetCurrentSymbol(symbol string) (changed bool, err error)
- func (m *Model) SidebarSymbols() []string
- func (m *Model) Stock(symbol string) (*Stock, error)
- func (m *Model) UpdateStockChart(symbol string, chart *Chart) error
- type MovingAverage
- type MovingAverageSeries
- type Quote
- type Range
- type Source
- type Stochastic
- type StochasticSeries
- type Stock
- type TradingSession
- type TradingSessionSeries
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 (*Model) AddSidebarSymbol ¶ added in v1.1.0
AddSidebarSymbol adds a symbol to the sidebar and returns true if the stock was newly added.
func (*Model) CurrentSymbol ¶ added in v1.1.0
CurrentSymbol returns the current symbol or empty string if no stock is set.
func (*Model) RemoveSidebarSymbol ¶ added in v1.1.0
RemoveSidebarSymbol removes a symbol from the sidebar and returns true if removed.
func (*Model) SetCurrentSymbol ¶ added in v1.1.0
SetCurrentSymbol sets the current stock symbol and returns true if the current symbol changed.
func (*Model) SidebarSymbols ¶ added in v1.1.0
SidebarSymbols returns the sidebar's symbols.
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 Source ¶
type Source int
Source is the quote data source.
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.