Files
aitrade/pkg/app/strategy/strategy.go
T
kaedwen ea141eb012
Build and Push Docker Image / build-and-push (push) Failing after 1m41s
initial
2026-07-02 20:09:44 +02:00

52 lines
1.2 KiB
Go

package strategy
import (
"context"
"github.com/pheinrich/aitrade/pkg/model"
)
type Strategy interface {
Name() string
Analyze(ctx context.Context, market *MarketData, news []*model.NewsArticle) (*TradeSignal, error)
CalculatePositionSize(price float64, confidence float64, availableCapital float64) int
GetRiskParams() RiskParameters
}
type MarketData struct {
Symbol string
LastPrice float64
BidPrice float64
AskPrice float64
Volume int64
Change float64
ChangePercent float64
}
type TradeSignal struct {
Symbol string
Action model.ActionType
Quantity int
Confidence float64 // 0.0 - 1.0
Reasoning string
}
type RiskParameters struct {
MaxParallelTrades int
MaxTradesPerHour int
PositionSizePercent float64 // Percentage of capital per trade
StopLossPercent float64
}
// Factory function to create strategy based on name
func NewStrategy(strategyName string, stopLossEnabled bool, stopLossPercent float64) Strategy {
switch strategyName {
case "defensive":
return NewDefensiveStrategy(stopLossEnabled, stopLossPercent)
case "aggressive":
return NewAggressiveStrategy(stopLossEnabled, stopLossPercent)
default: // "normal"
return NewNormalStrategy(stopLossEnabled, stopLossPercent)
}
}