nexustrade 1.3.1 → 1.5.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
|
@@ -23,6 +23,71 @@ npm install nexustrade
|
|
|
23
23
|
|
|
24
24
|
**Zero runtime dependencies.** ESM and CommonJS builds ship together, with types.
|
|
25
25
|
|
|
26
|
+
## MCP server
|
|
27
|
+
|
|
28
|
+
NexusTrade also exposes the platform as a hosted, remote Model Context Protocol
|
|
29
|
+
server. Modern MCP clients connect directly to the production Streamable HTTP
|
|
30
|
+
endpoint and discover NexusTrade OAuth automatically:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
claude mcp add --transport http nexustrade https://nexustrade.io/api/mcp
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Cursor and other remote-capable clients use:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"nexustrade": {
|
|
42
|
+
"url": "https://nexustrade.io/api/mcp"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For Claude Desktop and other stdio-only clients, use the established
|
|
49
|
+
`mcp-remote` bridge—no clone or local NexusTrade server is required:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"nexustrade": {
|
|
55
|
+
"command": "npx",
|
|
56
|
+
"args": [
|
|
57
|
+
"-y",
|
|
58
|
+
"mcp-remote@latest",
|
|
59
|
+
"https://nexustrade.io/api/mcp",
|
|
60
|
+
"--transport",
|
|
61
|
+
"http-only"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The live server exposes more than 120 tools across market research, portfolio
|
|
69
|
+
construction, backtesting, optimization, walk-forward validation, managed
|
|
70
|
+
compute, Aurora agents, paper trading, and controlled brokerage operations.
|
|
71
|
+
Its creator-marketplace tools cover the full strategy adoption path:
|
|
72
|
+
|
|
73
|
+
- `search_creators` discovers public creators and their marketplace portfolios.
|
|
74
|
+
- `subscribe_portfolio` validates a monetized listing and returns a safe
|
|
75
|
+
checkout preview; the user completes payment in NexusTrade, never through the
|
|
76
|
+
MCP tool.
|
|
77
|
+
- `fork_shared_portfolio` creates a one-time editable copy of a marketplace
|
|
78
|
+
strategy in a new or existing portfolio.
|
|
79
|
+
- `copy_trade_shared` continuously mirrors an accessible strategy into a paper
|
|
80
|
+
or live portfolio at an explicit allocation.
|
|
81
|
+
|
|
82
|
+
See the [developer guide](https://nexustrade.io/developers), the
|
|
83
|
+
[utility tool reference](https://nexustrade.io/docs/api-reference/mcp-tools-utility),
|
|
84
|
+
and the [Aurora tool reference](https://nexustrade.io/docs/api-reference/mcp-tools-aurora).
|
|
85
|
+
|
|
86
|
+
Research and historical results are not investment advice and do not guarantee
|
|
87
|
+
future performance. Keep paper and live modes explicit. Tools that can affect
|
|
88
|
+
portfolios, schedules, or brokerage orders remain subject to the authenticated
|
|
89
|
+
account's NexusTrade permissions and approval controls.
|
|
90
|
+
|
|
26
91
|
## Quickstart
|
|
27
92
|
|
|
28
93
|
```ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = exports.geneStructureKind = exports.geneTakeProfitPct = exports.geneRollTriggerDte = exports.geneDeploymentPct = exports.geneTotalBudgetPct = exports.geneAllocationPct = exports.geneBuyingPowerPct = exports.geneRankSignal = exports.geneEntryCooldownDays = exports.geneExitCondition = exports.geneEntryCondition = void 0;
|
|
3
|
+
exports.portfolio = exports.sessionFlatten = exports.strategy = 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.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.geneEntryCooldownDays = exports.geneExitCondition = exports.geneEntryCondition = exports.geneSubject = exports.optimization = exports.walkForward = exports.backtest = exports.SMA = exports.RSI = exports.PriceStdDev = exports.EMA = exports.BBand = void 0;
|
|
5
5
|
exports.universe = universe;
|
|
6
6
|
exports.AbsoluteValue = AbsoluteValue;
|
|
7
7
|
exports.AverageTrueRange = AverageTrueRange;
|
|
@@ -97,6 +97,7 @@ exports.PriceChangeSinceOpen = PriceChangeSinceOpen;
|
|
|
97
97
|
exports.PriceMeanAbsoluteDeviation = PriceMeanAbsoluteDeviation;
|
|
98
98
|
exports.PriceRateOfChange = PriceRateOfChange;
|
|
99
99
|
exports.PriceStandardDeviation = PriceStandardDeviation;
|
|
100
|
+
exports.RebalanceDecisionMetric = RebalanceDecisionMetric;
|
|
100
101
|
exports.RelativeStrengthIndex = RelativeStrengthIndex;
|
|
101
102
|
exports.SimpleMovingAverage = SimpleMovingAverage;
|
|
102
103
|
exports.SquareRoot = SquareRoot;
|
|
@@ -257,6 +258,59 @@ exports.multi = multi;
|
|
|
257
258
|
/** Always-true gate for strategies whose cadence lives in the pipeline. */
|
|
258
259
|
const always = () => compare(Value(1), Value(0), "greaterThan");
|
|
259
260
|
exports.always = always;
|
|
261
|
+
const meanVarianceAllocation = (config = {}) => ({
|
|
262
|
+
type: "MeanVariance",
|
|
263
|
+
lookbackPeriods: 252,
|
|
264
|
+
minimumObservations: 60,
|
|
265
|
+
riskAversion: 4,
|
|
266
|
+
expectedReturnShrinkage: 0.5,
|
|
267
|
+
covarianceShrinkage: 0.25,
|
|
268
|
+
turnoverPenalty: 1,
|
|
269
|
+
estimatedTransactionCostBps: 10,
|
|
270
|
+
...config,
|
|
271
|
+
});
|
|
272
|
+
exports.meanVarianceAllocation = meanVarianceAllocation;
|
|
273
|
+
const riskParityAllocation = (config = {}) => ({
|
|
274
|
+
type: "RiskParity",
|
|
275
|
+
lookbackPeriods: 252,
|
|
276
|
+
minimumObservations: 60,
|
|
277
|
+
covarianceShrinkage: 0.25,
|
|
278
|
+
turnoverPenalty: 1,
|
|
279
|
+
estimatedTransactionCostBps: 10,
|
|
280
|
+
...config,
|
|
281
|
+
});
|
|
282
|
+
exports.riskParityAllocation = riskParityAllocation;
|
|
283
|
+
const maximumDiversificationAllocation = (config = {}) => ({
|
|
284
|
+
type: "MaximumDiversification",
|
|
285
|
+
lookbackPeriods: 252,
|
|
286
|
+
minimumObservations: 60,
|
|
287
|
+
covarianceShrinkage: 0.25,
|
|
288
|
+
turnoverPenalty: 1,
|
|
289
|
+
estimatedTransactionCostBps: 10,
|
|
290
|
+
...config,
|
|
291
|
+
});
|
|
292
|
+
exports.maximumDiversificationAllocation = maximumDiversificationAllocation;
|
|
293
|
+
const volatilityTarget = (config = {}) => ({
|
|
294
|
+
type: "VolatilityTarget",
|
|
295
|
+
lookbackPeriods: 60,
|
|
296
|
+
minimumObservations: 20,
|
|
297
|
+
covarianceShrinkage: 0.25,
|
|
298
|
+
targetAnnualizedVolatilityPercent: 12,
|
|
299
|
+
estimatedTransactionCostBps: 10,
|
|
300
|
+
...config,
|
|
301
|
+
});
|
|
302
|
+
exports.volatilityTarget = volatilityTarget;
|
|
303
|
+
const rebalanceDecisionMetric = (metric) => ({ type: "RebalanceDecisionMetric", metric });
|
|
304
|
+
const RebalanceAllocationDrift = () => rebalanceDecisionMetric("allocationDrift");
|
|
305
|
+
exports.RebalanceAllocationDrift = RebalanceAllocationDrift;
|
|
306
|
+
const RebalancePlannedTurnover = () => rebalanceDecisionMetric("plannedTurnover");
|
|
307
|
+
exports.RebalancePlannedTurnover = RebalancePlannedTurnover;
|
|
308
|
+
const RebalanceEstimatedCost = () => rebalanceDecisionMetric("estimatedCost");
|
|
309
|
+
exports.RebalanceEstimatedCost = RebalanceEstimatedCost;
|
|
310
|
+
const RebalanceExpectedBenefit = () => rebalanceDecisionMetric("expectedBenefit");
|
|
311
|
+
exports.RebalanceExpectedBenefit = RebalanceExpectedBenefit;
|
|
312
|
+
const RebalanceNetBenefit = () => rebalanceDecisionMetric("netBenefit");
|
|
313
|
+
exports.RebalanceNetBenefit = RebalanceNetBenefit;
|
|
260
314
|
const filter = (condition) => ({ type: "Filter", condition });
|
|
261
315
|
exports.filter = filter;
|
|
262
316
|
const selectTop = (metric, limit, direction = "Highest") => ({ type: "SelectTop", metric, limit, direction });
|
|
@@ -1349,6 +1403,15 @@ function PriceStandardDeviation(asset, length = 30, interval = "Day") {
|
|
|
1349
1403
|
return d;
|
|
1350
1404
|
}
|
|
1351
1405
|
exports.PriceStdDev = PriceStandardDeviation;
|
|
1406
|
+
/**
|
|
1407
|
+
* RebalanceDecisionMetric indicator.
|
|
1408
|
+
* @param metric Reads the prospective plan calculated by DynamicRebalance or RebalanceOption before the strategy condition runs.
|
|
1409
|
+
*/
|
|
1410
|
+
function RebalanceDecisionMetric(metric = "netBenefit") {
|
|
1411
|
+
const d = { type: "RebalanceDecisionMetric" };
|
|
1412
|
+
d["metric"] = metric;
|
|
1413
|
+
return d;
|
|
1414
|
+
}
|
|
1352
1415
|
/**
|
|
1353
1416
|
* RelativeStrengthIndex indicator.
|
|
1354
1417
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1636,21 +1699,29 @@ const geneDeploymentPct = (strategyIndex, values) => ({
|
|
|
1636
1699
|
});
|
|
1637
1700
|
exports.geneDeploymentPct = geneDeploymentPct;
|
|
1638
1701
|
/** Sweep RollTriggerDte (Action scope) over a value set. */
|
|
1639
|
-
const geneRollTriggerDte = (
|
|
1702
|
+
const geneRollTriggerDte = (values, strategyIndex) => ({
|
|
1640
1703
|
field: "RollTriggerDte",
|
|
1641
1704
|
scope: "Action",
|
|
1642
|
-
target: { scope: "Action", field: "RollTriggerDte", strategyIndex },
|
|
1705
|
+
target: { scope: "Action", field: "RollTriggerDte", ...(strategyIndex === undefined ? {} : { strategyIndex }) },
|
|
1643
1706
|
values: values,
|
|
1644
1707
|
});
|
|
1645
1708
|
exports.geneRollTriggerDte = geneRollTriggerDte;
|
|
1646
1709
|
/** Sweep TakeProfitPct (Action scope) over a value set. */
|
|
1647
|
-
const geneTakeProfitPct = (
|
|
1710
|
+
const geneTakeProfitPct = (values, strategyIndex) => ({
|
|
1648
1711
|
field: "TakeProfitPct",
|
|
1649
1712
|
scope: "Action",
|
|
1650
|
-
target: { scope: "Action", field: "TakeProfitPct", strategyIndex },
|
|
1713
|
+
target: { scope: "Action", field: "TakeProfitPct", ...(strategyIndex === undefined ? {} : { strategyIndex }) },
|
|
1651
1714
|
values: values,
|
|
1652
1715
|
});
|
|
1653
1716
|
exports.geneTakeProfitPct = geneTakeProfitPct;
|
|
1717
|
+
/** Sweep StopLossPct (Action scope) over a value set. */
|
|
1718
|
+
const geneStopLossPct = (values, strategyIndex) => ({
|
|
1719
|
+
field: "StopLossPct",
|
|
1720
|
+
scope: "Action",
|
|
1721
|
+
target: { scope: "Action", field: "StopLossPct", ...(strategyIndex === undefined ? {} : { strategyIndex }) },
|
|
1722
|
+
values: values,
|
|
1723
|
+
});
|
|
1724
|
+
exports.geneStopLossPct = geneStopLossPct;
|
|
1654
1725
|
/** Sweep StructureKind (Action scope) over a value set. */
|
|
1655
1726
|
const geneStructureKind = (strategyIndex, values) => ({
|
|
1656
1727
|
field: "StructureKind",
|
|
@@ -1659,6 +1730,22 @@ const geneStructureKind = (strategyIndex, values) => ({
|
|
|
1659
1730
|
values: values,
|
|
1660
1731
|
});
|
|
1661
1732
|
exports.geneStructureKind = geneStructureKind;
|
|
1733
|
+
/** Sweep AllocationPolicy (Action scope) over a value set. */
|
|
1734
|
+
const geneAllocationPolicy = (strategyIndex, values) => ({
|
|
1735
|
+
field: "AllocationPolicy",
|
|
1736
|
+
scope: "Action",
|
|
1737
|
+
target: { scope: "Action", field: "AllocationPolicy", strategyIndex },
|
|
1738
|
+
values: values,
|
|
1739
|
+
});
|
|
1740
|
+
exports.geneAllocationPolicy = geneAllocationPolicy;
|
|
1741
|
+
/** Sweep ExposurePolicy (Action scope) over a value set. */
|
|
1742
|
+
const geneExposurePolicy = (strategyIndex, values) => ({
|
|
1743
|
+
field: "ExposurePolicy",
|
|
1744
|
+
scope: "Action",
|
|
1745
|
+
target: { scope: "Action", field: "ExposurePolicy", strategyIndex },
|
|
1746
|
+
values: values,
|
|
1747
|
+
});
|
|
1748
|
+
exports.geneExposurePolicy = geneExposurePolicy;
|
|
1662
1749
|
/** Sweep OptionDelta (OptionLeg scope) over a value set. */
|
|
1663
1750
|
const geneOptionDelta = (strategyIndex, legIndex, values) => ({
|
|
1664
1751
|
field: "OptionDelta",
|
|
@@ -1683,6 +1770,14 @@ const geneDteBracket = (strategyIndex, legIndex, values) => ({
|
|
|
1683
1770
|
values: values,
|
|
1684
1771
|
});
|
|
1685
1772
|
exports.geneDteBracket = geneDteBracket;
|
|
1773
|
+
/** Sweep MaxSpreadPct (OptionLeg scope) over a value set. */
|
|
1774
|
+
const geneMaxSpreadPct = (strategyIndex, legIndex, values) => ({
|
|
1775
|
+
field: "MaxSpreadPct",
|
|
1776
|
+
scope: "OptionLeg",
|
|
1777
|
+
target: { scope: "OptionLeg", field: "MaxSpreadPct", strategyIndex, legIndex },
|
|
1778
|
+
values: values,
|
|
1779
|
+
});
|
|
1780
|
+
exports.geneMaxSpreadPct = geneMaxSpreadPct;
|
|
1686
1781
|
/** Sweep SelectTopLimit (UniversePipeline scope) over a value set. */
|
|
1687
1782
|
const geneSelectTopLimit = (strategyIndex, stageIndex, values) => ({
|
|
1688
1783
|
field: "SelectTopLimit",
|
|
@@ -261,6 +261,42 @@ export interface LaunchAgentAction {
|
|
|
261
261
|
skipPlanning: boolean;
|
|
262
262
|
cooldownMinutes?: number;
|
|
263
263
|
}
|
|
264
|
+
export interface MeanVarianceAllocationPolicy {
|
|
265
|
+
type: "MeanVariance";
|
|
266
|
+
lookbackPeriods: number;
|
|
267
|
+
minimumObservations: number;
|
|
268
|
+
riskAversion: number;
|
|
269
|
+
expectedReturnShrinkage: number;
|
|
270
|
+
covarianceShrinkage: number;
|
|
271
|
+
turnoverPenalty: number;
|
|
272
|
+
estimatedTransactionCostBps: number;
|
|
273
|
+
}
|
|
274
|
+
export interface RiskParityAllocationPolicy {
|
|
275
|
+
type: "RiskParity";
|
|
276
|
+
lookbackPeriods: number;
|
|
277
|
+
minimumObservations: number;
|
|
278
|
+
covarianceShrinkage: number;
|
|
279
|
+
turnoverPenalty: number;
|
|
280
|
+
estimatedTransactionCostBps: number;
|
|
281
|
+
}
|
|
282
|
+
export interface MaximumDiversificationAllocationPolicy {
|
|
283
|
+
type: "MaximumDiversification";
|
|
284
|
+
lookbackPeriods: number;
|
|
285
|
+
minimumObservations: number;
|
|
286
|
+
covarianceShrinkage: number;
|
|
287
|
+
turnoverPenalty: number;
|
|
288
|
+
estimatedTransactionCostBps: number;
|
|
289
|
+
}
|
|
290
|
+
export type AllocationPolicy = MeanVarianceAllocationPolicy | RiskParityAllocationPolicy | MaximumDiversificationAllocationPolicy;
|
|
291
|
+
export interface VolatilityTargetExposurePolicy {
|
|
292
|
+
type: "VolatilityTarget";
|
|
293
|
+
lookbackPeriods: number;
|
|
294
|
+
minimumObservations: number;
|
|
295
|
+
covarianceShrinkage: number;
|
|
296
|
+
targetAnnualizedVolatilityPercent: number;
|
|
297
|
+
estimatedTransactionCostBps: number;
|
|
298
|
+
}
|
|
299
|
+
export type ExposurePolicy = VolatilityTargetExposurePolicy;
|
|
264
300
|
/** Book-level sizing is deploymentPercent. totalBudget is RebalanceOption-only and absent by design. */
|
|
265
301
|
export interface DynamicRebalanceAction {
|
|
266
302
|
type: "DynamicRebalance";
|
|
@@ -276,6 +312,8 @@ export interface DynamicRebalanceAction {
|
|
|
276
312
|
* indicator values fail closed (retain). deploymentPercent: 0 overrides.
|
|
277
313
|
*/
|
|
278
314
|
canSell?: Condition | CandidateCondition;
|
|
315
|
+
allocationPolicy?: AllocationPolicy;
|
|
316
|
+
exposurePolicy?: ExposurePolicy;
|
|
279
317
|
}
|
|
280
318
|
/** Book-level sizing is totalBudget. deploymentPercent is DynamicRebalance-only and absent by design. */
|
|
281
319
|
export interface RebalanceOptionAction {
|
|
@@ -289,6 +327,8 @@ export interface RebalanceOptionAction {
|
|
|
289
327
|
perNameAllocation?: OptionAllocation;
|
|
290
328
|
positionScope?: RebalanceOptionPositionScope;
|
|
291
329
|
sleeves?: RebalanceOptionSleeve[];
|
|
330
|
+
allocationPolicy?: AllocationPolicy;
|
|
331
|
+
exposurePolicy?: ExposurePolicy;
|
|
292
332
|
}
|
|
293
333
|
export type OptionParentSelectionSort = "oldest" | "highestPnl" | "nearestExpiry";
|
|
294
334
|
export type ParentStrikeOffset = {
|
|
@@ -411,6 +451,15 @@ export declare const exactly: (count: number, ...conditions: Condition[]) => Con
|
|
|
411
451
|
export declare const multi: (count: number, comparison: Comparator, ...conditions: Condition[]) => Condition;
|
|
412
452
|
/** Always-true gate for strategies whose cadence lives in the pipeline. */
|
|
413
453
|
export declare const always: () => Condition;
|
|
454
|
+
export declare const meanVarianceAllocation: (config?: Partial<Omit<MeanVarianceAllocationPolicy, "type">>) => MeanVarianceAllocationPolicy;
|
|
455
|
+
export declare const riskParityAllocation: (config?: Partial<Omit<RiskParityAllocationPolicy, "type">>) => RiskParityAllocationPolicy;
|
|
456
|
+
export declare const maximumDiversificationAllocation: (config?: Partial<Omit<MaximumDiversificationAllocationPolicy, "type">>) => MaximumDiversificationAllocationPolicy;
|
|
457
|
+
export declare const volatilityTarget: (config?: Partial<Omit<VolatilityTargetExposurePolicy, "type">>) => VolatilityTargetExposurePolicy;
|
|
458
|
+
export declare const RebalanceAllocationDrift: () => Indicator;
|
|
459
|
+
export declare const RebalancePlannedTurnover: () => Indicator;
|
|
460
|
+
export declare const RebalanceEstimatedCost: () => Indicator;
|
|
461
|
+
export declare const RebalanceExpectedBenefit: () => Indicator;
|
|
462
|
+
export declare const RebalanceNetBenefit: () => Indicator;
|
|
414
463
|
export declare const filter: (condition: Condition) => PipelineStage;
|
|
415
464
|
export declare const selectTop: (metric: Indicator, limit: number, direction?: SelectDirection) => PipelineStage;
|
|
416
465
|
export declare const selectPercentile: (metric: Indicator, percentile: number, direction?: SelectDirection) => PipelineStage;
|
|
@@ -437,6 +486,8 @@ export declare const dynamicRebalance: (config: {
|
|
|
437
486
|
deploymentPercent?: number;
|
|
438
487
|
perNameAllocation?: PerNameAllocation;
|
|
439
488
|
canSell?: Condition | CandidateCondition;
|
|
489
|
+
allocationPolicy?: AllocationPolicy;
|
|
490
|
+
exposurePolicy?: ExposurePolicy;
|
|
440
491
|
}) => DynamicRebalanceAction;
|
|
441
492
|
/**
|
|
442
493
|
* One leg of a spread. Distance is signed from ATM; 0 is ATM.
|
|
@@ -485,6 +536,8 @@ export declare const rebalanceOption: (config: {
|
|
|
485
536
|
perNameAllocation?: OptionAllocation;
|
|
486
537
|
positionScope?: RebalanceOptionPositionScope;
|
|
487
538
|
sleeves?: RebalanceOptionSleeve[];
|
|
539
|
+
allocationPolicy?: AllocationPolicy;
|
|
540
|
+
exposurePolicy?: ExposurePolicy;
|
|
488
541
|
}) => RebalanceOptionAction;
|
|
489
542
|
export declare const pnlTrigger: (bounds: {
|
|
490
543
|
minPnlPercent?: number;
|
|
@@ -1079,6 +1132,11 @@ export declare function PriceRateOfChange(asset: AssetArg, length?: number, inte
|
|
|
1079
1132
|
*/
|
|
1080
1133
|
export declare function PriceStandardDeviation(asset: AssetArg, length?: number, interval?: Interval): Indicator;
|
|
1081
1134
|
export declare const PriceStdDev: typeof PriceStandardDeviation;
|
|
1135
|
+
/**
|
|
1136
|
+
* RebalanceDecisionMetric indicator.
|
|
1137
|
+
* @param metric Reads the prospective plan calculated by DynamicRebalance or RebalanceOption before the strategy condition runs.
|
|
1138
|
+
*/
|
|
1139
|
+
export declare function RebalanceDecisionMetric(metric?: "allocationDrift" | "plannedTurnover" | "estimatedCost" | "expectedBenefit" | "netBenefit"): Indicator;
|
|
1082
1140
|
/**
|
|
1083
1141
|
* RelativeStrengthIndex indicator.
|
|
1084
1142
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1350,11 +1408,23 @@ export declare const geneTotalBudgetPct: (strategyIndex: number, values: number[
|
|
|
1350
1408
|
/** Sweep DeploymentPct (Action scope) over a value set. */
|
|
1351
1409
|
export declare const geneDeploymentPct: (strategyIndex: number, values: number[]) => Gene;
|
|
1352
1410
|
/** Sweep RollTriggerDte (Action scope) over a value set. */
|
|
1353
|
-
export declare const geneRollTriggerDte: (
|
|
1411
|
+
export declare const geneRollTriggerDte: (values: number[], strategyIndex?: number) => Gene;
|
|
1354
1412
|
/** Sweep TakeProfitPct (Action scope) over a value set. */
|
|
1355
|
-
export declare const geneTakeProfitPct: (
|
|
1413
|
+
export declare const geneTakeProfitPct: (values: number[], strategyIndex?: number) => Gene;
|
|
1414
|
+
/** Sweep StopLossPct (Action scope) over a value set. */
|
|
1415
|
+
export declare const geneStopLossPct: (values: number[], strategyIndex?: number) => Gene;
|
|
1356
1416
|
/** Sweep StructureKind (Action scope) over a value set. */
|
|
1357
1417
|
export declare const geneStructureKind: (strategyIndex: number, values: string[]) => Gene;
|
|
1418
|
+
/** Sweep AllocationPolicy (Action scope) over a value set. */
|
|
1419
|
+
export declare const geneAllocationPolicy: (strategyIndex: number, values: {
|
|
1420
|
+
label: string;
|
|
1421
|
+
policy: AllocationPolicy;
|
|
1422
|
+
}[]) => Gene;
|
|
1423
|
+
/** Sweep ExposurePolicy (Action scope) over a value set. */
|
|
1424
|
+
export declare const geneExposurePolicy: (strategyIndex: number, values: {
|
|
1425
|
+
label: string;
|
|
1426
|
+
policy: ExposurePolicy;
|
|
1427
|
+
}[]) => Gene;
|
|
1358
1428
|
/** Sweep OptionDelta (OptionLeg scope) over a value set. */
|
|
1359
1429
|
export declare const geneOptionDelta: (strategyIndex: number, legIndex: number, values: number[]) => Gene;
|
|
1360
1430
|
/** Sweep StrikeDistance (OptionLeg scope) over a value set. */
|
|
@@ -1364,6 +1434,8 @@ export declare const geneStrikeDistance: (strategyIndex: number, legIndex: numbe
|
|
|
1364
1434
|
}[]) => Gene;
|
|
1365
1435
|
/** Sweep DteBracket (OptionLeg scope) over a value set. */
|
|
1366
1436
|
export declare const geneDteBracket: (strategyIndex: number, legIndex: number, values: [number, number][]) => Gene;
|
|
1437
|
+
/** Sweep MaxSpreadPct (OptionLeg scope) over a value set. */
|
|
1438
|
+
export declare const geneMaxSpreadPct: (strategyIndex: number, legIndex: number, values: number[]) => Gene;
|
|
1367
1439
|
/** Sweep SelectTopLimit (UniversePipeline scope) over a value set. */
|
|
1368
1440
|
export declare const geneSelectTopLimit: (strategyIndex: number, stageIndex: number, values: number[]) => Gene;
|
|
1369
1441
|
/** Sweep UniversePipelineFilter (UniversePipeline scope) over a value set. */
|
|
@@ -129,6 +129,50 @@ export const exactly = (count, ...conditions) => ({ type: "Multi", comparison: "
|
|
|
129
129
|
export const multi = (count, comparison, ...conditions) => ({ type: "Multi", comparison, value: count, conditions });
|
|
130
130
|
/** Always-true gate for strategies whose cadence lives in the pipeline. */
|
|
131
131
|
export const always = () => compare(Value(1), Value(0), "greaterThan");
|
|
132
|
+
export const meanVarianceAllocation = (config = {}) => ({
|
|
133
|
+
type: "MeanVariance",
|
|
134
|
+
lookbackPeriods: 252,
|
|
135
|
+
minimumObservations: 60,
|
|
136
|
+
riskAversion: 4,
|
|
137
|
+
expectedReturnShrinkage: 0.5,
|
|
138
|
+
covarianceShrinkage: 0.25,
|
|
139
|
+
turnoverPenalty: 1,
|
|
140
|
+
estimatedTransactionCostBps: 10,
|
|
141
|
+
...config,
|
|
142
|
+
});
|
|
143
|
+
export const riskParityAllocation = (config = {}) => ({
|
|
144
|
+
type: "RiskParity",
|
|
145
|
+
lookbackPeriods: 252,
|
|
146
|
+
minimumObservations: 60,
|
|
147
|
+
covarianceShrinkage: 0.25,
|
|
148
|
+
turnoverPenalty: 1,
|
|
149
|
+
estimatedTransactionCostBps: 10,
|
|
150
|
+
...config,
|
|
151
|
+
});
|
|
152
|
+
export const maximumDiversificationAllocation = (config = {}) => ({
|
|
153
|
+
type: "MaximumDiversification",
|
|
154
|
+
lookbackPeriods: 252,
|
|
155
|
+
minimumObservations: 60,
|
|
156
|
+
covarianceShrinkage: 0.25,
|
|
157
|
+
turnoverPenalty: 1,
|
|
158
|
+
estimatedTransactionCostBps: 10,
|
|
159
|
+
...config,
|
|
160
|
+
});
|
|
161
|
+
export const volatilityTarget = (config = {}) => ({
|
|
162
|
+
type: "VolatilityTarget",
|
|
163
|
+
lookbackPeriods: 60,
|
|
164
|
+
minimumObservations: 20,
|
|
165
|
+
covarianceShrinkage: 0.25,
|
|
166
|
+
targetAnnualizedVolatilityPercent: 12,
|
|
167
|
+
estimatedTransactionCostBps: 10,
|
|
168
|
+
...config,
|
|
169
|
+
});
|
|
170
|
+
const rebalanceDecisionMetric = (metric) => ({ type: "RebalanceDecisionMetric", metric });
|
|
171
|
+
export const RebalanceAllocationDrift = () => rebalanceDecisionMetric("allocationDrift");
|
|
172
|
+
export const RebalancePlannedTurnover = () => rebalanceDecisionMetric("plannedTurnover");
|
|
173
|
+
export const RebalanceEstimatedCost = () => rebalanceDecisionMetric("estimatedCost");
|
|
174
|
+
export const RebalanceExpectedBenefit = () => rebalanceDecisionMetric("expectedBenefit");
|
|
175
|
+
export const RebalanceNetBenefit = () => rebalanceDecisionMetric("netBenefit");
|
|
132
176
|
export const filter = (condition) => ({ type: "Filter", condition });
|
|
133
177
|
export const selectTop = (metric, limit, direction = "Highest") => ({ type: "SelectTop", metric, limit, direction });
|
|
134
178
|
export const selectPercentile = (metric, percentile, direction = "Highest") => ({ type: "SelectPercentile", metric, percentile, direction });
|
|
@@ -1198,6 +1242,15 @@ export function PriceStandardDeviation(asset, length = 30, interval = "Day") {
|
|
|
1198
1242
|
return d;
|
|
1199
1243
|
}
|
|
1200
1244
|
export const PriceStdDev = PriceStandardDeviation;
|
|
1245
|
+
/**
|
|
1246
|
+
* RebalanceDecisionMetric indicator.
|
|
1247
|
+
* @param metric Reads the prospective plan calculated by DynamicRebalance or RebalanceOption before the strategy condition runs.
|
|
1248
|
+
*/
|
|
1249
|
+
export function RebalanceDecisionMetric(metric = "netBenefit") {
|
|
1250
|
+
const d = { type: "RebalanceDecisionMetric" };
|
|
1251
|
+
d["metric"] = metric;
|
|
1252
|
+
return d;
|
|
1253
|
+
}
|
|
1201
1254
|
/**
|
|
1202
1255
|
* RelativeStrengthIndex indicator.
|
|
1203
1256
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1473,17 +1526,24 @@ export const geneDeploymentPct = (strategyIndex, values) => ({
|
|
|
1473
1526
|
values: values,
|
|
1474
1527
|
});
|
|
1475
1528
|
/** Sweep RollTriggerDte (Action scope) over a value set. */
|
|
1476
|
-
export const geneRollTriggerDte = (
|
|
1529
|
+
export const geneRollTriggerDte = (values, strategyIndex) => ({
|
|
1477
1530
|
field: "RollTriggerDte",
|
|
1478
1531
|
scope: "Action",
|
|
1479
|
-
target: { scope: "Action", field: "RollTriggerDte", strategyIndex },
|
|
1532
|
+
target: { scope: "Action", field: "RollTriggerDte", ...(strategyIndex === undefined ? {} : { strategyIndex }) },
|
|
1480
1533
|
values: values,
|
|
1481
1534
|
});
|
|
1482
1535
|
/** Sweep TakeProfitPct (Action scope) over a value set. */
|
|
1483
|
-
export const geneTakeProfitPct = (
|
|
1536
|
+
export const geneTakeProfitPct = (values, strategyIndex) => ({
|
|
1484
1537
|
field: "TakeProfitPct",
|
|
1485
1538
|
scope: "Action",
|
|
1486
|
-
target: { scope: "Action", field: "TakeProfitPct", strategyIndex },
|
|
1539
|
+
target: { scope: "Action", field: "TakeProfitPct", ...(strategyIndex === undefined ? {} : { strategyIndex }) },
|
|
1540
|
+
values: values,
|
|
1541
|
+
});
|
|
1542
|
+
/** Sweep StopLossPct (Action scope) over a value set. */
|
|
1543
|
+
export const geneStopLossPct = (values, strategyIndex) => ({
|
|
1544
|
+
field: "StopLossPct",
|
|
1545
|
+
scope: "Action",
|
|
1546
|
+
target: { scope: "Action", field: "StopLossPct", ...(strategyIndex === undefined ? {} : { strategyIndex }) },
|
|
1487
1547
|
values: values,
|
|
1488
1548
|
});
|
|
1489
1549
|
/** Sweep StructureKind (Action scope) over a value set. */
|
|
@@ -1493,6 +1553,20 @@ export const geneStructureKind = (strategyIndex, values) => ({
|
|
|
1493
1553
|
target: { scope: "Action", field: "StructureKind", strategyIndex },
|
|
1494
1554
|
values: values,
|
|
1495
1555
|
});
|
|
1556
|
+
/** Sweep AllocationPolicy (Action scope) over a value set. */
|
|
1557
|
+
export const geneAllocationPolicy = (strategyIndex, values) => ({
|
|
1558
|
+
field: "AllocationPolicy",
|
|
1559
|
+
scope: "Action",
|
|
1560
|
+
target: { scope: "Action", field: "AllocationPolicy", strategyIndex },
|
|
1561
|
+
values: values,
|
|
1562
|
+
});
|
|
1563
|
+
/** Sweep ExposurePolicy (Action scope) over a value set. */
|
|
1564
|
+
export const geneExposurePolicy = (strategyIndex, values) => ({
|
|
1565
|
+
field: "ExposurePolicy",
|
|
1566
|
+
scope: "Action",
|
|
1567
|
+
target: { scope: "Action", field: "ExposurePolicy", strategyIndex },
|
|
1568
|
+
values: values,
|
|
1569
|
+
});
|
|
1496
1570
|
/** Sweep OptionDelta (OptionLeg scope) over a value set. */
|
|
1497
1571
|
export const geneOptionDelta = (strategyIndex, legIndex, values) => ({
|
|
1498
1572
|
field: "OptionDelta",
|
|
@@ -1514,6 +1588,13 @@ export const geneDteBracket = (strategyIndex, legIndex, values) => ({
|
|
|
1514
1588
|
target: { scope: "OptionLeg", field: "DteBracket", strategyIndex, legIndex },
|
|
1515
1589
|
values: values,
|
|
1516
1590
|
});
|
|
1591
|
+
/** Sweep MaxSpreadPct (OptionLeg scope) over a value set. */
|
|
1592
|
+
export const geneMaxSpreadPct = (strategyIndex, legIndex, values) => ({
|
|
1593
|
+
field: "MaxSpreadPct",
|
|
1594
|
+
scope: "OptionLeg",
|
|
1595
|
+
target: { scope: "OptionLeg", field: "MaxSpreadPct", strategyIndex, legIndex },
|
|
1596
|
+
values: values,
|
|
1597
|
+
});
|
|
1517
1598
|
/** Sweep SelectTopLimit (UniversePipeline scope) over a value set. */
|
|
1518
1599
|
export const geneSelectTopLimit = (strategyIndex, stageIndex, values) => ({
|
|
1519
1600
|
field: "SelectTopLimit",
|