analyser

package
v0.0.0-...-5a29284 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveProspects

func ActiveProspects(dbClient *database.DBClient, itemChecker *watcher.StockItemChecker) (map[string]string, time.Time)

func CleanupOldCandleplots

func CleanupOldCandleplots() error

CleanupOldCandleplots rm -rf plots

func FindProspects

func FindProspects(dbClient *database.DBClient, itemChecker *watcher.StockItemChecker, onFind func(msg, savePath string))

FindProspects Find prospects using this function. This function uses cache.

func MkCandlePlotDir

func MkCandlePlotDir() error

MkCandlePlotDir mkdir CandlePlotDir

func NewCandlePlot

func NewCandlePlot(dbClient *database.DBClient, days int, stockID string, stockAccess *watcher.StockItemChecker) (bool, string)

NewCandlePlot draws and saves a new candle plot of Stock ID

didPlot bool
savePath string, full path

func NewCrossEqualIndicatorRule

func NewCrossEqualIndicatorRule(lhs, rhs techan.Indicator) techan.Rule

NewCrossEqualIndicatorRule returns a new Rule checking if two indicators' calculation are equal

func NewCrossGTEIndicatorRule

func NewCrossGTEIndicatorRule(lhs, rhs techan.Indicator) techan.Rule

NewCrossGTEIndicatorRule returns a new Rule checking if two indicators' calculation are equal

func NewCrossGTIndicatorRule

func NewCrossGTIndicatorRule(lhs, rhs techan.Indicator) techan.Rule

NewCrossGTIndicatorRule returns a new Rule checking if two indicators' calculation are equal

func NewCrossLTEIndicatorRule

func NewCrossLTEIndicatorRule(lhs, rhs techan.Indicator) techan.Rule

NewCrossLTEIndicatorRule returns a new Rule checking if two indicators' calculation are equal

func NewCrossLTIndicatorRule

func NewCrossLTIndicatorRule(lhs, rhs techan.Indicator) techan.Rule

NewCrossLTIndicatorRule returns a new Rule checking if two indicators' calculation are equal

func NewCustomEMAIndicator

func NewCustomEMAIndicator(indicator techan.Indicator, window int) techan.Indicator

NewCustomEMAIndicator returns a derivative indicator which returns the average of the current and preceding values in the given window, with values closer to current index given more weight. A more in-depth explanation can be found here: http://www.investopedia.com/terms/e/ema.asp

func NewCustomMACDHistogramIndicator

func NewCustomMACDHistogramIndicator(macdIdicator techan.Indicator, signalLinewindow int) techan.Indicator

NewCustomMACDHistogramIndicator returns a derivative Indicator based on the MACDIndicator, the result of which is the macd indicator minus it's signalLinewindow EMA. A more in-depth explanation can be found here: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:macd-histogram

func NewCustomMACDIndicator

func NewCustomMACDIndicator(baseIndicator techan.Indicator, shortwindow, longwindow int) techan.Indicator

NewCustomMACDIndicator returns a derivative Indicator which returns the difference between two EMAIndicators with long and short windows. It's useful for gauging the strength of price movements. A more in-depth explanation can be found here: http://www.investopedia.com/terms/m/macd.asp

func NewProspect

func NewProspect(dbClient *database.DBClient, days int, stockID string) []structs.StockPrice

NewProspect find new prospect of the day

Types

type Analyser

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

Analyser is a struct for signalling to users by condition they have set.

func NewAnalyser

func NewAnalyser(stockID string) *Analyser

NewAnalyser creates and returns a pointer of a new prepared Analyser struct

func (*Analyser) AppendPastPrice

func (a *Analyser) AppendPastPrice(stockPrice structs.StockPrice)

AppendPastPrice appends price into the time series

func (*Analyser) AppendStrategy

func (a *Analyser) AppendStrategy(strategy structs.UserStock, callback EventCallback) (bool, error)

AppendStrategy Appends strategy with callback

func (*Analyser) CalculateStrategies

func (a *Analyser) CalculateStrategies()

CalculateStrategies calculates strategies from the last candle

func (*Analyser) Count

func (a *Analyser) Count() int

Count implementation of ReferenceCounting

func (*Analyser) DeleteStrategy

func (a *Analyser) DeleteStrategy(userid int64, orderside techan.OrderSide)

DeleteStrategy Deletes strategy of a user with side

