Documentation ¶
Index ¶
- func ActiveProspects(dbClient *database.DBClient, itemChecker *watcher.StockItemChecker) (map[string]string, time.Time)
- func CleanupOldCandleplots() error
- func FindProspects(dbClient *database.DBClient, itemChecker *watcher.StockItemChecker, ...)
- func MkCandlePlotDir() error
- func NewCandlePlot(dbClient *database.DBClient, days int, stockID string, ...) (bool, string)
- func NewCrossEqualIndicatorRule(lhs, rhs techan.Indicator) techan.Rule
- func NewCrossGTEIndicatorRule(lhs, rhs techan.Indicator) techan.Rule
- func NewCrossGTIndicatorRule(lhs, rhs techan.Indicator) techan.Rule
- func NewCrossLTEIndicatorRule(lhs, rhs techan.Indicator) techan.Rule
- func NewCrossLTIndicatorRule(lhs, rhs techan.Indicator) techan.Rule
- func NewCustomEMAIndicator(indicator techan.Indicator, window int) techan.Indicator
- func NewCustomMACDHistogramIndicator(macdIdicator techan.Indicator, signalLinewindow int) techan.Indicator
- func NewCustomMACDIndicator(baseIndicator techan.Indicator, shortwindow, longwindow int) techan.Indicator
- func NewProspect(dbClient *database.DBClient, days int, stockID string) []structs.StockPrice
- type Analyser
- func (a *Analyser) AppendPastPrice(stockPrice structs.StockPrice)
- func (a *Analyser) AppendStrategy(strategy structs.UserStock, callback EventCallback) (bool, error)
- func (a *Analyser) CalculateStrategies()
- func (a *Analyser) Count() int
- func (a *Analyser) DeleteStrategy(userid int64, orderside techan.OrderSide)
- func (a *Analyser) NeedPriceFrom() int64
- func (a *Analyser) Release()
- func (a *Analyser) Retain()
- type Broker
- func (b *Broker) AddStrategy(userStrategy UserStock, callback EventCallback, updateDB bool) (bool, error)
- func (b *Broker) CanFeedPrice(stockID string) bool
- func (b *Broker) DeleteStrategy(user User, stockID string, orderSide int) error
- func (b *Broker) Description() string
- func (b *Broker) FeedPrice(stockID string, provider <-chan structs.StockPrice)
- func (b *Broker) GetStrategy(user User) []UserStock
- func (b *Broker) Situation(stockName, stockID string) (bool, string, string)
- func (b *Broker) StopFeedingPrice()
- func (b *Broker) UpdatePastPrice()
- func (b *Broker) UpdatePastPriceOfStock(stockID string)
- type BrokerAccess
- type CandleSticks
- type Candles
- type EventCallback
- type EventTrigger
- type SmoothSplineCalculator
- type User
- type UserStock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveProspects ¶
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 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 ¶
NewCrossEqualIndicatorRule returns a new Rule checking if two indicators' calculation are equal
func NewCrossGTEIndicatorRule ¶
NewCrossGTEIndicatorRule returns a new Rule checking if two indicators' calculation are equal
func NewCrossGTIndicatorRule ¶
NewCrossGTIndicatorRule returns a new Rule checking if two indicators' calculation are equal
func NewCrossLTEIndicatorRule ¶
NewCrossLTEIndicatorRule returns a new Rule checking if two indicators' calculation are equal
func NewCrossLTIndicatorRule ¶
NewCrossLTIndicatorRule returns a new Rule checking if two indicators' calculation are equal
func NewCustomEMAIndicator ¶
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 ¶
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 ¶
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 ¶
AppendStrategy Appends strategy with callback
func (*Analyser) CalculateStrategies ¶
func (a *Analyser) CalculateStrategies()
CalculateStrategies calculates strategies from the last candle
func (*Analyser) DeleteStrategy ¶
DeleteStrategy Deletes strategy of a user with side
func (*Analyser) NeedPriceFrom ¶
NeedPriceFrom calculates timestamp from when to fetch coin price data.
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker is an Analysis Manager
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 ¶
CanFeedPrice returns if can feed price to analyser
func (*Broker) DeleteStrategy ¶
DeleteStrategy deletes a strategy from the managing list. Analyser will be destroyed only if there are no need to manage it.
func (*Broker) Description ¶
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 ¶
GetStrategy gets strategy of a specific user.
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 ¶
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
type Candles ¶
type Candles []candle
Candles array of candle
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