nexustrade 1.41.0 → 1.42.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
|
@@ -772,6 +772,38 @@ publication; backtests keep membership local to the run and never edit the user'
|
|
|
772
772
|
visible list. Discovery and data loads remain full, so this does not establish a
|
|
773
773
|
performance saving. Omitted amount basis uses `LowerBound`.
|
|
774
774
|
|
|
775
|
+
`updateInstitutionalWatchlist` follows an exact manager's latest publicly
|
|
776
|
+
available complete equity book. `updateInsiderWatchlist` selects qualifying
|
|
777
|
+
positive purchases by first public availability, with optional owner, issuer,
|
|
778
|
+
and role scope. Both use the same publication and consumer contract:
|
|
779
|
+
|
|
780
|
+
```ts
|
|
781
|
+
const manager = nt.updateInstitutionalWatchlist({
|
|
782
|
+
watchlistKey: "berkshire-equities", managerCik: "1067983",
|
|
783
|
+
});
|
|
784
|
+
const insider = nt.updateInsiderWatchlist({
|
|
785
|
+
watchlistKey: "insider-purchases", windowDays: 90, role: "OfficerOrDirector",
|
|
786
|
+
});
|
|
787
|
+
const screen = nt.updateScreenerWatchlist({
|
|
788
|
+
watchlistKey: "berkshire-top-20", refreshMinutes: 1440,
|
|
789
|
+
columns: [nt.screenColumn("price", nt.screenPrice()),
|
|
790
|
+
nt.screenColumn("holding", nt.screenDisclosure(manager.source))],
|
|
791
|
+
filter: nt.screenAll(nt.screenCompare("price", "Gte", 5),
|
|
792
|
+
nt.screenCompare("holding", "Gt", 0)),
|
|
793
|
+
selection: nt.screenTop("holding", 20),
|
|
794
|
+
});
|
|
795
|
+
const screenUniverse = nt.watchlistUniverse("berkshire-top-20");
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
The screen evaluates on its scheduled cadence and reuses accepted membership
|
|
799
|
+
between refreshes. Missing facts remain unknown. `screenAny` composes OR rules;
|
|
800
|
+
`screenPercentile` ranks the filtered candidates with known rank values.
|
|
801
|
+
`screenBarVolume` and `screenBarDollarVolume` require a completed historical
|
|
802
|
+
bar; live quotes do not supply those metrics in this release. Price and disclosure
|
|
803
|
+
metrics support live screens. Failed coverage or publication blocks new allocation
|
|
804
|
+
while consumers retain their exit behavior. Screen execution uses in-memory DuckDB;
|
|
805
|
+
no local database volume or LLM call is required for refreshes.
|
|
806
|
+
|
|
775
807
|
## Complete method reference
|
|
776
808
|
|
|
777
809
|
Every public method on `NexusTradeClient`. A test in this package fails if one
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.screenPercentile = exports.screenTop = exports.screenAny = exports.screenAll = exports.screenCompare = exports.screenDisclosure = exports.screenBarDollarVolume = exports.screenBarVolume = exports.screenPrice = exports.screenColumn = exports.updateScreenerWatchlist = exports.updateInsiderWatchlist = exports.updateInstitutionalWatchlist = 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.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 = 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 = void 0;
|
|
5
|
+
exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneMaxSpreadPct = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = void 0;
|
|
5
6
|
exports.universe = universe;
|
|
6
7
|
exports.AbsoluteValue = AbsoluteValue;
|
|
7
8
|
exports.AccumulationDistribution = AccumulationDistribution;
|
|
@@ -401,6 +402,47 @@ const updateWatchlist = (config) => ({
|
|
|
401
402
|
}),
|
|
402
403
|
});
|
|
403
404
|
exports.updateWatchlist = updateWatchlist;
|
|
405
|
+
const updateInstitutionalWatchlist = (config) => ({
|
|
406
|
+
type: "UpdateWatchlist", watchlistKey: config.watchlistKey,
|
|
407
|
+
...(config.output ? { output: config.output } : {}),
|
|
408
|
+
source: compact({ type: "InstitutionalHoldings", managerCik: config.managerCik, windowDays: config.windowDays }),
|
|
409
|
+
});
|
|
410
|
+
exports.updateInstitutionalWatchlist = updateInstitutionalWatchlist;
|
|
411
|
+
const updateInsiderWatchlist = (config) => ({
|
|
412
|
+
type: "UpdateWatchlist", watchlistKey: config.watchlistKey,
|
|
413
|
+
...(config.output ? { output: config.output } : {}),
|
|
414
|
+
source: compact({ type: "InsiderPurchases", windowDays: config.windowDays, role: config.role,
|
|
415
|
+
ownerCik: config.ownerCik, issuerCik: config.issuerCik }),
|
|
416
|
+
});
|
|
417
|
+
exports.updateInsiderWatchlist = updateInsiderWatchlist;
|
|
418
|
+
/** Scalar PIT screen: facts are sampled only when due. Volume uses certified completed historical OHLC at the replay interval; live quote/trade volume stays unknown. */
|
|
419
|
+
const updateScreenerWatchlist = (config) => ({
|
|
420
|
+
type: "UpdateWatchlist", watchlistKey: config.watchlistKey,
|
|
421
|
+
...(config.output ? { output: config.output } : {}),
|
|
422
|
+
source: compact({ type: "Screener", columns: config.columns, filter: config.filter,
|
|
423
|
+
selection: config.selection, refreshMinutes: config.refreshMinutes }),
|
|
424
|
+
});
|
|
425
|
+
exports.updateScreenerWatchlist = updateScreenerWatchlist;
|
|
426
|
+
const screenColumn = (key, metric) => ({ key, metric });
|
|
427
|
+
exports.screenColumn = screenColumn;
|
|
428
|
+
const screenPrice = () => ({ type: "ObservedPrice" });
|
|
429
|
+
exports.screenPrice = screenPrice;
|
|
430
|
+
const screenBarVolume = () => ({ type: "BarVolume" });
|
|
431
|
+
exports.screenBarVolume = screenBarVolume;
|
|
432
|
+
const screenBarDollarVolume = () => ({ type: "BarDollarVolume" });
|
|
433
|
+
exports.screenBarDollarVolume = screenBarDollarVolume;
|
|
434
|
+
const screenDisclosure = (source) => ({ type: "Disclosure", source });
|
|
435
|
+
exports.screenDisclosure = screenDisclosure;
|
|
436
|
+
const screenCompare = (field, op, value) => ({ type: "Compare", field, op, value });
|
|
437
|
+
exports.screenCompare = screenCompare;
|
|
438
|
+
const screenAll = (...rules) => ({ type: "All", rules });
|
|
439
|
+
exports.screenAll = screenAll;
|
|
440
|
+
const screenAny = (...rules) => ({ type: "Any", rules });
|
|
441
|
+
exports.screenAny = screenAny;
|
|
442
|
+
const screenTop = (field, limit, direction = "Descending") => ({ type: "Top", field, direction, limit });
|
|
443
|
+
exports.screenTop = screenTop;
|
|
444
|
+
const screenPercentile = (field, percentile, direction = "Descending") => ({ type: "Percentile", field, direction, percentile });
|
|
445
|
+
exports.screenPercentile = screenPercentile;
|
|
404
446
|
const dynamicRebalance = (config) => compact({ type: "DynamicRebalance", ...config });
|
|
405
447
|
exports.dynamicRebalance = dynamicRebalance;
|
|
406
448
|
// ---- options ----
|
|
@@ -268,11 +268,64 @@ export interface AlertAction {
|
|
|
268
268
|
message: string;
|
|
269
269
|
}
|
|
270
270
|
/**
|
|
271
|
-
* Keep a portfolio-scoped list set to
|
|
272
|
-
*
|
|
271
|
+
* Keep a portfolio-scoped list set to currently public source membership.
|
|
272
|
+
* Refreshes every tick, places no orders, and
|
|
273
273
|
* takes no condition. A DynamicRebalance reads it with watchlistUniverse(key).
|
|
274
274
|
* Backtests use run-local membership; live and paper wait for durable publication.
|
|
275
275
|
*/
|
|
276
|
+
export type DisclosureWatchlistSource = {
|
|
277
|
+
type: "PoliticalRemainingPurchases";
|
|
278
|
+
memberId: string;
|
|
279
|
+
instrument?: "Equity" | "Option" | "All";
|
|
280
|
+
amountBasis?: "LowerBound" | "Midpoint" | "UpperBound";
|
|
281
|
+
chamber?: "All" | "House" | "Senate";
|
|
282
|
+
} | {
|
|
283
|
+
type: "InstitutionalHoldings";
|
|
284
|
+
managerCik: string;
|
|
285
|
+
windowDays?: number;
|
|
286
|
+
} | {
|
|
287
|
+
type: "InsiderPurchases";
|
|
288
|
+
windowDays: number;
|
|
289
|
+
role?: "Any" | "Officer" | "Director" | "TenPercentOwner" | "OfficerOrDirector";
|
|
290
|
+
ownerCik?: string;
|
|
291
|
+
issuerCik?: string;
|
|
292
|
+
};
|
|
293
|
+
export type ScreenMetric = {
|
|
294
|
+
type: "ObservedPrice" | "BarVolume" | "BarDollarVolume";
|
|
295
|
+
} | {
|
|
296
|
+
type: "Disclosure";
|
|
297
|
+
source: DisclosureWatchlistSource;
|
|
298
|
+
};
|
|
299
|
+
export type ScreenRule = {
|
|
300
|
+
type: "Compare";
|
|
301
|
+
field: string;
|
|
302
|
+
op: "Gt" | "Gte" | "Lt" | "Lte" | "Eq" | "Ne";
|
|
303
|
+
value: number;
|
|
304
|
+
} | {
|
|
305
|
+
type: "All" | "Any";
|
|
306
|
+
rules: ScreenRule[];
|
|
307
|
+
};
|
|
308
|
+
export type ScreenSelection = {
|
|
309
|
+
type: "Top";
|
|
310
|
+
field: string;
|
|
311
|
+
direction: "Ascending" | "Descending";
|
|
312
|
+
limit: number;
|
|
313
|
+
} | {
|
|
314
|
+
type: "Percentile";
|
|
315
|
+
field: string;
|
|
316
|
+
direction: "Ascending" | "Descending";
|
|
317
|
+
percentile: number;
|
|
318
|
+
};
|
|
319
|
+
export interface ScreenerSource {
|
|
320
|
+
type: "Screener";
|
|
321
|
+
columns: {
|
|
322
|
+
key: string;
|
|
323
|
+
metric: ScreenMetric;
|
|
324
|
+
}[];
|
|
325
|
+
filter: ScreenRule;
|
|
326
|
+
selection?: ScreenSelection;
|
|
327
|
+
refreshMinutes: number;
|
|
328
|
+
}
|
|
276
329
|
export interface UpdateWatchlistAction {
|
|
277
330
|
type: "UpdateWatchlist";
|
|
278
331
|
watchlistKey: string;
|
|
@@ -286,16 +339,11 @@ export interface UpdateWatchlistAction {
|
|
|
286
339
|
briefCadence: "inherit" | "daily" | "weekly" | "never";
|
|
287
340
|
};
|
|
288
341
|
};
|
|
289
|
-
source:
|
|
290
|
-
type: "PoliticalRemainingPurchases";
|
|
291
|
-
memberId: string;
|
|
292
|
-
instrument?: "Equity" | "Option" | "All";
|
|
293
|
-
amountBasis?: "LowerBound" | "Midpoint" | "UpperBound";
|
|
294
|
-
chamber?: "All" | "House" | "Senate";
|
|
295
|
-
};
|
|
342
|
+
source: DisclosureWatchlistSource | ScreenerSource;
|
|
296
343
|
}
|
|
297
344
|
export interface LaunchAgentAction {
|
|
298
345
|
type: "LaunchAgent";
|
|
346
|
+
watchlistId?: string;
|
|
299
347
|
planningModel: string;
|
|
300
348
|
executionModel: string;
|
|
301
349
|
initialMessage: string;
|
|
@@ -616,6 +664,7 @@ export declare const launchAgent: (config: {
|
|
|
616
664
|
continueExisting: boolean;
|
|
617
665
|
skipPlanning: boolean;
|
|
618
666
|
cooldownMinutes?: number;
|
|
667
|
+
watchlistId?: string;
|
|
619
668
|
}) => LaunchAgentAction;
|
|
620
669
|
export declare const updateWatchlist: (config: {
|
|
621
670
|
watchlistKey: string;
|
|
@@ -624,7 +673,50 @@ export declare const updateWatchlist: (config: {
|
|
|
624
673
|
instrument?: "Equity" | "Option" | "All";
|
|
625
674
|
amountBasis?: "LowerBound" | "Midpoint" | "UpperBound";
|
|
626
675
|
chamber?: "All" | "House" | "Senate";
|
|
627
|
-
}) => UpdateWatchlistAction
|
|
676
|
+
}) => UpdateWatchlistAction & {
|
|
677
|
+
source: Extract<DisclosureWatchlistSource, {
|
|
678
|
+
type: "PoliticalRemainingPurchases";
|
|
679
|
+
}>;
|
|
680
|
+
};
|
|
681
|
+
export declare const updateInstitutionalWatchlist: (config: {
|
|
682
|
+
watchlistKey: string;
|
|
683
|
+
managerCik: string;
|
|
684
|
+
windowDays?: number;
|
|
685
|
+
output?: UpdateWatchlistAction["output"];
|
|
686
|
+
}) => UpdateWatchlistAction & {
|
|
687
|
+
source: Extract<DisclosureWatchlistSource, {
|
|
688
|
+
type: "InstitutionalHoldings";
|
|
689
|
+
}>;
|
|
690
|
+
};
|
|
691
|
+
export declare const updateInsiderWatchlist: (config: {
|
|
692
|
+
watchlistKey: string;
|
|
693
|
+
windowDays: number;
|
|
694
|
+
role?: "Any" | "Officer" | "Director" | "TenPercentOwner" | "OfficerOrDirector";
|
|
695
|
+
ownerCik?: string;
|
|
696
|
+
issuerCik?: string;
|
|
697
|
+
output?: UpdateWatchlistAction["output"];
|
|
698
|
+
}) => UpdateWatchlistAction & {
|
|
699
|
+
source: Extract<DisclosureWatchlistSource, {
|
|
700
|
+
type: "InsiderPurchases";
|
|
701
|
+
}>;
|
|
702
|
+
};
|
|
703
|
+
/** Scalar PIT screen: facts are sampled only when due. Volume uses certified completed historical OHLC at the replay interval; live quote/trade volume stays unknown. */
|
|
704
|
+
export declare const updateScreenerWatchlist: (config: Omit<ScreenerSource, "type"> & {
|
|
705
|
+
watchlistKey: string;
|
|
706
|
+
output?: UpdateWatchlistAction["output"];
|
|
707
|
+
}) => UpdateWatchlistAction & {
|
|
708
|
+
source: ScreenerSource;
|
|
709
|
+
};
|
|
710
|
+
export declare const screenColumn: (key: string, metric: ScreenMetric) => ScreenerSource["columns"][number];
|
|
711
|
+
export declare const screenPrice: () => ScreenMetric;
|
|
712
|
+
export declare const screenBarVolume: () => ScreenMetric;
|
|
713
|
+
export declare const screenBarDollarVolume: () => ScreenMetric;
|
|
714
|
+
export declare const screenDisclosure: (source: DisclosureWatchlistSource) => ScreenMetric;
|
|
715
|
+
export declare const screenCompare: (field: string, op: "Gt" | "Gte" | "Lt" | "Lte" | "Eq" | "Ne", value: number) => ScreenRule;
|
|
716
|
+
export declare const screenAll: (...rules: ScreenRule[]) => ScreenRule;
|
|
717
|
+
export declare const screenAny: (...rules: ScreenRule[]) => ScreenRule;
|
|
718
|
+
export declare const screenTop: (field: string, limit: number, direction?: "Ascending" | "Descending") => ScreenSelection;
|
|
719
|
+
export declare const screenPercentile: (field: string, percentile: number, direction?: "Ascending" | "Descending") => ScreenSelection;
|
|
628
720
|
export declare const dynamicRebalance: (config: {
|
|
629
721
|
universe: Universe;
|
|
630
722
|
pipeline: PipelineStage[];
|
|
@@ -219,6 +219,34 @@ export const updateWatchlist = (config) => ({
|
|
|
219
219
|
chamber: config.chamber,
|
|
220
220
|
}),
|
|
221
221
|
});
|
|
222
|
+
export const updateInstitutionalWatchlist = (config) => ({
|
|
223
|
+
type: "UpdateWatchlist", watchlistKey: config.watchlistKey,
|
|
224
|
+
...(config.output ? { output: config.output } : {}),
|
|
225
|
+
source: compact({ type: "InstitutionalHoldings", managerCik: config.managerCik, windowDays: config.windowDays }),
|
|
226
|
+
});
|
|
227
|
+
export const updateInsiderWatchlist = (config) => ({
|
|
228
|
+
type: "UpdateWatchlist", watchlistKey: config.watchlistKey,
|
|
229
|
+
...(config.output ? { output: config.output } : {}),
|
|
230
|
+
source: compact({ type: "InsiderPurchases", windowDays: config.windowDays, role: config.role,
|
|
231
|
+
ownerCik: config.ownerCik, issuerCik: config.issuerCik }),
|
|
232
|
+
});
|
|
233
|
+
/** Scalar PIT screen: facts are sampled only when due. Volume uses certified completed historical OHLC at the replay interval; live quote/trade volume stays unknown. */
|
|
234
|
+
export const updateScreenerWatchlist = (config) => ({
|
|
235
|
+
type: "UpdateWatchlist", watchlistKey: config.watchlistKey,
|
|
236
|
+
...(config.output ? { output: config.output } : {}),
|
|
237
|
+
source: compact({ type: "Screener", columns: config.columns, filter: config.filter,
|
|
238
|
+
selection: config.selection, refreshMinutes: config.refreshMinutes }),
|
|
239
|
+
});
|
|
240
|
+
export const screenColumn = (key, metric) => ({ key, metric });
|
|
241
|
+
export const screenPrice = () => ({ type: "ObservedPrice" });
|
|
242
|
+
export const screenBarVolume = () => ({ type: "BarVolume" });
|
|
243
|
+
export const screenBarDollarVolume = () => ({ type: "BarDollarVolume" });
|
|
244
|
+
export const screenDisclosure = (source) => ({ type: "Disclosure", source });
|
|
245
|
+
export const screenCompare = (field, op, value) => ({ type: "Compare", field, op, value });
|
|
246
|
+
export const screenAll = (...rules) => ({ type: "All", rules });
|
|
247
|
+
export const screenAny = (...rules) => ({ type: "Any", rules });
|
|
248
|
+
export const screenTop = (field, limit, direction = "Descending") => ({ type: "Top", field, direction, limit });
|
|
249
|
+
export const screenPercentile = (field, percentile, direction = "Descending") => ({ type: "Percentile", field, direction, percentile });
|
|
222
250
|
export const dynamicRebalance = (config) => compact({ type: "DynamicRebalance", ...config });
|
|
223
251
|
// ---- options ----
|
|
224
252
|
/**
|