# Strategies and validation

Start with an authenticated session; every snippet below uses `qts`:

```ts
import { authenticate } from '@qtsurfer/sdk';

const qts = await authenticate(); // reads QTSURFER_APIKEY
```

`compileStrategy` registers Java source and returns its `strategyId`. Validate before an expensive
run: validation loads the class and drives a bounded synthetic series.

```ts
const compiled = await qts.compileStrategy(source);
const outcome = await qts.validateStrategy(compiled.strategyId);

if (outcome.queued) {
  const state = await qts.getStrategy(compiled.strategyId);
  console.log(state.validation);
}
```

Validation is idempotent. `queued: false` means no new check was started, not necessarily that a
check passed. Poll `getStrategy` with an application deadline while validation is `pending`; a
passed bounded check is a useful floor, not a trading-performance guarantee.

```ts
const mine = await qts.getStrategies();
const catalogIncludingDeleted = await qts.getStrategies({ includeDeleted: true });
const removedAt = catalogIncludingDeleted.find((strategy) => strategy.deletedAt);
console.log(removedAt?.strategyId, removedAt?.deletedAt);
const registeredSource = await qts.getStrategyCode(compiled.strategyId);
await qts.deleteStrategy(compiled.strategyId);
```

`getStrategies()` excludes soft-deleted strategies by default. Use `{ includeDeleted: true }` when
reconciling a local catalog; deleted entries carry `deletedAt`. Listing them does not restore them,
and a deleted strategy cannot be used for a new run.

For indicators, `emitBuy`/`emitSell`, information signals, order configuration, and chart metadata,
see the API's [Coding Java strategies](https://www.qtsurfer.com/docs/developers/api/strategy_coding) guide
and the [`qtsurfer-java-strategy`](https://github.com/QTSurfer/strategy-skills) skill.
