Explore more topics
Trading task guide

Backtest trading strategies with Claude.ai

Use Claude.ai to validate strategy rules, submit a reviewed historical test and compare returns with SPY. Start with the completed dividend-growth example.

As of 2026-10-13

Jump to a section

TL;DR

Connect Claude.ai, inspect the dividend strategy's rules, save a draft and run one historical test. The completed example below shows what to inspect. Review its costs, drawdown and longer comparison before changing the strategy.

Inspect the recorded 2025 through 2026 simulation

Recorded daily closes for the five-dividend-growers strategy and SPY from January 2, 2025 through October 7, 2026
$10,000 initial capital, fractional shares and reinvested dividends. Candidate stock transactions pay 0.1%; the stored SPY benchmark pays no candidate commissions.
Strategy return
44.80%
SPY return
33.99%
Maximum drawdown
24.33%
Strategy fees
$24.15

NexusTrade recorded this simulation on October 8, 2026. Read the drawdown and the longer comparison below alongside the return.

1. Connect Claude.ai

https://nexustrade.io/api/mcp

Scroll horizontally to read the full command, or copy it.

Open Customize, Connectors and add a custom connector named NexusTrade using the URL above. Complete OAuth, then enable NexusTrade with +, Connectors in this conversation. For Team or Enterprise, an authorized organization owner first adds the connector; each member connects their own account.

2. Review the strategy rules

The dividend strategy's universe, filter, ranking, equal weights and rebalance trigger in NexusTrade
NexusTrade's strategy display renders the exact saved dividend rules used by this recorded simulation.

The strategy selects the five largest qualifying SP500 companies by market value, weights them equally and targets full deployment. It checks a ten-year consecutive dividend-increase condition. Rebalancing triggers when portfolio value equals initial value or at least 30 days have passed since a filled buy.

3. Save your reviewed draft

Copy this request into the connected Claude conversation. Review the displayed rules, then save the draft and keep its returned ID.

Prompt
Reproduce the five-dividend-growers experiment in Claude.ai. Read the exact configuration at https://nexustrade-prod.nyc3.cdn.digitaloceanspaces.com/Explore/Data/existing-dividend-five-configuration-20261010-2468740bdaf783a8.json. Pass the complete configuration to build_portfolio. Show valid, issues and canonical rules. Preserve the universe, filter, ranking, weighting, rebalance trigger, fractional shares and dividend policy. After I approve the rules, save the same JSON with create_portfolio, then read the returned portfolio_id with get_portfolio. Record that chat draft ID. Stop before backtesting or deployment.

4. Run the historical test

Replace the placeholder with the returned chat draft ID. Review these inputs, then approve one backtest_portfolio call. They match the displayed 2025 run. Save the accepted backtest ID before leaving the conversation.

generate_events is false for the curve comparison. Enable it when you want to inspect individual signals and orders; detailed event capture uses more credits. Keep all other settings fixed when making that inspection run.

Show the table · 7 rows, 2 columns
InputExplicit choice
portfolio_idExact returned chat draft ID
start_date / end_date2025-01-02 / 2026-10-07
intervalDay
initial_value10000
baseline_symbolSPY
fee_config / dividend_policyStock: 0.1 percent; reinvest
generate_eventsfalse for the curve; true for detailed signal and order inspection
JSON
{
  "portfolio_id": "REPLACE_WITH_RETURNED_CHAT_ID",
  "start_date": "2025-01-02",
  "end_date": "2026-10-07",
  "interval": "Day",
  "initial_value": 10000,
  "baseline_symbol": "SPY",
  "generate_events": false,
  "dividend_policy": "reinvest",
  "fee_config": {
    "Stock": {
      "amount": 0.1,
      "type": "percent"
    }
  }
}

5. Inspect the result and a rebalance

Poll query_backtest_status with the accepted backtest_id. PENDING or RUNNING means continue with that same ID. Resolve a reported ERROR before changing the experiment. Once complete, read query_backtest_history and follow pagination for the full period. Save the completed statistics and history with the rules and inputs.

Compare value with comparisonValue, then follow cash and positionValue around a rebalance or drawdown. With detailed events enabled, ask the client to read query_backtest_events and explain which condition fired, which stocks qualified, how weights changed and which orders filled. Keep the explanation tied to returned records.

