nexustrade 1.12.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.
|
@@ -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",
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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",
|