Documentation ¶
Index ¶
- Constants
- func NewBigMACDSignal(macd BigMACD, signalEMA *BigEMA, next *big.Float) (*BigMACDSignal, BigMACDSignalResults)
- func NewMACDSignal(macd MACD, signalEMA *EMA, next float64) (*MACDSignal, MACDSignalResults)
- type BigEMA
- type BigMACD
- type BigMACDResults
- type BigMACDSignal
- type BigMACDSignalResults
- type EMA
- type MACD
- type MACDResults
- type MACDSignal
- type MACDSignalResults
- type SMA
- type SMABig
Constants ¶
const ( // DefaultLongMACDPeriod is a common MACD period for the long input EMA algorithm. DefaultLongMACDPeriod = 26 // DefaultShortMACDPeriod is a common MACD period for the short input EMA algorithm. DefaultShortMACDPeriod = 12 // DefaultSignalEMAPeriod is a common MACD period for the signal EMA that will crossover the MACD line. DefaultSignalEMAPeriod = 9 )
const (
// DefaultEMASmoothing is a common smoothing constant for the EMA algorithm.
DefaultEMASmoothing = 2
)
const ( // RequiredSamplesForDefaultMACDSignal is the required number of period samples for an MACD signal using the default // arguments. RequiredSamplesForDefaultMACDSignal = DefaultLongMACDPeriod + DefaultSignalEMAPeriod )
Variables ¶
This section is empty.
Functions ¶
func NewBigMACDSignal ¶ added in v0.1.0
func NewBigMACDSignal(macd BigMACD, signalEMA *BigEMA, next *big.Float) (*BigMACDSignal, BigMACDSignalResults)
NewBigMACDSignal creates a new MACD and signal EMA pair. It's calculations are done in tandem to produced buy/sell signals.
func NewMACDSignal ¶ added in v0.1.0
func NewMACDSignal(macd MACD, signalEMA *EMA, next float64) (*MACDSignal, MACDSignalResults)
NewMACDSignal creates a new MACD and signal EMA pair. It's calculations are done in tandem to produced buy/sell signals.
Types ¶
type BigEMA ¶ added in v0.1.0
type BigEMA struct {
// contains filtered or unexported fields
}
BigEMA represents the state of an Exponential Moving Average (EMA) algorithm.
type BigMACD ¶ added in v0.1.0
BigMACD represents the state of a Moving Average Convergence Divergence (MACD) algorithm.
func NewBigMACD ¶ added in v0.1.0
NewBigMACD creates a new MACD data structure and returns the initial result.
func (BigMACD) Calculate ¶ added in v0.1.0
func (macd BigMACD) Calculate(next *big.Float) BigMACDResults
Calculate produces the next MACD result given the next input.
func (BigMACD) SignalEMA ¶ added in v0.1.0
func (macd BigMACD) SignalEMA(firstMACDResult *big.Float, next []*big.Float, smoothing *big.Float) (signalEMA *BigEMA, signalResult *big.Float, macdResults []BigMACDResults)
SignalEMA creates a signal EMA for the current MACD.
The first MACD result *must* be saved in order to create the signal EMA. Then, the next period samples required for the creation of the signal EMA must be given. The period length of the EMA is `1 + len(next)`.
type BigMACDResults ¶ added in v0.1.0
BigMACDResults holds the results fo an MACD calculation.
type BigMACDSignal ¶ added in v0.1.0
type BigMACDSignal struct {
// contains filtered or unexported fields
}
BigMACDSignal represents an MACD and signal EMA pair.
func DefaultBigMACDSignal ¶ added in v0.1.0
func DefaultBigMACDSignal(initial []*big.Float) *BigMACDSignal
DefaultBigMACDSignal is a helper function to create an MACD and signal EMA pair from the default parameters given the initial input data points.
There must be at least 35 data points in the initial slice. This accounts for the number of data points required to make the MACD (26) and the number of data points to make the signal EMA from the MACD (9).
If the initial input slice does not have enough data points, the function will return `nil`.
If the initial input slice does has too many data points, the MACD and signal EMA pair will be "caught" up to the last data point given, but no results will be accessible.
func (*BigMACDSignal) Calculate ¶ added in v0.1.0
func (m *BigMACDSignal) Calculate(next *big.Float) BigMACDSignalResults
Calculate computes the next MACD and signal EMA pair's results. It may also trigger a buy/sell signal.
type BigMACDSignalResults ¶ added in v0.1.0
type BigMACDSignalResults struct { BuySignal *bool MACD BigMACDResults SignalEMA *big.Float }
BigMACDSignalResults holds the results of an MACD and signal EMA pair's calculation.
If the calculation triggered a buy signal BuySignal will not be `nil`. It will be a pointer to `true`, if the signal indicates a buy and a pointer to `false` if the signal indicates a sell.
type EMA ¶ added in v0.1.0
type EMA struct {
// contains filtered or unexported fields
}
EMA represents the state of an Exponential Moving Average (EMA).
type MACD ¶ added in v0.1.0
MACD represents the state of a Moving Average Convergence Divergence (MACD) algorithm.
func NewMACD ¶ added in v0.1.0
NewMACD creates a new MACD data structure and returns the initial result.
func (MACD) Calculate ¶ added in v0.1.0
func (macd MACD) Calculate(next float64) MACDResults
Calculate produces the next MACD result given the next input.
func (MACD) SignalEMA ¶ added in v0.1.0
func (macd MACD) SignalEMA(firstMACDResult float64, next []float64, smoothing float64) (signalEMA *EMA, signalResult float64, macdResults []MACDResults)
SignalEMA creates a signal EMA for the current MACD.
The first MACD result *must* be saved in order to create the signal EMA. Then, the next period samples required for the creation of the signal EMA must be given. The period length of the EMA is `1 + len(next)`.
type MACDResults ¶ added in v0.1.0
MACDResults holds the results fo an MACD calculation.
type MACDSignal ¶ added in v0.1.0
type MACDSignal struct {
// contains filtered or unexported fields
}
MACDSignal represents an MACD and signal EMA pair.
func DefaultMACDSignal ¶ added in v0.1.0
func DefaultMACDSignal(initial []float64) *MACDSignal
DefaultMACDSignal is a helper function to create an MACD and signal EMA pair from the default parameters given the initial input data points.
There must be at least 35 data points in the initial slice. This accounts for the number of data points required to make the MACD (26) and the number of data points to make the signal EMA from the MACD (9).
If the initial input slice does not have enough data points, the function will return `nil`.
If the initial input slice does has too many data points, the MACD and signal EMA pair will be "caught" up to the last data point given, but no results will be accessible.
func (*MACDSignal) Calculate ¶ added in v0.1.0
func (m *MACDSignal) Calculate(next float64) MACDSignalResults
Calculate computes the next MACD and signal EMA pair's results. It may also trigger a buy/sell signal.
type MACDSignalResults ¶ added in v0.1.0
type MACDSignalResults struct { BuySignal *bool MACD MACDResults SignalEMA float64 }
MACDSignalResults holds the results of an MACD and signal EMA pair's calculation.
If the calculation triggered a buy signal BuySignal will not be `nil`. It will be a pointer to `true`, if the signal indicates a buy and a pointer to `false` if the signal indicates a sell.
type SMA ¶ added in v0.1.0
type SMA struct {
// contains filtered or unexported fields
}
SMA represents the state of a Simple Moving Average (SMA) algorithm.
type SMABig ¶
type SMABig struct {
// contains filtered or unexported fields
}
SMABig represents the state of a Simple Moving Average (SMA) algorithm.