Explore more topics
AI trading walkthrough

I connected VS Code Copilot to a trading API and tested a SPY put spread

An experiment in using Copilot beyond code. Research a SPY bear put spread and inspect the completed 2024 test, which lost 13.34% against SPY.

As of 2026-10-14

Worked strategy
SPY bear put spread
Evidence status
Completed 2024 development test; strategy and SPY curves included
Jump to a section

Follow this worked strategy

I connected VS Code Copilot to the NexusTrade trading API and had it research a SPY bear put spread, build the spread rules, and inspect the completed 2024 test. The agent operated this workflow through NexusTrade's MCP server; it did not build the integration. The spread lost 13.34% against full-capital SPY at 25.30%, including a recorded trade that lost $487.82. This is a development test on examined dates. Judge frozen rules on dates you have not used yet.

Follow the full journey

Step 1 of 6

Connect VS Code Copilot

Add the NexusTrade server

{
  "servers": {
    "nexustrade": {
      "type": "http",
      "url": "https://nexustrade.io/api/mcp"
    }
  }
}

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

Open the Command Palette with Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows/Linux. Run MCP: Add Server and follow the remote HTTP server flow with the URL shown above and name nexustrade. Choose workspace .mcp.json or Copilot Global for a new portable configuration.

Sign in to your NexusTrade account

Alternatively, run MCP: Open User Configuration and merge the servers configuration shown above into that VS Code profile file. It is the VS Code profile format, rather than the portable mcpServers format. Run MCP: List Servers, select NexusTrade and start it. Complete the account sign-in requested by the connection, then inspect its tools in chat. Workspace trust and server enablement can affect availability.

What you should see

The result identifies Apple's company filing, filing date and source URL. The connection check makes no account changes.

Inspect the request

Step 2 of 6

Research SPY and the put spread

Read the SPY underlying, option expiry and strike selectors together. The long and short put legs use the same expiry; inspect the actual selected contracts before reviewing the debit and collateral.

What you should see

A dated brief names the instrument, original sources and assumptions that matter to this strategy.

Inspect the request

Animation: the bear put spread strategy as built in the AI chat (Price(SPY) < SMA(SPY,50,Day); Price(SPY) >= SMA(SPY,50,Day); 14 DTE) is saved as 3 rules. Its legs (sell 1 put at -5% resolving to $557, buy 1 put at ATM resolving to $586; nearest expiry 30 to 45 days out, Jan 17, 2025) appear on a strike line. Then the expiration payoff of the recorded bear put spread (Sell the SPY $557 put, buy the $586 put; both expire Jan 17, 2025) draws as the SPY price sweeps from $537 to $606: max profit $2,235.79; max loss $664.21; breakeven $579.36; per contract before commissions. Then the same position's profit or loss is drawn at each session close from Dec 18, 2024 to Dec 24, 2024, ending at -$487.82 after commissions.
The algorithmic strategy held this position from Dec 18 to Dec 24, 2024 in its backtest and lost $487.82 after commissions.
Step 3 of 6

Build the SPY put spread

Enter when SPY is below its 50-day average and no matching option position is open. Review both legs and the signal and 14-DTE exits before saving.

Entry
SPY < SMA50; matching position count = 0
Legs
Buy ATM put; sell put at -5% strike
Expiry
Nearest available expiry 30 to 45 days away; ratios 1:1
Sizing
One strategy unit; collateral and liquidity apply
Exit
SPY >= SMA50 or at most 14 DTE
What you should see

The preview shows three rules, both contract selectors and the exact sizing method.

Inspect the request

Bear put spread: completed 2024 backtest13K8.2K2024-01-022024-12-31
Bear put spread 2024-12-31, 21:00:00 UTC
8,665.52
Full-capital SPY buy and hold 2024-12-31, 21:00:00 UTC
12,530.29
Bear put spreadFull-capital SPY buy and holdHistorical simulation
Recorded 2024 SPY bear put spread simulation; $10,000 initial capital. Full-capital SPY is a comparison with different exposure.
Step 4 of 6

Inspect the completed 2024 spread test

Compare the spread curve with full-capital SPY over the same year. Option contract selection and execution assumptions belong to this result.

Return
-13.34%
SPY buy and hold
25.30%
Max drawdown
23.74%
Closed option legs
16
Commissions
$22.10
What you should see

The bear put spread returned -13.34% in this completed historical simulation.

Inspect the request

Step 5 of 6

Observe SPY bear put spread in paper trading

Keep the selectors and sizing fixed in a separate paper portfolio. Inspect the long and short legs as one spread, with matching expiries and the exits defined above.

Inspect before accepting an order
The selected SPY strikes, matching expiry, contract quantities, debit, collateral, pending order legs and 14-DTE exit.
What you should see

