feat: add momentum indicators and expand function coverage
Add a full Momentum Indicators category (momentum_indicators.go) with 26 new wrapped functions: ADX, ADXR, APO, AROON, AROONOSC, BOP, CCI, CMO, DX, IMI, MACD, MACDEXT, MACDFIX, MFI, MOM, MINUS_DI, MINUS_DM, PLUS_DI, PLUS_DM, PPO, ROC, ROCP, ROCR, ROCR100, RSI, STOCH, STOCHF, STOCHRSI, TRIX, ULTOSC, WILLR - Register all new native symbols in Load() (loader.go) - Declare corresponding native function variables in functions.go - Add MAType enum (ta_ma_type.go) for MA-type parameters (SMA, EMA, WMA, DEMA, TEMA, TRIMA, KAMA, MAMA, T3) - Add taResult constants (ta_result.go) mirroring TA-Lib return codes - Each wrapper includes a doc comment with formula, interpretation, and known behavioral edge-case notes
This commit is contained in:
@@ -23,6 +23,13 @@ This project currently exposes a small subset of TA-Lib functions:
|
||||
- Exponential/Logarithmic: `Exp`, `Ln`, `Log10`
|
||||
- Rounding: `Ceil`, `Floor`, `Sqrt`
|
||||
|
||||
**Momentum Indicators**
|
||||
- Directional Movement: `ADX`, `ADXR`, `DX`, `MINUS_DI`, `MINUS_DM`, `PLUS_DI`, `PLUS_DM`
|
||||
- Oscillators: `APO`, `AROON`, `AROONOSC`, `BOP`, `CCI`, `CMO`, `IMI`, `MFI`, `MOM`, `PPO`, `RSI`, `TRIX`, `WILLR`, `ULTOSC`
|
||||
- Rate of Change: `ROC`, `ROCP`, `ROCR`, `ROCR100`
|
||||
- MACD family: `MACD`, `MACDEXT`, `MACDFIX`
|
||||
- Stochastic family: `STOCH`, `STOCHF`, `STOCHRSI`
|
||||
|
||||
## Requirements
|
||||
|
||||
- Go `1.26`
|
||||
@@ -107,6 +114,8 @@ func main() {
|
||||
|
||||
- Indicator functions return `nil` when the underlying TA-Lib call fails.
|
||||
- Native TA-Lib functions are exposed with Go-style exported names such as `Add`, `Div`, `Max`, and `Sum`.
|
||||
- Functions accepting a moving-average type use the `MAType` constant (`SMA`, `EMA`, `WMA`, `DEMA`, `TEMA`, `TRIMA`, `KAMA`, `MAMA`, `T3`).
|
||||
- Functions returning two outputs (e.g. `AROON`, `MACD`, `STOCH`) return multiple slices; all are `nil` on failure.
|
||||
|
||||
## Project status
|
||||
|
||||
|
||||
+372
@@ -298,4 +298,376 @@ var (
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
adx func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
adxr func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
apo func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInFastPeriod int32,
|
||||
optInSlowPeriod int32,
|
||||
optInMAType int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
aroon func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outAroonDown []float64,
|
||||
outAroonUp []float64,
|
||||
) int32
|
||||
|
||||
aroonosc func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
bop func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inOpen []float64,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
cci func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
cmo func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
dx func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
imi func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inOpen []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
macd func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInFastPeriod int32,
|
||||
optInSlowPeriod int32,
|
||||
optInSignalPeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outMACD []float64,
|
||||
outMACDSignal []float64,
|
||||
outMACDHist []float64,
|
||||
) int32
|
||||
|
||||
macdext func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInFastPeriod int32,
|
||||
optInFastMAType int32,
|
||||
optInSlowPeriod int32,
|
||||
optInSlowMAType int32,
|
||||
optInSignalPeriod int32,
|
||||
optInSignalMAType int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outMACD []float64,
|
||||
outMACDSignal []float64,
|
||||
outMACDHist []float64,
|
||||
) int32
|
||||
|
||||
macdfix func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInSignalPeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outMACD []float64,
|
||||
outMACDSignal []float64,
|
||||
outMACDHist []float64,
|
||||
) int32
|
||||
|
||||
mfi func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
inVolume []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
mom func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
minus_di func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
minus_dm func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
plus_di func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
plus_dm func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
ppo func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInFastPeriod int32,
|
||||
optInSlowPeriod int32,
|
||||
optInMAType int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
roc func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
rocp func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
rocr func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
rocr100 func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
rsi func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
stoch func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInFastKPeriod int32,
|
||||
optInSlowKPeriod int32,
|
||||
optInSlowKMAType int32,
|
||||
optInSlowDPeriod int32,
|
||||
optInSlowDMAType int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outSlowK []float64,
|
||||
outSlowD []float64,
|
||||
) int32
|
||||
|
||||
stochf func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInFastKPeriod int32,
|
||||
optInFastDPeriod int32,
|
||||
optInFastDMAType int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outFastK []float64,
|
||||
outFastD []float64,
|
||||
) int32
|
||||
|
||||
stochrsi func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
optInFastKPeriod int32,
|
||||
optInFastDPeriod int32,
|
||||
optInFastDMAType int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outFastK []float64,
|
||||
outFastD []float64,
|
||||
) int32
|
||||
|
||||
trix func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inReal []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
ultosc func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod1 int32,
|
||||
optInTimePeriod2 int32,
|
||||
optInTimePeriod3 int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
|
||||
willr func(
|
||||
startIdx int32,
|
||||
endIdx int32,
|
||||
inHigh []float64,
|
||||
inLow []float64,
|
||||
inClose []float64,
|
||||
optInTimePeriod int32,
|
||||
outBegIdx *int32,
|
||||
outNBElement *int32,
|
||||
outReal []float64,
|
||||
) int32
|
||||
)
|
||||
|
||||
@@ -56,13 +56,45 @@ func Load() (uintptr, error) {
|
||||
purego.RegisterLibFunc(&tanh, ptr, "TA_TANH")
|
||||
|
||||
purego.RegisterLibFunc(&ceil, ptr, "TA_CEIL")
|
||||
purego.RegisterLibFunc(&exp, ptr, "TA_EXP")
|
||||
purego.RegisterLibFunc(&floor, ptr, "TA_FLOOR")
|
||||
purego.RegisterLibFunc(&sqrt, ptr, "TA_SQRT")
|
||||
|
||||
purego.RegisterLibFunc(&exp, ptr, "TA_EXP")
|
||||
purego.RegisterLibFunc(&ln, ptr, "TA_LN")
|
||||
purego.RegisterLibFunc(&log10, ptr, "TA_LOG10")
|
||||
|
||||
purego.RegisterLibFunc(&adx, ptr, "TA_ADX")
|
||||
purego.RegisterLibFunc(&adxr, ptr, "TA_ADXR")
|
||||
purego.RegisterLibFunc(&apo, ptr, "TA_APO")
|
||||
purego.RegisterLibFunc(&aroon, ptr, "TA_AROON")
|
||||
purego.RegisterLibFunc(&aroonosc, ptr, "TA_AROONOSC")
|
||||
purego.RegisterLibFunc(&bop, ptr, "TA_BOP")
|
||||
purego.RegisterLibFunc(&cci, ptr, "TA_CCI")
|
||||
purego.RegisterLibFunc(&cmo, ptr, "TA_CMO")
|
||||
purego.RegisterLibFunc(&dx, ptr, "TA_DX")
|
||||
purego.RegisterLibFunc(&imi, ptr, "TA_IMI")
|
||||
purego.RegisterLibFunc(&macd, ptr, "TA_MACD")
|
||||
purego.RegisterLibFunc(&macdext, ptr, "TA_MACDEXT")
|
||||
purego.RegisterLibFunc(&macdfix, ptr, "TA_MACDFIX")
|
||||
purego.RegisterLibFunc(&mfi, ptr, "TA_MFI")
|
||||
purego.RegisterLibFunc(&mom, ptr, "TA_MOM")
|
||||
purego.RegisterLibFunc(&minus_di, ptr, "TA_MINUS_DI")
|
||||
purego.RegisterLibFunc(&minus_dm, ptr, "TA_MINUS_DM")
|
||||
purego.RegisterLibFunc(&plus_di, ptr, "TA_PLUS_DI")
|
||||
purego.RegisterLibFunc(&plus_dm, ptr, "TA_PLUS_DM")
|
||||
purego.RegisterLibFunc(&ppo, ptr, "TA_PPO")
|
||||
purego.RegisterLibFunc(&roc, ptr, "TA_ROC")
|
||||
purego.RegisterLibFunc(&rocp, ptr, "TA_ROCP")
|
||||
purego.RegisterLibFunc(&rocr, ptr, "TA_ROCR")
|
||||
purego.RegisterLibFunc(&rocr100, ptr, "TA_ROCR100")
|
||||
purego.RegisterLibFunc(&rsi, ptr, "TA_RSI")
|
||||
purego.RegisterLibFunc(&stoch, ptr, "TA_STOCH")
|
||||
purego.RegisterLibFunc(&stochf, ptr, "TA_STOCHF")
|
||||
purego.RegisterLibFunc(&stochrsi, ptr, "TA_STOCHRSI")
|
||||
purego.RegisterLibFunc(&trix, ptr, "TA_TRIX")
|
||||
purego.RegisterLibFunc(&ultosc, ptr, "TA_ULTOSC")
|
||||
purego.RegisterLibFunc(&willr, ptr, "TA_WILLR")
|
||||
|
||||
return ptr, nil
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
package talib
|
||||
|
||||
type MAType int32
|
||||
|
||||
const (
|
||||
SMA MAType = 0 // Simple Moving Average
|
||||
EMA MAType = 1 // Exponential Moving Average
|
||||
WMA MAType = 2 // Weighted Moving Average
|
||||
DEMA MAType = 3 // Double Exponential Moving Average
|
||||
TEMA MAType = 4 // Triple Exponential Moving Average
|
||||
TRIMA MAType = 5 // Triangular Moving Average
|
||||
KAMA MAType = 6 // Kaufman Adaptive Moving Average
|
||||
MAMA MAType = 7 // MESA Adaptive Moving Average
|
||||
T3 MAType = 8 // Triple Exponential Moving Average (T3)
|
||||
)
|
||||
Reference in New Issue
Block a user