sigma-terminal 2.0.2__py3-none-any.whl → 3.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sigma/__init__.py +182 -6
- sigma/__main__.py +2 -2
- sigma/analytics/__init__.py +636 -0
- sigma/app.py +563 -898
- sigma/backtest.py +372 -0
- sigma/charts.py +407 -0
- sigma/cli.py +434 -0
- sigma/comparison.py +611 -0
- sigma/config.py +195 -0
- sigma/core/__init__.py +4 -17
- sigma/core/engine.py +493 -0
- sigma/core/intent.py +595 -0
- sigma/core/models.py +516 -125
- sigma/data/__init__.py +681 -0
- sigma/data/models.py +130 -0
- sigma/llm.py +401 -0
- sigma/monitoring.py +666 -0
- sigma/portfolio.py +697 -0
- sigma/reporting.py +658 -0
- sigma/robustness.py +675 -0
- sigma/setup.py +305 -402
- sigma/strategy.py +753 -0
- sigma/tools/backtest.py +23 -5
- sigma/tools.py +617 -0
- sigma/visualization.py +766 -0
- sigma_terminal-3.2.0.dist-info/METADATA +298 -0
- sigma_terminal-3.2.0.dist-info/RECORD +30 -0
- sigma_terminal-3.2.0.dist-info/entry_points.txt +6 -0
- sigma_terminal-3.2.0.dist-info/licenses/LICENSE +25 -0
- sigma/core/agent.py +0 -205
- sigma/core/config.py +0 -119
- sigma/core/llm.py +0 -794
- sigma/tools/__init__.py +0 -5
- sigma/tools/charts.py +0 -400
- sigma/tools/financial.py +0 -1457
- sigma/ui/__init__.py +0 -1
- sigma_terminal-2.0.2.dist-info/METADATA +0 -222
- sigma_terminal-2.0.2.dist-info/RECORD +0 -19
- sigma_terminal-2.0.2.dist-info/entry_points.txt +0 -2
- sigma_terminal-2.0.2.dist-info/licenses/LICENSE +0 -42
- {sigma_terminal-2.0.2.dist-info → sigma_terminal-3.2.0.dist-info}/WHEEL +0 -0
sigma/config.py
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""Configuration management for Sigma v3.2.0."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from enum import Enum
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
from pydantic import Field
|
|
9
|
+
from pydantic_settings import BaseSettings
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
__version__ = "3.2.0"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class LLMProvider(str, Enum):
|
|
16
|
+
"""Supported LLM providers."""
|
|
17
|
+
GOOGLE = "google"
|
|
18
|
+
OPENAI = "openai"
|
|
19
|
+
ANTHROPIC = "anthropic"
|
|
20
|
+
GROQ = "groq"
|
|
21
|
+
XAI = "xai"
|
|
22
|
+
OLLAMA = "ollama"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Available models per provider
|
|
26
|
+
AVAILABLE_MODELS = {
|
|
27
|
+
"google": ["gemini-2.0-flash", "gemini-1.5-flash", "gemini-1.5-pro"],
|
|
28
|
+
"openai": ["gpt-4o", "gpt-4o-mini", "gpt-4-turbo", "o1-preview", "o1-mini"],
|
|
29
|
+
"anthropic": ["claude-sonnet-4-20250514", "claude-3-5-sonnet-20241022", "claude-3-opus-20240229"],
|
|
30
|
+
"groq": ["llama-3.3-70b-versatile", "llama-3.1-8b-instant", "mixtral-8x7b-32768"],
|
|
31
|
+
"xai": ["grok-2", "grok-2-mini"],
|
|
32
|
+
"ollama": ["llama3.2", "llama3.1", "mistral", "codellama", "phi3"],
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# Config directory
|
|
36
|
+
CONFIG_DIR = Path.home() / ".sigma"
|
|
37
|
+
CONFIG_FILE = CONFIG_DIR / "config.env"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Settings(BaseSettings):
|
|
41
|
+
"""Application settings."""
|
|
42
|
+
|
|
43
|
+
# Provider settings
|
|
44
|
+
default_provider: LLMProvider = LLMProvider.GOOGLE
|
|
45
|
+
default_model: str = Field(default="gemini-2.0-flash", alias="DEFAULT_MODEL")
|
|
46
|
+
|
|
47
|
+
# API Keys
|
|
48
|
+
google_api_key: Optional[str] = Field(default=None, alias="GOOGLE_API_KEY")
|
|
49
|
+
openai_api_key: Optional[str] = Field(default=None, alias="OPENAI_API_KEY")
|
|
50
|
+
anthropic_api_key: Optional[str] = Field(default=None, alias="ANTHROPIC_API_KEY")
|
|
51
|
+
groq_api_key: Optional[str] = Field(default=None, alias="GROQ_API_KEY")
|
|
52
|
+
xai_api_key: Optional[str] = Field(default=None, alias="XAI_API_KEY")
|
|
53
|
+
|
|
54
|
+
# Model settings
|
|
55
|
+
google_model: str = "gemini-2.0-flash"
|
|
56
|
+
openai_model: str = "gpt-4o"
|
|
57
|
+
anthropic_model: str = "claude-sonnet-4-20250514"
|
|
58
|
+
groq_model: str = "llama-3.3-70b-versatile"
|
|
59
|
+
xai_model: str = "grok-2"
|
|
60
|
+
ollama_model: str = "llama3.2"
|
|
61
|
+
|
|
62
|
+
# Ollama settings
|
|
63
|
+
ollama_host: str = "http://localhost:11434"
|
|
64
|
+
|
|
65
|
+
# Data API keys
|
|
66
|
+
alpha_vantage_api_key: str = "6ER128DD3NQUPTVC" # Built-in free key
|
|
67
|
+
exa_api_key: Optional[str] = None
|
|
68
|
+
|
|
69
|
+
class Config:
|
|
70
|
+
env_file = str(CONFIG_FILE)
|
|
71
|
+
env_file_encoding = "utf-8"
|
|
72
|
+
extra = "ignore"
|
|
73
|
+
|
|
74
|
+
def get_api_key(self, provider: LLMProvider) -> Optional[str]:
|
|
75
|
+
"""Get API key for a provider."""
|
|
76
|
+
key_map = {
|
|
77
|
+
LLMProvider.GOOGLE: self.google_api_key,
|
|
78
|
+
LLMProvider.OPENAI: self.openai_api_key,
|
|
79
|
+
LLMProvider.ANTHROPIC: self.anthropic_api_key,
|
|
80
|
+
LLMProvider.GROQ: self.groq_api_key,
|
|
81
|
+
LLMProvider.XAI: self.xai_api_key,
|
|
82
|
+
LLMProvider.OLLAMA: None, # No key needed
|
|
83
|
+
}
|
|
84
|
+
return key_map.get(provider)
|
|
85
|
+
|
|
86
|
+
def get_model(self, provider: LLMProvider) -> str:
|
|
87
|
+
"""Get model for a provider."""
|
|
88
|
+
model_map = {
|
|
89
|
+
LLMProvider.GOOGLE: self.google_model,
|
|
90
|
+
LLMProvider.OPENAI: self.openai_model,
|
|
91
|
+
LLMProvider.ANTHROPIC: self.anthropic_model,
|
|
92
|
+
LLMProvider.GROQ: self.groq_model,
|
|
93
|
+
LLMProvider.XAI: self.xai_model,
|
|
94
|
+
LLMProvider.OLLAMA: self.ollama_model,
|
|
95
|
+
}
|
|
96
|
+
return model_map.get(provider, "")
|
|
97
|
+
|
|
98
|
+
def get_available_providers(self) -> list[LLMProvider]:
|
|
99
|
+
"""Get list of providers with configured API keys."""
|
|
100
|
+
available = []
|
|
101
|
+
for provider in LLMProvider:
|
|
102
|
+
if provider == LLMProvider.OLLAMA:
|
|
103
|
+
available.append(provider) # Always available
|
|
104
|
+
elif self.get_api_key(provider):
|
|
105
|
+
available.append(provider)
|
|
106
|
+
return available
|
|
107
|
+
|
|
108
|
+
def is_configured(self) -> bool:
|
|
109
|
+
"""Check if at least one provider is configured."""
|
|
110
|
+
return len(self.get_available_providers()) > 0
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def get_settings() -> Settings:
|
|
114
|
+
"""Get application settings."""
|
|
115
|
+
# Ensure config directory exists
|
|
116
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
117
|
+
|
|
118
|
+
# Load from environment and config file
|
|
119
|
+
return Settings()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def save_api_key(provider: str, key: str) -> None:
|
|
123
|
+
"""Save an API key to the config file."""
|
|
124
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
125
|
+
|
|
126
|
+
# Read existing config
|
|
127
|
+
config = {}
|
|
128
|
+
if CONFIG_FILE.exists():
|
|
129
|
+
with open(CONFIG_FILE) as f:
|
|
130
|
+
for line in f:
|
|
131
|
+
line = line.strip()
|
|
132
|
+
if "=" in line and not line.startswith("#"):
|
|
133
|
+
k, v = line.split("=", 1)
|
|
134
|
+
config[k] = v
|
|
135
|
+
|
|
136
|
+
# Update key
|
|
137
|
+
key_map = {
|
|
138
|
+
"google": "GOOGLE_API_KEY",
|
|
139
|
+
"openai": "OPENAI_API_KEY",
|
|
140
|
+
"anthropic": "ANTHROPIC_API_KEY",
|
|
141
|
+
"groq": "GROQ_API_KEY",
|
|
142
|
+
"xai": "XAI_API_KEY",
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
env_key = key_map.get(provider.lower())
|
|
146
|
+
if env_key:
|
|
147
|
+
config[env_key] = key
|
|
148
|
+
|
|
149
|
+
# Write back
|
|
150
|
+
with open(CONFIG_FILE, "w") as f:
|
|
151
|
+
f.write("# Sigma Configuration\n\n")
|
|
152
|
+
for k, v in sorted(config.items()):
|
|
153
|
+
f.write(f"{k}={v}\n")
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def get_api_key(provider: str) -> Optional[str]:
|
|
157
|
+
"""Get API key for a provider."""
|
|
158
|
+
settings = get_settings()
|
|
159
|
+
try:
|
|
160
|
+
return settings.get_api_key(LLMProvider(provider.lower()))
|
|
161
|
+
except ValueError:
|
|
162
|
+
return None
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def save_setting(key: str, value: str) -> None:
|
|
166
|
+
"""Save a setting to the config file."""
|
|
167
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
168
|
+
|
|
169
|
+
# Read existing config
|
|
170
|
+
config = {}
|
|
171
|
+
if CONFIG_FILE.exists():
|
|
172
|
+
with open(CONFIG_FILE) as f:
|
|
173
|
+
for line in f:
|
|
174
|
+
line = line.strip()
|
|
175
|
+
if "=" in line and not line.startswith("#"):
|
|
176
|
+
k, v = line.split("=", 1)
|
|
177
|
+
config[k] = v
|
|
178
|
+
|
|
179
|
+
# Map setting name to config key
|
|
180
|
+
setting_map = {
|
|
181
|
+
"default_provider": "DEFAULT_PROVIDER",
|
|
182
|
+
"default_model": "DEFAULT_MODEL",
|
|
183
|
+
"output_dir": "OUTPUT_DIR",
|
|
184
|
+
"cache_enabled": "CACHE_ENABLED",
|
|
185
|
+
"lean_cli_path": "LEAN_CLI_PATH",
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
config_key = setting_map.get(key, key.upper())
|
|
189
|
+
config[config_key] = str(value)
|
|
190
|
+
|
|
191
|
+
# Write back
|
|
192
|
+
with open(CONFIG_FILE, "w") as f:
|
|
193
|
+
f.write("# Sigma Configuration\n\n")
|
|
194
|
+
for k, v in sorted(config.items()):
|
|
195
|
+
f.write(f"{k}={v}\n")
|
sigma/core/__init__.py
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
"""Core
|
|
1
|
+
"""Core infrastructure for Sigma Financial Intelligence Platform."""
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from sigma.core.models import Message, MessageRole, ToolCall, ToolResult
|
|
7
|
-
|
|
8
|
-
__all__ = [
|
|
9
|
-
"SigmaAgent",
|
|
10
|
-
"LLMProvider",
|
|
11
|
-
"Settings",
|
|
12
|
-
"get_settings",
|
|
13
|
-
"get_llm",
|
|
14
|
-
"Message",
|
|
15
|
-
"MessageRole",
|
|
16
|
-
"ToolCall",
|
|
17
|
-
"ToolResult",
|
|
18
|
-
]
|
|
3
|
+
from .models import *
|
|
4
|
+
from .intent import *
|
|
5
|
+
from .engine import *
|