An institutional-grade portfolio management and automated research suite built natively around the TradingView Desktop application. Designed for advanced power users, this toolkit combines TradingView CDP visual/chart automation with an Agentic AI operating systemβenabling autonomous research, multi-scenario DCF valuation, adversarial portfolio audits, and human-supervised portfolio synchronization.
Tip
InvestmentToolkit is strictly an interactive decision-support system, NOT an unattended bot.
- Active Human Review & Approval: Every trade calculation (shares, limit price, sizing) is staged interactively on your screen (via
TradePrepModalor the active TradingView Desktop GUI). No order is ever placed without the human user reviewing, accepting, and confirming it. - Personal Display & Local Workstation: All CDP automation runs on your local licensed workstation directly alongside your active TradingView Desktop display for personal portfolio tracking and visual analysis.
- No Unattended Auto-Trading: Background AI agents and scripts are strictly forbidden from placing live orders autonomously while unattended. See
.agent/rules/trade-execution-policy.md.
Warning
TradingViewβs Terms of Use strictly prohibit headless, unattended "black-box" algorithmic trading and third-party automated execution APIs operating without direct human display interaction. InvestmentToolkit's architecture explicitly adheres to these terms by enforcing a 100% human-supervised workflow.
The true power of this repository is not just the frontend UIβit is the Agentic Operating System behind it. Launch your CLI agent (Claude Code, Gemini CLI, or Copilot CLI) and use one of these triggers:
/toolkit-onboardingor "Help me set up the toolkit"
Runs the toolkit-onboarding skill. This coordinator checks your dependencies, initializes private data templates, and guides you into the application.
/tv-onboardingor "Set up TradingView for me"
Runs the tv-onboarding skill. This deep-dive guide covers:
- TradingView Desktop install check
- Subscription tier verification (Premium recommended for real-time data)
- Broker panel connection inside TradingView (no separate API credentials needed)
- CDP health check and remote debugging port 9222 verification
- First
/tv-portfolio-syncβ pulls live positions from all accounts (TFSA + RRSP + Cash)
python3 run_investment_toolkit.pyThis automatically starts the backend, frontend, and TradingView Desktop with CDP debugging enabled.
Then, ask your agent to run: /tv-portfolio-sync or /daily
All agent tooling is organized as portable plugins inside the plugins/ directory and loaded natively as on-demand skills in .agents/skills/.
An adversarial suite that acts as a hedge fund auditor. It challenges your bull cases, flags failing investment pillars, and proposes weight changes based on real-time drift.
- Daily command:
/dailyβ one interactive loop: portfolio sync β morning brief (macro + TA + DCF + earnings) β ranked triage cards β trade execution β self-evolution log. - Intake & Audit:
/stock-intake(automated 5-in-1 discovery & intake),/portfolio-coverage-audit(audit analysis gaps across watchlist),/data-quality-audit(database integrity checks). - Research & Rebalancing:
/review-portfolio,/strategic-review,/rebalance,/calibrate-targets,/update-portfolio-targets,/x-news-sweep,/weekly-review,/bundle-thesis-review,/13f-tracker,/13f-analyze,/norberts-gambit,/ytd-return,/run-advisor(post-catalyst orchestrator).
An autonomous buy-side analyst. Fetches real-time financial data, builds Bear/Base/Bull DCF scenarios, and generates fair value recommendations.
- Skills:
/evaluate-stock,/research-stock,/forward-valuation-challenge,/valuation-math-validation
Purpose-built for thematic, closed-end, and cash fund ETFs.
- Skills:
/analyze-etf
TradingView Desktop is the primary layer for live prices, portfolio sync, order execution, Pine Script authoring, and deep technical analysis via CDP (Chrome DevTools Protocol) automation.
- Skills:
/setup-tradingview,/tv-onboarding,/tv-portfolio-sync,/tv-watchlist-sync,/place-order,/modify-order,/cancel-order,/get-orders,/tv-alert-sync,/tv-price-refresh,/tv-snapshot,/pine-inject,/author-pine,/tv-ta-deep,/ta-daily-sweep - Agents:
ta-guideβ interactive TA tutor and Pine Script architect; walks users through live chart analysis step-by-step and builds custom indicator views.
Orchestrator for managing server startup and onboarding.
- Skills:
/start-screener,/toolkit-onboarding
The investment_screener/ app is the web-based financial analysis dashboard.
-
Frontend: React 19, Vite, Tailwind CSS 4.0
-
Backend: Node.js (Express), TypeScript, SQLite (WAL mode indexing via
better-sqlite3) -
Analytical Engine: Python 3.11 Utility Layer (
py_services/) leveraging standardsqlite3for local indexing andyfinancefor math, validation, and historical financials.
-
Portfolio Summary & Table: Live views synced from TV CDP.
-
Market Heatmap: Real-time sector performance mapping.
-
Stock Analysis & Metrics: Deep-dive AI Expert Thesis and 15+ fundamental metrics.
-
Valuation Modeler: Interactive Bear/Base/Bull scenario modeling with automatic persistence to projection JSON files.
-
Trade Log: Real-time mirror of the TradingView order panel via CDP.
The backend is SQLite-first as of the Domain Data Model v3.2 migration program (Waves 0-5E,
closed by Wave 6, 2026-07-25 β see docs/superpowers/status/wave6-program-closure-report.md for
the full closure report, KPI rollup, and retained-JSON rationale). Two gitignored, self-creating
SQLite files under investment_screener/backend/data/:
| File | Domain | Key tables |
|---|---|---|
domain_model.sqlite |
Investment/target/watchlist/pillars/price-levels/notes/alerts/projections/trade-log/orders/cash-flow/portfolio-policy (Waves 0-5E) | account, strategy_pillar, sub_strategy, investment, investment_price, account_investment, price_level_set, price_level_tier, alert, investment_note, projection_version, projection_scenario, trade_log_entry, order_execution, cash_flow, cash_flow_baseline, portfolio_policy, broker_exchange_rate, broker_reported_total (20 tables total) |
intelligence.sqlite |
Research/TA-sweep/prediction event ledger | instrument, ledger_checkpoint, intelligence_event (+ FTS5 virtual table), queried via py_services/intelligence/ |
Both are gitignored β a fresh checkout won't have them. Rebuild domain_model.sqlite via:
cd investment_screener/backend/py_services
python3 -m domain_model.migrate_projections_to_sqlite --write
python3 -m domain_model.migrate_target_portfolio_to_sqlite --write
Common read-only inspection commands (never open a write transaction by hand β always go through the py_services/domain_model/ repository layer for real writes):
# Open a shell against the domain model
sqlite3 investment_screener/backend/data/domain_model.sqlite
# List all tables
sqlite3 investment_screener/backend/data/domain_model.sqlite ".tables"
# Row counts across every table
sqlite3 investment_screener/backend/data/domain_model.sqlite \
"SELECT 'investment', COUNT(*) FROM investment
UNION ALL SELECT 'projection_version', COUNT(*) FROM projection_version
UNION ALL SELECT 'alert', COUNT(*) FROM alert;"
# Look up one ticker's full row
sqlite3 -header -column investment_screener/backend/data/domain_model.sqlite \
"SELECT * FROM investment WHERE symbol = 'NVDA';"
# Same pattern for the research/event ledger
sqlite3 investment_screener/backend/data/intelligence.sqlite ".tables"
portfolio.json and theses/target-portfolio.json (Waves 7/8) are fully retired β archived under
ARCHIVE/investment_screener/backend/data/, with domain_model.sqlite as the sole source of truth
for portfolio holdings, thesis targets, pillars, price levels, and standing decisions.
A small set of other JSON files remain intentionally retained, each with a documented Retained-JSON
Rationale Bar (not "out of scope" hand-waving): thesis_breaker_state.json (per-breaker evaluation
detail β thesisBreakers still has no SQLite schema), projections/*.json, trade-log.json,
cash_flows.json. See docs/superpowers/status/wave6-program-closure-report.md for the final
program-wide state, and each wave's own exit report under docs/superpowers/status/ for what was
cut over vs. retained, with rationale.
Plugins are self-contained. To link or reinstall them into your local agent environment:
1. Install Project-Specific Plugins (Local):
uvx --from git+https://github.com/richfrem/agent-plugins-skills plugin-add /Users/richardfremmerlid/Projects/InvestmentToolkit/plugins
2. Install Core Library Plugins (Remote):
uvx --from git+https://github.com/richfrem/agent-plugins-skills plugin-add richfrem/agent-plugins-skills
-
Required for real-time market data and live order execution. The toolkit integrates directly with TradingView Desktop (running with
--remote-debugging-port=9222). -
Free/Essential Plans: yfinance remains the fallback source for delayed data (15-20 min).
π Deep Dive: For a comprehensive system map, context diagrams, and component interactions, read the Architecture Overview.
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
-
The primary test harnesses must shell out via subprocess to exactly mirror the execution paths of the AI plugins and the Node Express bridge.
-
Mocking is strictly prohibited on critical runtime paths.
-
Never perform financial calculations inline (bash/python snippets).
-
Always use or create versioned
.pyscripts ininvestment_screener/backend/py_services/.
The project leverages the Exploration Cycle architecture to systematize AI agent workflows in 4 phases:
- Discovery Planning
- Visual Blueprinting
- Prototyping
- Handoff & Specs
(Managed by the
exploration-workflowskill andexploration-dashboard.mdstate file)
The TradingView CDP automation layer was informed by studying the following open-source projects:
| Project | GitHub | What It Does |
|---|---|---|
| tradingview-mcp (tradesdontlie) | https://github.com/tradesdontlie/tradingview-mcp | The most complete CDP-based TradingView automation library available. 5,000+ lines, 15+ command namespaces. Its pine.js uses React fiber tree traversal (__reactFiber prefix) to locate Monaco editor internals β more resilient than CSS selectors alone. No live broker order execution. |
|
| tradingview-mcp (atilaahmettaner) | https://github.com/atilaahmettaner/tradingview-mcp | TradingView screener/scanner using the tradingview-screener Python library (REST API). 30+ tools for market scanning and symbol filtering. No CDP, no live orders.
|
Our key architectural difference: Both reference projects are chart analysis and research tools. InvestmentToolkit is a live broker execution layer β it navigates TradingView's built-in Questrade broker panel via CDP to place, modify, and cancel real orders, with 3-step HITL confirmation, safety gates (stale portfolio exit 4, size cap exit 3), multi-account support, tvOrderId tracking, and automatic portfolio sync after fills. Pine Script injection (via /pine-inject) uses the React fiber traversal technique from tradesdontlie's implementation to locate Monaco editor internals without relying on fragile CSS class selectors.
-
browser-use/browser-harness β Inspired our approach to self-healing, self-evolving skills and direct CDP automation. By allowing the agent to write its own helpers and domain skills when it encounters issues or gaps, the system continuously improves itself during execution.
-
orba/superpowers β The TDD (Iron Law: no production code without a failing test first), brainstorming, and sub-agent driven development skills used throughout this project come from the superpowers plugin library. These skills enforce rigorous Red-Green-Refactor discipline and orchestrate parallel multi-agent task execution.
-
richfrem/agent-plugins-skills β The Exploration Workflow (4-phase: Discovery Planning β Visual Blueprinting β Prototyping β Handoff & Specs) and all project-local AI agent plugins and skills are organized and distributed through this repository.
IMPORTANT DISCLAIMER: InvestmentToolkit is strictly an analytical and educational suite. It does not provide financial, investment, tax, or legal advice.
- All valuation models (DCF scenarios), technical indicators, and AI agent outputs are informational and advisory only.
- Past performance and quantitative projections do not guarantee future returns.
- The software is provided "as is", without warranty of any kind. You are solely responsible for your own investment decisions and any broker order executions.
Distributed under the MIT License. See LICENSE for more information.
Data and desktop integration from TradingView are subject to their Terms of Use: https://www.tradingview.com/policies/







