techindicators

package module
v0.0.0-...-37ec4f2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 10 Imported by: 0

README

techindicators

Golang library for financial technical indicators

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BollingerBreakout

func BollingerBreakout(dataset []OHLCV, period int, multiplier float64, priceType PriceType) (string, error)

BollingerBreakout detects potential breakouts from Bollinger Bands

func BollingerSqueeze

func BollingerSqueeze(dataset []OHLCV, period int, multiplier float64, priceType PriceType, lookback int) (bool, error)

BollingerSqueeze detects if bands are in a squeeze (low volatility)

func CalculateMultipleSMA

func CalculateMultipleSMA(dataset []OHLCV, periods []int, priceType PriceType) (map[int][]SMAResult, error)

CalculateMultipleSMA calculates multiple SMAs with different periods

func ExampleUsage

func ExampleUsage()

ExampleUsage demonstrates comprehensive usage of all technical indicators with OHLCV data

func GetLatestSMA

func GetLatestSMA(dataset []OHLCV, period int, priceType PriceType) (float64, error)

GetLatestSMA returns the most recent SMA value

func IsPriceAboveSMA

func IsPriceAboveSMA(dataset []OHLCV, period int, priceType PriceType) (bool, error)

IsPriceAboveSMA checks if current price is above the SMA

func SMACrossover

func SMACrossover(dataset []OHLCV, fastPeriod, slowPeriod int, priceType PriceType) (string, error)

SMACrossover detects if there's a bullish/bearish crossover between two SMAs

func SharpeRatioHandler

func SharpeRatioHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)

Types

type BollingerBands

type BollingerBands struct {
	Timestamp  string  `json:"timestamp"`
	UpperBand  float64 `json:"upper_band"`
	MiddleBand float64 `json:"middle_band"` // This is the SMA
	LowerBand  float64 `json:"lower_band"`
	BandWidth  float64 `json:"band_width"` // (Upper - Lower) / Middle
}

BollingerBands represents Bollinger Bands values

func CalculateBollingerBands

func CalculateBollingerBands(dataset []OHLCV, period int, multiplier float64, priceType PriceType) ([]BollingerBands, error)

CalculateBollingerBands calculates Bollinger Bands for the given dataset

func GetLatestBollingerBands

func GetLatestBollingerBands(dataset []OHLCV, period int, multiplier float64, priceType PriceType) (BollingerBands, error)

GetLatestBollingerBands returns the most recent Bollinger Bands values

type BollingerPosition

type BollingerPosition string

BollingerPosition indicates where the price is relative to Bollinger Bands

const (
	AboveUpperBand BollingerPosition = "above_upper"    // Potential overbought
	BetweenBands   BollingerPosition = "between_bands"  // Normal range
	BelowLowerBand BollingerPosition = "below_lower"    // Potential oversold
	TouchingUpper  BollingerPosition = "touching_upper" // Near upper band
	TouchingLower  BollingerPosition = "touching_lower" // Near lower band
)

func GetPricePosition

func GetPricePosition(dataset []OHLCV, period int, multiplier float64, priceType PriceType, tolerance float64) (BollingerPosition, error)

GetPricePosition determines where current price is relative to Bollinger Bands

type BollingerStrategy

type BollingerStrategy struct {
	Position  BollingerPosition `json:"position"`
	Breakout  string            `json:"breakout"`
	Squeeze   bool              `json:"squeeze"`
	BandWidth float64           `json:"band_width"`
	Signal    string            `json:"signal"`
}

BollingerStrategy provides comprehensive Bollinger Bands analysis

func AnalyzeBollingerStrategy

func AnalyzeBollingerStrategy(dataset []OHLCV, period int, multiplier float64, priceType PriceType) (BollingerStrategy, error)

AnalyzeBollingerStrategy provides complete Bollinger Bands analysis for trading decisions

type CombinedTechnicalAnalysis

type CombinedTechnicalAnalysis struct {
	SMASignal       string `json:"sma_signal"`
	BollingerSignal string `json:"bollinger_signal"`
	RSISignal       string `json:"rsi_signal"`
	FinalSignal     string `json:"final_signal"`
	Confidence      string `json:"confidence"`
	RiskLevel       string `json:"risk_level"`
}

