Trading Strategy Comparator is a local-first application for checking whether a Pine Script strategy and a Python strategy produce the same indicator values and trade behavior on the same candle set.
The primary goal is parity analysis:
- compare indicator outputs
- compare trade events
- find the first divergence
- explain likely causes
- help the user inspect or fix the Python side with a local Ollama assistant
The current product supports:
- imported Excel and CSV datasets
- deterministic replay on saved candles
- dataset-backed incremental playback called
live - manual Pine bridge artifacts uploaded through the UI
- local Python strategy execution
- LLM analysis using locally installed Ollama models
The current product does not yet support:
- fully automated TradingView export capture
- broker execution
- exchange-connected real-time streaming
- multi-user authentication
- production-grade secure sandboxing
- Stage:
alpha / local pilot - Intended user: one user on one machine
- Intended use: historical comparison, debugging, and workflow validation
- Not intended use: unattended production trading or multi-user hosted deployment
flowchart TD
IMPORTS["Imports route"] --> API["FastAPI API"]
WORKSPACE["Workspace route"] --> API
RUNS["Runs route"] --> API
SETTINGS["Settings route"] --> API
API --> DS["DatasetService"]
API --> RS["RunService"]
API --> BS["BridgeService"]
API --> CS["ChatService"]
API --> PS["PermissionManager"]
API --> DEP["DependencyService"]
DS --> DM["DataManager"]
RS --> PY["PythonStrategyEngine"]
RS --> CMP["ComparisonEngine"]
CS --> OLLAMA["Local Ollama API"]
DM --> STORE["data/cache + data/artifacts"]
BS --> STORE
PS --> STORE
RS --> STORE
| Area | Current implementation | Target design |
|---|---|---|
| Frontend | React + Vite + route-based shell | Same, with richer chart sync and workflows |
| Backend | FastAPI with in-process services | Same API shape, with more isolated workers |
| Storage | JSON + CSV artifact storage | SQLite + DuckDB + Parquet |
| Pine truth | Manual bridge artifact upload | Automated TradingView bridge plus manual fallback |
| Live mode | Dataset playback one bar per second | Provider-backed live bars with replay continuation |
| LLM | Ollama chat + fallback + model discovery | Same, plus patch apply and deeper grounding |
frontend/src/app/App.tsxfrontend/src/pages/ImportsPage.tsxfrontend/src/pages/WorkspacePage.tsxfrontend/src/pages/RunsPage.tsxfrontend/src/pages/SettingsPage.tsx
backend/app/main.pybackend/app/api/*.pybackend/app/services/*.pybackend/app/core/python_engine.pybackend/app/core/comparison_engine.pybackend/app/core/data_manager.py
shared/python/contracts.pyshared/typescript/contracts.ts
A saved candle source normalized into:
timestampopenhighlowclosevolume
User-provided source code plus metadata:
- Pine artifact
- Python artifact
- declared outputs
- read/write permissions
A replay or live execution record containing:
- candle window
- Python indicator series
- Pine indicator series
- trade events
- comparison result
- lifecycle and progress
User-uploaded Pine output bundle containing:
- indicator series
- trade events
- optional source code snapshot
A local Ollama analysis request with:
- selected model
- intent
- latest messages
- optional run context
- requested access targets
For a new developer or AI agent:
- Read Current Status
- Read Workflow
- Read API Reference
- Read AI Handoff
- Open the key files listed above