nexustrade 1.28.1 → 1.29.1
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/AGENTS.md
CHANGED
|
@@ -261,13 +261,13 @@ const book = nt.portfolio("Momentum", [
|
|
|
261
261
|
],
|
|
262
262
|
weightIndicator: nt.RSI(nt.CANDIDATE, 14),
|
|
263
263
|
limit: 10,
|
|
264
|
-
deploymentPercent: 80,
|
|
264
|
+
deploymentPercent: nt.Value(80),
|
|
265
265
|
})),
|
|
266
266
|
], { initialValue: 100_000 });
|
|
267
267
|
```
|
|
268
268
|
|
|
269
269
|
Note the key is `universe`, not `universeConfig` (the Python SDK spells it
|
|
270
|
-
`universe_config`). `deploymentPercent: 80` invests 80% of the portfolio across
|
|
270
|
+
`universe_config`). `deploymentPercent: nt.Value(80)` invests 80% of the portfolio across
|
|
271
271
|
the selection and leaves the rest in cash — a **total** cap, not per-name.
|
|
272
272
|
</details>
|
|
273
273
|
|
package/README.md
CHANGED
|
@@ -166,7 +166,7 @@ const book = nt.portfolio(
|
|
|
166
166
|
],
|
|
167
167
|
weightIndicator: nt.RSI(nt.CANDIDATE, 14),
|
|
168
168
|
limit: 10,
|
|
169
|
-
deploymentPercent: 80,
|
|
169
|
+
deploymentPercent: nt.Value(80),
|
|
170
170
|
})
|
|
171
171
|
),
|
|
172
172
|
],
|
|
@@ -239,7 +239,7 @@ price target. Live option strategies must choose an explicit Limit policy.
|
|
|
239
239
|
|
|
240
240
|
| Group | Examples |
|
|
241
241
|
| ------------------- | -------------------------------------------------------------------------------------------- |
|
|
242
|
-
| **Price & volume** | `Price` `OpeningPrice` `HighOfDay` `MinuteBarHigh` `MinuteBarLow` `VWAP` `Volume` `GapPercentage` |
|
|
242
|
+
| **Price & volume** | `Price` `OpeningPrice` `HighOfDay` `MinuteBarHigh` `MinuteBarLow` `HeikinAshi` `VWAP` `Volume` `GapPercentage` |
|
|
243
243
|
| **Technicals** | `SMA` `EMA` `RSI` `BollingerBand` `AverageTrueRange` `CrossAbove` |
|
|
244
244
|
| **Position state** | `PositionValue` `PositionPercentChange` `PositionMaxDrawdown` |
|
|
245
245
|
| **Portfolio state** | `PortfolioValue` `BuyingPower` `MaxDrawdown` `InitialValue` |
|
|
@@ -42,6 +42,7 @@ exports.Exponentiation = Exponentiation;
|
|
|
42
42
|
exports.Fundamental = Fundamental;
|
|
43
43
|
exports.GapPercentage = GapPercentage;
|
|
44
44
|
exports.GapSize = GapSize;
|
|
45
|
+
exports.HeikinAshi = HeikinAshi;
|
|
45
46
|
exports.HighOfDay = HighOfDay;
|
|
46
47
|
exports.IchimokuCloud = IchimokuCloud;
|
|
47
48
|
exports.ImpliedVolatility = ImpliedVolatility;
|
|
@@ -106,6 +107,7 @@ exports.OptionSpreadEntryPrice = OptionSpreadEntryPrice;
|
|
|
106
107
|
exports.OptionUnrealizedPnL = OptionUnrealizedPnL;
|
|
107
108
|
exports.ParabolicSar = ParabolicSar;
|
|
108
109
|
exports.Plus = Plus;
|
|
110
|
+
exports.PoliticalPurchaseShare = PoliticalPurchaseShare;
|
|
109
111
|
exports.PoliticalTrades = PoliticalTrades;
|
|
110
112
|
exports.PortfolioValue = PortfolioValue;
|
|
111
113
|
exports.PositionMaxDrawdown = PositionMaxDrawdown;
|
|
@@ -907,6 +909,17 @@ function GapSize(asset) {
|
|
|
907
909
|
setAsset(d, "targetAsset", asset);
|
|
908
910
|
return d;
|
|
909
911
|
}
|
|
912
|
+
/**
|
|
913
|
+
* HeikinAshi indicator.
|
|
914
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
915
|
+
* @param line Which one-minute Heikin-Ashi value to evaluate. streak is the signed length of the current same-color run (0 once it shows an opposite-direction wick, and on a doji)
|
|
916
|
+
*/
|
|
917
|
+
function HeikinAshi(asset, line = "close") {
|
|
918
|
+
const d = { type: "HeikinAshi" };
|
|
919
|
+
setAsset(d, "targetAsset", asset);
|
|
920
|
+
d["line"] = line;
|
|
921
|
+
return d;
|
|
922
|
+
}
|
|
910
923
|
/**
|
|
911
924
|
* HighOfDay indicator.
|
|
912
925
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1660,6 +1673,19 @@ function Plus(left, right) {
|
|
|
1660
1673
|
d.indicators = [left, right];
|
|
1661
1674
|
return d;
|
|
1662
1675
|
}
|
|
1676
|
+
/**
|
|
1677
|
+
* PoliticalPurchaseShare indicator.
|
|
1678
|
+
* @param memberId Bioguide member id, for example P000197. The share uses the member's whole public purchase record.
|
|
1679
|
+
* @param instrument Which side of the equity/option purchase mix to return, as a percent from 0 to 100.
|
|
1680
|
+
* @param amountBasis Estimate for disclosed purchase ranges. Midpoint is the default.
|
|
1681
|
+
*/
|
|
1682
|
+
function PoliticalPurchaseShare(memberId, instrument = "Equity", amountBasis = "Midpoint") {
|
|
1683
|
+
const d = { type: "PoliticalPurchaseShare" };
|
|
1684
|
+
d["memberId"] = memberId;
|
|
1685
|
+
d["instrument"] = instrument;
|
|
1686
|
+
d["amountBasis"] = amountBasis;
|
|
1687
|
+
return d;
|
|
1688
|
+
}
|
|
1663
1689
|
/**
|
|
1664
1690
|
* PoliticalTrades indicator.
|
|
1665
1691
|
* @param asset Pass CANDIDATE inside a rebalance pipeline to bind each stock.
|
|
@@ -90,9 +90,10 @@ export interface PerNameAllocation {
|
|
|
90
90
|
type: "percent of portfolio" | "dollars";
|
|
91
91
|
amount: number;
|
|
92
92
|
}
|
|
93
|
+
/** Author budget values as indicators, including Value for a constant. */
|
|
93
94
|
export interface DeploymentBudget {
|
|
94
95
|
type: DeploymentBudgetType;
|
|
95
|
-
amount:
|
|
96
|
+
amount: Indicator;
|
|
96
97
|
}
|
|
97
98
|
export interface ExpirationSelector {
|
|
98
99
|
minDaysToExpiration: number;
|
|
@@ -317,7 +318,7 @@ export interface DynamicRebalanceAction {
|
|
|
317
318
|
pipeline: PipelineStage[];
|
|
318
319
|
weightIndicator: Indicator | CandidateIndicator;
|
|
319
320
|
limit?: number;
|
|
320
|
-
deploymentPercent?:
|
|
321
|
+
deploymentPercent?: Indicator;
|
|
321
322
|
perNameAllocation?: PerNameAllocation;
|
|
322
323
|
/**
|
|
323
324
|
* Candidate-bound gate on NON-TARGET FULL EXITS only. Omitted = always sell
|
|
@@ -345,6 +346,7 @@ export interface RebalanceOptionAction {
|
|
|
345
346
|
limit?: number;
|
|
346
347
|
totalBudget?: DeploymentBudget;
|
|
347
348
|
perNameAllocation?: OptionAllocation;
|
|
349
|
+
sizingMode?: "fixedPerName" | "proportionalToWeight";
|
|
348
350
|
positionScope?: RebalanceOptionPositionScope;
|
|
349
351
|
sleeves?: RebalanceOptionSleeve[];
|
|
350
352
|
allocationPolicy?: AllocationPolicy;
|
|
@@ -498,6 +500,7 @@ export type PositionEffect = "open" | "close";
|
|
|
498
500
|
export type OrderStatus = "Pending" | "Accepted" | "Pending User Approval" | "Canceled" | "Filled" | "Partially Filled";
|
|
499
501
|
export type Side = "Buy" | "Sell";
|
|
500
502
|
export type MinOrMax = "min" | "max";
|
|
503
|
+
export type AmountBasis = "LowerBound" | "Midpoint" | "UpperBound";
|
|
501
504
|
export declare const CANDIDATE: Candidate;
|
|
502
505
|
/** Portfolio-wide targetAssets: [] — rebalance cadence, not per-ticker DCA. */
|
|
503
506
|
export declare const PORTFOLIO_WIDE: PortfolioWide;
|
|
@@ -575,7 +578,7 @@ export declare const dynamicRebalance: (config: {
|
|
|
575
578
|
pipeline: PipelineStage[];
|
|
576
579
|
weightIndicator: Indicator | CandidateIndicator;
|
|
577
580
|
limit?: number;
|
|
578
|
-
deploymentPercent?:
|
|
581
|
+
deploymentPercent?: Indicator;
|
|
579
582
|
perNameAllocation?: PerNameAllocation;
|
|
580
583
|
canSell?: Condition | CandidateCondition;
|
|
581
584
|
allowShorts?: boolean;
|
|
@@ -628,6 +631,7 @@ export declare const rebalanceOption: (config: {
|
|
|
628
631
|
limit?: number;
|
|
629
632
|
totalBudget?: DeploymentBudget;
|
|
630
633
|
perNameAllocation?: OptionAllocation;
|
|
634
|
+
sizingMode?: "fixedPerName" | "proportionalToWeight";
|
|
631
635
|
positionScope?: RebalanceOptionPositionScope;
|
|
632
636
|
sleeves?: RebalanceOptionSleeve[];
|
|
633
637
|
allocationPolicy?: AllocationPolicy;
|
|
@@ -921,6 +925,12 @@ export declare function GapPercentage(asset: AssetArg): Indicator;
|
|
|
921
925
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
922
926
|
*/
|
|
923
927
|
export declare function GapSize(asset: AssetArg): Indicator;
|
|
928
|
+
/**
|
|
929
|
+
* HeikinAshi indicator.
|
|
930
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
931
|
+
* @param line Which one-minute Heikin-Ashi value to evaluate. streak is the signed length of the current same-color run (0 once it shows an opposite-direction wick, and on a doji)
|
|
932
|
+
*/
|
|
933
|
+
export declare function HeikinAshi(asset: AssetArg, line?: "open" | "high" | "low" | "close" | "streak"): Indicator;
|
|
924
934
|
/**
|
|
925
935
|
* HighOfDay indicator.
|
|
926
936
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1328,6 +1338,13 @@ export declare function ParabolicSar(asset: AssetArg, interval?: Interval, step?
|
|
|
1328
1338
|
* Plus indicator.
|
|
1329
1339
|
*/
|
|
1330
1340
|
export declare function Plus(left: Indicator, right: Indicator): Indicator;
|
|
1341
|
+
/**
|
|
1342
|
+
* PoliticalPurchaseShare indicator.
|
|
1343
|
+
* @param memberId Bioguide member id, for example P000197. The share uses the member's whole public purchase record.
|
|
1344
|
+
* @param instrument Which side of the equity/option purchase mix to return, as a percent from 0 to 100.
|
|
1345
|
+
* @param amountBasis Estimate for disclosed purchase ranges. Midpoint is the default.
|
|
1346
|
+
*/
|
|
1347
|
+
export declare function PoliticalPurchaseShare(memberId: string, instrument?: "Equity" | "Option", amountBasis?: AmountBasis): Indicator;
|
|
1331
1348
|
/**
|
|
1332
1349
|
* PoliticalTrades indicator.
|
|
1333
1350
|
* @param asset Pass CANDIDATE inside a rebalance pipeline to bind each stock.
|
|
@@ -1339,7 +1356,7 @@ export declare function Plus(left: Indicator, right: Indicator): Indicator;
|
|
|
1339
1356
|
* @param chamber Optional advanced cohort filter; named-member requests should normally use All.
|
|
1340
1357
|
* @param memberId Bioguide id such as P000197. Matches exactly and overrides filer, because names collide.
|
|
1341
1358
|
*/
|
|
1342
|
-
export declare function PoliticalTrades(asset: AssetArg, filer: string, metric?: "NetAmount" | "BuyAmount" | "SellAmount" | "BuyCount" | "SellCount" | "DistinctBuyers" | "Held", windowDays?: number, amountBasis?:
|
|
1359
|
+
export declare function PoliticalTrades(asset: AssetArg, filer: string, metric?: "NetAmount" | "BuyAmount" | "SellAmount" | "BuyCount" | "SellCount" | "DistinctBuyers" | "Held", windowDays?: number, amountBasis?: AmountBasis, instrument?: "Equity" | "Option" | "All", chamber?: "All" | "House" | "Senate", memberId?: string): Indicator;
|
|
1343
1360
|
/**
|
|
1344
1361
|
* PortfolioValue indicator.
|
|
1345
1362
|
*/
|
|
@@ -713,6 +713,17 @@ export function GapSize(asset) {
|
|
|
713
713
|
setAsset(d, "targetAsset", asset);
|
|
714
714
|
return d;
|
|
715
715
|
}
|
|
716
|
+
/**
|
|
717
|
+
* HeikinAshi indicator.
|
|
718
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
719
|
+
* @param line Which one-minute Heikin-Ashi value to evaluate. streak is the signed length of the current same-color run (0 once it shows an opposite-direction wick, and on a doji)
|
|
720
|
+
*/
|
|
721
|
+
export function HeikinAshi(asset, line = "close") {
|
|
722
|
+
const d = { type: "HeikinAshi" };
|
|
723
|
+
setAsset(d, "targetAsset", asset);
|
|
724
|
+
d["line"] = line;
|
|
725
|
+
return d;
|
|
726
|
+
}
|
|
716
727
|
/**
|
|
717
728
|
* HighOfDay indicator.
|
|
718
729
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1466,6 +1477,19 @@ export function Plus(left, right) {
|
|
|
1466
1477
|
d.indicators = [left, right];
|
|
1467
1478
|
return d;
|
|
1468
1479
|
}
|
|
1480
|
+
/**
|
|
1481
|
+
* PoliticalPurchaseShare indicator.
|
|
1482
|
+
* @param memberId Bioguide member id, for example P000197. The share uses the member's whole public purchase record.
|
|
1483
|
+
* @param instrument Which side of the equity/option purchase mix to return, as a percent from 0 to 100.
|
|
1484
|
+
* @param amountBasis Estimate for disclosed purchase ranges. Midpoint is the default.
|
|
1485
|
+
*/
|
|
1486
|
+
export function PoliticalPurchaseShare(memberId, instrument = "Equity", amountBasis = "Midpoint") {
|
|
1487
|
+
const d = { type: "PoliticalPurchaseShare" };
|
|
1488
|
+
d["memberId"] = memberId;
|
|
1489
|
+
d["instrument"] = instrument;
|
|
1490
|
+
d["amountBasis"] = amountBasis;
|
|
1491
|
+
return d;
|
|
1492
|
+
}
|
|
1469
1493
|
/**
|
|
1470
1494
|
* PoliticalTrades indicator.
|
|
1471
1495
|
* @param asset Pass CANDIDATE inside a rebalance pipeline to bind each stock.
|