feat: add portfolio

This commit is contained in:
ytshih committed 2026-09-11 09:54:49 +08:00
1 parent ba63c5deb0
commit f09cf4d5c2
11 files changed
+669 -38

No files matched your search

+24 -5
View File
@@ -87,13 +87,32 @@ type ArchiveConfig struct {
Dir string `yaml:"dir"`
}
// PortfolioConfig controls the paper-trading portfolio state that Claude's
// buy/sell recommendations are executed against. State is always on
// (Claude's recommendations are meaningless without something tracking
// them): a fresh portfolio starts at InitialBudgetUSD (default $10,000) and
// its state persists across runs in a JSON file under Dir.
type PortfolioConfig struct {
// Dir is the directory portfolio.json and memory.md are stored in.
// Supports a leading "~". Defaults to "~/.local/state/stonks" if empty.
Dir string `yaml:"dir"`
// InitialBudgetUSD seeds a brand-new portfolio's starting cash. Defaults
// to 10000 if zero. Ignored once a portfolio.json already exists.
InitialBudgetUSD float64 `yaml:"initial_budget_usd"`
// MaxLeverage caps the leverage multiplier any single recommendation can
// request; requests above it are clamped down by internal/portfolio, not
// trusted from Claude. Defaults to 3 if zero.
MaxLeverage float64 `yaml:"max_leverage"`
}
// Config is the full stonks configuration.
type Config struct {
Targets Targets `yaml:"targets"`
Fetchers []PluginConfig `yaml:"fetchers"`
Analyzer AnalyzerConfig `yaml:"analyzer"`
Outputs []PluginConfig `yaml:"outputs"`
Archive ArchiveConfig `yaml:"archive"`
Targets Targets `yaml:"targets"`
Fetchers []PluginConfig `yaml:"fetchers"`
Analyzer AnalyzerConfig `yaml:"analyzer"`
Outputs []PluginConfig `yaml:"outputs"`
Archive ArchiveConfig `yaml:"archive"`
Portfolio PortfolioConfig `yaml:"portfolio"`
}
// Load reads and parses the config file at path.