func (*Analyser) NeedPriceFrom

func (a *Analyser) NeedPriceFrom() int64

NeedPriceFrom calculates timestamp from when to fetch coin price data.

func (*Analyser) Release

func (a *Analyser) Release()

Release implementation of ReferenceCounting

func (*Analyser) Retain

func (a *Analyser) Retain()

Retain implementation of ReferenceCounting

type Broker

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

Broker is an Analysis Manager

func NewBroker

func NewBroker(dbClient *database.DBClient) *Broker

NewBroker creates a new initialized pointer of Broker

func (*Broker) AddStrategy

func (b *Broker) AddStrategy(userStrategy UserStock, callback EventCallback, updateDB bool) (bool, error)

AddStrategy adds a user's strategy with a callback which will be for sending push messages. Returns

didRetainAnalyser   bool
error               error

func (*Broker) CanFeedPrice

func (b *Broker) CanFeedPrice(stockID string) bool

CanFeedPrice returns if can feed price to analyser

func (*Broker) DeleteStrategy

func (b *Broker) DeleteStrategy(user User, stockID string, orderSide int) error

DeleteStrategy deletes a strategy from the managing list. Analyser will be destroyed only if there are no need to manage it.

func (*Broker) Description

func (b *Broker) Description() string

Description description of this Watcher

func (*Broker) FeedPrice

func (b *Broker) FeedPrice(stockID string, provider <-chan structs.StockPrice)

FeedPrice is a function for updating the latest stock price.

func (*Broker) GetStrategy

func (b *Broker) GetStrategy(user User) []UserStock

GetStrategy gets strategy of a specific user.

func (*Broker) Situation

func (b *Broker) Situation(stockName, stockID string) (bool, string, string)

func (*Broker) StopFeedingPrice

func (b *Broker) StopFeedingPrice()

StopFeedingPrice Stop feeding price of all analysers

func (*Broker) UpdatePastPrice

func (b *Broker) UpdatePastPrice()

UpdatePastPrice is for updating the past price of the stock.

func (*Broker) UpdatePastPriceOfStock

func (b *Broker) UpdatePastPriceOfStock(stockID string)

UpdatePastPriceOfStock is for updating the past price of the specific stock.

type BrokerAccess

type BrokerAccess interface {
	AccessBroker() *Broker
}

BrokerAccess give access to broker

type CandleSticks

type CandleSticks struct {
	Candles

	UpColor, DownColor color.Color
	// contains filtered or unexported fields
}

CandleSticks struct of candle sticks

func NewCandleSticks

func NewCandleSticks(cs Candles, timeSeries *techan.TimeSeries, days int, up, down color.Color) *CandleSticks

NewCandleSticks factory method for candle sticks

func (*CandleSticks) DataRange

func (cs *CandleSticks) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange DataRange

func (*CandleSticks) GlyphBoxes

func (cs *CandleSticks) GlyphBoxes(p *plot.Plot) []plot.GlyphBox

GlyphBoxes GlyphBoxes

func (*CandleSticks) Plot

func (cs *CandleSticks) Plot(c draw.Canvas, plt *plot.Plot)

Plot Plot

type Candles

type Candles []candle

Candles array of candle

func (Candles) Candle

func (c Candles) Candle(i int) (float64, float64, float64, float64, float64)

Candle timestamp, open, close, high, low

func (Candles) Len

func (c Candles) Len() int

Len length of the array

type EventCallback

type EventCallback func(price structs.StockPrice, orderSide int, userid int64, repeat bool)

EventCallback is a type of callback when the trigger is triggered.

type EventTrigger

type EventTrigger interface {
	OrderSide() techan.OrderSide
	IsTriggered(index int, record *techan.TradingRecord) bool
	SetCallback(callback EventCallback)
	OnEvent(price structs.StockPrice, orderSide int, userid int64, repeat bool)
}

EventTrigger is an interface for triggering events.

type SmoothSplineCalculator

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

SmoothSplineCalculator Wrapper of cubicSpline.NaturalCubicSplines

func (SmoothSplineCalculator) Graph

func (ld SmoothSplineCalculator) Graph(index int) []float64

Graph Returns local smooth spline values around the index

type User

type User = structs.User

User alias

type UserStock

type UserStock = structs.UserStock

UserStock alias

Jump to

Keyboard shortcuts

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