nexustrade 1.37.0 → 1.41.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
|
@@ -747,6 +747,31 @@ tables; your SQL does not change when it does.
|
|
|
747
747
|
> The Python SDK additionally ships `nt.lake.sql(...)`, a DuckDB/pandas
|
|
748
748
|
> convenience layer over these same endpoints.
|
|
749
749
|
|
|
750
|
+
## Managed watchlist universes
|
|
751
|
+
|
|
752
|
+
`nt.updateWatchlist({watchlistKey, memberId, instrument, amountBasis, chamber, output})`
|
|
753
|
+
maintains a visible managed list from `PoliticalRemainingPurchases`. Its strategy
|
|
754
|
+
has no condition and places no orders. `nt.watchlistUniverse(watchlistKey)` selects
|
|
755
|
+
that producer's committed membership for a separate `DynamicRebalance` in the same
|
|
756
|
+
portfolio. Each key has one producer and may have several consumers. Other action
|
|
757
|
+
types cannot consume this universe.
|
|
758
|
+
|
|
759
|
+
```ts
|
|
760
|
+
const producer = nt.updateWatchlist({
|
|
761
|
+
watchlistKey: "pelosi-holdings", memberId: "P000197", instrument: "Equity",
|
|
762
|
+
amountBasis: "Midpoint", chamber: "All",
|
|
763
|
+
output: {name: "Pelosi disclosed holdings", purpose: "Follow public holdings",
|
|
764
|
+
alertSettings: {onChange: true, inApp: true, email: true, briefCadence: "weekly"}},
|
|
765
|
+
});
|
|
766
|
+
const consumerUniverse = nt.watchlistUniverse("pelosi-holdings");
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
`output` supplies initial name, purpose and alerts. Subsequent user renames and
|
|
770
|
+
settings remain authoritative. Live and paper consumers wait for durable list
|
|
771
|
+
publication; backtests keep membership local to the run and never edit the user's
|
|
772
|
+
visible list. Discovery and data loads remain full, so this does not establish a
|
|
773
|
+
performance saving. Omitted amount basis uses `LowerBound`.
|
|
774
|
+
|
|
750
775
|
## Complete method reference
|
|
751
776
|
|
|
752
777
|
Every public method on `NexusTradeClient`. A test in this package fails if one
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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;
|
|
3
|
+
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.updateWatchlist = exports.launchAgent = exports.alert = exports.sell = exports.buy = exports.watchlistUniverse = 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.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 = exports.currentLimit = exports.limitOrder = void 0;
|
|
5
5
|
exports.universe = universe;
|
|
6
6
|
exports.AbsoluteValue = AbsoluteValue;
|
|
7
7
|
exports.AccumulationDistribution = AccumulationDistribution;
|
|
@@ -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;
|
|
@@ -373,6 +376,9 @@ function universe(source, assets) {
|
|
|
373
376
|
}
|
|
374
377
|
return { source };
|
|
375
378
|
}
|
|
379
|
+
/** The latest revision of the list an updateWatchlist producer in this portfolio maintains. */
|
|
380
|
+
const watchlistUniverse = (watchlistKey) => ({ source: "WATCHLIST", watchlistKey });
|
|
381
|
+
exports.watchlistUniverse = watchlistUniverse;
|
|
376
382
|
// ---- equity + cash actions ----
|
|
377
383
|
const buy = (target, amount, type = "percent of portfolio") => ({ type: "Buy", targetAsset: toAsset(target), amount: { type, amount } });
|
|
378
384
|
exports.buy = buy;
|
|
@@ -382,6 +388,19 @@ const alert = (message) => ({ type: "Alert", message });
|
|
|
382
388
|
exports.alert = alert;
|
|
383
389
|
const launchAgent = (config) => compact({ type: "LaunchAgent", ...config });
|
|
384
390
|
exports.launchAgent = launchAgent;
|
|
391
|
+
const updateWatchlist = (config) => ({
|
|
392
|
+
type: "UpdateWatchlist",
|
|
393
|
+
watchlistKey: config.watchlistKey,
|
|
394
|
+
...(config.output ? { output: config.output } : {}),
|
|
395
|
+
source: compact({
|
|
396
|
+
type: "PoliticalRemainingPurchases",
|
|
397
|
+
memberId: config.memberId,
|
|
398
|
+
instrument: config.instrument,
|
|
399
|
+
amountBasis: config.amountBasis,
|
|
400
|
+
chamber: config.chamber,
|
|
401
|
+
}),
|
|
402
|
+
});
|
|
403
|
+
exports.updateWatchlist = updateWatchlist;
|
|
385
404
|
const dynamicRebalance = (config) => compact({ type: "DynamicRebalance", ...config });
|
|
386
405
|
exports.dynamicRebalance = dynamicRebalance;
|
|
387
406
|
// ---- options ----
|
|
@@ -638,6 +657,32 @@ function CompoundAnnualGrowthRate(asset, metric, years) {
|
|
|
638
657
|
d["years"] = years;
|
|
639
658
|
return d;
|
|
640
659
|
}
|
|
660
|
+
/**
|
|
661
|
+
* 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).
|
|
662
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
663
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
664
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
665
|
+
*/
|
|
666
|
+
function ConsecutiveDecrease(indicator, period, lookback) {
|
|
667
|
+
const d = { type: "ConsecutiveDecrease" };
|
|
668
|
+
d["period"] = period;
|
|
669
|
+
d["lookback"] = lookback;
|
|
670
|
+
d.indicators = [indicator];
|
|
671
|
+
return d;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* 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).
|
|
675
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
676
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
677
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
678
|
+
*/
|
|
679
|
+
function ConsecutiveIncrease(indicator, period, lookback) {
|
|
680
|
+
const d = { type: "ConsecutiveIncrease" };
|
|
681
|
+
d["period"] = period;
|
|
682
|
+
d["lookback"] = lookback;
|
|
683
|
+
d.indicators = [indicator];
|
|
684
|
+
return d;
|
|
685
|
+
}
|
|
641
686
|
/**
|
|
642
687
|
* ConsecutiveTrue indicator.
|
|
643
688
|
* @param condition Condition evaluated over the window.
|
|
@@ -1210,6 +1255,15 @@ function KeltnerChannel(asset, length = 20, interval = "Day", multiplier = 2, li
|
|
|
1210
1255
|
d.window = { length: length, interval: interval };
|
|
1211
1256
|
return d;
|
|
1212
1257
|
}
|
|
1258
|
+
/**
|
|
1259
|
+
* 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).
|
|
1260
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1261
|
+
*/
|
|
1262
|
+
function LastDividend(asset) {
|
|
1263
|
+
const d = { type: "LastDividend" };
|
|
1264
|
+
setAsset(d, "targetAsset", asset);
|
|
1265
|
+
return d;
|
|
1266
|
+
}
|
|
1213
1267
|
/**
|
|
1214
1268
|
* LastOrderPrice indicator.
|
|
1215
1269
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -72,6 +72,9 @@ export type Universe = {
|
|
|
72
72
|
} | {
|
|
73
73
|
source: "SPECIFIC_ASSETS";
|
|
74
74
|
assets: Asset[];
|
|
75
|
+
} | {
|
|
76
|
+
source: "WATCHLIST";
|
|
77
|
+
watchlistKey: string;
|
|
75
78
|
};
|
|
76
79
|
export interface Allocation {
|
|
77
80
|
type: AllocationType;
|
|
@@ -264,6 +267,33 @@ export interface AlertAction {
|
|
|
264
267
|
type: "Alert";
|
|
265
268
|
message: string;
|
|
266
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Keep a portfolio-scoped list set to every security where a member of Congress
|
|
272
|
+
* still holds disclosed purchases. Refreshes every tick, places no orders, and
|
|
273
|
+
* takes no condition. A DynamicRebalance reads it with watchlistUniverse(key).
|
|
274
|
+
* Backtests use run-local membership; live and paper wait for durable publication.
|
|
275
|
+
*/
|
|
276
|
+
export interface UpdateWatchlistAction {
|
|
277
|
+
type: "UpdateWatchlist";
|
|
278
|
+
watchlistKey: string;
|
|
279
|
+
output?: {
|
|
280
|
+
name?: string;
|
|
281
|
+
purpose?: string;
|
|
282
|
+
alertSettings?: {
|
|
283
|
+
onChange: boolean;
|
|
284
|
+
inApp: boolean;
|
|
285
|
+
email: boolean;
|
|
286
|
+
briefCadence: "inherit" | "daily" | "weekly" | "never";
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
source: {
|
|
290
|
+
type: "PoliticalRemainingPurchases";
|
|
291
|
+
memberId: string;
|
|
292
|
+
instrument?: "Equity" | "Option" | "All";
|
|
293
|
+
amountBasis?: "LowerBound" | "Midpoint" | "UpperBound";
|
|
294
|
+
chamber?: "All" | "House" | "Senate";
|
|
295
|
+
};
|
|
296
|
+
}
|
|
267
297
|
export interface LaunchAgentAction {
|
|
268
298
|
type: "LaunchAgent";
|
|
269
299
|
planningModel: string;
|
|
@@ -406,7 +436,7 @@ export interface CloseOptionAction {
|
|
|
406
436
|
triggers?: CloseOptionTrigger[];
|
|
407
437
|
quantity?: CloseQuantity;
|
|
408
438
|
}
|
|
409
|
-
export type Action = BuyOrSellAction | DepositOrWithdrawAction | AlertAction | LaunchAgentAction | DynamicRebalanceAction | RebalanceOptionAction | OpenOptionAction | CloseOptionAction;
|
|
439
|
+
export type Action = BuyOrSellAction | DepositOrWithdrawAction | AlertAction | LaunchAgentAction | DynamicRebalanceAction | RebalanceOptionAction | OpenOptionAction | CloseOptionAction | UpdateWatchlistAction;
|
|
410
440
|
export type StrategyLimitWorkingTime = {
|
|
411
441
|
type: "Day";
|
|
412
442
|
} | {
|
|
@@ -488,7 +518,7 @@ export type AssetType = "Stock" | "Cryptocurrency" | "Option" | "Other";
|
|
|
488
518
|
export type Interval = "Day" | "Hour" | "Minute";
|
|
489
519
|
export type Comparator = "lessThan" | "greaterThan" | "lessThanOrEqual" | "greaterThanOrEqual" | "equal" | "notEqual";
|
|
490
520
|
export type SelectDirection = "Highest" | "Lowest";
|
|
491
|
-
export type UniverseSource = "ALL_US_STOCKS" | "SP500" | "NASDAQ100" | "DJIA" | "CRYPTO" | "SPECIFIC_ASSETS";
|
|
521
|
+
export type UniverseSource = "ALL_US_STOCKS" | "SP500" | "NASDAQ100" | "DJIA" | "CRYPTO" | "SPECIFIC_ASSETS" | "WATCHLIST";
|
|
492
522
|
export type AllocationType = "percent of portfolio" | "percent of buying power" | "percent of current positions" | "dollars" | "number of assets";
|
|
493
523
|
export type DepositWithdrawAllocationType = "percent of portfolio" | "percent of buying power" | "dollars";
|
|
494
524
|
export type OptionAllocationType = "dollars" | "percent of portfolio" | "percent of buying power" | "contracts" | "percent of realized premium";
|
|
@@ -504,6 +534,7 @@ export type OptionSpreadType = "vertical" | "calendar" | "diagonal" | "ironCondo
|
|
|
504
534
|
export type CloseScope = "spread" | "leg";
|
|
505
535
|
export type RebalanceOptionPositionScope = "portfolio" | "strategy";
|
|
506
536
|
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";
|
|
537
|
+
export type Period = "Year" | "Quarter" | "Month";
|
|
507
538
|
export type PositionEffect = "open" | "close";
|
|
508
539
|
export type OrderStatus = "Pending" | "Accepted" | "Pending User Approval" | "Canceled" | "Filled" | "Partially Filled";
|
|
509
540
|
export type Side = "Buy" | "Sell";
|
|
@@ -571,6 +602,8 @@ export declare const selectTop: (metric: Indicator, limit: number, direction?: S
|
|
|
571
602
|
export declare const selectPercentile: (metric: Indicator, percentile: number, direction?: SelectDirection) => PipelineStage;
|
|
572
603
|
export declare function universe(source: "ALL_US_STOCKS" | "SP500" | "NASDAQ100" | "DJIA" | "CRYPTO"): Universe;
|
|
573
604
|
export declare function universe(source: "SPECIFIC_ASSETS", assets: AssetArg[]): Universe;
|
|
605
|
+
/** The latest revision of the list an updateWatchlist producer in this portfolio maintains. */
|
|
606
|
+
export declare const watchlistUniverse: (watchlistKey: string) => Universe;
|
|
574
607
|
export declare const buy: (target: AssetArg, amount: number, type?: AllocationType) => BuyOrSellAction;
|
|
575
608
|
export declare const sell: (target: AssetArg, amount: number, type?: AllocationType) => BuyOrSellAction;
|
|
576
609
|
export declare const alert: (message: string) => AlertAction;
|
|
@@ -584,6 +617,14 @@ export declare const launchAgent: (config: {
|
|
|
584
617
|
skipPlanning: boolean;
|
|
585
618
|
cooldownMinutes?: number;
|
|
586
619
|
}) => LaunchAgentAction;
|
|
620
|
+
export declare const updateWatchlist: (config: {
|
|
621
|
+
watchlistKey: string;
|
|
622
|
+
memberId: string;
|
|
623
|
+
output?: UpdateWatchlistAction["output"];
|
|
624
|
+
instrument?: "Equity" | "Option" | "All";
|
|
625
|
+
amountBasis?: "LowerBound" | "Midpoint" | "UpperBound";
|
|
626
|
+
chamber?: "All" | "House" | "Senate";
|
|
627
|
+
}) => UpdateWatchlistAction;
|
|
587
628
|
export declare const dynamicRebalance: (config: {
|
|
588
629
|
universe: Universe;
|
|
589
630
|
pipeline: PipelineStage[];
|
|
@@ -786,6 +827,20 @@ export declare function CommodityChannelIndex(asset: AssetArg, length?: number,
|
|
|
786
827
|
* @param years Floating point years value
|
|
787
828
|
*/
|
|
788
829
|
export declare function CompoundAnnualGrowthRate(asset: AssetArg, metric: FundamentalMetric, years: number): Indicator;
|
|
830
|
+
/**
|
|
831
|
+
* 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).
|
|
832
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
833
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
834
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
835
|
+
*/
|
|
836
|
+
export declare function ConsecutiveDecrease(indicator: Indicator, period: Period, lookback: number): Indicator;
|
|
837
|
+
/**
|
|
838
|
+
* 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).
|
|
839
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
840
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
841
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
842
|
+
*/
|
|
843
|
+
export declare function ConsecutiveIncrease(indicator: Indicator, period: Period, lookback: number): Indicator;
|
|
789
844
|
/**
|
|
790
845
|
* ConsecutiveTrue indicator.
|
|
791
846
|
* @param condition Condition evaluated over the window.
|
|
@@ -1097,6 +1152,11 @@ export declare function IVRank(asset: AssetArg, length?: number, interval?: Inte
|
|
|
1097
1152
|
* @param line Which Keltner line to evaluate
|
|
1098
1153
|
*/
|
|
1099
1154
|
export declare function KeltnerChannel(asset: AssetArg, length?: number, interval?: Interval, multiplier?: number, line?: "upper" | "middle" | "lower"): Indicator;
|
|
1155
|
+
/**
|
|
1156
|
+
* 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).
|
|
1157
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1158
|
+
*/
|
|
1159
|
+
export declare function LastDividend(asset: AssetArg): Indicator;
|
|
1100
1160
|
/**
|
|
1101
1161
|
* LastOrderPrice indicator.
|
|
1102
1162
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -200,11 +200,25 @@ export function universe(source, assets) {
|
|
|
200
200
|
}
|
|
201
201
|
return { source };
|
|
202
202
|
}
|
|
203
|
+
/** The latest revision of the list an updateWatchlist producer in this portfolio maintains. */
|
|
204
|
+
export const watchlistUniverse = (watchlistKey) => ({ source: "WATCHLIST", watchlistKey });
|
|
203
205
|
// ---- equity + cash actions ----
|
|
204
206
|
export const buy = (target, amount, type = "percent of portfolio") => ({ type: "Buy", targetAsset: toAsset(target), amount: { type, amount } });
|
|
205
207
|
export const sell = (target, amount, type = "percent of portfolio") => ({ type: "Sell", targetAsset: toAsset(target), amount: { type, amount } });
|
|
206
208
|
export const alert = (message) => ({ type: "Alert", message });
|
|
207
209
|
export const launchAgent = (config) => compact({ type: "LaunchAgent", ...config });
|
|
210
|
+
export const updateWatchlist = (config) => ({
|
|
211
|
+
type: "UpdateWatchlist",
|
|
212
|
+
watchlistKey: config.watchlistKey,
|
|
213
|
+
...(config.output ? { output: config.output } : {}),
|
|
214
|
+
source: compact({
|
|
215
|
+
type: "PoliticalRemainingPurchases",
|
|
216
|
+
memberId: config.memberId,
|
|
217
|
+
instrument: config.instrument,
|
|
218
|
+
amountBasis: config.amountBasis,
|
|
219
|
+
chamber: config.chamber,
|
|
220
|
+
}),
|
|
221
|
+
});
|
|
208
222
|
export const dynamicRebalance = (config) => compact({ type: "DynamicRebalance", ...config });
|
|
209
223
|
// ---- options ----
|
|
210
224
|
/**
|
|
@@ -438,6 +452,32 @@ export function CompoundAnnualGrowthRate(asset, metric, years) {
|
|
|
438
452
|
d["years"] = years;
|
|
439
453
|
return d;
|
|
440
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* 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).
|
|
457
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
458
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
459
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
460
|
+
*/
|
|
461
|
+
export function ConsecutiveDecrease(indicator, period, lookback) {
|
|
462
|
+
const d = { type: "ConsecutiveDecrease" };
|
|
463
|
+
d["period"] = period;
|
|
464
|
+
d["lookback"] = lookback;
|
|
465
|
+
d.indicators = [indicator];
|
|
466
|
+
return d;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* 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).
|
|
470
|
+
* @param indicator The inner indicator whose period closing values are compared. Pass CANDIDATE to its asset in a dynamic rebalance pipeline.
|
|
471
|
+
* @param period Calendar period (America/New_York) whose closing values are compared.
|
|
472
|
+
* @param lookback Whole number of completed periods to count, 1 to 60; the streak is capped here.
|
|
473
|
+
*/
|
|
474
|
+
export function ConsecutiveIncrease(indicator, period, lookback) {
|
|
475
|
+
const d = { type: "ConsecutiveIncrease" };
|
|
476
|
+
d["period"] = period;
|
|
477
|
+
d["lookback"] = lookback;
|
|
478
|
+
d.indicators = [indicator];
|
|
479
|
+
return d;
|
|
480
|
+
}
|
|
441
481
|
/**
|
|
442
482
|
* ConsecutiveTrue indicator.
|
|
443
483
|
* @param condition Condition evaluated over the window.
|
|
@@ -1010,6 +1050,15 @@ export function KeltnerChannel(asset, length = 20, interval = "Day", multiplier
|
|
|
1010
1050
|
d.window = { length: length, interval: interval };
|
|
1011
1051
|
return d;
|
|
1012
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* 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).
|
|
1055
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1056
|
+
*/
|
|
1057
|
+
export function LastDividend(asset) {
|
|
1058
|
+
const d = { type: "LastDividend" };
|
|
1059
|
+
setAsset(d, "targetAsset", asset);
|
|
1060
|
+
return d;
|
|
1061
|
+
}
|
|
1013
1062
|
/**
|
|
1014
1063
|
* LastOrderPrice indicator.
|
|
1015
1064
|
* @param asset Ticker name (ex. SPY, BTC)
|