ai

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentDecision

type AgentDecision struct {
	Agent      string
	Provider   Provider
	Signal     Signal
	Confidence float64 // 0.0 to 1.0
	Reasoning  string
}

AgentDecision is the output from a single AI agent

type ConsensusResult

type ConsensusResult struct {
	FinalSignal   Signal
	BuyScore      float64
	SellScore     float64
	HoldScore     float64
	AvgConfidence float64
	Decisions     []AgentDecision
	SentimentData *SentimentData
}

ConsensusResult aggregates decisions from all agents

func (*ConsensusResult) ShouldBuy

func (cr *ConsensusResult) ShouldBuy() bool

ShouldBuy returns true if AI consensus supports buying

func (*ConsensusResult) ShouldSell

func (cr *ConsensusResult) ShouldSell() bool

ShouldSell returns true if AI consensus supports selling

func (*ConsensusResult) String

func (cr *ConsensusResult) String() string

String returns a human-readable summary

type LLMClient

type LLMClient struct {
	Provider   Provider
	APIKey     string
	Model      string
	BaseURL    string
	HTTPClient *http.Client
}

LLMClient provides a unified interface across AI providers

func NewLLMClient

func NewLLMClient(provider Provider, apiKey, model string) *LLMClient

NewLLMClient creates a client for the specified provider

func (*LLMClient) Chat

func (c *LLMClient) Chat(ctx context.Context, systemPrompt string, messages []Message) (*LLMResponse, error)

Chat sends a prompt and returns the model's response

type LLMResponse

type LLMResponse struct {
	Content string
}

LLMResponse is the parsed response from any provider

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a chat message

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator manages multiple AI agents and produces consensus decisions

func NewOrchestrator

func NewOrchestrator(openaiKey, deepseekKey, claudeKey string, openaiModel, deepseekModel, claudeModel string) *Orchestrator

NewOrchestrator builds an orchestrator from the available API keys

func (*Orchestrator) Analyze

func (o *Orchestrator) Analyze(ctx context.Context, ts *TechnicalSnapshot, tradeType string) (*ConsensusResult, error)

Analyze runs the multi-agent pipeline and returns a consensus

func (*Orchestrator) IsEnabled

func (o *Orchestrator) IsEnabled() bool

IsEnabled returns true if at least one provider is configured

type Provider

type Provider string

Provider identifies which LLM backend to use

const (
	ProviderOpenAI   Provider = "openai"
	ProviderDeepSeek Provider = "deepseek"
	ProviderClaude   Provider = "claude"
)

type SentimentData

type SentimentData struct {
	NewsHeadlines  []string
	FearGreedIndex int
	FearGreedLabel string
	FetchedAt      time.Time
}

SentimentData holds aggregated market sentiment from multiple sources

func FetchSentimentData

func FetchSentimentData(ctx context.Context, symbol string) (*SentimentData, error)

FetchSentimentData gathers sentiment data from free public APIs

func (*SentimentData) FormatForPrompt

func (sd *SentimentData) FormatForPrompt() string

FormatForPrompt returns a text block ready to include in an LLM prompt

type Signal

type Signal string

Signal represents a trading recommendation

const (
	SignalBuy     Signal = "BUY"
	SignalSell    Signal = "SELL"
	SignalHold    Signal = "HOLD"
	SignalUnknown Signal = "UNKNOWN"
)

type TechnicalSnapshot

type TechnicalSnapshot struct {
	Symbol         string
	Price          float64
	PrevPrice      float64
	RSI            float64
	MACDLine       float64
	SignalLine     float64
	PrevMACDLine   float64
	PrevSignalLine float64
	UpperBand      float64
	LowerBand      float64
	DEMA           float64
	Tendency       string
	ADX            float64
	Volume         float64
	AvgVolume      float64
}

TechnicalSnapshot contains the current state of all technical indicators

func (*TechnicalSnapshot) FormatForPrompt

func (ts *TechnicalSnapshot) FormatForPrompt() string

FormatForPrompt returns technical data formatted for LLM consumption

Jump to

Keyboard shortcuts

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