Follow the example
Choose a step to follow the example. Opening a request lets you review it; it does not submit a job or change your account.
Freeze the candidate before running it
Save and read back the strategy rules first. Record the selected underlying, strike and expiry rules, premium budget and exits. Choose a fixed period before looking at its result. Changing rules after reviewing returns creates a new candidate; keep the original result alongside the change.
- Dates
- Worked examples: 2024-01-01 through 2024-12-31
- Starting value
- Worked examples: $10,000 simulated capital
- Interval
- Worked examples: Day
- Baseline
- Worked examples: SPY
A named field or event to inspect, rather than a generic options preset.
Submit the saved draft
In Aurora, ask to backtest your verified saved draft with these fixed inputs. Review the displayed research-token cost before submitting. Request detailed events when you need to inspect signals, contract resolution and orders. Detailed events cost 5 times the usual research tokens and remain available for 3 days after the run; capture the audit while it is retained.
An explained difference between intended selector, resolved contract, sent size and simulated fill.
Inspect or preview deliberately
Open the contextual request with your actual returned backtest identifier when required. Review the request before sending; do not rerun simply because a result is disappointing.
A bounded review of the requested task, without automatic deployment or broker orders.
Freeze the candidate before running it
Save and read back the strategy rules first. Record the selected underlying, strike and expiry rules, premium budget and exits. Choose a fixed period before looking at its result. Changing rules after reviewing returns creates a new candidate; keep the original result alongside the change.
Scroll sideways to compare all columns. Select a heading to sort.
| Dates | 2024-01-01 through 2024-12-31 |
| Starting value | $10,000 simulated capital |
| Interval | Day |
| Baseline | SPY |
| Candidate dividends | cash |
| Option commissions | $0.65 per contract |
| Default option slippage | 0.5 of half-spread; liquidity impact may add cost |
No matching rows. Clear the filter to see all records.
Submit the saved draft
In Aurora, ask to backtest your verified saved draft with these fixed inputs. Review the displayed research-token cost before submitting. Request detailed events when you need to inspect signals, contract resolution and orders. Detailed events cost 5 times the usual research tokens and remain available for 3 days after the run; capture the audit while it is retained.
Create, test and iterate in Aurora
Start this worked example in the NexusTrade app. Review the filled-in request, open it in Aurora, then send it when ready. Continue in the same conversation through these steps.
Create the exact strategy
Ask: "Review Long call. Entry: SPY price > SMA(50, Day) AND zero matching long-call positions; $1,000 premium budget. Exit: Close all matching spreads when SPY price <= SMA50 or at 14 or fewer DTE. Show the resolved rules and selectors before saving." The request includes this example's complete draft.
Run the 2024 development comparison
Ask: "Backtest the saved rules from January 1 through December 31, 2024, daily, starting with $10,000. Keep the displayed fees and capture detailed events." Compare the completed curve with SPY buy and hold.
Explain what happened
Ask: "Explain one entry signal and its Filled orders using the recorded indicator values, comparisons, allocation, prices, quantity and fees. Then follow the largest drawdown through trades, cash and holdings."
Create one variant, then test unseen dates
Ask: "Change only the timed close trigger from 14 DTE to 10 DTE. Show the rule diff and compare both candidates on the 2024 development period with every other setting fixed." After choosing, freeze the rules and select another test period you have not inspected. The displayed 2024 results already make 2024 a viewed development period. Keep any later revisions in a new research cycle.
Create and backtest with Python
Python SDK 1.42.0. Save the runner below as run_long_call.py.
Install and download
python3 -m pip install nexustrade==1.42.0
export NEXUSTRADE_API_KEY="YOUR_API_KEY"
curl --fail --output long_call.py https://nexustrade.io/seo/strategy-examples/long-call.py
Create, test and inspect
from long_call import create_long_call, backtest_long_call
book = create_long_call()
completed = backtest_long_call()
print(completed["result"])
Run
python3 run_long_call.py
Python strategy and backtest functions
View complete Python SDK functions
The backtest function submits the 2024 test with SPY as its benchmark, records events and waits for the result. Use a new request key when changing rules, dates or fees.
import nexustrade as nt
def create_long_call():
asset = nt.stock_asset("SPY")
return nt.portfolio(
"Public SEO example - Long call",
[
nt.strategy(
"Open Long call",
((nt.Price(asset) > nt.SMA(asset, 50, "Day")) & (nt.OptionPositionCount("SPY", "call", "long", "custom") == nt.Value(0))),
nt.open_option(
builder=nt.options_builder(
legs=[nt.leg(option_type="call", direction="long", min_days_to_expiration=30, max_days_to_expiration=45, preference="nearest", distance=0, ratio=1)],
underlying_symbol="SPY",
spread_type="custom"
),
allocation={'type': 'dollars', 'amount': 1000}
)
),
nt.strategy(
"Close when trend breaks",
(nt.Price(asset) <= nt.SMA(asset, 50, "Day")),
nt.close_option(
underlyings=['SPY'],
spread_type="custom",
close_scope="spread",
quantity={'type': 'all'}
)
),
nt.strategy(
"Close at 14 DTE",
(nt.Value(1) > nt.Value(0)),
nt.close_option(
underlyings=['SPY'],
spread_type="custom",
close_scope="spread",
quantity={'type': 'all'},
triggers=[nt.dte_trigger(max_dte=14)]
)
),
],
initial_value=10000,
alerts_enabled=False,
)
def backtest_long_call(client=None):
client = client or nt.NexusTradeClient.from_environment()
operation = client.create_backtest(
nt.backtest(
create_long_call(),
start_date="2024-01-01", end_date="2024-12-31",
interval="Day", baseline_symbol="SPY",
initial_value=10000, generate_events=True,
dividend_policy="cash",
fee_config={"Stock": {"type": "percent", "amount": 0.1},
"Cryptocurrency": {"type": "percent", "amount": 0.7},
"Option": {"type": "dollars", "amount": 0.65}},
),
idempotency_key="explore-long-call-2024-spy-v1",
)
return client.wait_for_backtest(operation["id"])
# Build locally: book = create_long_call()
# Run and inspect: completed = backtest_long_call(); print(completed["result"])
Create and backtest with TypeScript
TypeScript SDK 1.42.0. Save the runner below as run-long-call.ts.
Install and download
npm install nexustrade@1.42.0
npm install --save-dev tsx
export NEXUSTRADE_API_KEY="YOUR_API_KEY"
curl --fail --output long-call.ts https://nexustrade.io/seo/strategy-examples/long-call.ts
Create, test and inspect
import { createLongCall, backtestLongCall } from "./long-call";
async function main() {
const book = createLongCall();
const completed = await backtestLongCall();
console.log(completed.result);
}
main().catch((error: unknown) => {
console.error(error);
process.exitCode = 1;
});
Run
npx tsx run-long-call.ts
TypeScript strategy and backtest functions
View complete TypeScript SDK functions
The same rules, dates and fees are used in both SDKs. The backtest function keeps its request key across retries.
import * as nt from "nexustrade";
export function createLongCall() {
const asset = nt.stockAsset("SPY");
return nt.portfolio(
"Public SEO example - Long call",
[
nt.strategy(
"Open Long call",
nt.and(
nt.gt(nt.Price(asset), nt.SMA(asset, 50, "Day")),
nt.eq(nt.OptionPositionCount("SPY", "call", "long", "custom"), nt.Value(0))
),
nt.openOption({ builder: nt.optionsBuilder({ legs: [nt.leg({ optionType: "call", direction: "long", minDaysToExpiration: 30, maxDaysToExpiration: 45, preference: "nearest", distance: 0, ratio: 1 })], underlyingSymbol: "SPY", spreadType: "custom" }), allocation: {"type": "dollars", "amount": 1000} })
),
nt.strategy(
"Close when trend breaks",
nt.lte(nt.Price(asset), nt.SMA(asset, 50, "Day")),
nt.closeOption({ underlyings: ["SPY"], spreadType: "custom", closeScope: "spread", quantity: {"type": "all"} })
),
nt.strategy(
"Close at 14 DTE",
nt.gt(nt.Value(1), nt.Value(0)),
nt.closeOption({ underlyings: ["SPY"], spreadType: "custom", closeScope: "spread", quantity: {"type": "all"}, triggers: [nt.dteTrigger({ maxDte: 14 })] })
),
],
{ initialValue: 10000, alertsEnabled: false }
);
}
export async function backtestLongCall(client = new nt.NexusTradeClient()) {
const operation = await client.createBacktest(
nt.backtest(createLongCall(), {
startDate: "2024-01-01", endDate: "2024-12-31",
interval: "Day", baselineSymbol: "SPY",
initialValue: 10000, generateEvents: true,
dividendPolicy: "cash",
feeConfig: {
Stock: { type: "percent", amount: 0.1 },
Cryptocurrency: { type: "percent", amount: 0.7 },
Option: { type: "dollars", amount: 0.65 },
},
}),
{ idempotencyKey: "explore-long-call-2024-spy-v1" }
);
if (typeof operation.id !== "string") throw new Error("Missing backtest ID");
return client.waitForBacktest(operation.id);
}
// Build locally: const book = createLongCall();
// Run and inspect: const completed = await backtestLongCall(); console.log(completed.result);
Keep the fee contract and result together
The SDK function submits the saved rules with the dates and fees shown above. Read the saved fee contract after completion to see the platform's option slippage setting. Opening orders may include liquidity impact as well as the configured half-spread cost. Inspect the recorded premiums alongside commissions to explore total trade costs.
In Aurora, ask for the saved test's status. Once it is complete, inspect the full history and trade events. If the run failed, inspect the reported error before submitting another test.
For my completed backtest, report the saved rules, date range, interval, starting capital, fee contract, modeled return and maximum drawdown. Inspect the full history, opening and closing orders, selected contracts and option resolution audits. Distinguish Filled orders from signals and repeated order-status events. Do not rerun or change the candidate.Understand the SPY comparison
The worked examples compare with full-capital fractional SPY buy and hold. That comparator reinvests dividends and applies no strategy commission. The candidate uses a $1,000 option premium budget per opening and its own fees. Different capital deployment, dividends and costs affect the comparison. Explore the cash and position-value history to understand the difference.