Prompt
Use the accepted backtest_id to poll query_backtest_status until complete. Then read query_backtest_history with that same ID, page 1 and page_size 500; follow all pages. Show the strategy and SPY curves, return, maximum drawdown and fees for 2025-01-02 through 2026-10-07. Explain one rebalance or drawdown using cash, holdings and recorded order events when available. Preserve the returned IDs and source fields in the experiment record. Keep polling the existing test rather than submitting another.

Compare the other recorded periods

The same dividend rules across three recorded windows

Scale: 0 to 419.23 % · zero baseline

Jan 2025 to Oct 2026

  • Dividend strategy+44.8%
  • Stored SPY+33.99%

Jan 2022 to Oct 2026

  • Dividend strategy+134.94%
  • Stored SPY+73.13%

Jan 2014 to Oct 2026

  • Dividend strategy+340.9%
  • Stored SPY+419.23%

Total returns through October 7, 2026 from different start dates, each with $10,000. Strategy stock fills cost 0.1%; stored SPY pays no candidate commissions. These durations are separate comparisons.

Show the table · 3 rows, 6 columns

Scroll sideways to compare all columns. Select a heading to sort.

2025-01-0244.80%33.99%24.33%49$24.15
2022-01-03134.94%73.13%24.16%153$103.47
2014-01-02340.90%419.23%24.16%422$331.98

The same rules also have completed runs starting in 2022 and 2014. Compare the full period table before selecting a variant; the long 2014 run returned less than SPY.

Check the universe used by the simulation

Historical S&P 500 membership at each date is not established by this recorded example. Treat the longer window as a retrospective simulation, then verify universe membership and data availability before interpreting it as an investable historical selection.

Create one variant, then test unseen dates

Save a separate variant that changes only SelectTop.limit from five to ten. Keep the universe, dividend filter, weights, capital, fees, interval and development dates fixed. Record both configurations and their completed backtest IDs before comparing return, drawdown, holdings and turnover.

After choosing a candidate, freeze its configuration and decision criteria. The three displayed historical periods have already been inspected. Select another chronological period you have not used in the example, corpus search or variant selection, then evaluate the frozen candidate once. Keep further revisions in a new research cycle. An optional final lockbox follows the same rule.

Open tool reference, exact configuration and troubleshooting

Check the returned account tools

The result is a paginated object with portfolios, total and totalPages. Walk pages when necessary. A new account may return an empty list. Keep authentication errors and missing results separate.

Use fetch_portfolios with the JSON below. Read a portfolioId returned by that call with get_portfolio, setting its portfolio_id argument to the same value. Compare the name, type and strategies with the intended NexusTrade account. If no portfolio exists, keep the empty result and continue to the new draft preview below. Do not create anything during this check.

{
  "include_paper": true,
  "include_live": false,
  "include_chat_portfolios": true,
  "include_positions": false,
  "limit": 20,
  "page": 1
}

Confirm permission for this task

Discover build_portfolio, create_portfolio, get_portfolio and backtest_portfolio, query_backtest_status and query_backtest_history in the current connection. Check that the granted app actions allow this task before submitting anything. A plugin listing or successful read does not grant write access. Keep approvals enabled for saving and account changes.

Tool reference

  1. Validate a new candidate

    NexusTrade tool

    build_portfolio

    Review

    Canonical configuration and component issues; nothing is saved

  2. Save the validated draft

    NexusTrade tool

    create_portfolio

    Review

    Use the reviewed configuration and retain the returned chat portfolio ID

  3. Read the saved book

    NexusTrade tool

    get_portfolio

    Review

    Exact strategies, action sizing, and portfolio identity

  4. Submit the historical test

    NexusTrade tool

    backtest_portfolio

    Review

    Explicit dates, interval, capital and benchmark

  5. Poll the same operation

    NexusTrade tool

    query_backtest_status

    Review

    Terminal state and warnings; do not resubmit while running

  6. Inspect the curve

    NexusTrade tool

    query_backtest_history

    Review

    Historical values for the returned backtest_id

  7. Compare candidates

    NexusTrade tool

    compare_backtests

    Review

    Identical period and assumptions, with activity and risk

Show the table · 7 rows, 3 columns

Scroll sideways to compare all columns. Select a heading to sort.

