custplotter

package
v0.0.0-...-68ab3c6 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2018 License: BSD-3-Clause Imports: 6 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCandleWidthFactor = 3

DefaultCandleWidthFactor is the default width of the candle relative to the DefaultLineStyle.Width.

View Source
var DefaultTickWidth = vg.Points(2)

DefaultTickWidth is the default width of the open and close ticks.

Functions

This section is empty.

Types

type Candlesticks

type Candlesticks struct {
	TOHLCVs

	// ColorUp is the color of sticks where C >= O
	ColorUp color.Color

	// ColorDown is the color of sticks where C < O
	ColorDown color.Color

	// LineStyle is the style used to draw the sticks.
	draw.LineStyle

	// CandleWidth is the width of a candlestick
	CandleWidth vg.Length

	// FixedLineColor determines if a fixed line color can be used for up and down bars.
	// When set to true then the color of LineStyle is used to draw the sticks and
	// the borders of the candle. If set to false then ColorUp or ColorDown are used to
	// draw the sticks and the borders of the candle. Thus a candle's fill color is also
	// used for the borders and sticks.
	FixedLineColor bool
}

Candlesticks implements the Plotter interface, drawing a bar plot of time, open, high, low, close tuples.

func NewCandlesticks

func NewCandlesticks(TOHLCV TOHLCVer) (*Candlesticks, error)

NewCandlesticks creates as new candlestick plotter for the given data.

func (*Candlesticks) DataRange

func (sticks *Candlesticks) DataRange() (xMin, xMax, yMin, yMax float64)

DataRange implements the DataRange method of the plot.DataRanger interface.

func (*Candlesticks) GlyphBoxes

func (sticks *Candlesticks) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface. We just return 2 glyph boxes at xmin, ymin and xmax, ymax Important is that they provide space for the left part of the first candle's body and for the right part of the last candle's body

func (*Candlesticks) Plot

func (sticks *Candlesticks) Plot(c draw.Canvas, plt *plot.Plot)

Plot implements the Plot method of the plot.Plotter interface.

type OHLCBars

type OHLCBars struct {
	TOHLCVs

	// ColorUp is the color of bars where C >= O
	ColorUp color.Color

	// ColorDown is the color of bars where C < O
	ColorDown color.Color

	// LineStyle is the style used to draw the bars.
	draw.LineStyle

	// CapWidth is the width of the caps drawn at the top
	// of each error bar.
	TickWidth vg.Length
}

OHLCBars implements the Plotter interface, drawing a bar plot of time, open, high, low, close tuples.

func NewOHLCBars

func NewOHLCBars(TOHLCV TOHLCVer) (*OHLCBars, error)

NewBars creates as new bar plotter for the given data.

func (*OHLCBars) DataRange

func (bars *OHLCBars) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange implements the DataRange method of the plot.DataRanger interface.

func (*OHLCBars) GlyphBoxes

func (bars *OHLCBars) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface. We just return 2 glyph boxes at xmin, ymin and xmax, ymax Important is that they provide space for the first open tick and the last close tick

func (*OHLCBars) Plot

func (bars *OHLCBars) Plot(c draw.Canvas, plt *plot.Plot)

Plot implements the Plot method of the plot.Plotter interface.

type TOHLCVer

type TOHLCVer interface {
	// Len returns the number of time, open, high, low, close, volume tuples.
	Len() int

	// TOHLCV returns an time, open, high, low, close, volume tuple.
	TOHLCV(int) (float64, float64, float64, float64, float64, float64)
}

TOHLCV wraps the Len and TOHLCV methods.

type TOHLCVs

type TOHLCVs []struct{ T, O, H, L, C, V float64 }

TOHLCVs implements the TOHLCVer interface using a slice.

func CopyTOHLCVs

func CopyTOHLCVs(data TOHLCVer) (TOHLCVs, error)

CopyTOHLCVs copies an TOHLCVer.

func (TOHLCVs) Len

func (TOHLCV TOHLCVs) Len() int

Len implements the Len method of the TOHLCVer interface.

func (TOHLCVs) TOHLCV

func (TOHLCV TOHLCVs) TOHLCV(i int) (float64, float64, float64, float64, float64, float64)

TOHLCV implements the TOHLCV method of the TOHLCVer interface.

type VBars

type VBars struct {
	TOHLCVs

	// ColorUp is the color of bars where C >= O
	ColorUp color.Color

	// ColorDown is the color of bars where C < O
	ColorDown color.Color

	// LineStyle is the style used to draw the bars.
	draw.LineStyle
}

VBars implements the Plotter interface, drawing a volume bar plot.

func NewVBars

func NewVBars(TOHLCV TOHLCVer) (*VBars, error)

NewBars creates as new bar plotter for the given data.

func (*VBars) DataRange

func (bars *VBars) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange implements the DataRange method of the plot.DataRanger interface.

func (*VBars) GlyphBoxes

func (bars *VBars) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface. We just return 2 glyph boxes at xmin, ymin and xmax, ymax Important is that they provide space for the left part of the first candle's body and for the right part of the last candle's body

func (*VBars) Plot

func (bars *VBars) Plot(c draw.Canvas, plt *plot.Plot)

Plot implements the Plot method of the plot.Plotter interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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