Documentation ¶
Overview ¶
Package trend offers classic trend following algos.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeApexBotFromConfig ¶
MakeApexBotFromConfig returns a bot configured with an ApexPredicter.
Types ¶
type ApexPredicter ¶
type ApexPredicter struct { // PriceSelector is the kline component to use for price. Close by default. PriceSelector ta.PriceSelector // MA is the smoothed price series to evaluate for a peak or valley. MA ta.Indicator[float64] // MMI is the trend filter. MMI ta.Indicator[float64] // contains filtered or unexported fields }
ApexPredicter predicts price direction based on trend turning points with a market meaness index filter. Peak signals the start of a downward price trend. Valley signal the start of an upward price trend.
func NewApexPredicter ¶
func NewApexPredicter(ma, mmi ta.Indicator[float64]) *ApexPredicter
NewApexPredicter creates a new predicter with Close quote price selector.
func (*ApexPredicter) Predict ¶
func (p *ApexPredicter) Predict() float64
Predict returns a score to indicate confidence of price direction.
1.0 = Valley with MMI confluence.
0.9 = Valley (no MMI confluence).
-0.9 = Peak (no MMI confluence).
-1.0 = Peak with MMI confluence.
[0.0, 0.1] = Flat trend.
func (*ApexPredicter) ReceivePrice ¶
ReceivePrice updates the prediction algo with the next market price. Call Predict() to get the resulting score.
func (*ApexPredicter) Valid ¶
func (p *ApexPredicter) Valid() bool
Valid returns true if MA and MMI indicators are valid.
type Bot ¶
type Bot struct { Asset market.Asset EnterLong float64 ExitLong float64 EnterShort float64 ExitShort float64 Predicter trader.Predicter Risker risk.Risker Sizer money.Sizer // contains filtered or unexported fields }
Bot will open and/or close a single market position based on the score from the the given trader.Predicter and the associated EnterLong et al params. Stop loss and position size is determined by the given risk.Risker and money.Sizer.
func NewBot ¶
func NewBot() *Bot
NewBot sets default enter and exit scores and basic Risker and Sizer implementations. Post creation of the bot the Predicter and Asset field must be set and a call made to SetDealer().
func (*Bot) ReceivePrice ¶
ReceivePrice updates the algo with latest market price potentially triggering buy and/or sell orders.
type CrossPredicter ¶
type CrossPredicter struct { // PriceSelector is the kline component to use for price. Close by default. PriceSelector ta.PriceSelector // Osc is the moving average oscillator to use for entery and exit signals. Osc ta.Indicator[float64] // MMI is the signal filter. MMI ta.Indicator[float64] // contains filtered or unexported fields }
CrossPredicter predicts price direction based on a moving average cross with a market meaness index filter.
func NewCrossPredicter ¶
func NewCrossPredicter(osc, mmi ta.Indicator[float64]) *CrossPredicter
NewCrossPredicter creates a new predicter with Close quote price selector.
func (*CrossPredicter) Predict ¶
func (p *CrossPredicter) Predict() float64
Predict returns a score to indicate confidence of price direction.
1.0 = Long trend cross over with MMI in confluence.
0.9 = Long trend cross over (no MMI confluence).
-0.9 = Short trend cross over (no MMI confluence).
-1.0 = Short trend with MMI confluence.
[0.0, 0.1] = Flat trend.
func (*CrossPredicter) ReceivePrice ¶
ReceivePrice updates the prediction algo with the next market price. Call Predict() to get the resulting score.
func (*CrossPredicter) Valid ¶
func (p *CrossPredicter) Valid() bool
Valid returns true if Osc and MMI indicators are valid.