Your paper portfolio has its own ID, start date, schedule and dated history. These forward observations begin with your own run.

Inspect the request

Step 6 of 6

Review SPY bear put spread for live deployment

Review the spread in the target account only after confirming that its broker connection supports the required multi-leg option actions and your account has the necessary options permissions.

Open the live deployment walkthrough
Account and instrument review
SPY multi-leg options support, account permission level, debit and collateral, quote availability, both leg quantities and exit support.
What you should see

The review identifies the target account, supported instruments, rule changes and approval settings before confirmation.

Inspect the request

Follow the VS Code Copilot session

{
  "servers": {
    "nexustrade": {
      "type": "http",
      "url": "https://nexustrade.io/api/mcp"
    }
  }
}

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

This guide runs on NexusTrade's MCP server. VS Code Copilot operated the trading workflow below, from connection to the live review. The agent's role here is operating the workflow through that server.

The table names the tool call, the approval checkpoint, and the artifact to keep at each stage. Placeholders such as a returned draft ID stand for values your own run returns. This page records no IDs from anyone else's run.

The recorded anchor is the completed 2024 spread test below, including the recorded trade that lost $487.82 and the largest decline in the exported history.

Show the table · 6 rows, 4 columns

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

Connect VS Code Copilotsec_edgar list_filings for AAPL with limit 1Public read only. No portfolios, ingested filings, or changes.Filing company, form, date, and source URL
Research the spreadInstrument and option sources for the SPY bear put spreadRead-only step. Payoff stays separate from mark-to-market history.Dated spread brief
Draft the rulesbuild_portfolio preview, then one create_portfolioApprove the rules before saving. Stop before paid tests.Returned draft ID with a readback
Test history2024 backtest at $10,000 with an SPY baseline and modeled commissionsShow the request and estimated cost before submission.History, contracts, collateral, and quote timing
Trade on paperSeparate paper-only deployment at $10,000Show the plan. Verify the portfolio is paper.Running paper ID and dated history
Review liveLive deployment review against the actual accountLive trading stays unchanged until explicit confirmation.Reviewed plan, or a stop report when unsupported

Where VS Code Copilot stops for approval

Each consequential action in this guide waits at an approval gate. The agent previews first and acts only after explicit approval.

The rules preview returns valid and issues before anything is saved. The agent resolves problems and re-previews instead of saving a candidate with open problems.

  1. Approve the rules before the agent saves them

    The agent previews the configuration with build_portfolio and shows entry, sizing, exits, valid, and issues. It saves with create_portfolio only after approval and reads the returned draft back.

  2. Approve the test cost before the agent submits once

    Historical tests are paid runs. The agent shows the exact request and estimated cost for approval before submitting once, then polls the same returned test ID until complete.

  3. Approve the paper plan and verify it is paper

    The paper deployment is a separate portfolio with its own ID. The agent shows the plan for approval, verifies the deployment type, and leaves brokerage accounts unchanged.

  4. Confirm the live move explicitly, or nothing moves

    The agent reads the actual account and broker capabilities first and keeps live trading unchanged until explicit confirmation. It reports an unsupported instrument or action and stops.

Inspect the spread execution assumptions

Inspect the recorded pricing and trade details

How the example did on SPY, 2024-01-01 to 2024-12-31, starting with $10,000.

The 2024 curve pairs the spread with full-capital SPY buy and hold over the same dates. Treat the result as development evidence from examined dates and freeze the selectors before using unused dates.

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

StatusCOMPLETE
Requested period2024-01-01 through 2024-12-31
Starting capital$10000.00
Modeled return-13.34%
Reported maximum drawdown23.74%
Full-capital SPY comparator return25.30%
Recorded commissions$22.10
Engine closed-trade count16
Peak reserved collateral$892.00
Median reserved collateral while holding positions$596.00
Pricing contract version8
Observed / synthetic half-spread calls42 / 26
Unknown-timing quote accesses2505
Missing-current-quote checks0
Rejected fill groups / marks0 / 0
Stale basket / single-option marks0 / 0

Follow the recorded put trade

Inspect one recorded spread trade

One position from the worked example, opened Dec 18, 2024 and closed Dec 24, 2024.

Long $586 put
−$854.65
Short $557 put
+$369.42
Commissions
−$2.60
Net
−$487.82
Inspect the worked example's records

