# Polarline Markets — Scout CLI Documentation > Scout is an AI trading assistant for building, validating, backtesting, and iterating on algorithmic investing strategies from your terminal. Source: https://www.polarline.io/docs --- # Intro Scout is an AI trading assistant. You describe a trading idea in plain English; Scout generates Python strategy code, runs backtests, and helps you iterate, all from your terminal. Scout is built for traders and developers who want to move from idea to inspectable algorithm without abandoning the terminal. Generated code stays open and reviewable, backtests run against real historical data, and broker connections, when you choose to add them, sit behind explicit configuration on your machine. ## What you can do with Scout - **Generate strategies**: Describe an idea in natural language. Scout writes complete Python strategies and saves them to your workspace. - **Backtest with real data**: Run `/backtest` to simulate strategies against historical market data via `yfinance`. - **Connect brokerages**: Link Alpaca or Binance for paper or live workflows. Local CLI credentials are stored on your machine and used to authenticate the broker connection. - **Bring your own key**: Use Claude, OpenAI, Gemini, or a local model. ## Quick start ```bash npm i -g finny finny ``` On first run, Scout walks you through picking a provider and pasting an API key. ## Product positioning Scout is built for traders and developers searching for AI backtesting, trading strategy generation, and terminal-native market automation. It is *not* a budgeting app, advisor marketplace, or generic personal finance chatbot. Relevant search intent: AI trading assistant, AI backtesting tool, algorithmic trading AI, trading strategy generator, Python trading strategies, automated market analysis. --- # Install ## Prerequisites Scout requires **Node.js 18+** installed on your system. Python 3 and `yfinance` are needed for backtesting with real market data. ## Install ```bash npm i -g finny ``` ## First run ```bash finny ``` On first run, Scout guides you through setting up your API key and preferred AI provider. You can re-run the setup at any time with `/init` inside the CLI. ### Backtesting prerequisites ```bash pip install yfinance ``` If commands fail with "python: command not found", make sure Python 3 is on your PATH. On macOS, install via Homebrew: `brew install python`. --- # Agent Modes Scout operates in three distinct modes. Press **Tab** to cycle between them. - **Build Mode**: Generate and iterate on full trading strategies. Scout writes complete Python algorithms based on your natural language descriptions, saves them to your workspace, and refines them across multiple turns. - **Research Mode**: Ask market-related questions, get analysis on tickers, explore trading concepts, and investigate technical indicators. Scout acts as your financial research assistant. - **Chat Mode**: General-purpose conversation. Discuss ideas, ask for explanations, or brainstorm strategies before committing to a build. --- # Commands Type these slash commands directly into the Scout CLI: - `/algos`: List all algorithms saved in your current workspace. Shows strategy names, creation dates, and file paths. - `/code`: View the raw source of your most recently generated or selected algorithm, printed directly in the terminal. - `/backtest`: Run a backtest using historical market data pulled via yfinance. Returns Sharpe Ratio, Max Drawdown, Win Rate, and Profit Factor. - `/review`: Get an AI-powered code review of your current algorithm. Scout analyzes for potential issues, edge cases, and optimization opportunities. - `/init`: Reinitialize your Scout configuration. Re-run the setup wizard to change your API key, provider, or workspace settings. - `/portfolio`: Open the portfolio view. Add or remove brokerage accounts and inspect current positions. - `/settings`: Open settings. Manage paper-trading connections, reset the managed Python env, and tweak preferences. --- # Strategy Templates A template gives the AI agent a clear strategy shape: indicators, entry logic, exit logic, and risk assumptions. Start from a template and ask Scout to modify the logic, add filters, change symbols, or adjust risk controls. ## Included templates - **Momentum**: Trades based on rate-of-change. Enters positions when momentum indicators (RSI, ROC) confirm a sustained directional move. - **Mean Reversion**: Capitalizes on price returning to its historical average. Uses Bollinger Bands and z-score. - **Breakout**: Detects when price breaks through key support or resistance with volume confirmation. - **DCA (Dollar Cost Averaging)**: Systematic time-based buying. Accumulates a position at regular intervals. - **Golden Cross**: Moving-average crossover. Enters long when the 50-day MA crosses above the 200-day MA. - **Scalping**: High-frequency, short-duration trades targeting small price movements. - **Custom**: Blank canvas. Define your own entry/exit logic and risk parameters. ## Example prompt ``` Build a momentum strategy for BTC/USD using RSI and trend confirmation. Add a stop loss, a take-profit rule, and run it through a backtest. Show me the generated Python before I run it. ``` ## Review generated code ``` /code /review /backtest ``` --- # Backtesting Backtesting simulates a generated strategy against historical market data. The goal isn't to prove it works live, it's to catch weak assumptions before you commit further. ## Run a backtest ``` /backtest ``` Scout uses **yfinance** to fetch real OHLCV data for any supported ticker. ## Performance metrics - **Sharpe Ratio**: Risk-adjusted return per unit of volatility. Above 1.0 is generally good. - **Max Drawdown**: Largest peak-to-trough decline. Lower is better. - **Win Rate**: Percentage of profitable trades. Context-dependent. - **Profit Factor**: Gross profit divided by gross loss. Above 1.0 is net profitable. ## Data source Historical data is pulled from Yahoo Finance via the `yfinance` Python library. ```bash pip install yfinance ``` ## Limitations Backtests can mislead when a strategy has lookahead bias, overfit parameters, poor liquidity assumptions, missing fees, or unrealistic fills. Treat every result as research, not investment advice. --- # Brokerages Link a brokerage for paper or live workflows. In the local CLI, credentials are saved in a local auth file and used to authenticate the broker connection. Hosted workflows use the agreed deployment boundary. ## Supported - **Alpaca** (active): US equities and USD-quoted crypto. Paper and live endpoints. Crypto symbols like `BTC-USDT` are auto-normalized to `BTC/USD`. Taker fee modeled at 0.25%. - **Binance** (active): Crypto spot via testnet (mainnet not yet exposed). Quotes default to USDT. Taker fee modeled at 0.1%. No futures. - **Polymarket** (coming soon). - **Questrade / Interactive Brokers** (coming soon). ## Connecting Accounts are added from the TUI, there is no `/connect` command. Open `/portfolio` → **Add account**: or `/settings` → **Paper Trading**. ### Alpaca fields ``` Label my-alpaca-paper Key ID ******************************** Secret **************************************** Endpoint https://paper-api.alpaca.markets # or live URL ``` Env-var fallback: ```bash export ALPACA_API_KEY_ID="..." export ALPACA_API_SECRET_KEY="..." export ALPACA_ENDPOINT="https://paper-api.alpaca.markets" export ALPACA_PAPER="true" ``` Requires `alpaca-py>=0.30`, installed into Scout's managed Python venv on first use. ### Binance fields ``` Label my-binance-testnet API key ******************************** API secret **************************************** ``` Env-var fallback: ```bash export BINANCE_API_KEY="..." export BINANCE_API_SECRET="..." export BINANCE_TESTNET="true" ``` Powered by `ccxt>=4` with `set_sandbox_mode(True)` for testnet routing. ## Where credentials live ``` ~/.local/share/finny/auth.json (mode 0600, plaintext JSON) ``` No OS keychain integration today. The file is plaintext with restrictive permissions, treat your machine as the trust boundary. ## Strategy interface Generated strategies receive a `broker` instance from Scout. ```python def run(broker): if not broker.market_is_open("BTC/USD"): return bar = broker.fetch_bar("BTC/USD", interval="1h") cash = broker.cash() if bar.close > bar.open and broker.position("BTC/USD") == 0: broker.buy("BTC/USD", notional=cash * 0.1) ``` Available methods: `buy()`, `sell()`, `position()`, `cash()`, `equity()`, `price()`, `fetch_bar()`, `market_is_open()`. ## Things worth knowing - First run installs `alpaca-py` / `ccxt` into `~/.local/share/finny/python-env/`, expect a 30–60s cold start. - `auth.json` is plaintext (0600, no keychain). Don't sync it. - Binance is testnet-only and spot-only in the current UI. - Alpaca crypto is USD-quoted only. --- # API Keys (BYOK) Scout supports Bring Your Own Key. ## Supported providers - **Anthropic (Claude)**: Claude 4.5 Sonnet, Claude 4 Opus, and other Claude models. - **OpenAI**: GPT-4o, GPT-4, and other OpenAI models. - **Google (Gemini)**: Gemini Pro, Gemini Ultra, and other Google AI models. - **Local models**: Ollama, LM Studio, or any compatible API endpoint. Run `/init` inside the Scout CLI to switch provider or rotate keys. In the local CLI, keys are stored in your Scout config and used to authenticate requests to your selected provider. Hosted models receive your prompts and included context; local models use your configured endpoint. Review that provider's data-handling terms before sending sensitive information. --- # FAQ **What does Scout do?** Scout is a CLI-based AI trading assistant. You describe a trading idea in plain English, and Scout helps generate strategy code, validate it, save iterations, and run backtests. **Is Scout a budgeting app or financial advisor?** No. Scout is not a budgeting app and does not provide personal financial advice. It is a developer and trader tool for algorithmic investing workflows, market research, strategy generation, and backtesting. **Which markets and broker workflows does Scout support?** Scout supports stock and crypto strategy workflows, with Alpaca and Binance integrations documented today. Broker support is designed around paper trading, live trading workflows, and inspectable strategy code. **Does Scout execute trades automatically?** Scout can support broker-connected workflows, but generated strategies should be reviewed and tested before live use. The core value is faster strategy development, validation, and backtesting, not black-box investment advice. --- # Troubleshooting ## Python + yfinance required for backtesting ```bash pip install yfinance ``` Scout shells out to Python for data fetching and backtest execution. Without these dependencies, `/backtest` will fail. ## Common issues - **"Command not found: finny"**: Ensure Scout is installed globally (`npm i -g finny`). Check that your npm global bin directory is on your PATH. - **"API key not set"**: Run `/init` inside the Scout CLI to configure your API key and provider. - **Backtest returns no data**: Verify the ticker is valid and yfinance can fetch data for it. Some delisted or very new tickers may not have historical data. - **Broker connection fails after install**: Reset the managed Python env from `/settings` → Paper Trading. The first run after a reset takes 30–60s to reinstall `alpaca-py` / `ccxt`.