Documentation ¶
Index ¶
- type IPositionStock
- type IStock
- type Position
- type PositionAgg
- type PositionStock
- type Stock
- func (esStock *Stock) GetDateForNumPoint(symbol string, numPoints int, endDate time.Time) (*time.Time, error)
- func (esStock *Stock) GetStockStats(symbol string, startDate time.Time, endDate time.Time) (*StocksStats, error)
- func (esStock *Stock) GetStocksAgg(symbol string, movAvgWindow int, step int, startDate time.Time, ...) ([]StocksAgg, error)
- func (esStock *Stock) Index(stock finance.Stock) error
- type StocksAgg
- type StocksStats
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
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
type PositionAgg ¶
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
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 ¶
StocksStats contains all stats concerning a stock