nexustrade 1.12.0 → 1.14.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
@@ -194,6 +194,21 @@ nt.strategy("Sell the spread for $1.50 or better", nt.always(), optionAction, {
194
194
  });
195
195
  ```
196
196
 
197
+ An option net limit can also follow a position the strategy holds. Pass an
198
+ indicator instead of a number and the engine evaluates it when the strategy
199
+ fires. If it has no positive value at that moment, no order is placed:
200
+
201
+ ```ts
202
+ nt.strategy("Sell the credit spread for the debit fill plus $0.50", whenDebitSpreadHeld, creditSpreadAction, {
203
+ orderExecution: nt.limitOrder({
204
+ price: nt.minimumNetCredit(
205
+ nt.Plus(nt.OptionSpreadEntryPrice("SPX", "call", "long", "vertical"), nt.Value(0.5)),
206
+ ),
207
+ workingTime: nt.goodForDay(),
208
+ }),
209
+ });
210
+ ```
211
+
197
212
  `currentLimit()` creates a quote-relative Limit for dynamic rebalance strategies.
198
213
  It keeps the no-worse-than-current-quote protection, but it is not a resting
199
214
  price target. Live option strategies must choose an explicit Limit policy.
@@ -208,7 +223,7 @@ price target. Live option strategies must choose an explicit Limit policy.
208
223
  | **Position state** | `PositionValue` `PositionPercentChange` `PositionMaxDrawdown` |
209
224
  | **Portfolio state** | `PortfolioValue` `BuyingPower` `MaxDrawdown` `InitialValue` |
210
225
  | **Fundamentals** | `Fundamental` `Economic` `DaysUntilEarnings` `IsIndexMember` `IsIndustry` |
211
- | **Options** | `OptionDaysToExpiration` `OptionCollateral` `OptionUnrealizedPnL` `openOption` `closeOption` |
226
+ | **Options** | `OptionDaysToExpiration` `OptionCollateral` `OptionSpreadEntryPrice` `OptionUnrealizedPnL` `openOption` `closeOption` |
212
227
  | **Actions** | `buy` `sell` `alert` `dynamicRebalance` `rebalanceOption` |
213
228
  | **Selection** | `filter` `selectTop` `selectPercentile` `universe` |
214
229
  | **Logic** | `always` `atLeast` `atMost` `exactly` `fewerThan` `multi` `and` `or` `sequence` |
@@ -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,7 +84,10 @@ 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;
90
+ exports.OptionSpreadEntryPrice = OptionSpreadEntryPrice;
88
91
  exports.OptionUnrealizedPnL = OptionUnrealizedPnL;
89
92
  exports.Plus = Plus;
90
93
  exports.PortfolioValue = PortfolioValue;
@@ -436,11 +439,13 @@ const unitPriceLimit = (amount) => ({
436
439
  amount,
437
440
  });
438
441
  exports.unitPriceLimit = unitPriceLimit;
442
+ /** Dollars per share, or an indicator evaluated when the strategy fires. */
439
443
  const maximumNetDebit = (amount) => ({
440
444
  type: "MaximumNetDebit",
441
445
  amount,
442
446
  });
443
447
  exports.maximumNetDebit = maximumNetDebit;
448
+ /** Dollars per share, or an indicator evaluated when the strategy fires. */
444
449
  const minimumNetCredit = (amount) => ({
445
450
  type: "MinimumNetCredit",
446
451
  amount,
@@ -1337,6 +1342,36 @@ function OptionPositionValue(underlying, optionType, direction, spreadType) {
1337
1342
  d["spreadType"] = spreadType;
1338
1343
  return d;
1339
1344
  }
1345
+ /**
1346
+ * OptionRealizedPnL indicator.
1347
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1348
+ * @param optionType Filter by Call or Put. Leave empty for all.
1349
+ * @param direction Filter by Long or Short. Leave empty for all.
1350
+ * @param spreadType Filter by spread type. Leave empty for all.
1351
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1352
+ */
1353
+ function OptionRealizedPnL(underlying, optionType, direction, spreadType, lookbackDays) {
1354
+ const d = { type: "OptionRealizedPnL" };
1355
+ d["underlying"] = underlying;
1356
+ d["optionType"] = optionType;
1357
+ d["direction"] = direction;
1358
+ d["spreadType"] = spreadType;
1359
+ if (lookbackDays !== undefined)
1360
+ d["lookbackDays"] = lookbackDays;
1361
+ return d;
1362
+ }
1363
+ /**
1364
+ * OptionRealizedPremium indicator.
1365
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1366
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1367
+ */
1368
+ function OptionRealizedPremium(underlying, lookbackDays) {
1369
+ const d = { type: "OptionRealizedPremium" };
1370
+ d["underlying"] = underlying;
1371
+ if (lookbackDays !== undefined)
1372
+ d["lookbackDays"] = lookbackDays;
1373
+ return d;
1374
+ }
1340
1375
  /**
1341
1376
  * OptionSpreadCount indicator.
1342
1377
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1352,6 +1387,21 @@ function OptionSpreadCount(underlying, optionType, direction, spreadType) {
1352
1387
  d["spreadType"] = spreadType;
1353
1388
  return d;
1354
1389
  }
1390
+ /**
1391
+ * OptionSpreadEntryPrice indicator.
1392
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1393
+ * @param optionType Filter by Call or Put. Leave empty for all.
1394
+ * @param direction Filter by Long or Short. Leave empty for all.
1395
+ * @param spreadType Filter by spread type. Leave empty for all.
1396
+ */
1397
+ function OptionSpreadEntryPrice(underlying, optionType, direction, spreadType) {
1398
+ const d = { type: "OptionSpreadEntryPrice" };
1399
+ d["underlying"] = underlying;
1400
+ d["optionType"] = optionType;
1401
+ d["direction"] = direction;
1402
+ d["spreadType"] = spreadType;
1403
+ return d;
1404
+ }
1355
1405
  /**
1356
1406
  * OptionUnrealizedPnL indicator.
1357
1407
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1721,6 +1771,14 @@ const geneEntryCondition = (strategyIndex, values) => ({
1721
1771
  values: values,
1722
1772
  });
1723
1773
  exports.geneEntryCondition = geneEntryCondition;
1774
+ /** Sweep EntryCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1775
+ const geneReplaceEntryCondition = (strategyIndex, values) => ({
1776
+ field: "EntryCondition",
1777
+ scope: "Strategy",
1778
+ target: { scope: "Strategy", field: "EntryCondition", strategyIndex, replace: true },
1779
+ values: values,
1780
+ });
1781
+ exports.geneReplaceEntryCondition = geneReplaceEntryCondition;
1724
1782
  /** Sweep ExitCondition (Strategy scope) over a value set. */
1725
1783
  const geneExitCondition = (strategyIndex, values) => ({
1726
1784
  field: "ExitCondition",
@@ -1729,6 +1787,14 @@ const geneExitCondition = (strategyIndex, values) => ({
1729
1787
  values: values,
1730
1788
  });
1731
1789
  exports.geneExitCondition = geneExitCondition;
1790
+ /** Sweep ExitCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1791
+ const geneReplaceExitCondition = (strategyIndex, values) => ({
1792
+ field: "ExitCondition",
1793
+ scope: "Strategy",
1794
+ target: { scope: "Strategy", field: "ExitCondition", strategyIndex, replace: true },
1795
+ values: values,
1796
+ });
1797
+ exports.geneReplaceExitCondition = geneReplaceExitCondition;
1732
1798
  /** Sweep EntryCooldownDays (Strategy scope) over a value set. */
1733
1799
  const geneEntryCooldownDays = (strategyIndex, values) => ({
1734
1800
  field: "EntryCooldownDays",
@@ -407,10 +407,10 @@ export type StrategyLimitPricePolicy = {
407
407
  amount: number;
408
408
  } | {
409
409
  type: "MaximumNetDebit";
410
- amount: number;
410
+ amount: number | Indicator;
411
411
  } | {
412
412
  type: "MinimumNetCredit";
413
- amount: number;
413
+ amount: number | Indicator;
414
414
  };
415
415
  export type StrategyOrderExecutionPolicy = {
416
416
  type: "Market";
@@ -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";
@@ -636,8 +636,10 @@ export declare const limitOrder: (config: {
636
636
  }) => StrategyOrderExecutionPolicy;
637
637
  export declare const currentLimit: () => StrategyLimitPricePolicy;
638
638
  export declare const unitPriceLimit: (amount: number) => StrategyLimitPricePolicy;
639
- export declare const maximumNetDebit: (amount: number) => StrategyLimitPricePolicy;
640
- export declare const minimumNetCredit: (amount: number) => StrategyLimitPricePolicy;
639
+ /** Dollars per share, or an indicator evaluated when the strategy fires. */
640
+ export declare const maximumNetDebit: (amount: number | Indicator) => StrategyLimitPricePolicy;
641
+ /** Dollars per share, or an indicator evaluated when the strategy fires. */
642
+ export declare const minimumNetCredit: (amount: number | Indicator) => StrategyLimitPricePolicy;
641
643
  export declare const goodForDay: () => StrategyLimitWorkingTime;
642
644
  export declare const goodForMinutes: (minutes: number) => StrategyLimitWorkingTime;
643
645
  export declare const strategy: (name: string, condition: StrategyCondition, action: Action, options?: {
@@ -1131,6 +1133,21 @@ export declare function OptionPositionPercentChange(underlying: string, optionTy
1131
1133
  * @param spreadType Filter by spread type. Leave empty for all.
1132
1134
  */
1133
1135
  export declare function OptionPositionValue(underlying: string, optionType: OptionType, direction: OptionDirection, spreadType: OptionSpreadType): Indicator;
1136
+ /**
1137
+ * OptionRealizedPnL indicator.
1138
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1139
+ * @param optionType Filter by Call or Put. Leave empty for all.
1140
+ * @param direction Filter by Long or Short. Leave empty for all.
1141
+ * @param spreadType Filter by spread type. Leave empty for all.
1142
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1143
+ */
1144
+ export declare function OptionRealizedPnL(underlying: string, optionType: OptionType, direction: OptionDirection, spreadType: OptionSpreadType, lookbackDays?: number): Indicator;
1145
+ /**
1146
+ * OptionRealizedPremium indicator.
1147
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1148
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1149
+ */
1150
+ export declare function OptionRealizedPremium(underlying: string, lookbackDays?: number): Indicator;
1134
1151
  /**
1135
1152
  * OptionSpreadCount indicator.
1136
1153
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1139,6 +1156,14 @@ export declare function OptionPositionValue(underlying: string, optionType: Opti
1139
1156
  * @param spreadType Filter by spread type. Leave empty for all.
1140
1157
  */
1141
1158
  export declare function OptionSpreadCount(underlying: string, optionType: OptionType, direction: OptionDirection, spreadType: OptionSpreadType): Indicator;
1159
+ /**
1160
+ * OptionSpreadEntryPrice indicator.
1161
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1162
+ * @param optionType Filter by Call or Put. Leave empty for all.
1163
+ * @param direction Filter by Long or Short. Leave empty for all.
1164
+ * @param spreadType Filter by spread type. Leave empty for all.
1165
+ */
1166
+ export declare function OptionSpreadEntryPrice(underlying: string, optionType: OptionType, direction: OptionDirection, spreadType: OptionSpreadType): Indicator;
1142
1167
  /**
1143
1168
  * OptionUnrealizedPnL indicator.
1144
1169
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1340,13 +1365,13 @@ export interface JobRequest {
1340
1365
  args: Record<string, unknown>;
1341
1366
  }
1342
1367
  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. */
1368
+ /** 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
1369
  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. */
1370
+ /** 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
1371
  endDate: string;
1347
1372
  /** 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
1373
  baselineSymbol?: string;
1349
- /** Time interval: Day or Minute (default Day). Minute is a daytrade tape — first-look 90 days, hard max 365 days. */
1374
+ /** 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
1375
  interval?: "Day" | "Minute";
1351
1376
  /** Starting portfolio value (default 10000) Range 1..inf. */
1352
1377
  initialValue?: number;
@@ -1356,7 +1381,7 @@ export interface BacktestConfig {
1356
1381
  feeConfig?: FeeConfig;
1357
1382
  }
1358
1383
  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. */
1384
+ /** 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
1385
  globalStartDate: string;
1361
1386
  /** Global calendar end for the walk-forward study (ISO date). */
1362
1387
  globalEndDate: string;
@@ -1420,9 +1445,9 @@ export interface WalkForwardConfig {
1420
1445
  genes?: Gene[];
1421
1446
  }
1422
1447
  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. */
1448
+ /** 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
1449
  startDate: string;
1425
- /** Optimization end date (ISO format, e.g. 2024-12-31). Minute selected range cannot exceed 365 days. */
1450
+ /** 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
1451
  endDate: string;
1427
1452
  /** Fitness functions: sharpeRatio, sortinoRatio, maxDrawdown, avgDrawdown, percentChange, dollarsSold, ulcerPerformanceIndex, participationRate, distinctUnderlyingsTraded, medianDeployment */
1428
1453
  fitnessFunctions?: ("sharpeRatio" | "sortinoRatio" | "maxDrawdown" | "avgDrawdown" | "percentChange" | "dollarsSold" | "ulcerPerformanceIndex" | "participationRate" | "distinctUnderlyingsTraded" | "medianDeployment")[];
@@ -1472,11 +1497,21 @@ export declare const geneEntryCondition: (strategyIndex: number, values: {
1472
1497
  label: string;
1473
1498
  condition: Condition;
1474
1499
  }[]) => Gene;
1500
+ /** Sweep EntryCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1501
+ export declare const geneReplaceEntryCondition: (strategyIndex: number, values: {
1502
+ label: string;
1503
+ condition: Condition;
1504
+ }[]) => Gene;
1475
1505
  /** Sweep ExitCondition (Strategy scope) over a value set. */
1476
1506
  export declare const geneExitCondition: (strategyIndex: number, values: {
1477
1507
  label: string;
1478
1508
  condition: Condition;
1479
1509
  }[]) => Gene;
1510
+ /** Sweep ExitCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1511
+ export declare const geneReplaceExitCondition: (strategyIndex: number, values: {
1512
+ label: string;
1513
+ condition: Condition;
1514
+ }[]) => Gene;
1480
1515
  /** Sweep EntryCooldownDays (Strategy scope) over a value set. */
1481
1516
  export declare const geneEntryCooldownDays: (strategyIndex: number, values: number[]) => Gene;
1482
1517
  /** Sweep ConditionWindowLength (Strategy scope) over a value set. */
@@ -273,10 +273,12 @@ export const unitPriceLimit = (amount) => ({
273
273
  type: "UnitPrice",
274
274
  amount,
275
275
  });
276
+ /** Dollars per share, or an indicator evaluated when the strategy fires. */
276
277
  export const maximumNetDebit = (amount) => ({
277
278
  type: "MaximumNetDebit",
278
279
  amount,
279
280
  });
281
+ /** Dollars per share, or an indicator evaluated when the strategy fires. */
280
282
  export const minimumNetCredit = (amount) => ({
281
283
  type: "MinimumNetCredit",
282
284
  amount,
@@ -1167,6 +1169,36 @@ export function OptionPositionValue(underlying, optionType, direction, spreadTyp
1167
1169
  d["spreadType"] = spreadType;
1168
1170
  return d;
1169
1171
  }
1172
+ /**
1173
+ * OptionRealizedPnL indicator.
1174
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1175
+ * @param optionType Filter by Call or Put. Leave empty for all.
1176
+ * @param direction Filter by Long or Short. Leave empty for all.
1177
+ * @param spreadType Filter by spread type. Leave empty for all.
1178
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1179
+ */
1180
+ export function OptionRealizedPnL(underlying, optionType, direction, spreadType, lookbackDays) {
1181
+ const d = { type: "OptionRealizedPnL" };
1182
+ d["underlying"] = underlying;
1183
+ d["optionType"] = optionType;
1184
+ d["direction"] = direction;
1185
+ d["spreadType"] = spreadType;
1186
+ if (lookbackDays !== undefined)
1187
+ d["lookbackDays"] = lookbackDays;
1188
+ return d;
1189
+ }
1190
+ /**
1191
+ * OptionRealizedPremium indicator.
1192
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1193
+ * @param lookbackDays Only count activity within this many days of the evaluation date. Leave empty for the whole life of the book.
1194
+ */
1195
+ export function OptionRealizedPremium(underlying, lookbackDays) {
1196
+ const d = { type: "OptionRealizedPremium" };
1197
+ d["underlying"] = underlying;
1198
+ if (lookbackDays !== undefined)
1199
+ d["lookbackDays"] = lookbackDays;
1200
+ return d;
1201
+ }
1170
1202
  /**
1171
1203
  * OptionSpreadCount indicator.
1172
1204
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1182,6 +1214,21 @@ export function OptionSpreadCount(underlying, optionType, direction, spreadType)
1182
1214
  d["spreadType"] = spreadType;
1183
1215
  return d;
1184
1216
  }
1217
+ /**
1218
+ * OptionSpreadEntryPrice indicator.
1219
+ * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
1220
+ * @param optionType Filter by Call or Put. Leave empty for all.
1221
+ * @param direction Filter by Long or Short. Leave empty for all.
1222
+ * @param spreadType Filter by spread type. Leave empty for all.
1223
+ */
1224
+ export function OptionSpreadEntryPrice(underlying, optionType, direction, spreadType) {
1225
+ const d = { type: "OptionSpreadEntryPrice" };
1226
+ d["underlying"] = underlying;
1227
+ d["optionType"] = optionType;
1228
+ d["direction"] = direction;
1229
+ d["spreadType"] = spreadType;
1230
+ return d;
1231
+ }
1185
1232
  /**
1186
1233
  * OptionUnrealizedPnL indicator.
1187
1234
  * @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
@@ -1546,6 +1593,13 @@ export const geneEntryCondition = (strategyIndex, values) => ({
1546
1593
  target: { scope: "Strategy", field: "EntryCondition", strategyIndex },
1547
1594
  values: values,
1548
1595
  });
1596
+ /** Sweep EntryCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1597
+ export const geneReplaceEntryCondition = (strategyIndex, values) => ({
1598
+ field: "EntryCondition",
1599
+ scope: "Strategy",
1600
+ target: { scope: "Strategy", field: "EntryCondition", strategyIndex, replace: true },
1601
+ values: values,
1602
+ });
1549
1603
  /** Sweep ExitCondition (Strategy scope) over a value set. */
1550
1604
  export const geneExitCondition = (strategyIndex, values) => ({
1551
1605
  field: "ExitCondition",
@@ -1553,6 +1607,13 @@ export const geneExitCondition = (strategyIndex, values) => ({
1553
1607
  target: { scope: "Strategy", field: "ExitCondition", strategyIndex },
1554
1608
  values: values,
1555
1609
  });
1610
+ /** Sweep ExitCondition (Strategy scope), replacing the seed's gate rather than adding to it. */
1611
+ export const geneReplaceExitCondition = (strategyIndex, values) => ({
1612
+ field: "ExitCondition",
1613
+ scope: "Strategy",
1614
+ target: { scope: "Strategy", field: "ExitCondition", strategyIndex, replace: true },
1615
+ values: values,
1616
+ });
1556
1617
  /** Sweep EntryCooldownDays (Strategy scope) over a value set. */
1557
1618
  export const geneEntryCooldownDays = (strategyIndex, values) => ({
1558
1619
  field: "EntryCooldownDays",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexustrade",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "Typed TypeScript SDK for NexusTrade portfolio authoring, backtesting, and optimization",
5
5
  "license": "MIT",
6
6
  "author": "Starks Technology",