The example trade's fills

  1. 2024-12-18 21:00:00

    Contract

    SPY250117P00586000

    Action

    Buy to open

    Contracts

    1

    Premium per share

    $11.0660

    Fee

    $0.65

  2. 2024-12-18 21:00:00

    Contract

    SPY250117P00557000

    Action

    Sell to open

    Contracts

    1

    Premium per share

    $4.4239

    Fee

    $0.65

  3. 2024-12-24 18:00:00

    Contract

    SPY250117P00557000

    Action

    Buy to close

    Contracts

    1

    Premium per share

    $0.7297

    Fee

    $0.65

  4. 2024-12-24 18:00:00

    Contract

    SPY250117P00586000

    Action

    Sell to close

    Contracts

    1

    Premium per share

    $2.5195

    Fee

    $0.65

Recorded rows in source order; spacing does not represent elapsed time.

Show the table · 4 rows, 6 columns

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

2024-12-18 21:00:00SPY250117P00586000Buy to open1$11.0660$0.65
2024-12-18 21:00:00SPY250117P00557000Sell to open1$4.4239$0.65
2024-12-24 18:00:00SPY250117P00557000Buy to close1$0.7297$0.65
2024-12-24 18:00:00SPY250117P00586000Sell to close1$2.5195$0.65

Each premium is per share; one contract is 100 shares.

Inspect the candidate book

Inspect the candidate book

This is the indicative selected-candidate snapshot from the opening size decision. Compare the selected symbols and ratios with the actual Filled orders. Use the candidate bid, ask and mid to follow the sizing calculation, then compare the recorded execution premium.

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

SPY250117P00586000$586.002025-01-1730$11.02$11.08$11.051949; sessionVolume
SPY250117P00557000$557.002025-01-1730$4.40$4.52$4.46198; sessionVolume
JSON
{
  "modelVersion": 2,
  "enforced": true,
  "chosenIndex": 0,
  "path": "targetKept",
  "reason": "target size limit 24 covers 1",
  "requestedQuantity": 1,
  "quantity": 1,
  "sizingChain": [
    {
      "kind": "allocationImplied",
      "bound": 1,
      "quantity": 1,
      "binding": true
    },
    {
      "kind": "buyingPowerCap",
      "bound": 13,
      "quantity": 1,
      "binding": false
    },
    {
      "kind": "volumeLimit",
      "bound": 24,
      "quantity": 1,
      "binding": false
    },
    {
      "kind": "finalPriceRecap",
      "bound": 1,
      "quantity": 1,
      "binding": false
    }
  ],
  "pricing": {
    "mid": 15.510000000000002,
    "halfSpread": 0.08999999999999986,
    "participation": 0.01020408163265306,
    "impactCost": 0.7034756477055026
  }
}

Inspect a contract-resolution audit

Inspect a contract-resolution audit

This is the latest retained resolution attempt, which can belong to a different position than the matched trade above. Its outcome, capital and risk codes explain what the resolver accepted or rejected at that decision. Follow the resulting Order events to see its fill status.

JSON
{
  "time": "2024-12-27T14:31:00.000Z",
  "status": "success",
  "reason": null,
  "riskAudit": {
    "rulesetVersion": 1,
    "outcome": "allowed",
    "longSharesAvailable": 0,
    "unhedgedShortCallContractsPerSpread": 0,
    "buyingPowerEffective": 8210.239390131885,
    "allocationRequested": 1,
    "allocation": {
      "type": "contracts",
      "amount": 1
    },
    "portfolioValue": 8210.239390131885,
    "underlyingPrice": 597.5399780273438,
    "maxLossPerUnit": 595.9999999999999,
    "finalContractQuantity": 1,
    "collateralReserved": 595.9999999999999,
    "committedCostBefore": 0
  }
}

Inspect the largest decline in the exported history

Scale: 0 to 9.4K USD · zero baseline

Cash

  • 2024-04-19T20:00:00.000Z$9398.84
  • 2024-12-24T18:00:00.000Z$8210.24

Scale: 0 to 1.36K USD · zero baseline

Position value

  • 2024-04-19T20:00:00.000Z$1361.00
  • 2024-12-24T18:00:00.000Z$0.00

Scale: 0 to 554 USD · zero baseline

Reserved collateral

  • 2024-04-19T20:00:00.000Z$554.00
  • 2024-12-24T18:00:00.000Z$0.00
Inspect the largest decline in the exported history

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

2024-04-19T20:00:00.000Z$9398.84$1361.00$554.00
2024-12-24T18:00:00.000Z$8210.24$0.00$0.00

The exported grid's largest peak-to-trough decline was 23.70%, from $10759.84 at 2024-04-19T20:00:00.000Z to $8210.24 at 2024-12-24T18:00:00.000Z. The engine reported maximum drawdown of 23.74%. Compare the history snapshots with the reported statistic and inspect the events around this period.

Continue exploring

Discussion

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

No comments yet.

Aurora · AI research assistant

Try this in Aurora

Edit the request, then open it in Aurora. You choose when to send it.