nexustrade 1.36.0 → 1.39.3
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/dist/cjs/client.js +1 -0
- package/dist/cjs/generated/ntSdk.generated.js +39 -0
- package/dist/cjs/portfolio.js +12 -0
- package/dist/esm/client.js +1 -0
- package/dist/esm/generated/ntSdk.generated.d.ts +26 -0
- package/dist/esm/generated/ntSdk.generated.js +36 -0
- package/dist/esm/portfolio.d.ts +5 -1
- package/dist/esm/portfolio.js +12 -0
- package/package.json +1 -1
package/dist/cjs/client.js
CHANGED
|
@@ -518,6 +518,7 @@ const BACKTEST_ARG_NAMES = [
|
|
|
518
518
|
["initial_value", "initialValue"],
|
|
519
519
|
["generate_events", "generateEvents"],
|
|
520
520
|
["fee_config", "feeConfig"],
|
|
521
|
+
["dividend_policy", "dividendPolicy"],
|
|
521
522
|
];
|
|
522
523
|
function isJsonObject(value) {
|
|
523
524
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -14,6 +14,8 @@ exports.BuyingPower = BuyingPower;
|
|
|
14
14
|
exports.ChaikinMoneyFlow = ChaikinMoneyFlow;
|
|
15
15
|
exports.CommodityChannelIndex = CommodityChannelIndex;
|
|
16
16
|
exports.CompoundAnnualGrowthRate = CompoundAnnualGrowthRate;
|
|
17
|
+
exports.ConsecutiveDecrease = ConsecutiveDecrease;
|
|
18
|
+
exports.ConsecutiveIncrease = ConsecutiveIncrease;
|
|
17
19
|
exports.ConsecutiveTrue = ConsecutiveTrue;
|
|
18
20
|
exports.Correlation = Correlation;
|
|
19
21
|
exports.CountTrue = CountTrue;
|
|
@@ -67,6 +69,7 @@ exports.IVHVRatio = IVHVRatio;
|
|
|
67
69
|
exports.IVPercentile = IVPercentile;
|
|
68
70
|
exports.IVRank = IVRank;
|
|
69
71
|
exports.KeltnerChannel = KeltnerChannel;
|
|
72
|
+
exports.LastDividend = LastDividend;
|
|
70
73
|
exports.LastOrderPrice = LastOrderPrice;
|
|
71
74
|
exports.Log = Log;
|
|
72
75
|
exports.LowOfDay = LowOfDay;
|
|
@@ -638,6 +641,32 @@ function CompoundAnnualGrowthRate(asset, metric, years) {
|
|
|
638
641
|
d["years"] = years;
|
|
639
642
|
return d;
|
|
640
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Number of consecutive completed calendar periods (America/New_York; period is Year, Quarter or Month), ending with the last completed period, whose closing value of the inner indicator was strictly higher (ConsecutiveIncrease) or strictly lower (ConsecutiveDecrease) than the previous period's closing value. A period's closing value is the inner indicator's last non-null value observed in that period. The in-progress current period never counts, equal values are not a change, and a completed period with no value breaks the streak. The count is capped at lookback (an integer from 1 to 60). Returns null when no completed period has a value. Examples: ConsecutiveIncrease(LastDividend(KO), Year, 10) >= 10 (KO raised its regular dividend per share in each of the last 10 completed years); ConsecutiveIncrease(Fundamental(AAPL, totalRevenue), Quarter, 8) (consecutive completed quarters of higher reported revenue for AAPL, up to 8).
|
|
646
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
647
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
648
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
649
|
+
*/
|
|
650
|
+
function ConsecutiveDecrease(indicator, period, lookback) {
|
|
651
|
+
const d = { type: "ConsecutiveDecrease" };
|
|
652
|
+
d["period"] = period;
|
|
653
|
+
d["lookback"] = lookback;
|
|
654
|
+
d.indicators = [indicator];
|
|
655
|
+
return d;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Number of consecutive completed calendar periods (America/New_York; period is Year, Quarter or Month), ending with the last completed period, whose closing value of the inner indicator was strictly higher (ConsecutiveIncrease) or strictly lower (ConsecutiveDecrease) than the previous period's closing value. A period's closing value is the inner indicator's last non-null value observed in that period. The in-progress current period never counts, equal values are not a change, and a completed period with no value breaks the streak. The count is capped at lookback (an integer from 1 to 60). Returns null when no completed period has a value. Examples: ConsecutiveIncrease(LastDividend(KO), Year, 10) >= 10 (KO raised its regular dividend per share in each of the last 10 completed years); ConsecutiveIncrease(Fundamental(AAPL, totalRevenue), Quarter, 8) (consecutive completed quarters of higher reported revenue for AAPL, up to 8).
|
|
659
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
660
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
661
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
662
|
+
*/
|
|
663
|
+
function ConsecutiveIncrease(indicator, period, lookback) {
|
|
664
|
+
const d = { type: "ConsecutiveIncrease" };
|
|
665
|
+
d["period"] = period;
|
|
666
|
+
d["lookback"] = lookback;
|
|
667
|
+
d.indicators = [indicator];
|
|
668
|
+
return d;
|
|
669
|
+
}
|
|
641
670
|
/**
|
|
642
671
|
* ConsecutiveTrue indicator.
|
|
643
672
|
* @param condition Condition evaluated over the window.
|
|
@@ -1210,6 +1239,15 @@ function KeltnerChannel(asset, length = 20, interval = "Day", multiplier = 2, li
|
|
|
1210
1239
|
d.window = { length: length, interval: interval };
|
|
1211
1240
|
return d;
|
|
1212
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* The most recent regular cash dividend per share whose ex-dividend date is on or before the evaluation date (America/New_York), split-adjusted onto today's share basis, special dividends excluded. Returns null when the asset has no regular dividend on or before that date. Each payment is one observation for TrailingSum, so TrailingSum(LastDividend(asset), 4) sums the last four payments, which is trailing-twelve-month dividends for a quarterly payer (use 12 for a monthly payer).
|
|
1244
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1245
|
+
*/
|
|
1246
|
+
function LastDividend(asset) {
|
|
1247
|
+
const d = { type: "LastDividend" };
|
|
1248
|
+
setAsset(d, "targetAsset", asset);
|
|
1249
|
+
return d;
|
|
1250
|
+
}
|
|
1213
1251
|
/**
|
|
1214
1252
|
* LastOrderPrice indicator.
|
|
1215
1253
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -2096,6 +2134,7 @@ const backtest = (portfolio, config) => ({
|
|
|
2096
2134
|
"initial_value": config.initialValue,
|
|
2097
2135
|
"generate_events": config.generateEvents,
|
|
2098
2136
|
"fee_config": config.feeConfig,
|
|
2137
|
+
"dividend_policy": config.dividendPolicy,
|
|
2099
2138
|
}),
|
|
2100
2139
|
});
|
|
2101
2140
|
exports.backtest = backtest;
|
package/dist/cjs/portfolio.js
CHANGED
|
@@ -132,6 +132,8 @@ class PortfolioHandle {
|
|
|
132
132
|
supportsFractionalShares;
|
|
133
133
|
supportsCrypto;
|
|
134
134
|
alertsEnabled;
|
|
135
|
+
/** "cash" (the default when omitted) or "reinvest". */
|
|
136
|
+
dividendPolicy;
|
|
135
137
|
/** Chat draft id after `save()`, or fetched portfolio id. Not serialized. */
|
|
136
138
|
id = null;
|
|
137
139
|
/** Present on list/get summaries: paper | live | chat. */
|
|
@@ -188,6 +190,9 @@ class PortfolioHandle {
|
|
|
188
190
|
if (typeof record.alertsEnabled === "boolean") {
|
|
189
191
|
this.alertsEnabled = record.alertsEnabled;
|
|
190
192
|
}
|
|
193
|
+
if (record.dividendPolicy === "cash" || record.dividendPolicy === "reinvest") {
|
|
194
|
+
this.dividendPolicy = record.dividendPolicy;
|
|
195
|
+
}
|
|
191
196
|
if (record.type === "paper" ||
|
|
192
197
|
record.type === "live" ||
|
|
193
198
|
record.type === "chat") {
|
|
@@ -218,6 +223,7 @@ class PortfolioHandle {
|
|
|
218
223
|
key === "supportsFractionalShares" ||
|
|
219
224
|
key === "supportsCrypto" ||
|
|
220
225
|
key === "alertsEnabled" ||
|
|
226
|
+
key === "dividendPolicy" ||
|
|
221
227
|
key === "type" ||
|
|
222
228
|
key === "isActive" ||
|
|
223
229
|
key === "strategyNames" ||
|
|
@@ -264,6 +270,9 @@ class PortfolioHandle {
|
|
|
264
270
|
if (this.alertsEnabled !== undefined) {
|
|
265
271
|
body.alertsEnabled = this.alertsEnabled;
|
|
266
272
|
}
|
|
273
|
+
if (this.dividendPolicy !== undefined) {
|
|
274
|
+
body.dividendPolicy = this.dividendPolicy;
|
|
275
|
+
}
|
|
267
276
|
if (this.type !== undefined)
|
|
268
277
|
body.type = this.type;
|
|
269
278
|
if (this.isActive !== undefined)
|
|
@@ -378,6 +387,9 @@ class PortfolioHandle {
|
|
|
378
387
|
}
|
|
379
388
|
if (options.feeConfig !== undefined)
|
|
380
389
|
input.feeConfig = options.feeConfig;
|
|
390
|
+
if (options.dividendPolicy !== undefined) {
|
|
391
|
+
input.dividendPolicy = options.dividendPolicy;
|
|
392
|
+
}
|
|
381
393
|
const response = await transport.request("POST", "backtests/batch", {
|
|
382
394
|
body: { backtests: [input] },
|
|
383
395
|
idempotencyKey: options.idempotencyKey,
|
package/dist/esm/client.js
CHANGED
|
@@ -508,6 +508,7 @@ const BACKTEST_ARG_NAMES = [
|
|
|
508
508
|
["initial_value", "initialValue"],
|
|
509
509
|
["generate_events", "generateEvents"],
|
|
510
510
|
["fee_config", "feeConfig"],
|
|
511
|
+
["dividend_policy", "dividendPolicy"],
|
|
511
512
|
];
|
|
512
513
|
function isJsonObject(value) {
|
|
513
514
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -479,8 +479,11 @@ export interface Portfolio {
|
|
|
479
479
|
supportsFractionalShares?: boolean;
|
|
480
480
|
supportsCrypto?: boolean;
|
|
481
481
|
alertsEnabled?: boolean;
|
|
482
|
+
/** "cash" (default when omitted) or "reinvest" into the paying stock. */
|
|
483
|
+
dividendPolicy?: DividendPolicy;
|
|
482
484
|
policy?: AuthoredPortfolioPolicy;
|
|
483
485
|
}
|
|
486
|
+
export type DividendPolicy = "cash" | "reinvest";
|
|
484
487
|
export type AssetType = "Stock" | "Cryptocurrency" | "Option" | "Other";
|
|
485
488
|
export type Interval = "Day" | "Hour" | "Minute";
|
|
486
489
|
export type Comparator = "lessThan" | "greaterThan" | "lessThanOrEqual" | "greaterThanOrEqual" | "equal" | "notEqual";
|
|
@@ -501,6 +504,7 @@ export type OptionSpreadType = "vertical" | "calendar" | "diagonal" | "ironCondo
|
|
|
501
504
|
export type CloseScope = "spread" | "leg";
|
|
502
505
|
export type RebalanceOptionPositionScope = "portfolio" | "strategy";
|
|
503
506
|
export type FundamentalMetric = "totalRevenue" | "grossProfit" | "operatingIncome" | "ebitda" | "epsActual" | "epsEstimate" | "netIncome" | "freeCashFlow" | "totalAssets" | "totalLiab" | "shortTermDebt" | "longTermDebt" | "commonStockSharesOutstanding" | "dividendYield" | "openingPrice" | "highestPrice" | "lowestPrice" | "closingPrice" | "volume" | "marketCap" | "peRatioTTM" | "psRatioTTM" | "pbRatioTTM" | "enterpriseValue";
|
|
507
|
+
export type Period = "Year" | "Quarter" | "Month";
|
|
504
508
|
export type PositionEffect = "open" | "close";
|
|
505
509
|
export type OrderStatus = "Pending" | "Accepted" | "Pending User Approval" | "Canceled" | "Filled" | "Partially Filled";
|
|
506
510
|
export type Side = "Buy" | "Sell";
|
|
@@ -710,6 +714,7 @@ export declare const portfolio: (name: string, strategies: Strategy[], options?:
|
|
|
710
714
|
supportsFractionalShares?: boolean;
|
|
711
715
|
supportsCrypto?: boolean;
|
|
712
716
|
alertsEnabled?: boolean;
|
|
717
|
+
dividendPolicy?: DividendPolicy;
|
|
713
718
|
policy?: AuthoredPortfolioPolicy;
|
|
714
719
|
}) => PortfolioHandle;
|
|
715
720
|
/**
|
|
@@ -782,6 +787,20 @@ export declare function CommodityChannelIndex(asset: AssetArg, length?: number,
|
|
|
782
787
|
* @param years Floating point years value
|
|
783
788
|
*/
|
|
784
789
|
export declare function CompoundAnnualGrowthRate(asset: AssetArg, metric: FundamentalMetric, years: number): Indicator;
|
|
790
|
+
/**
|
|
791
|
+
* Number of consecutive completed calendar periods (America/New_York; period is Year, Quarter or Month), ending with the last completed period, whose closing value of the inner indicator was strictly higher (ConsecutiveIncrease) or strictly lower (ConsecutiveDecrease) than the previous period's closing value. A period's closing value is the inner indicator's last non-null value observed in that period. The in-progress current period never counts, equal values are not a change, and a completed period with no value breaks the streak. The count is capped at lookback (an integer from 1 to 60). Returns null when no completed period has a value. Examples: ConsecutiveIncrease(LastDividend(KO), Year, 10) >= 10 (KO raised its regular dividend per share in each of the last 10 completed years); ConsecutiveIncrease(Fundamental(AAPL, totalRevenue), Quarter, 8) (consecutive completed quarters of higher reported revenue for AAPL, up to 8).
|
|
792
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
793
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
794
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
795
|
+
*/
|
|
796
|
+
export declare function ConsecutiveDecrease(indicator: Indicator, period: Period, lookback: number): Indicator;
|
|
797
|
+
/**
|
|
798
|
+
* Number of consecutive completed calendar periods (America/New_York; period is Year, Quarter or Month), ending with the last completed period, whose closing value of the inner indicator was strictly higher (ConsecutiveIncrease) or strictly lower (ConsecutiveDecrease) than the previous period's closing value. A period's closing value is the inner indicator's last non-null value observed in that period. The in-progress current period never counts, equal values are not a change, and a completed period with no value breaks the streak. The count is capped at lookback (an integer from 1 to 60). Returns null when no completed period has a value. Examples: ConsecutiveIncrease(LastDividend(KO), Year, 10) >= 10 (KO raised its regular dividend per share in each of the last 10 completed years); ConsecutiveIncrease(Fundamental(AAPL, totalRevenue), Quarter, 8) (consecutive completed quarters of higher reported revenue for AAPL, up to 8).
|
|
799
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
800
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
801
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
802
|
+
*/
|
|
803
|
+
export declare function ConsecutiveIncrease(indicator: Indicator, period: Period, lookback: number): Indicator;
|
|
785
804
|
/**
|
|
786
805
|
* ConsecutiveTrue indicator.
|
|
787
806
|
* @param condition Condition evaluated over the window.
|
|
@@ -1093,6 +1112,11 @@ export declare function IVRank(asset: AssetArg, length?: number, interval?: Inte
|
|
|
1093
1112
|
* @param line Which Keltner line to evaluate
|
|
1094
1113
|
*/
|
|
1095
1114
|
export declare function KeltnerChannel(asset: AssetArg, length?: number, interval?: Interval, multiplier?: number, line?: "upper" | "middle" | "lower"): Indicator;
|
|
1115
|
+
/**
|
|
1116
|
+
* The most recent regular cash dividend per share whose ex-dividend date is on or before the evaluation date (America/New_York), split-adjusted onto today's share basis, special dividends excluded. Returns null when the asset has no regular dividend on or before that date. Each payment is one observation for TrailingSum, so TrailingSum(LastDividend(asset), 4) sums the last four payments, which is trailing-twelve-month dividends for a quarterly payer (use 12 for a monthly payer).
|
|
1117
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1118
|
+
*/
|
|
1119
|
+
export declare function LastDividend(asset: AssetArg): Indicator;
|
|
1096
1120
|
/**
|
|
1097
1121
|
* LastOrderPrice indicator.
|
|
1098
1122
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1629,6 +1653,8 @@ export interface BacktestConfig {
|
|
|
1629
1653
|
generateEvents?: boolean;
|
|
1630
1654
|
/** Optional fee contract keyed by AssetTypeEnum (Stock/Cryptocurrency/Option) with {amount, type: percent|dollars}. Omit for shared defaults (Option $0.65/contract). For replay of an optimizer/walk-forward study, pass that study's persisted feeConfig. Option fill slippage (OptionSlippageFraction) is not set here — engine default 0.5 applies. */
|
|
1631
1655
|
feeConfig?: FeeConfig;
|
|
1656
|
+
/** Overrides the portfolio's dividend policy for this run only. Omit to use the portfolio's own setting (cash unless it was set to reinvest). "reinvest" buys more of the paying stock on each pay date, which is what a buy-and-hold comparison against the SPY total-return baseline needs. */
|
|
1657
|
+
dividendPolicy?: "cash" | "reinvest";
|
|
1632
1658
|
}
|
|
1633
1659
|
export interface WalkForwardConfig {
|
|
1634
1660
|
/** 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. */
|
|
@@ -438,6 +438,32 @@ export function CompoundAnnualGrowthRate(asset, metric, years) {
|
|
|
438
438
|
d["years"] = years;
|
|
439
439
|
return d;
|
|
440
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Number of consecutive completed calendar periods (America/New_York; period is Year, Quarter or Month), ending with the last completed period, whose closing value of the inner indicator was strictly higher (ConsecutiveIncrease) or strictly lower (ConsecutiveDecrease) than the previous period's closing value. A period's closing value is the inner indicator's last non-null value observed in that period. The in-progress current period never counts, equal values are not a change, and a completed period with no value breaks the streak. The count is capped at lookback (an integer from 1 to 60). Returns null when no completed period has a value. Examples: ConsecutiveIncrease(LastDividend(KO), Year, 10) >= 10 (KO raised its regular dividend per share in each of the last 10 completed years); ConsecutiveIncrease(Fundamental(AAPL, totalRevenue), Quarter, 8) (consecutive completed quarters of higher reported revenue for AAPL, up to 8).
|
|
443
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
444
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
445
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
446
|
+
*/
|
|
447
|
+
export function ConsecutiveDecrease(indicator, period, lookback) {
|
|
448
|
+
const d = { type: "ConsecutiveDecrease" };
|
|
449
|
+
d["period"] = period;
|
|
450
|
+
d["lookback"] = lookback;
|
|
451
|
+
d.indicators = [indicator];
|
|
452
|
+
return d;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Number of consecutive completed calendar periods (America/New_York; period is Year, Quarter or Month), ending with the last completed period, whose closing value of the inner indicator was strictly higher (ConsecutiveIncrease) or strictly lower (ConsecutiveDecrease) than the previous period's closing value. A period's closing value is the inner indicator's last non-null value observed in that period. The in-progress current period never counts, equal values are not a change, and a completed period with no value breaks the streak. The count is capped at lookback (an integer from 1 to 60). Returns null when no completed period has a value. Examples: ConsecutiveIncrease(LastDividend(KO), Year, 10) >= 10 (KO raised its regular dividend per share in each of the last 10 completed years); ConsecutiveIncrease(Fundamental(AAPL, totalRevenue), Quarter, 8) (consecutive completed quarters of higher reported revenue for AAPL, up to 8).
|
|
456
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
457
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
458
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
459
|
+
*/
|
|
460
|
+
export function ConsecutiveIncrease(indicator, period, lookback) {
|
|
461
|
+
const d = { type: "ConsecutiveIncrease" };
|
|
462
|
+
d["period"] = period;
|
|
463
|
+
d["lookback"] = lookback;
|
|
464
|
+
d.indicators = [indicator];
|
|
465
|
+
return d;
|
|
466
|
+
}
|
|
441
467
|
/**
|
|
442
468
|
* ConsecutiveTrue indicator.
|
|
443
469
|
* @param condition Condition evaluated over the window.
|
|
@@ -1010,6 +1036,15 @@ export function KeltnerChannel(asset, length = 20, interval = "Day", multiplier
|
|
|
1010
1036
|
d.window = { length: length, interval: interval };
|
|
1011
1037
|
return d;
|
|
1012
1038
|
}
|
|
1039
|
+
/**
|
|
1040
|
+
* The most recent regular cash dividend per share whose ex-dividend date is on or before the evaluation date (America/New_York), split-adjusted onto today's share basis, special dividends excluded. Returns null when the asset has no regular dividend on or before that date. Each payment is one observation for TrailingSum, so TrailingSum(LastDividend(asset), 4) sums the last four payments, which is trailing-twelve-month dividends for a quarterly payer (use 12 for a monthly payer).
|
|
1041
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1042
|
+
*/
|
|
1043
|
+
export function LastDividend(asset) {
|
|
1044
|
+
const d = { type: "LastDividend" };
|
|
1045
|
+
setAsset(d, "targetAsset", asset);
|
|
1046
|
+
return d;
|
|
1047
|
+
}
|
|
1013
1048
|
/**
|
|
1014
1049
|
* LastOrderPrice indicator.
|
|
1015
1050
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1896,6 +1931,7 @@ export const backtest = (portfolio, config) => ({
|
|
|
1896
1931
|
"initial_value": config.initialValue,
|
|
1897
1932
|
"generate_events": config.generateEvents,
|
|
1898
1933
|
"fee_config": config.feeConfig,
|
|
1934
|
+
"dividend_policy": config.dividendPolicy,
|
|
1899
1935
|
}),
|
|
1900
1936
|
});
|
|
1901
1937
|
/** Submit a walk-forward study (anchored or rolling folds, GA or sweep engine). */
|
package/dist/esm/portfolio.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* import this module without a cycle through `client.ts`.
|
|
10
10
|
*/
|
|
11
11
|
import { type JsonObject, type Transport } from "./client.ts";
|
|
12
|
-
import type { AuthoredPortfolioPolicy, AuthoredStockEligibility, Portfolio, Strategy } from "./generated/ntSdk.generated.js";
|
|
12
|
+
import type { AuthoredPortfolioPolicy, AuthoredStockEligibility, DividendPolicy, Portfolio, Strategy } from "./generated/ntSdk.generated.js";
|
|
13
13
|
export type PortfolioType = "paper" | "live" | "chat";
|
|
14
14
|
export type DeployOutcome = "minted" | "reactivated" | "already_active" | "seed_recovered";
|
|
15
15
|
export interface DeployResult {
|
|
@@ -68,6 +68,8 @@ export declare class PortfolioHandle implements Portfolio {
|
|
|
68
68
|
supportsFractionalShares?: boolean;
|
|
69
69
|
supportsCrypto?: boolean;
|
|
70
70
|
alertsEnabled?: boolean;
|
|
71
|
+
/** "cash" (the default when omitted) or "reinvest". */
|
|
72
|
+
dividendPolicy?: DividendPolicy;
|
|
71
73
|
/** Chat draft id after `save()`, or fetched portfolio id. Not serialized. */
|
|
72
74
|
id: string | null;
|
|
73
75
|
/** Present on list/get summaries: paper | live | chat. */
|
|
@@ -112,6 +114,8 @@ export declare class PortfolioHandle implements Portfolio {
|
|
|
112
114
|
initialValue?: number;
|
|
113
115
|
generateEvents?: boolean;
|
|
114
116
|
feeConfig?: JsonObject;
|
|
117
|
+
/** Overrides the portfolio's own dividend policy for this run only. */
|
|
118
|
+
dividendPolicy?: DividendPolicy;
|
|
115
119
|
transport?: Transport;
|
|
116
120
|
}): Promise<JsonObject>;
|
|
117
121
|
}
|
package/dist/esm/portfolio.js
CHANGED
|
@@ -95,6 +95,8 @@ export class PortfolioHandle {
|
|
|
95
95
|
supportsFractionalShares;
|
|
96
96
|
supportsCrypto;
|
|
97
97
|
alertsEnabled;
|
|
98
|
+
/** "cash" (the default when omitted) or "reinvest". */
|
|
99
|
+
dividendPolicy;
|
|
98
100
|
/** Chat draft id after `save()`, or fetched portfolio id. Not serialized. */
|
|
99
101
|
id = null;
|
|
100
102
|
/** Present on list/get summaries: paper | live | chat. */
|
|
@@ -151,6 +153,9 @@ export class PortfolioHandle {
|
|
|
151
153
|
if (typeof record.alertsEnabled === "boolean") {
|
|
152
154
|
this.alertsEnabled = record.alertsEnabled;
|
|
153
155
|
}
|
|
156
|
+
if (record.dividendPolicy === "cash" || record.dividendPolicy === "reinvest") {
|
|
157
|
+
this.dividendPolicy = record.dividendPolicy;
|
|
158
|
+
}
|
|
154
159
|
if (record.type === "paper" ||
|
|
155
160
|
record.type === "live" ||
|
|
156
161
|
record.type === "chat") {
|
|
@@ -181,6 +186,7 @@ export class PortfolioHandle {
|
|
|
181
186
|
key === "supportsFractionalShares" ||
|
|
182
187
|
key === "supportsCrypto" ||
|
|
183
188
|
key === "alertsEnabled" ||
|
|
189
|
+
key === "dividendPolicy" ||
|
|
184
190
|
key === "type" ||
|
|
185
191
|
key === "isActive" ||
|
|
186
192
|
key === "strategyNames" ||
|
|
@@ -227,6 +233,9 @@ export class PortfolioHandle {
|
|
|
227
233
|
if (this.alertsEnabled !== undefined) {
|
|
228
234
|
body.alertsEnabled = this.alertsEnabled;
|
|
229
235
|
}
|
|
236
|
+
if (this.dividendPolicy !== undefined) {
|
|
237
|
+
body.dividendPolicy = this.dividendPolicy;
|
|
238
|
+
}
|
|
230
239
|
if (this.type !== undefined)
|
|
231
240
|
body.type = this.type;
|
|
232
241
|
if (this.isActive !== undefined)
|
|
@@ -341,6 +350,9 @@ export class PortfolioHandle {
|
|
|
341
350
|
}
|
|
342
351
|
if (options.feeConfig !== undefined)
|
|
343
352
|
input.feeConfig = options.feeConfig;
|
|
353
|
+
if (options.dividendPolicy !== undefined) {
|
|
354
|
+
input.dividendPolicy = options.dividendPolicy;
|
|
355
|
+
}
|
|
344
356
|
const response = await transport.request("POST", "backtests/batch", {
|
|
345
357
|
body: { backtests: [input] },
|
|
346
358
|
idempotencyKey: options.idempotencyKey,
|