sigma-terminal 3.4.0__tar.gz → 3.5.0__tar.gz
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_terminal-3.5.0/.github/copilot-instructions.md +83 -0
- sigma_terminal-3.5.0/PKG-INFO +184 -0
- sigma_terminal-3.5.0/README.md +124 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/pyproject.toml +1 -1
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/scripts/build.sh +1 -1
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/scripts/create_app.py +1 -1
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/__init__.py +4 -5
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/analytics/__init__.py +11 -9
- sigma_terminal-3.5.0/sigma/app.py +445 -0
- sigma_terminal-3.5.0/sigma/backtest/__init__.py +2 -0
- sigma_terminal-3.5.0/sigma/backtest/service.py +116 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/charts.py +2 -2
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/cli.py +15 -13
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/comparison.py +2 -2
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/config.py +25 -12
- sigma_terminal-3.5.0/sigma/core/command_router.py +93 -0
- sigma_terminal-3.5.0/sigma/llm/__init__.py +3 -0
- sigma_terminal-3.5.0/sigma/llm/providers/anthropic_provider.py +196 -0
- sigma_terminal-3.5.0/sigma/llm/providers/base.py +29 -0
- sigma_terminal-3.5.0/sigma/llm/providers/google_provider.py +197 -0
- sigma_terminal-3.5.0/sigma/llm/providers/ollama_provider.py +156 -0
- sigma_terminal-3.5.0/sigma/llm/providers/openai_provider.py +168 -0
- sigma_terminal-3.5.0/sigma/llm/providers/sigma_cloud_provider.py +57 -0
- sigma_terminal-3.5.0/sigma/llm/rate_limit.py +40 -0
- sigma_terminal-3.5.0/sigma/llm/registry.py +66 -0
- sigma_terminal-3.5.0/sigma/llm/router.py +122 -0
- sigma_terminal-3.5.0/sigma/setup_agent.py +188 -0
- sigma_terminal-3.5.0/sigma/tools/__init__.py +23 -0
- sigma_terminal-3.5.0/sigma/tools/adapter.py +38 -0
- sigma_terminal-3.4.0/sigma/tools.py → sigma_terminal-3.5.0/sigma/tools/library.py +593 -1
- sigma_terminal-3.5.0/sigma/tools/registry.py +108 -0
- sigma_terminal-3.5.0/sigma/utils/extraction.py +83 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/tests/test_comprehensive.py +10 -8
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/tests/verify_ui.py +2 -2
- sigma_terminal-3.4.0/PKG-INFO +0 -264
- sigma_terminal-3.4.0/README.md +0 -204
- sigma_terminal-3.4.0/sigma/app.py +0 -1186
- sigma_terminal-3.4.0/sigma/llm.py +0 -786
- sigma_terminal-3.4.0/sigma/setup.py +0 -440
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/.github/workflows/release.yml +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/.gitignore +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/LICENSE +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/__main__.py +0 -0
- /sigma_terminal-3.4.0/sigma/backtest.py → /sigma_terminal-3.5.0/sigma/backtest/simple_engine.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/core/__init__.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/core/engine.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/core/intent.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/core/models.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/data/__init__.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/data/models.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/monitoring.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/portfolio.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/reporting.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/robustness.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/strategy.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/tools/backtest.py +0 -0
- {sigma_terminal-3.4.0 → sigma_terminal-3.5.0}/sigma/visualization.py +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Copilot Instructions for Sigma
|
|
2
|
+
|
|
3
|
+
This guide helps AI agents explore, understand, and contribute to the Sigma codebase efficiently.
|
|
4
|
+
|
|
5
|
+
## 🏗 Global Architecture & Core Components
|
|
6
|
+
|
|
7
|
+
Sigma is a terminal-based financial research agent built with Python, Textual, and multiple AI providers.
|
|
8
|
+
|
|
9
|
+
### Key Components
|
|
10
|
+
|
|
11
|
+
- **Core Engine (`sigma/core/engine.py`)**: The brain of the application. It orchestrates the entire lifecycle of a user query:
|
|
12
|
+
- **Intent Parsing**: Determines what the user wants (via `IntentParser`).
|
|
13
|
+
- **Decisiveness**: Handles vague queries (via `DecisivenessEngine`).
|
|
14
|
+
- **Execution**: Coordinates tool usage and LLM responses.
|
|
15
|
+
- **UI & Interaction (`sigma/app.py`)**: A Textual application (`App`) that manages the TUI.
|
|
16
|
+
- Handles user input, markdown rendering (`rich`), and command loop.
|
|
17
|
+
- Includes custom widgets like `RichLog`, `Input`, and `Footer`.
|
|
18
|
+
- **Tool System (`sigma/tools.py`)**: Collection of financial data functions.
|
|
19
|
+
- Wraps `yfinance` for stock data (quotes, history, financials).
|
|
20
|
+
- Functions return simple dicts or pandas objects, processed for the generic LLM context.
|
|
21
|
+
- **LLM Abstraction (`sigma/llm.py`)**: Unified interface for providers like OpenAI, Anthropic, Gemini, Groq, and Ollama.
|
|
22
|
+
- **Data Models (`sigma/core/models.py`)**: Pydantic models used for structured data exchange (e.g., `ResearchPlan`, `Alert`, `BacktestResult`).
|
|
23
|
+
|
|
24
|
+
### Data Flow
|
|
25
|
+
|
|
26
|
+
1. **User Input**: Captured in `sigma/app.py` via Textual `Input` widget.
|
|
27
|
+
2. **Engine Processing**: `SigmaEngine.process_query()` receives the input string.
|
|
28
|
+
3. **Intent Analysis**: The intent is parsed into a `ResearchPlan`.
|
|
29
|
+
4. **Execution**: The engine calls necessary tools defined in `sigma/tools.py`.
|
|
30
|
+
5. **LLM Generation**: Context + tool outputs are sent to the LLM via `sigma/llm.py`.
|
|
31
|
+
6. **Rendering**: The response is streamed back to the UI log in `sigma/app.py`.
|
|
32
|
+
|
|
33
|
+
## 🛠 Developer Workflows
|
|
34
|
+
|
|
35
|
+
### Running & Building
|
|
36
|
+
|
|
37
|
+
- **Run Locally**:
|
|
38
|
+
```bash
|
|
39
|
+
# Run as module
|
|
40
|
+
python -m sigma
|
|
41
|
+
```
|
|
42
|
+
- **Build Distribution**:
|
|
43
|
+
- Use the helper script: `scripts/build.sh`
|
|
44
|
+
- This cleans `dist/`, installs build tools, and runs `python -m build`.
|
|
45
|
+
|
|
46
|
+
### Dependencies
|
|
47
|
+
|
|
48
|
+
- **Management**: Defined in `pyproject.toml`.
|
|
49
|
+
- **Key Libraries**: `textual` (UI), `rich` (formatting), `yfinance` (data), `openai`/`anthropic`/etc (AI).
|
|
50
|
+
|
|
51
|
+
### Testing
|
|
52
|
+
|
|
53
|
+
*(Verify specific test runner, likely `pytest` based on standard python structure)*
|
|
54
|
+
- Run tests: `pytest tests/`
|
|
55
|
+
|
|
56
|
+
## 🧩 Project Conventions & Patterns
|
|
57
|
+
|
|
58
|
+
### Asynchronous Design
|
|
59
|
+
- **Core Logic**: The engine and UI event handlers are heavily asynchronous (`async def`).
|
|
60
|
+
- **Pattern**: Use `await` for LLM calls and potentially long-running data fetches to keep the TUI responsive.
|
|
61
|
+
|
|
62
|
+
### Type Safety
|
|
63
|
+
- **Strict Typing**: Use Python type hints everywhere (`typing.List`, `typing.Dict`, `typing.Optional`).
|
|
64
|
+
- **Models**: Prefer passing Pydantic objects over raw dictionaries within the `core` logic.
|
|
65
|
+
|
|
66
|
+
### UI Rendering
|
|
67
|
+
- **Rich Integration**: Use `rich` for formatting text, tables, and markdown before displaying in Textual widgets.
|
|
68
|
+
- **Animation**: See `SIGMA_FRAMES` in `sigma/app.py` for branding animations.
|
|
69
|
+
- **Color Coding**: Helper functions like `format_return` and `format_price_change` in `app.py` strictly define color semantics (Green `#22c55e` for positive, Red `#ef4444` for negative).
|
|
70
|
+
|
|
71
|
+
### Error Handling
|
|
72
|
+
- **Custom Errors**: Use `SigmaError` and `ErrorCode` (from `sigma/config.py`) for specific application failures.
|
|
73
|
+
- **Graceful Degradation**: Tools catch exceptions and return error dictionaries `{"error": "message"}` rather than crashing the app.
|
|
74
|
+
|
|
75
|
+
## 🔌 Integration Points
|
|
76
|
+
|
|
77
|
+
### AI Providers
|
|
78
|
+
- **Adding a Provider**: Update `sigma/config.py` to add to `AVAILABLE_MODELS` and implementing the wrapper in `sigma/llm.py`.
|
|
79
|
+
- **API Keys**: Stored in `~/.sigma/` (via `save_api_key`).
|
|
80
|
+
|
|
81
|
+
### Financial Data
|
|
82
|
+
- **Source**: Primarily `yfinance`.
|
|
83
|
+
- **Extension**: Add new data functions in `sigma/tools.py` and register them in `sigma/tools.py`'s `TOOLS` list or equivalent registry so the LLM knows about them.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sigma-terminal
|
|
3
|
+
Version: 3.5.0
|
|
4
|
+
Summary: Sigma - Finance Research Agent
|
|
5
|
+
Project-URL: Homepage, https://github.com/desenyon/sigma
|
|
6
|
+
Project-URL: Documentation, https://github.com/desenyon/sigma/wiki
|
|
7
|
+
Project-URL: Repository, https://github.com/desenyon/sigma
|
|
8
|
+
Author: Sigma Team
|
|
9
|
+
License: Proprietary
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,analytics,backtesting,finance,investment,portfolio,quantitative,research,stocks,terminal,trading
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
15
|
+
Classifier: License :: Other/Proprietary License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
22
|
+
Requires-Dist: anthropic>=0.18.0
|
|
23
|
+
Requires-Dist: google-genai>=1.0.0
|
|
24
|
+
Requires-Dist: groq>=0.4.0
|
|
25
|
+
Requires-Dist: httpx>=0.26.0
|
|
26
|
+
Requires-Dist: kaleido>=0.2.1
|
|
27
|
+
Requires-Dist: numpy>=1.26.0
|
|
28
|
+
Requires-Dist: openai>=1.12.0
|
|
29
|
+
Requires-Dist: pandas>=2.2.0
|
|
30
|
+
Requires-Dist: pillow>=10.2.0
|
|
31
|
+
Requires-Dist: plotext>=5.2.8
|
|
32
|
+
Requires-Dist: plotly>=5.18.0
|
|
33
|
+
Requires-Dist: pydantic-settings>=2.1.0
|
|
34
|
+
Requires-Dist: pydantic>=2.6.0
|
|
35
|
+
Requires-Dist: pyobjc-framework-cocoa>=10.0; sys_platform == 'darwin'
|
|
36
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
37
|
+
Requires-Dist: requests>=2.31.0
|
|
38
|
+
Requires-Dist: rich>=13.7.0
|
|
39
|
+
Requires-Dist: scipy>=1.12.0
|
|
40
|
+
Requires-Dist: textual>=0.47.0
|
|
41
|
+
Requires-Dist: yfinance>=0.2.36
|
|
42
|
+
Provides-Extra: all
|
|
43
|
+
Requires-Dist: black>=24.0.0; extra == 'all'
|
|
44
|
+
Requires-Dist: lean>=1.0.0; extra == 'all'
|
|
45
|
+
Requires-Dist: mypy>=1.8.0; extra == 'all'
|
|
46
|
+
Requires-Dist: py2app>=0.28.0; extra == 'all'
|
|
47
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'all'
|
|
48
|
+
Requires-Dist: pytest>=8.0.0; extra == 'all'
|
|
49
|
+
Requires-Dist: ruff>=0.2.0; extra == 'all'
|
|
50
|
+
Provides-Extra: dev
|
|
51
|
+
Requires-Dist: black>=24.0.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: mypy>=1.8.0; extra == 'dev'
|
|
53
|
+
Requires-Dist: py2app>=0.28.0; extra == 'dev'
|
|
54
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
55
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
56
|
+
Requires-Dist: ruff>=0.2.0; extra == 'dev'
|
|
57
|
+
Provides-Extra: lean
|
|
58
|
+
Requires-Dist: lean>=1.0.0; extra == 'lean'
|
|
59
|
+
Description-Content-Type: text/markdown
|
|
60
|
+
|
|
61
|
+
<h1 align="center">
|
|
62
|
+
<code>σ</code> SIGMA
|
|
63
|
+
</h1>
|
|
64
|
+
|
|
65
|
+
<p align="center">
|
|
66
|
+
<strong>The Terminal-Based Financial Research Agent</strong>
|
|
67
|
+
</p>
|
|
68
|
+
|
|
69
|
+
<p align="center">
|
|
70
|
+
<img src="https://img.shields.io/badge/version-3.5.0-blue.svg" alt="Version 3.5.0"/>
|
|
71
|
+
<img src="https://img.shields.io/badge/python-3.11+-green.svg" alt="Python 3.11+"/>
|
|
72
|
+
<img src="https://img.shields.io/badge/license-Proprietary-red.svg" alt="License"/>
|
|
73
|
+
<img src="https://img.shields.io/badge/UI-Textual-purple.svg" alt="UI Framework"/>
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## What is Sigma?
|
|
79
|
+
|
|
80
|
+
Sigma is a financial analysis terminal powered by modern AI. It unifies natural language research, quantitative backtesting, and real-time market data into a single, high-performance CLI application.
|
|
81
|
+
|
|
82
|
+
Unlike generic chat tools, Sigma is built for finance:
|
|
83
|
+
|
|
84
|
+
- **Deterministic Tools**: Real APIs for quotes, financials, and news—no hallucinations.
|
|
85
|
+
- **Local & Cloud AI**: Route queries to OpenAI, Anthropic, Gemini, or run locally with Ollama.
|
|
86
|
+
- **Integrated Backtesting**: First-class support for LEAN engine to test strategies instantly.
|
|
87
|
+
- **Privacy First**: Your API keys and strategies stay on your machine.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Installation
|
|
92
|
+
|
|
93
|
+
### Prerequisites
|
|
94
|
+
|
|
95
|
+
- Python 3.11+
|
|
96
|
+
- [Optional] Docker (for LEAN) or LEAN CLI
|
|
97
|
+
- [Optional] Ollama (for local inference)
|
|
98
|
+
|
|
99
|
+
### One-Command Setup
|
|
100
|
+
|
|
101
|
+
Sigma includes an intelligent **Setup Agent** that handles the heavy lifting.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Clone and install
|
|
105
|
+
pip install sigma-terminal
|
|
106
|
+
|
|
107
|
+
# Launch (triggers Setup Agent on first run)
|
|
108
|
+
python -m sigma
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The Setup Agent will:
|
|
112
|
+
|
|
113
|
+
1. Detect your OS and Python environment.
|
|
114
|
+
2. Install the LEAN backtesting engine (if missing).
|
|
115
|
+
3. Install and configure Ollama (if missing).
|
|
116
|
+
4. help you add API keys for data providers (Polygon, Alpha Vantage, etc.).
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Usage
|
|
121
|
+
|
|
122
|
+
Sigma is designed for natural language. Just type what you need.
|
|
123
|
+
|
|
124
|
+
### Market Research
|
|
125
|
+
|
|
126
|
+
> "Analyze AAPL and compare it with MSFT for the last 5 years"
|
|
127
|
+
> "Get me the latest earnings report for NVDA and summarize risks"
|
|
128
|
+
> "Show me a chart of SPY vs QQQ YTD"
|
|
129
|
+
|
|
130
|
+
### Quantitative Backtesting
|
|
131
|
+
|
|
132
|
+
> "Backtest a simple moving average crossover on BTC-USD from 2020"
|
|
133
|
+
> "Run a momentum strategy on TSLA, weekly rebalance"
|
|
134
|
+
|
|
135
|
+
### Tool & System Control
|
|
136
|
+
|
|
137
|
+
> "Switch model to local llama3"
|
|
138
|
+
> "List all available tools"
|
|
139
|
+
> "/backtest AAPL -s sma_cross" (Shortcuts available)
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Architecture
|
|
144
|
+
|
|
145
|
+
Sigma v3.5.0 is built on a modular, event-driven architecture:
|
|
146
|
+
|
|
147
|
+
| Component | Description |
|
|
148
|
+
| -------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
149
|
+
| **Core Engine** | Orchestrates intent parsing, tool routing, and result synthesis. |
|
|
150
|
+
| **LLM Router** | Intelligent routing between OpenAI, Anthropic, Google, and Ollama. Handles rate limits and fallbacks. |
|
|
151
|
+
| **Tool Registry** | A typed system connecting the LLM to 30+ financial data functions. |
|
|
152
|
+
| **Backtest Service** | Wraps the LEAN engine to stream logs and results directly to the TUI. |
|
|
153
|
+
| **UI (Textual)** | A multi-pane terminal interface with real-time streaming, trace logs, and plotting. |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Configuration
|
|
158
|
+
|
|
159
|
+
Configuration is stored in `~/.sigma/` and managed automatically. You can also edit it manually:
|
|
160
|
+
|
|
161
|
+
`~/.sigma/config.json`:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"default_model": "gpt-4o",
|
|
166
|
+
"ollama_url": "http://localhost:11434",
|
|
167
|
+
"data_providers": {
|
|
168
|
+
"polygon": "ENABLED",
|
|
169
|
+
"yfinance": "FALLBACK"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Supported Providers
|
|
175
|
+
|
|
176
|
+
- **AI**: OpenAI, Anthropic (Claude), Google (Gemini), Ollama (Local)
|
|
177
|
+
- **Data**: Polygon.io, Alpha Vantage, Financial Modeling Prep, YFinance (Default)
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
Proprietary / Closed Source.
|
|
184
|
+
Copyright (c) 2026 Sigma Team. All Rights Reserved.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<code>σ</code> SIGMA
|
|
3
|
+
</h1>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<strong>The Terminal-Based Financial Research Agent</strong>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="https://img.shields.io/badge/version-3.5.0-blue.svg" alt="Version 3.5.0"/>
|
|
11
|
+
<img src="https://img.shields.io/badge/python-3.11+-green.svg" alt="Python 3.11+"/>
|
|
12
|
+
<img src="https://img.shields.io/badge/license-Proprietary-red.svg" alt="License"/>
|
|
13
|
+
<img src="https://img.shields.io/badge/UI-Textual-purple.svg" alt="UI Framework"/>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What is Sigma?
|
|
19
|
+
|
|
20
|
+
Sigma is a financial analysis terminal powered by modern AI. It unifies natural language research, quantitative backtesting, and real-time market data into a single, high-performance CLI application.
|
|
21
|
+
|
|
22
|
+
Unlike generic chat tools, Sigma is built for finance:
|
|
23
|
+
|
|
24
|
+
- **Deterministic Tools**: Real APIs for quotes, financials, and news—no hallucinations.
|
|
25
|
+
- **Local & Cloud AI**: Route queries to OpenAI, Anthropic, Gemini, or run locally with Ollama.
|
|
26
|
+
- **Integrated Backtesting**: First-class support for LEAN engine to test strategies instantly.
|
|
27
|
+
- **Privacy First**: Your API keys and strategies stay on your machine.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### Prerequisites
|
|
34
|
+
|
|
35
|
+
- Python 3.11+
|
|
36
|
+
- [Optional] Docker (for LEAN) or LEAN CLI
|
|
37
|
+
- [Optional] Ollama (for local inference)
|
|
38
|
+
|
|
39
|
+
### One-Command Setup
|
|
40
|
+
|
|
41
|
+
Sigma includes an intelligent **Setup Agent** that handles the heavy lifting.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Clone and install
|
|
45
|
+
pip install sigma-terminal
|
|
46
|
+
|
|
47
|
+
# Launch (triggers Setup Agent on first run)
|
|
48
|
+
python -m sigma
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The Setup Agent will:
|
|
52
|
+
|
|
53
|
+
1. Detect your OS and Python environment.
|
|
54
|
+
2. Install the LEAN backtesting engine (if missing).
|
|
55
|
+
3. Install and configure Ollama (if missing).
|
|
56
|
+
4. help you add API keys for data providers (Polygon, Alpha Vantage, etc.).
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
Sigma is designed for natural language. Just type what you need.
|
|
63
|
+
|
|
64
|
+
### Market Research
|
|
65
|
+
|
|
66
|
+
> "Analyze AAPL and compare it with MSFT for the last 5 years"
|
|
67
|
+
> "Get me the latest earnings report for NVDA and summarize risks"
|
|
68
|
+
> "Show me a chart of SPY vs QQQ YTD"
|
|
69
|
+
|
|
70
|
+
### Quantitative Backtesting
|
|
71
|
+
|
|
72
|
+
> "Backtest a simple moving average crossover on BTC-USD from 2020"
|
|
73
|
+
> "Run a momentum strategy on TSLA, weekly rebalance"
|
|
74
|
+
|
|
75
|
+
### Tool & System Control
|
|
76
|
+
|
|
77
|
+
> "Switch model to local llama3"
|
|
78
|
+
> "List all available tools"
|
|
79
|
+
> "/backtest AAPL -s sma_cross" (Shortcuts available)
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Architecture
|
|
84
|
+
|
|
85
|
+
Sigma v3.5.0 is built on a modular, event-driven architecture:
|
|
86
|
+
|
|
87
|
+
| Component | Description |
|
|
88
|
+
| -------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
89
|
+
| **Core Engine** | Orchestrates intent parsing, tool routing, and result synthesis. |
|
|
90
|
+
| **LLM Router** | Intelligent routing between OpenAI, Anthropic, Google, and Ollama. Handles rate limits and fallbacks. |
|
|
91
|
+
| **Tool Registry** | A typed system connecting the LLM to 30+ financial data functions. |
|
|
92
|
+
| **Backtest Service** | Wraps the LEAN engine to stream logs and results directly to the TUI. |
|
|
93
|
+
| **UI (Textual)** | A multi-pane terminal interface with real-time streaming, trace logs, and plotting. |
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
Configuration is stored in `~/.sigma/` and managed automatically. You can also edit it manually:
|
|
100
|
+
|
|
101
|
+
`~/.sigma/config.json`:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"default_model": "gpt-4o",
|
|
106
|
+
"ollama_url": "http://localhost:11434",
|
|
107
|
+
"data_providers": {
|
|
108
|
+
"polygon": "ENABLED",
|
|
109
|
+
"yfinance": "FALLBACK"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Supported Providers
|
|
115
|
+
|
|
116
|
+
- **AI**: OpenAI, Anthropic (Claude), Google (Gemini), Ollama (Local)
|
|
117
|
+
- **Data**: Polygon.io, Alpha Vantage, Financial Modeling Prep, YFinance (Default)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
Proprietary / Closed Source.
|
|
124
|
+
Copyright (c) 2026 Sigma Team. All Rights Reserved.
|
|
@@ -7,7 +7,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
7
7
|
PROJECT_DIR="$( cd "$SCRIPT_DIR/.." && pwd )"
|
|
8
8
|
|
|
9
9
|
echo "========================================"
|
|
10
|
-
echo " Sigma v3.4.
|
|
10
|
+
echo " Sigma v3.4.1 Build Script"
|
|
11
11
|
echo "========================================"
|
|
12
12
|
echo ""
|
|
13
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Sigma v3.
|
|
2
|
+
Sigma v3.5.0 - Finance Research Agent
|
|
3
3
|
|
|
4
4
|
An elite finance research agent combining:
|
|
5
5
|
- Multi-provider AI (Google Gemini, OpenAI, Anthropic, Groq, xAI, Ollama)
|
|
@@ -12,8 +12,8 @@ An elite finance research agent combining:
|
|
|
12
12
|
- Monitoring, alerts, and watchlists
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
__version__ = "3.
|
|
16
|
-
__author__ = "
|
|
15
|
+
__version__ = "3.5.0"
|
|
16
|
+
__author__ = "Desenyon"
|
|
17
17
|
|
|
18
18
|
# Core functionality
|
|
19
19
|
from .app import launch, SigmaApp
|
|
@@ -101,7 +101,7 @@ from .robustness import (
|
|
|
101
101
|
)
|
|
102
102
|
|
|
103
103
|
# Setup
|
|
104
|
-
from .
|
|
104
|
+
from .setup_agent import run_setup
|
|
105
105
|
|
|
106
106
|
__all__ = [
|
|
107
107
|
# Version
|
|
@@ -181,5 +181,4 @@ __all__ = [
|
|
|
181
181
|
|
|
182
182
|
# Setup
|
|
183
183
|
"run_setup",
|
|
184
|
-
"quick_setup",
|
|
185
184
|
]
|
|
@@ -34,10 +34,10 @@ class PerformanceAnalytics:
|
|
|
34
34
|
if n < 2:
|
|
35
35
|
return {}
|
|
36
36
|
|
|
37
|
-
#
|
|
38
|
-
total_return = (1 + returns).prod() - 1
|
|
37
|
+
# Helper to ensure numeric
|
|
38
|
+
total_return = float((1 + returns).prod() - 1) # type: ignore
|
|
39
39
|
cagr = (1 + total_return) ** (periods_per_year / n) - 1
|
|
40
|
-
volatility = returns.std() * np.sqrt(periods_per_year)
|
|
40
|
+
volatility = float(returns.std() * np.sqrt(periods_per_year)) # type: ignore
|
|
41
41
|
|
|
42
42
|
# Downside metrics
|
|
43
43
|
negative_returns = returns[returns < 0]
|
|
@@ -98,7 +98,7 @@ class PerformanceAnalytics:
|
|
|
98
98
|
alpha = cagr - (risk_free_rate + beta * (aligned.iloc[:, 1].mean() * periods_per_year - risk_free_rate))
|
|
99
99
|
|
|
100
100
|
# R-squared
|
|
101
|
-
correlation = aligned.corr().iloc[0, 1]
|
|
101
|
+
correlation = float(aligned.corr().iloc[0, 1]) # type: ignore
|
|
102
102
|
r_squared = correlation ** 2
|
|
103
103
|
|
|
104
104
|
# Tracking error
|
|
@@ -278,7 +278,8 @@ class SeasonalityAnalyzer:
|
|
|
278
278
|
@staticmethod
|
|
279
279
|
def monthly_seasonality(returns: pd.Series) -> Dict[int, Dict[str, float]]:
|
|
280
280
|
"""Analyze month-of-year seasonality."""
|
|
281
|
-
|
|
281
|
+
idx = pd.DatetimeIndex(returns.index)
|
|
282
|
+
monthly = returns.groupby(idx.month)
|
|
282
283
|
|
|
283
284
|
result = {}
|
|
284
285
|
for month in range(1, 13):
|
|
@@ -299,7 +300,8 @@ class SeasonalityAnalyzer:
|
|
|
299
300
|
@staticmethod
|
|
300
301
|
def day_of_week_seasonality(returns: pd.Series) -> Dict[int, Dict[str, float]]:
|
|
301
302
|
"""Analyze day-of-week seasonality."""
|
|
302
|
-
|
|
303
|
+
idx = pd.DatetimeIndex(returns.index)
|
|
304
|
+
daily = returns.groupby(idx.dayofweek)
|
|
303
305
|
|
|
304
306
|
day_names = {0: "Monday", 1: "Tuesday", 2: "Wednesday", 3: "Thursday", 4: "Friday"}
|
|
305
307
|
|
|
@@ -329,7 +331,7 @@ class SeasonalityAnalyzer:
|
|
|
329
331
|
post_returns = []
|
|
330
332
|
|
|
331
333
|
for event_date in event_dates:
|
|
332
|
-
event_idx = returns.index.get_indexer([event_date], method='nearest')[0]
|
|
334
|
+
event_idx = returns.index.get_indexer(pd.Index([event_date]), method='nearest')[0]
|
|
333
335
|
|
|
334
336
|
if event_idx >= pre_days and event_idx < len(returns) - post_days:
|
|
335
337
|
pre_ret = returns.iloc[event_idx - pre_days:event_idx].sum()
|
|
@@ -387,8 +389,8 @@ class FactorAnalyzer:
|
|
|
387
389
|
if len(aligned) < 30:
|
|
388
390
|
return {}
|
|
389
391
|
|
|
390
|
-
y = aligned["asset"].
|
|
391
|
-
X = aligned.drop("asset", axis=1).
|
|
392
|
+
y = aligned["asset"].to_numpy(dtype=float)
|
|
393
|
+
X = aligned.drop("asset", axis=1).to_numpy(dtype=float)
|
|
392
394
|
X = np.column_stack([np.ones(len(X)), X]) # Add intercept
|
|
393
395
|
|
|
394
396
|
# OLS regression
|