CombinedTechnicalAnalysis integrates SMA, Bollinger Bands, and RSI

func ComprehensiveAnalysis

func ComprehensiveAnalysis(dataset []OHLCV, smaPeriod, bbPeriod, rsiPeriod int, bbMultiplier float64, priceType PriceType) (CombinedTechnicalAnalysis, error)

ComprehensiveAnalysis combines all indicators for ultimate trading decisions

type OHLCV

type OHLCV struct {
	Timestamp time.Time `json:"timestamp"`
	Open      float64   `json:"open"`
	High      float64   `json:"high"`
	Low       float64   `json:"low"`
	Close     float64   `json:"close"`
	Volume    float64   `json:"volume"`
}

OHLCV represents a single candle with Open, High, Low, Close, Volume data

func ConvertStringDataToOHLCV

func ConvertStringDataToOHLCV(stringData [][]string) ([]OHLCV, error)

ConvertStringDataToOHLCV converts old [][]string format to new OHLCV format This helper function can be used to migrate existing data

func (OHLCV) ExtractPrice

func (o OHLCV) ExtractPrice(priceType PriceType) float64

ExtractPrice extracts the specified price type from OHLCV data

type PriceType

type PriceType int

PriceType represents which price to use for SMA calculation

const (
	ClosePrice PriceType = iota
	OpenPrice
	HighPrice
	LowPrice
	TypicalPrice  // (High + Low + Close) / 3
	WeightedPrice // (High + Low + 2*Close) / 4
)

type RSICondition

type RSICondition string

RSICondition represents RSI market conditions

const (
	RSIOverbought  RSICondition = "overbought"   // RSI > 70
	RSIOversold    RSICondition = "oversold"     // RSI < 30
	RSINeutral     RSICondition = "neutral"      // 30 <= RSI <= 70
	RSIExtremeHigh RSICondition = "extreme_high" // RSI > 80
	RSIExtremeLow  RSICondition = "extreme_low"  // RSI < 20
)

type RSIDivergence

type RSIDivergence struct {
	Type       string  `json:"type"`       // bullish, bearish, none
	Strength   string  `json:"strength"`   // regular, hidden
	Confidence float64 `json:"confidence"` // 0-1 scale
}

RSIDivergence detects bullish/bearish divergences between price and RSI

func DetectRSIDivergence

func DetectRSIDivergence(dataset []OHLCV, period int, priceType PriceType, lookback int) (RSIDivergence, error)

DetectRSIDivergence identifies potential trend reversal signals

type RSIResult

type RSIResult struct {
	Timestamp string  `json:"timestamp"`
	Value     float64 `json:"value"`
	Signal    string  `json:"signal"` // overbought, oversold, neutral
}

RSIResult represents RSI calculation result

func CalculateRSI

func CalculateRSI(dataset []OHLCV, period int, priceType PriceType) ([]RSIResult, error)

CalculateRSI calculates Relative Strength Index for the given dataset

func GetLatestRSI

func GetLatestRSI(dataset []OHLCV, period int, priceType PriceType) (RSIResult, error)

GetLatestRSI returns the most recent RSI value

type RSIStrategy

type RSIStrategy struct {
	Current    RSIResult     `json:"current"`
	Condition  RSICondition  `json:"condition"`
	Divergence RSIDivergence `json:"divergence"`
	Signal     string        `json:"signal"`
	Momentum   string        `json:"momentum"` // strengthening, weakening, neutral
}

RSIStrategy provides comprehensive RSI analysis

func AnalyzeRSIStrategy

func AnalyzeRSIStrategy(dataset []OHLCV, period int, priceType PriceType) (RSIStrategy, error)

AnalyzeRSIStrategy provides complete RSI analysis for trading decisions

type SMAResult

type SMAResult struct {
	Timestamp string  `json:"timestamp"`
	Value     float64 `json:"value"`
}

SMAResult represents the result of SMA calculation

func CalculateSMA

func CalculateSMA(dataset []OHLCV, period int, priceType PriceType) ([]SMAResult, error)

