bar

package
v0.0.0-...-25c745f Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

type Bar interface {
	// GetTime interval of this bar
	GetTime() time.Time

	// GetOpen price for the current bar
	GetOpen() float64

	// GetHigh price for the current bar
	GetHigh() float64

	// GetLow price for the current bar
	GetLow() float64

	// GetClose price for the current bar
	GetClose() float64

	// GetVolume of shares, options, coins, etc traded during this bar
	GetVolume() float64

	// GetOpenInterest (Optional) amount of derivatives currently outstanding for this bar
	// If there is no open interest then this will be -1, to indicate no data
	GetOpenInterest() int64

	// Clone makes a copy of the underlying bar
	Clone() (Bar, error)
}

Bar is modeled after the standard OHLC (Open/High/Low/Close) bar used commonly in trading platforms.

This is a simple wrapper around some basic price movement over a period of time, and allows us to understand what happened during in interval.

func New

func New(
	t time.Time,
	openValue,
	highValue,
	lowValue,
	closeValue,
	volumeValue float64,
	openInterestValue int64,
) Bar

func NewFakeBar

func NewFakeBar(t time.Time) Bar

type Loader

type Loader interface {
	Read(ctx context.Context, input io.Reader) ([]Bar, error)
	Write(ctx context.Context, output io.Writer, input []Bar) error
}

Loader reads and writes the Bar data to the desired format. There are several loaders to choose from, each of which are self-contained with their own schemas: 1. CSV 2. Avro 3. Proto

func NewAvroLoader

func NewAvroLoader() Loader

func NewCSVLoader

func NewCSVLoader() Loader

func NewJsonNewLineLoader

func NewJsonNewLineLoader() Loader

func NewProtoLoader

func NewProtoLoader() Loader

type StandardBar

type StandardBar struct {
	UnixTime     int64   `csv:"time" avro:"time" json:"time"`
	Open         float64 `csv:"open" avro:"open" json:"open"`
	High         float64 `csv:"high" avro:"high" json:"high"`
	Low          float64 `csv:"low" avro:"low" json:"low"`
	Close        float64 `csv:"close" avro:"close" json:"close"`
	Volume       float64 `csv:"volume" avro:"volume" json:"volume"`
	OpenInterest int64   `csv:"open_interest" avro:"open_interest" json:"open_interest"`
}

func (StandardBar) Clone

func (i StandardBar) Clone() (Bar, error)

func (StandardBar) GetClose

func (i StandardBar) GetClose() float64

func (StandardBar) GetHigh

func (i StandardBar) GetHigh() float64

func (StandardBar) GetLow

func (i StandardBar) GetLow() float64

func (StandardBar) GetOpen

func (i StandardBar) GetOpen() float64

func (StandardBar) GetOpenInterest

func (i StandardBar) GetOpenInterest() int64

func (StandardBar) GetTime

func (i StandardBar) GetTime() time.Time

func (StandardBar) GetVolume

func (i StandardBar) GetVolume() float64

Jump to

Keyboard shortcuts

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