NexusTrade guide

Create an algorithmic cryptocurrency strategy

Turn a crypto trading idea into explicit pair, indicator, allocation and exit rules.

As of 2026-10-10

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.

Define the trading rule: authored process map
Authored task map. It describes what to inspect; it is not an account screenshot or a measured result.
Step 1 of 3

Define the trading rule

Choose the full pair and Cryptocurrency asset type. The BTC trend example buys when BTC-USD price is above its 50-day average and no BTC position is held. It allocates 95% of buying power and sells all held units when price is at or below the average. Fractional units are enabled.

What you should see

A task anchored to the same saved example and pair.

Build with Aurora: authored process map
Authored task map. It describes what to inspect; it is not an account screenshot or a measured result.
Step 2 of 3

Build with Aurora

Review the saved conditions and actions together. Confirm the asset type, full pair, allocation and position-value check.

What you should see

Units and timestamps that explain the result, not an unexplained headline return.

Open a bounded review in Aurora: authored process map
Authored task map. It describes what to inspect; it is not an account screenshot or a measured result.
Step 3 of 3

Open a bounded review in Aurora

Review your request with the exact candidate or returned test ID. Keep the full pair and all cost assumptions. Do not resubmit an already running test.

What you should see

The next inspectable draft or read-only result request, with saving and execution left to explicit user action.

Define the trading rule

Choose the full pair and Cryptocurrency asset type. The BTC trend example buys when BTC-USD price is above its 50-day average and no BTC position is held. It allocates 95% of buying power and sells all held units when price is at or below the average. Fractional units are enabled.

Build with Aurora

Review the saved conditions and actions together. Confirm the asset type, full pair, allocation and position-value check.

Prompt
Create an undeployed research draft named BTC trend with $10,000 initial value, crypto support and fractional units enabled. Use BTC-USD as Cryptocurrency in every indicator and action. Buy 95% of buying power when Price(BTC-USD) > SMA(BTC-USD,50,Day) AND PositionValue(BTC-USD)=0. Sell 100% of current BTC-USD positions when Price <= SMA50 AND PositionValue > 0. Use Market execution and cash dividends. Review the draft, correct any validation issues, save it and show its exact saved rules and identifier. Keep automated trading off. Stop after saving.

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.

  1. Create the exact strategy

    Ask: "Review BTC 50-day trend. Entry: Price > SMA(50, Day) AND position value = 0. Exit: Price <= SMA(50, Day) AND position value > 0. Show the resolved rules and selectors before saving." The request includes this example's complete draft.

  2. 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 strategy with SPY and BTC buy and hold. Use SPY as the backtest baseline and a separate BTC buy-and-hold backtest with matching dates and starting capital.

  3. 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."

  4. Create one variant, then test unseen dates

    Ask: "Change only the entry allocation from 95% to 75% of buying power. 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_btc_trend_following.py.

Install and download

Shell
python3 -m pip install nexustrade==1.42.0
export NEXUSTRADE_API_KEY="YOUR_API_KEY"
curl --fail --output btc_trend_following.py https://nexustrade.io/seo/strategy-examples/btc-trend-following.py

Create, test and inspect

Python
from btc_trend_following import create_btc_trend_following, backtest_btc_trend_following

book = create_btc_trend_following()
completed = backtest_btc_trend_following()
print(completed["result"])

Run

Shell
python3 run_btc_trend_following.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.

Python
import nexustrade as nt


def create_btc_trend_following():
    asset = nt.crypto_asset("BTC-USD")
    return nt.portfolio(
        "Public SEO crypto example - BTC 50-day trend",
        [
            nt.strategy(
                "Enter BTC 50-day trend",
                ((nt.Price(asset) > nt.SMA(asset, 50, "Day")) & (nt.PositionValue(asset) == nt.Value(0))),
                nt.buy(asset, 95, "percent of buying power")
            ),
            nt.strategy(
                "Exit BTC 50-day trend",
                ((nt.Price(asset) <= nt.SMA(asset, 50, "Day")) & (nt.PositionValue(asset) > nt.Value(0))),
                nt.sell(asset, 100, "percent of current positions")
            ),
        ],
        initial_value=10000,
        supports_crypto=True,
        supports_fractional_shares=True,
        alerts_enabled=False,
        dividend_policy='cash',
    )


def backtest_btc_trend_following(client=None):
    client = client or nt.NexusTradeClient.from_environment()
    operation = client.create_backtest(
        nt.backtest(
            create_btc_trend_following(),
            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-btc-trend-following-2024-spy-v1",
    )
    return client.wait_for_backtest(operation["id"])


# Build locally: book = create_btc_trend_following()
# Run and inspect: completed = backtest_btc_trend_following(); print(completed["result"])

Create and backtest with TypeScript

TypeScript SDK 1.42.0. Save the runner below as run-btc-trend-following.ts.

Install and download

Shell
npm install nexustrade@1.42.0
npm install --save-dev tsx
export NEXUSTRADE_API_KEY="YOUR_API_KEY"
curl --fail --output btc-trend-following.ts https://nexustrade.io/seo/strategy-examples/btc-trend-following.ts

Create, test and inspect

TypeScript
import { createBtcTrendFollowing, backtestBtcTrendFollowing } from "./btc-trend-following";

async function main() {
  const book = createBtcTrendFollowing();
  const completed = await backtestBtcTrendFollowing();
  console.log(completed.result);
}

main().catch((error: unknown) => {
  console.error(error);
  process.exitCode = 1;
});

Run

Shell
npx tsx run-btc-trend-following.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.

TypeScript
import * as nt from "nexustrade";

export function createBtcTrendFollowing() {
  const asset = nt.cryptoAsset("BTC-USD");
  return nt.portfolio(
    "Public SEO crypto example - BTC 50-day trend",
    [
      nt.strategy(
          "Enter BTC 50-day trend",
          nt.and(
              nt.gt(nt.Price(asset), nt.SMA(asset, 50, "Day")),
              nt.eq(nt.PositionValue(asset), nt.Value(0))
          ),
          nt.buy(asset, 95, "percent of buying power")
      ),
      nt.strategy(
          "Exit BTC 50-day trend",
          nt.and(
              nt.lte(nt.Price(asset), nt.SMA(asset, 50, "Day")),
              nt.gt(nt.PositionValue(asset), nt.Value(0))
          ),
          nt.sell(asset, 100, "percent of current positions")
      ),
    ],
    { initialValue: 10000, supportsCrypto: true, supportsFractionalShares: true, alertsEnabled: false, dividendPolicy: "cash" }
  );
}

export async function backtestBtcTrendFollowing(client = new nt.NexusTradeClient()) {
  const operation = await client.createBacktest(
    nt.backtest(createBtcTrendFollowing(), {
      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-btc-trend-following-2024-spy-v1" }
  );
  if (typeof operation.id !== "string") throw new Error("Missing backtest ID");
  return client.waitForBacktest(operation.id);
}

// Build locally: const book = createBtcTrendFollowing();
// Run and inspect: const completed = await backtestBtcTrendFollowing(); console.log(completed.result);

Continue exploring

Aurora · AI research assistant

Try this in Aurora

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