CalculateSMA calculates Simple Moving Average for the given dataset

type Sharpe

type Sharpe struct {
	Coin              string  `json:"coin"`
	AvgDailyReturn    float64 `json:"avgDailyReturn"`
	DailyVolatility   float64 `json:"dailyVolatility"`
	DailySharpeRatio  float64 `json:"dailySharpeRatio"`
	AnnualSharpeRatio float64 `json:"anualSharpeRatio"`
}

type UltimateMemecoinAnalysis

type UltimateMemecoinAnalysis struct {
	Technical     CombinedTechnicalAnalysis `json:"technical"`
	Volume        VolumeStrategy            `json:"volume"`
	FinalSignal   string                    `json:"final_signal"`
	Confidence    string                    `json:"confidence"`
	RiskLevel     string                    `json:"risk_level"`
	RugPullRisk   string                    `json:"rug_pull_risk"`  // low, medium, high, extreme
	VolumeConfirm bool                      `json:"volume_confirm"` // true if volume confirms signal
}

UltimateMemecoinAnalysis combines all indicators with volume confirmation

func UltimateAnalysis

func UltimateAnalysis(dataset []OHLCV, smaPeriod, bbPeriod, rsiPeriod, vmaPeriod int, bbMultiplier float64) (UltimateMemecoinAnalysis, error)

UltimateAnalysis provides the most comprehensive memecoin analysis

type VolumeResult

type VolumeResult struct {
	Timestamp string  `json:"timestamp"`
	Volume    float64 `json:"volume"`
	VMA       float64 `json:"vma"`  // Volume Moving Average
	OBV       float64 `json:"obv"`  // On-Balance Volume
	VPT       float64 `json:"vpt"`  // Volume Price Trend
	VROC      float64 `json:"vroc"` // Volume Rate of Change
	ADL       float64 `json:"adl"`  // Accumulation/Distribution Line
}

VolumeResult represents volume analysis result

func CalculateVolumeAnalysis

func CalculateVolumeAnalysis(dataset []OHLCV, vmaPeriod, vrocPeriod int) ([]VolumeResult, error)

CalculateVolumeAnalysis performs comprehensive volume analysis

func GetLatestVolumeAnalysis

func GetLatestVolumeAnalysis(dataset []OHLCV, vmaPeriod, vrocPeriod int) (VolumeResult, error)

GetLatestVolumeAnalysis returns the most recent volume analysis

type VolumeSignal

type VolumeSignal struct {
	Type       string  `json:"type"`       // breakout, accumulation, distribution, normal
	Strength   string  `json:"strength"`   // weak, moderate, strong, extreme
	Trend      string  `json:"trend"`      // bullish, bearish, neutral
	Confidence float64 `json:"confidence"` // 0-1 scale
}

VolumeSignal represents volume-based trading signals

func DetectAccumulationDistribution

func DetectAccumulationDistribution(dataset []OHLCV, lookback int) (VolumeSignal, error)

DetectAccumulationDistribution analyzes money flow patterns

func DetectVolumeBreakout

func DetectVolumeBreakout(dataset []OHLCV, vmaPeriod int, multiplier float64) (VolumeSignal, error)

DetectVolumeBreakout identifies unusual volume activity

type VolumeStrategy

type VolumeStrategy struct {
	Current            VolumeResult `json:"current"`
	BreakoutSignal     VolumeSignal `json:"breakout_signal"`
	AccumulationSignal VolumeSignal `json:"accumulation_signal"`
	VolumeRatio        float64      `json:"volume_ratio"` // Current volume / VMA
	OBVTrend           string       `json:"obv_trend"`    // rising, falling, sideways
	Signal             string       `json:"signal"`       // buy, sell, hold, alert
}

VolumeStrategy provides comprehensive volume analysis

func AnalyzeVolumeStrategy

func AnalyzeVolumeStrategy(dataset []OHLCV, vmaPeriod, vrocPeriod int) (VolumeStrategy, error)

AnalyzeVolumeStrategy provides complete volume analysis for trading decisions

Jump to

Keyboard shortcuts

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