nexustrade 1.11.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -325,6 +325,49 @@ await client.listPortfolios({ includePaper: true, includePositions: true });
325
325
  await client.getPortfolio(portfolioId);
326
326
  ```
327
327
 
328
+ ### Editing a saved portfolio
329
+
330
+ `updatePortfolio` applies deterministic edits with no LLM in the path. The
331
+ `operations` array is a typed union, so the compiler knows which fields each
332
+ edit needs.
333
+
334
+ ```ts
335
+ import type { PortfolioEditOperation } from "nexustrade";
336
+
337
+ const operations: PortfolioEditOperation[] = [
338
+ { type: "rename", name: "AAPL Income" },
339
+ {
340
+ type: "replaceStrategy",
341
+ targetStrategyId: strategyId, // or targetStrategyName
342
+ strategyObject: nt.strategy(
343
+ "Buy AAPL",
344
+ nt.always(),
345
+ nt.buy(nt.stockAsset("AAPL"), 25, "percent of portfolio"),
346
+ {
347
+ orderExecution: nt.limitOrder({
348
+ price: nt.unitPriceLimit(150),
349
+ workingTime: nt.goodForDay(),
350
+ }),
351
+ },
352
+ ),
353
+ },
354
+ ];
355
+
356
+ await client.updatePortfolio(portfolioId, operations, {
357
+ idempotencyKey: "aapl-limit-v1",
358
+ });
359
+ ```
360
+
361
+ The five edits are `rename`, `addStrategies`, `removeStrategies`,
362
+ `replaceStrategy`, and `replaceStrategies`. Deploy, undeploy, delete,
363
+ scheduling, and trading-policy operations are not reachable on this route.
364
+
365
+ **`replaceStrategies` replaces the whole set**, so a strategy left out of the
366
+ array is deleted. Carry unchanged strategies through verbatim, including the
367
+ `orderExecution` each already has, or a working Limit silently reverts to
368
+ Market. `removeStrategies` takes strategy ids from a fetched portfolio; removal
369
+ by name is rejected.
370
+
328
371
  Fetched portfolio handles include a typed, read-only `policy` snapshot. Trading
329
372
  policy changes are intentionally unavailable through the SDK; edit them in
330
373
  Portfolio Settings. `PortfolioHandle.toJSON()` omits the snapshot so a fetched
@@ -25,6 +25,14 @@ function asJsonObject(value) {
25
25
  }
26
26
  return value;
27
27
  }
28
+ /**
29
+ * Boundary adapter, for the same reason `asJsonObject` exists: the operation
30
+ * members are `interface`s, which TypeScript denies the implicit index
31
+ * signature `JsonObject` requires. An operation is JSON by construction.
32
+ */
33
+ function editOperationAsJsonObject(operation) {
34
+ return { ...operation };
35
+ }
28
36
  function encodeQuery(params) {
29
37
  const search = new URLSearchParams();
30
38
  for (const [key, value] of Object.entries(params)) {
@@ -843,7 +851,7 @@ class NexusTradeClient {
843
851
  throw new Error("updatePortfolio needs at least one operation.");
844
852
  }
845
853
  const response = await this.transport.request("POST", `portfolios/${encodePathSegment(portfolioId)}/operations`, {
846
- body: { operations: operations.map((operation) => ({ ...operation })) },
854
+ body: { operations: operations.map(editOperationAsJsonObject) },
847
855
  idempotencyKey: options.idempotencyKey,
848
856
  });
849
857
  if (!isJsonObject(response.portfolio)) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.currentLimit = exports.limitOrder = exports.closeOption = exports.greeksTrigger = exports.daysHeldTrigger = exports.dteTrigger = exports.pnlTrigger = exports.rebalanceOption = exports.sleeve = exports.structureTemplate = exports.openOption = exports.againstParent = exports.optionsBuilder = exports.leg = exports.dynamicRebalance = exports.launchAgent = exports.alert = exports.sell = exports.buy = exports.selectPercentile = exports.selectTop = exports.filter = exports.RebalanceNetBenefit = exports.RebalanceExpectedBenefit = exports.RebalanceEstimatedCost = exports.RebalancePlannedTurnover = exports.RebalanceAllocationDrift = exports.volatilityTarget = exports.maximumDiversificationAllocation = exports.riskParityAllocation = exports.meanVarianceAllocation = exports.always = exports.andThen = exports.multi = exports.exactly = exports.fewerThan = exports.atMost = exports.atLeast = exports.or = exports.and = exports.neq = exports.eq = exports.lte = exports.gte = exports.lt = exports.gt = exports.cryptoAsset = exports.stockAsset = exports.PORTFOLIO_WIDE = exports.CANDIDATE = void 0;
4
- exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneMaxSpreadPct = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = exports.geneExposurePolicy = exports.geneAllocationPolicy = exports.geneStructureKind = exports.geneStopLossPct = exports.geneTakeProfitPct = exports.geneRollTriggerDte = exports.geneDeploymentPct = exports.geneTotalBudgetPct = exports.geneAllocationPct = exports.geneBuyingPowerPct = exports.geneRankSignal = exports.geneConditionThreshold = exports.geneConditionWindowLength = exports.geneEntryCooldownDays = exports.geneExitCondition = exports.geneEntryCondition = exports.geneSubject = exports.optimization = exports.walkForward = exports.backtest = exports.SMA = exports.RSI = exports.PriceStdDev = exports.EMA = exports.BBand = exports.portfolio = exports.sessionFlatten = exports.strategy = exports.goodForMinutes = exports.goodForDay = exports.minimumNetCredit = exports.maximumNetDebit = exports.unitPriceLimit = void 0;
4
+ exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneMaxSpreadPct = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = exports.geneExposurePolicy = exports.geneAllocationPolicy = exports.geneStructureKind = exports.geneStopLossPct = exports.geneTakeProfitPct = exports.geneRollTriggerDte = exports.geneDeploymentPct = exports.geneTotalBudgetPct = exports.geneAllocationPct = exports.geneBuyingPowerPct = exports.geneRankSignal = exports.geneConditionThreshold = exports.geneConditionWindowLength = exports.geneEntryCooldownDays = exports.geneReplaceExitCondition = exports.geneExitCondition = exports.geneReplaceEntryCondition = exports.geneEntryCondition = exports.geneSubject = exports.optimization = exports.walkForward = exports.backtest = exports.SMA = exports.RSI = exports.PriceStdDev = exports.EMA = exports.BBand = exports.portfolio = exports.sessionFlatten = exports.strategy = exports.goodForMinutes = exports.goodForDay = exports.minimumNetCredit = exports.maximumNetDebit = exports.unitPriceLimit = void 0;
5
5
  exports.universe = universe;
6
6
  exports.AbsoluteValue = AbsoluteValue;
7
7
  exports.AverageTrueRange = AverageTrueRange;
@@ -84,6 +84,8 @@ exports.OptionPositionCount = OptionPositionCount;
84
84
  exports.OptionPositionMaxDrawdown = OptionPositionMaxDrawdown;
85
85
  exports.OptionPositionPercentChange = OptionPositionPercentChange;
86
86
  exports.OptionPositionValue = OptionPositionValue;
87
+ exports.OptionRealizedPnL = OptionRealizedPnL;
88
+ exports.OptionRealizedPremium = OptionRealizedPremium;
87
89
  exports.OptionSpreadCount = OptionSpreadCount;
88
90
  exports.OptionUnrealizedPnL = OptionUnrealizedPnL;
89
91
  exports.Plus = Plus;
@@ -1337,6 +1339,36 @@ function OptionPositionValue(underlying, optionType, direction, spreadType) {
1337
1339
  d["spreadType"] = spreadType;
1338
1340
  return d;
1339
1341
  }
1342
+ /**
1343
+ * OptionRealizedPnL indicator.
1344
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1345
+ * @param optionType Filter by Call or Put. Leave empty for all.
1346
+ * @param direction Filter by Long or Short. Leave empty for all.
1347
+ * @param spreadType Filter by spread type. Leave empty for all.
1348
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1349
+ */
1350
+ function OptionRealizedPnL(underlying, optionType, direction, spreadType, lookbackDays) {
1351
+ const d = { type: "OptionRealizedPnL" };
1352
+ d["underlying"] = underlying;
1353
+ d["optionType"] = optionType;
1354
+ d["direction"] = direction;
1355
+ d["spreadType"] = spreadType;
1356
+ if (lookbackDays !== undefined)
1357
+ d["lookbackDays"] = lookbackDays;
1358
+ return d;
1359
+ }
1360
+ /**
1361
+ * OptionRealizedPremium indicator.
1362
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1363
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1364
+ */
1365
+ function OptionRealizedPremium(underlying, lookbackDays) {
1366
+ const d = { type: "OptionRealizedPremium" };
1367
+ d["underlying"] = underlying;
1368
+ if (lookbackDays !== undefined)
1369
+ d["lookbackDays"] = lookbackDays;
1370
+ return d;
1371
+ }
1340
1372
  /**
1341
1373
  * OptionSpreadCount indicator.
1342
1374
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1721,6 +1753,14 @@ const geneEntryCondition = (strategyIndex, values) => ({
1721
1753
  values: values,
1722
1754
  });
1723
1755
  exports.geneEntryCondition = geneEntryCondition;
1756
+ /** Sweep EntryCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1757
+ const geneReplaceEntryCondition = (strategyIndex, values) => ({
1758
+ field: "EntryCondition",
1759
+ scope: "Strategy",
1760
+ target: { scope: "Strategy", field: "EntryCondition", strategyIndex, replace: true },
1761
+ values: values,
1762
+ });
1763
+ exports.geneReplaceEntryCondition = geneReplaceEntryCondition;
1724
1764
  /** Sweep ExitCondition (Strategy scope) over a value set. */
1725
1765
  const geneExitCondition = (strategyIndex, values) => ({
1726
1766
  field: "ExitCondition",
@@ -1729,6 +1769,14 @@ const geneExitCondition = (strategyIndex, values) => ({
1729
1769
  values: values,
1730
1770
  });
1731
1771
  exports.geneExitCondition = geneExitCondition;
1772
+ /** Sweep ExitCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1773
+ const geneReplaceExitCondition = (strategyIndex, values) => ({
1774
+ field: "ExitCondition",
1775
+ scope: "Strategy",
1776
+ target: { scope: "Strategy", field: "ExitCondition", strategyIndex, replace: true },
1777
+ values: values,
1778
+ });
1779
+ exports.geneReplaceExitCondition = geneReplaceExitCondition;
1732
1780
  /** Sweep EntryCooldownDays (Strategy scope) over a value set. */
1733
1781
  const geneEntryCooldownDays = (strategyIndex, values) => ({
1734
1782
  field: "EntryCooldownDays",
@@ -5,7 +5,7 @@
5
5
  * pass an API key/base URL, or set NEXUSTRADE_API_KEY / NEXUSTRADE_API_BASE_URL.
6
6
  */
7
7
  import { AgentRun } from "./agent.ts";
8
- import type { JobRequest, Portfolio } from "./generated/ntSdk.generated.js";
8
+ import type { JobRequest, Portfolio, Strategy } from "./generated/ntSdk.generated.js";
9
9
  import { PortfolioHandle, type DeployResult, type PortfolioListResult } from "./portfolio.ts";
10
10
  export type JsonValue = string | number | boolean | null | JsonValue[] | {
11
11
  [key: string]: JsonValue;
@@ -25,6 +25,59 @@ export type JsonObject = {
25
25
  */
26
26
  export type PortfolioInput = Portfolio | JsonObject;
27
27
  export type JobInput = JobRequest | JsonObject;
28
+ /**
29
+ * One deterministic portfolio edit, as accepted by
30
+ * `POST /portfolios/:id/operations`. The book is addressed by the
31
+ * `updatePortfolio` argument, so an operation never carries a portfolio id of
32
+ * its own — the route stamps it and ignores one sent in the body.
33
+ *
34
+ * Strategy payloads are FINISHED objects in the shape `strategy()` emits,
35
+ * `orderExecution` included. The server ingests them deterministically, with no
36
+ * LLM in the path; natural-language strategy strings are rejected.
37
+ */
38
+ export interface PortfolioRenameOperation {
39
+ type: "rename";
40
+ name: string;
41
+ }
42
+ /** Append strategies. Existing strategies and their open orders are untouched. */
43
+ export interface AddStrategiesOperation {
44
+ type: "addStrategies";
45
+ strategyObjects: Strategy[];
46
+ }
47
+ /**
48
+ * Remove strategies by id, as returned on a fetched portfolio's `strategies`.
49
+ * Removal by name is not supported.
50
+ */
51
+ export interface RemoveStrategiesOperation {
52
+ type: "removeStrategies";
53
+ strategyIds: string[];
54
+ }
55
+ /** Swap a single strategy. Exactly one of the two targets identifies it. */
56
+ export type ReplaceStrategyOperation = {
57
+ type: "replaceStrategy";
58
+ strategyObject: Strategy;
59
+ } & ({
60
+ targetStrategyId: string;
61
+ targetStrategyName?: never;
62
+ } | {
63
+ targetStrategyName: string;
64
+ targetStrategyId?: never;
65
+ });
66
+ /**
67
+ * Replace the whole strategy set. The array REPLACES the book, so a strategy
68
+ * left out is deleted — carry unchanged strategies through verbatim, including
69
+ * the `orderExecution` each already has.
70
+ */
71
+ export interface ReplaceStrategiesOperation {
72
+ type: "replaceStrategies";
73
+ strategyObjects: Strategy[];
74
+ }
75
+ /**
76
+ * The edits `updatePortfolio` accepts. Deploy, undeploy, delete, scheduling and
77
+ * trading-policy operations are deliberately absent: they are not reachable on
78
+ * this route, so typing them here would only compile a guaranteed 403.
79
+ */
80
+ export type PortfolioEditOperation = PortfolioRenameOperation | AddStrategiesOperation | RemoveStrategiesOperation | ReplaceStrategyOperation | ReplaceStrategiesOperation;
28
81
  export interface ListPortfoliosOptions {
29
82
  portfolioIds?: string[];
30
83
  includeInactive?: boolean;
@@ -211,7 +264,7 @@ export declare class NexusTradeClient {
211
264
  * Guest workspaces may rename and add/remove/replace strategies; deployment,
212
265
  * scheduling, policy, and trading operations remain account-only.
213
266
  */
214
- updatePortfolio(portfolioId: string, operations: ReadonlyArray<JsonObject>, options: {
267
+ updatePortfolio(portfolioId: string, operations: ReadonlyArray<PortfolioEditOperation>, options: {
215
268
  idempotencyKey: string;
216
269
  }): Promise<PortfolioHandle>;
217
270
  /** Fork a public/shared portfolio into this workspace as an editable copy. */
@@ -18,6 +18,14 @@ function asJsonObject(value) {
18
18
  }
19
19
  return value;
20
20
  }
21
+ /**
22
+ * Boundary adapter, for the same reason `asJsonObject` exists: the operation
23
+ * members are `interface`s, which TypeScript denies the implicit index
24
+ * signature `JsonObject` requires. An operation is JSON by construction.
25
+ */
26
+ function editOperationAsJsonObject(operation) {
27
+ return { ...operation };
28
+ }
21
29
  function encodeQuery(params) {
22
30
  const search = new URLSearchParams();
23
31
  for (const [key, value] of Object.entries(params)) {
@@ -833,7 +841,7 @@ export class NexusTradeClient {
833
841
  throw new Error("updatePortfolio needs at least one operation.");
834
842
  }
835
843
  const response = await this.transport.request("POST", `portfolios/${encodePathSegment(portfolioId)}/operations`, {
836
- body: { operations: operations.map((operation) => ({ ...operation })) },
844
+ body: { operations: operations.map(editOperationAsJsonObject) },
837
845
  idempotencyKey: options.idempotencyKey,
838
846
  });
839
847
  if (!isJsonObject(response.portfolio)) {
@@ -450,7 +450,7 @@ export type SelectDirection = "Highest" | "Lowest";
450
450
  export type UniverseSource = "ALL_US_STOCKS" | "SP500" | "NASDAQ100" | "DJIA" | "CRYPTO" | "SPECIFIC_ASSETS";
451
451
  export type AllocationType = "percent of portfolio" | "percent of buying power" | "percent of current positions" | "dollars" | "number of assets";
452
452
  export type DepositWithdrawAllocationType = "percent of portfolio" | "percent of buying power" | "dollars";
453
- export type OptionAllocationType = "dollars" | "percent of portfolio" | "percent of buying power" | "contracts";
453
+ export type OptionAllocationType = "dollars" | "percent of portfolio" | "percent of buying power" | "contracts" | "percent of realized premium";
454
454
  export type DeploymentBudgetType = "dollars" | "percent of portfolio";
455
455
  export type ExpirationPreference = "nearest" | "middle" | "furthest";
456
456
  export type StrikeDistanceType = "percent" | "dollars" | "delta";
@@ -1131,6 +1131,21 @@ export declare function OptionPositionPercentChange(underlying: string, optionTy
1131
1131
  * @param spreadType Filter by spread type. Leave empty for all.
1132
1132
  */
1133
1133
  export declare function OptionPositionValue(underlying: string, optionType: OptionType, direction: OptionDirection, spreadType: OptionSpreadType): Indicator;
1134
+ /**
1135
+ * OptionRealizedPnL indicator.
1136
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1137
+ * @param optionType Filter by Call or Put. Leave empty for all.
1138
+ * @param direction Filter by Long or Short. Leave empty for all.
1139
+ * @param spreadType Filter by spread type. Leave empty for all.
1140
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1141
+ */
1142
+ export declare function OptionRealizedPnL(underlying: string, optionType: OptionType, direction: OptionDirection, spreadType: OptionSpreadType, lookbackDays?: number): Indicator;
1143
+ /**
1144
+ * OptionRealizedPremium indicator.
1145
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1146
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1147
+ */
1148
+ export declare function OptionRealizedPremium(underlying: string, lookbackDays?: number): Indicator;
1134
1149
  /**
1135
1150
  * OptionSpreadCount indicator.
1136
1151
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1340,13 +1355,13 @@ export interface JobRequest {
1340
1355
  args: Record<string, unknown>;
1341
1356
  }
1342
1357
  export interface BacktestConfig {
1343
- /** Backtest start date (ISO format, e.g. 2024-01-01). For interval=Minute, default first-look is the last 90 inclusive calendar days and the selected range cannot exceed 365 days. Do not use 2010-01-01 or a multi-year span on Minute. */
1358
+ /** Backtest start date (ISO format, e.g. 2024-01-01). For interval=Minute, default first-look is the last 90 inclusive calendar days and the selected range plus minute-indicator warmup cannot exceed 730 days of minute data. Do not use 2010-01-01 on Minute. */
1344
1359
  startDate: string;
1345
- /** Backtest end date (ISO format, e.g. 2024-12-31). Minute hard max is 365 days from start_date; extend a survivor in a later run instead of splitting into yearly Minute jobs. */
1360
+ /** Backtest end date (ISO format, e.g. 2024-12-31). Minute allows up to 730 days of minute data from start_date, counting minute-indicator warmup; never split a longer span into yearly Minute jobs. */
1346
1361
  endDate: string;
1347
1362
  /** Benchmark for comparisonValue (buy-and-hold of this ticker). Defaults to SPY if omitted — use SPY only for broad equity/market strategies. For single-name options, set to that underlying (AAPL options → AAPL). For multi-name options books, run separate backtests with each material underlying as baseline (AAPL for AAPL sleeve, MSFT for MSFT), or equal-weight B&H of the traded universe — do not default to SPY. */
1348
1363
  baselineSymbol?: string;
1349
- /** Time interval: Day or Minute (default Day). Minute is a daytrade tape — first-look 90 days, hard max 365 days. */
1364
+ /** Time interval: Day or Minute (default Day). Minute is a daytrade tape. 730 days of minute data (selected range plus warmup) is the HARD CAP; 90 days is only the DEFAULT when you name no dates. Name the dates you actually want — certifying a candidate on a full year or two is a normal second backtest, not an escalation. */
1350
1365
  interval?: "Day" | "Minute";
1351
1366
  /** Starting portfolio value (default 10000) Range 1..inf. */
1352
1367
  initialValue?: number;
@@ -1356,7 +1371,7 @@ export interface BacktestConfig {
1356
1371
  feeConfig?: FeeConfig;
1357
1372
  }
1358
1373
  export interface WalkForwardConfig {
1359
- /** Global calendar start for the walk-forward study (ISO date). Minute seed first-look is 90 days; each Minute evaluation window still cannot exceed 365 days. */
1374
+ /** Global calendar start for the walk-forward study (ISO date). Each Minute evaluation window cannot exceed 730 days of minute data counting minute-indicator warmup, which is the only cap; the 90-day seed first look is a default for callers who name no dates. */
1360
1375
  globalStartDate: string;
1361
1376
  /** Global calendar end for the walk-forward study (ISO date). */
1362
1377
  globalEndDate: string;
@@ -1420,9 +1435,9 @@ export interface WalkForwardConfig {
1420
1435
  genes?: Gene[];
1421
1436
  }
1422
1437
  export interface OptimizationConfig {
1423
- /** Optimization start date (ISO format, e.g. 2024-01-01). Minute interval inherits the backtest cap: first-look 90 days, hard max 365 days. */
1438
+ /** Optimization start date (ISO format, e.g. 2024-01-01). Minute has ONE cap: 730 days of minute data, counting minute-indicator warmup. The 90-day first look is a default for callers who name no dates, not a ceiling — pass the window the question needs. */
1424
1439
  startDate: string;
1425
- /** Optimization end date (ISO format, e.g. 2024-12-31). Minute selected range cannot exceed 365 days. */
1440
+ /** Optimization end date (ISO format, e.g. 2024-12-31). Minute selected range plus minute-indicator warmup cannot exceed 730 days of minute data. */
1426
1441
  endDate: string;
1427
1442
  /** Fitness functions: sharpeRatio, sortinoRatio, maxDrawdown, avgDrawdown, percentChange, dollarsSold, ulcerPerformanceIndex, participationRate, distinctUnderlyingsTraded, medianDeployment */
1428
1443
  fitnessFunctions?: ("sharpeRatio" | "sortinoRatio" | "maxDrawdown" | "avgDrawdown" | "percentChange" | "dollarsSold" | "ulcerPerformanceIndex" | "participationRate" | "distinctUnderlyingsTraded" | "medianDeployment")[];
@@ -1472,11 +1487,21 @@ export declare const geneEntryCondition: (strategyIndex: number, values: {
1472
1487
  label: string;
1473
1488
  condition: Condition;
1474
1489
  }[]) => Gene;
1490
+ /** Sweep EntryCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1491
+ export declare const geneReplaceEntryCondition: (strategyIndex: number, values: {
1492
+ label: string;
1493
+ condition: Condition;
1494
+ }[]) => Gene;
1475
1495
  /** Sweep ExitCondition (Strategy scope) over a value set. */
1476
1496
  export declare const geneExitCondition: (strategyIndex: number, values: {
1477
1497
  label: string;
1478
1498
  condition: Condition;
1479
1499
  }[]) => Gene;
1500
+ /** Sweep ExitCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1501
+ export declare const geneReplaceExitCondition: (strategyIndex: number, values: {
1502
+ label: string;
1503
+ condition: Condition;
1504
+ }[]) => Gene;
1480
1505
  /** Sweep EntryCooldownDays (Strategy scope) over a value set. */
1481
1506
  export declare const geneEntryCooldownDays: (strategyIndex: number, values: number[]) => Gene;
1482
1507
  /** Sweep ConditionWindowLength (Strategy scope) over a value set. */
@@ -1167,6 +1167,36 @@ export function OptionPositionValue(underlying, optionType, direction, spreadTyp
1167
1167
  d["spreadType"] = spreadType;
1168
1168
  return d;
1169
1169
  }
1170
+ /**
1171
+ * OptionRealizedPnL indicator.
1172
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1173
+ * @param optionType Filter by Call or Put. Leave empty for all.
1174
+ * @param direction Filter by Long or Short. Leave empty for all.
1175
+ * @param spreadType Filter by spread type. Leave empty for all.
1176
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1177
+ */
1178
+ export function OptionRealizedPnL(underlying, optionType, direction, spreadType, lookbackDays) {
1179
+ const d = { type: "OptionRealizedPnL" };
1180
+ d["underlying"] = underlying;
1181
+ d["optionType"] = optionType;
1182
+ d["direction"] = direction;
1183
+ d["spreadType"] = spreadType;
1184
+ if (lookbackDays !== undefined)
1185
+ d["lookbackDays"] = lookbackDays;
1186
+ return d;
1187
+ }
1188
+ /**
1189
+ * OptionRealizedPremium indicator.
1190
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1191
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1192
+ */
1193
+ export function OptionRealizedPremium(underlying, lookbackDays) {
1194
+ const d = { type: "OptionRealizedPremium" };
1195
+ d["underlying"] = underlying;
1196
+ if (lookbackDays !== undefined)
1197
+ d["lookbackDays"] = lookbackDays;
1198
+ return d;
1199
+ }
1170
1200
  /**
1171
1201
  * OptionSpreadCount indicator.
1172
1202
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1546,6 +1576,13 @@ export const geneEntryCondition = (strategyIndex, values) => ({
1546
1576
  target: { scope: "Strategy", field: "EntryCondition", strategyIndex },
1547
1577
  values: values,
1548
1578
  });
1579
+ /** Sweep EntryCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1580
+ export const geneReplaceEntryCondition = (strategyIndex, values) => ({
1581
+ field: "EntryCondition",
1582
+ scope: "Strategy",
1583
+ target: { scope: "Strategy", field: "EntryCondition", strategyIndex, replace: true },
1584
+ values: values,
1585
+ });
1549
1586
  /** Sweep ExitCondition (Strategy scope) over a value set. */
1550
1587
  export const geneExitCondition = (strategyIndex, values) => ({
1551
1588
  field: "ExitCondition",
@@ -1553,6 +1590,13 @@ export const geneExitCondition = (strategyIndex, values) => ({
1553
1590
  target: { scope: "Strategy", field: "ExitCondition", strategyIndex },
1554
1591
  values: values,
1555
1592
  });
1593
+ /** Sweep ExitCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1594
+ export const geneReplaceExitCondition = (strategyIndex, values) => ({
1595
+ field: "ExitCondition",
1596
+ scope: "Strategy",
1597
+ target: { scope: "Strategy", field: "ExitCondition", strategyIndex, replace: true },
1598
+ values: values,
1599
+ });
1556
1600
  /** Sweep EntryCooldownDays (Strategy scope) over a value set. */
1557
1601
  export const geneEntryCooldownDays = (strategyIndex, values) => ({
1558
1602
  field: "EntryCooldownDays",
@@ -1,7 +1,7 @@
1
1
  export { AgentRun } from "./agent.js";
2
2
  export type { AgentEvent, AgentRunOptions } from "./agent.js";
3
3
  export { HttpTransport, NexusTradeApiError, NexusTradeClient, NexusTradeWorkspaceSessionExpiredError, createCustomIndicator, createPortfolio, waitForOperation, } from "./client.js";
4
- export type { BacktestCollateralStatistics, CustomIndicatorInput, CustomIndicatorPointInput, HttpTransportOptions, JsonObject, JsonValue, ListPortfoliosOptions, NexusTradeClientOptions, RequestOptions, Transport, UploadTransport, WaitOptions, WorkspaceSessionTransport, } from "./client.js";
4
+ export type { AddStrategiesOperation, BacktestCollateralStatistics, CustomIndicatorInput, CustomIndicatorPointInput, HttpTransportOptions, JsonObject, JsonValue, ListPortfoliosOptions, NexusTradeClientOptions, PortfolioEditOperation, PortfolioRenameOperation, RemoveStrategiesOperation, ReplaceStrategiesOperation, ReplaceStrategyOperation, RequestOptions, Transport, UploadTransport, WaitOptions, WorkspaceSessionTransport, } from "./client.js";
5
5
  export { PortfolioHandle, portfolioHandleFromWire, } from "./portfolio.js";
6
6
  export type { DeployOutcome, DeployResult, PortfolioHandleOptions, PortfolioListResult, PortfolioType, ReadonlyPortfolioPolicy, } from "./portfolio.js";
7
7
  export * from "./generated/ntSdk.generated.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexustrade",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Typed TypeScript SDK for NexusTrade portfolio authoring, backtesting, and optimization",
5
5
  "license": "MIT",
6
6
  "author": "Starks Technology",