Files
nofx/nofxi/internal/thinking/engine.go
shinchan-zhai cf7bf16c28 feat: init nofxi - AI Trading Agent module
NOFXi — Your AI Trading Agent, built on NOFX.

Architecture:
- Agent Core: intent routing, conversation memory, trade confirmation
- Memory: SQLite (trades, conversations, preferences, strategies)
- Thinking: LLM client (OpenAI/claw402/DeepSeek compatible)
- Execution: Bridge to NOFX trader engine (9 exchanges)
- Perception: Market monitor, price alerts, anomaly detection
- Interaction: Telegram bot + REST API + OpenAI-compatible endpoint

Features:
- Natural language trading (中英文)
- /buy /sell /analyze /watch /alert /positions /balance
- Daily P/L reports, portfolio risk checks
- Trade confirmation flow (safety first)
- Price polling and alert notifications
2026-03-22 17:48:14 +08:00

29 lines
947 B
Go

package thinking
import "context"
// Engine is the AI decision-making interface.
type Engine interface {
// Chat sends a message to the LLM with conversation context and returns a response.
Chat(ctx context.Context, messages []Message) (string, error)
// Analyze asks the AI to analyze market data and provide a trading recommendation.
Analyze(ctx context.Context, prompt string) (*Analysis, error)
}
// Message represents a chat message.
type Message struct {
Role string `json:"role"` // "system", "user", "assistant"
Content string `json:"content"`
}
// Analysis holds an AI trading recommendation.
type Analysis struct {
Action string `json:"action"` // "buy", "sell", "hold", "wait"
Symbol string `json:"symbol"`
Confidence float64 `json:"confidence"` // 0.0 - 1.0
Reasoning string `json:"reasoning"`
StopLoss float64 `json:"stop_loss,omitempty"`
TakeProfit float64 `json:"take_profit,omitempty"`
}