Validate a new candidatebuild_portfolioCanonical configuration and component issues; nothing is saved
Save the validated draftcreate_portfolioUse the reviewed configuration and retain the returned chat portfolio ID
Read the saved bookget_portfolioExact strategies, action sizing, and portfolio identity
Submit the historical testbacktest_portfolioExplicit dates, interval, capital and benchmark
Poll the same operationquery_backtest_statusTerminal state and warnings; do not resubmit while running
Inspect the curvequery_backtest_historyHistorical values for the returned backtest_id
Compare candidatescompare_backtestsIdentical period and assumptions, with activity and risk

Inspect the discovered inputs before submitting a call. For a new candidate, validate and save it first; for a saved candidate, start with get_portfolio. Record the portfolio and backtest identifiers returned by the account tools.

Exact strategy configuration

JSON
{
  "initialValue": 10000,
  "supportsFractionalShares": true,
  "dividendPolicy": "reinvest",
  "strategies": [
    {
      "active": true,
      "condition": {
        "lhs": null,
        "rhs": null,
        "comparison": null,
        "type": "Or",
        "conditions": [
          {
            "lhs": {
              "compound": false,
              "targetAssets": [],
              "type": "PortfolioValue"
            },
            "rhs": {
              "compound": false,
              "targetAssets": [],
              "type": "InitialValue"
            },
            "comparison": "equal",
            "type": "Base"
          },
          {
            "lhs": {
              "compound": false,
              "targetAssets": [],
              "side": "Buy",
              "type": "DaysSinceOrder",
              "orderStatus": "Filled"
            },
            "rhs": {
              "compound": false,
              "targetAssets": [],
              "value": 30,
              "type": "Value"
            },
            "comparison": "greaterThanOrEqual",
            "type": "Base"
          }
        ]
      },
      "action": {
        "type": "DynamicRebalance",
        "universe": {
          "source": "SP500"
        },
        "pipeline": [
          {
            "type": "Filter",
            "condition": {
              "lhs": {
                "compound": true,
                "targetAssets": [],
                "type": "ConsecutiveIncrease",
                "maxLength": 1,
                "period": "Year",
                "lookback": 10,
                "indicators": [
                  {
                    "compound": false,
                    "targetAsset": {
                      "type": "",
                      "symbol": ""
                    },
                    "targetAssets": [],
                    "type": "LastDividend"
                  }
                ]
              },
              "rhs": {
                "compound": false,
                "targetAssets": [],
                "value": 10,
                "type": "Value"
              },
              "comparison": "greaterThanOrEqual",
              "type": "Base"
            }
          },
          {
            "type": "SelectTop",
            "metric": {
              "compound": false,
              "targetAsset": {
                "type": "",
                "symbol": ""
              },
              "targetAssets": [],
              "type": "Fundamental",
              "metric": "marketCap"
            },
            "limit": 5,
            "direction": "Highest"
          }
        ],
        "weightIndicator": {
          "compound": false,
          "targetAssets": [],
          "value": 1,
          "type": "Value"
        },
        "deploymentPercent": {
          "compound": false,
          "targetAssets": [],
          "value": 100,
          "type": "Value"
        }
      },
      "orderExecution": {
        "type": "Market"
      },
      "automaticOrderApproval": false
    }
  ],
  "name": "Five largest dividend growers",
  "cash": 10000,
  "buyingPower": 10000,
  "supportsCrypto": false,
  "alertsEnabled": false
}

Continue after a Claude.ai connection or test interruption

  1. NexusTrade or a tool is missing

    Enable NexusTrade with +, Connectors in this conversation. Organization members connect their own account after the owner adds the connector. Confirm build_portfolio, create_portfolio, backtest_portfolio, query_backtest_status and query_backtest_history are available before starting this workflow.

  2. An ID is rejected

    Use the portfolio_id or backtest_id returned to your own connected account. A demonstration ID or redacted receipt is not an identifier for your new test.

  3. The test is PENDING or RUNNING

    Poll query_backtest_status with the same accepted backtest_id. Continue the accepted operation after reconnecting rather than submitting another test.

  4. The test reports ERROR

    Retain the returned error and exact request. Resolve that cause before changing the experiment or approving another submission.

  5. History or detailed events are unavailable

    Backtest history is retained for 30 days. Detailed events require generate_events:true and are retained for three days. Save the completed result when it returns; enabling events costs 5× research tokens.

Continue exploring

Discussion

Sign in or create a free account to join the discussion.

No comments yet.