es

package
v0.0.0-...-ab9b54e Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPositionStock

type IPositionStock interface {
	AddPosition(position *Position) error
	GetPositions(username string) ([]PositionAgg, error)
}

IPositionStock contains all es position stock actions

func NewPosition

func NewPosition(es *elastic.Client) IPositionStock

NewPosition create a new elasticsearch poisitons manager

type IStock

type IStock interface {
	Index(stock finance.Stock) error
	GetStocksAgg(symbol string, movAvgWindow int, step int, startDate time.Time, endDate time.Time) ([]StocksAgg, error)
	GetStockStats(symbol string, startDate time.Time, endDate time.Time) (*StocksStats, error)
	GetDateForNumPoint(symbol string, numPoints int, endDate time.Time) (*time.Time, error)
}

IStock contains elasticsearch manager actions

func NewStock

func NewStock(es *elastic.Client) IStock

NewStock create a new elasticsearch manager object

type Position

type Position struct {
	Username string    `json:"username" validate:"required"`
	Broker   string    `json:"broker" validate:"required"`
	Symbol   string    `json:"symbol" validate:"required"`
	Date     time.Time `json:"date,string" validate:"required"`
	Number   int       `json:"number,int" validate:"required"`
	Value    float64   `json:"value,float" validate:"gt=0"`
	Cost     float64   `json:"cost,float" validate:"required"`
}

Position contains all values representing a stock position

func (Position) String

func (position Position) String() string

type PositionAgg

type PositionAgg struct {
	Symbol string
	Number int
	Cost   float64
}

PositionAgg contains the list of positions aggregation by symbol

func (PositionAgg) String

func (position PositionAgg) String() string

type PositionStock

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

PositionStock manage positons in elasticsearch

func (*PositionStock) AddPosition

func (posStock *PositionStock) AddPosition(position *Position) error

AddPosition adds a position into elasticsearch storage

AddPosition(position)

return the inserted position

func (*PositionStock) GetPositions

func (posStock *PositionStock) GetPositions(username string) ([]PositionAgg, error)

GetPositions gets all the positions concerning a user

GetPositions(username)

return the list of positions

type Stock

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

Stock manage stocks in elasticsearch

func (*Stock) GetDateForNumPoint

func (esStock *Stock) GetDateForNumPoint(symbol string, numPoints int, endDate time.Time) (*time.Time, error)

GetDateForNumPoint compute the start date to get a number of data points

GetDateForNumPoint("CW8.PA", endDate)

returns the start date

func (*Stock) GetStockStats

func (esStock *Stock) GetStockStats(symbol string, startDate time.Time, endDate time.Time) (*StocksStats, error)

GetStockStats retrives the stats about a stock

GetStockStats("CW8.PA", startDate, endDate)

return the stock stats

func (*Stock) GetStocksAgg

func (esStock *Stock) GetStocksAgg(symbol string, movAvgWindow int, step int, startDate time.Time, endDate time.Time) ([]StocksAgg, error)

GetStocksAgg retrieves aggregations of stock values by dates

GetStocksAgg("TEST", startDate, endDate)

returns an array ofg stocks aggregations

func (*Stock) Index

func (esStock *Stock) Index(stock finance.Stock) error

Index is used to index a stock into elasticsearch

type StocksAgg

type StocksAgg struct {
	Symbol   string  `json:"symbol"`
	MsTime   int64   `json:"mstime"`
	AvgClose float64 `json:"close"`
	MovClose float64 `json:"mv_close"`
}

StocksAgg is the a stock aggregation

type StocksStats

type StocksStats struct {
	Symbol            string
	StandardDeviation float64
	Avg               float64
}

StocksStats contains all stats concerning a stock

Jump to

Keyboard shortcuts

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