nexustrade 1.60.2 → 2.1.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/README.md
CHANGED
|
@@ -1120,3 +1120,69 @@ agent needs to write correct NexusTrade strategies on the first pass.
|
|
|
1120
1120
|
## License
|
|
1121
1121
|
|
|
1122
1122
|
MIT
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
## Compositional trading controls (2.1)
|
|
1126
|
+
|
|
1127
|
+
Account rules compose the existing `PortfolioValue`, arithmetic, `IndicatorWindowAgo`,
|
|
1128
|
+
`IndicatorAtCondition` and ordinary conditions. A conditional snapshot can retain
|
|
1129
|
+
any numeric operand; it has no built-in gain thresholds or release policy.
|
|
1130
|
+
Its `selection` is `First`, `Latest`, `Maximum` or `Minimum`. An initial value
|
|
1131
|
+
is only a fallback before a capture (or after expiry), not part of the extrema.
|
|
1132
|
+
For a second crossing within an hour, capture with `First` and use
|
|
1133
|
+
`andThen(60, "Minute", crossing(), crossing())` as the condition, where
|
|
1134
|
+
`crossing()` builds `gt(CrossAbove(Price(asset), Value(level)), Value(0))`.
|
|
1135
|
+
Staying above the level is not another crossing. The first capture remains
|
|
1136
|
+
fixed on later crossings unless an expiry was configured.
|
|
1137
|
+
`PositionEntryPrice`, `PositionPeakPrice` and `PositionMinutesSinceHigh` are
|
|
1138
|
+
narrow position measurements. Reuse `MinutesSinceOrder` for purchase cadence.
|
|
1139
|
+
Settlement accounting remains on the portfolio.
|
|
1140
|
+
|
|
1141
|
+
`sellHoldings` (Python `sell_holdings`) is a Sell action with a candidate-bound
|
|
1142
|
+
holding condition. Its strategy condition supplies the account/market gate;
|
|
1143
|
+
only actual qualifying stock holdings are sold. Ordinary fixed-asset Sell
|
|
1144
|
+
actions retain their existing behavior.
|
|
1145
|
+
|
|
1146
|
+
A Buy action can configure `funding`: candidate `condition`, `rankBy` indicator,
|
|
1147
|
+
`direction` (Highest/Lowest), and source sale `amount` expressed as a percentage
|
|
1148
|
+
of current positions. The strategy owns its pending workflow and every order.
|
|
1149
|
+
It waits for actual fills and settlement and rechecks its current condition;
|
|
1150
|
+
proposed proceeds never become cash. Symbol order breaks equal ranking scores.
|
|
1151
|
+
|
|
1152
|
+
Buy/Sell `executionPriority` is an integer: lower numbers execute first.
|
|
1153
|
+
Funding sales may supply their own numeric priority, otherwise they inherit the
|
|
1154
|
+
purchase priority. Untagged trading events keep FIFO order. Broker submission
|
|
1155
|
+
ordering is scoped per portfolio; one account cannot delay another account's
|
|
1156
|
+
orders through its priority settings. Already submitted broker orders cannot be
|
|
1157
|
+
reordered. `pendingOrderPolicy: "WaitForTarget"` checks orders for the actual
|
|
1158
|
+
target asset without cancellation; the default waits for portfolio orders.
|
|
1159
|
+
Priority never changes a safety gate or chooses which holdings are weak.
|
|
1160
|
+
|
|
1161
|
+
The portfolio retains `cashSettlement: "T1"` and engine-owned actual-fill
|
|
1162
|
+
settlement accounting. Configure it before deployment; edits to this setting
|
|
1163
|
+
are restricted to undeployed drafts. Current integration supports stock/ETF
|
|
1164
|
+
Buy/Sell actions, alerts and watchlist producers. Other asset/executor paths
|
|
1165
|
+
remain explicitly rejected with T1 until integrated.
|
|
1166
|
+
|
|
1167
|
+
Public cash-only requests use `useMargin: false`. Live admission additionally
|
|
1168
|
+
uses Public's cash-only withdrawal balance as a conservative cap, which can be
|
|
1169
|
+
stricter than settled trading cash. Missing cash/calendar evidence blocks buys.
|
|
1170
|
+
Other brokers need a live T1 evidence adapter. Existing owner approval and trade
|
|
1171
|
+
limits apply. Native strategy/indicator runtime uses the existing checkpoint
|
|
1172
|
+
path; its verification does not establish live broker execution.
|
|
1173
|
+
|
|
1174
|
+
ConsecutiveTrue retains optional distinct session checks at a configured
|
|
1175
|
+
cadence; missing/stale quotes reset the count. These are reusable components,
|
|
1176
|
+
not a verified complete ftr445 strategy or evidence of profitable returns.
|
|
1177
|
+
|
|
1178
|
+
`PortfolioValue` keeps its existing cash-plus-positions semantics during warmup
|
|
1179
|
+
and trading. Backtesting and paper trading do not depend on the selected pricing
|
|
1180
|
+
broker. Live capability checks reject T1 when the adapter lacks verified settled
|
|
1181
|
+
cash or cash-only submission support. Broker facts remain in the existing account
|
|
1182
|
+
reconciliation path. Porting a T1 strategy preserves its settlement policy.
|
|
1183
|
+
|
|
1184
|
+
For conditional capture, expiry runs from the retained observation's capture
|
|
1185
|
+
time. Minimum/Maximum with expiry is not a sliding-window minimum/maximum.
|
|
1186
|
+
Sampled CountTrue retains at most 10000 observations; its sorted runtime index
|
|
1187
|
+
is rebuilt when samples change and omitted from checkpoints. Moving references
|
|
1188
|
+
use binary-search queries, following the existing SortedIvWindow design.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneMaxSpreadPct = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = void 0;
|
|
3
|
+
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.sellHoldings = 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.geneStructureKind = exports.geneStopLossPct = exports.geneTakeProfitPct = exports.geneRollTriggerDte = exports.geneDeploymentPct = exports.geneTotalBudgetPct = exports.geneAllocationDollars = 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 = exports.screenPercentile = void 0;
|
|
5
|
+
exports.geneAppendUniversePipelineFilter = exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneMaxSpreadPct = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = exports.geneExposurePolicy = exports.geneAllocationPolicy = void 0;
|
|
6
6
|
exports.universe = universe;
|
|
7
7
|
exports.AbsoluteValue = AbsoluteValue;
|
|
8
8
|
exports.AccumulationDistribution = AccumulationDistribution;
|
|
@@ -51,6 +51,7 @@ exports.HighOfDay = HighOfDay;
|
|
|
51
51
|
exports.IchimokuCloud = IchimokuCloud;
|
|
52
52
|
exports.ImpliedVolatility = ImpliedVolatility;
|
|
53
53
|
exports.Index = Index;
|
|
54
|
+
exports.IndicatorAtCondition = IndicatorAtCondition;
|
|
54
55
|
exports.IndicatorAtEntry = IndicatorAtEntry;
|
|
55
56
|
exports.IndicatorAtMinutesAfterOpen = IndicatorAtMinutesAfterOpen;
|
|
56
57
|
exports.IndicatorExponentialMovingAverage = IndicatorExponentialMovingAverage;
|
|
@@ -121,8 +122,11 @@ exports.Plus = Plus;
|
|
|
121
122
|
exports.PoliticalPurchaseShare = PoliticalPurchaseShare;
|
|
122
123
|
exports.PoliticalTrades = PoliticalTrades;
|
|
123
124
|
exports.PortfolioValue = PortfolioValue;
|
|
125
|
+
exports.PositionEntryPrice = PositionEntryPrice;
|
|
124
126
|
exports.PositionMaxDrawdown = PositionMaxDrawdown;
|
|
125
127
|
exports.PositionMaxDrawup = PositionMaxDrawup;
|
|
128
|
+
exports.PositionMinutesSinceHigh = PositionMinutesSinceHigh;
|
|
129
|
+
exports.PositionPeakPrice = PositionPeakPrice;
|
|
126
130
|
exports.PositionPercentChange = PositionPercentChange;
|
|
127
131
|
exports.PositionValue = PositionValue;
|
|
128
132
|
exports.PreviousClosingPrice = PreviousClosingPrice;
|
|
@@ -260,6 +264,7 @@ function compact(obj) {
|
|
|
260
264
|
}
|
|
261
265
|
function compare(lhs, rhs, comparison) {
|
|
262
266
|
const right = typeof rhs === "number" ? Value(rhs) : rhs;
|
|
267
|
+
// Wire nodes carry no brand at runtime; nodeKind exists only in the types.
|
|
263
268
|
return { type: "Base", lhs, comparison, rhs: right };
|
|
264
269
|
}
|
|
265
270
|
const gt = (l, r) => compare(l, r, "greaterThan");
|
|
@@ -384,10 +389,14 @@ function universe(source, assets) {
|
|
|
384
389
|
const watchlistUniverse = (watchlistKey) => ({ source: "WATCHLIST", watchlistKey });
|
|
385
390
|
exports.watchlistUniverse = watchlistUniverse;
|
|
386
391
|
// ---- equity + cash actions ----
|
|
387
|
-
const buy = (target, amount, type = "percent of portfolio") => ({ type: "Buy", targetAsset: toAsset(target), amount: { type, amount } });
|
|
392
|
+
const buy = (target, amount, type = "percent of portfolio", options = {}) => ({ type: "Buy", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
388
393
|
exports.buy = buy;
|
|
389
|
-
const sell = (target, amount, type = "percent of portfolio") => ({ type: "Sell", targetAsset: toAsset(target), amount: { type, amount } });
|
|
394
|
+
const sell = (target, amount, type = "percent of portfolio", options = {}) => ({ type: "Sell", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
390
395
|
exports.sell = sell;
|
|
396
|
+
/** Sell only actual holdings that pass a candidate-bound condition. */
|
|
397
|
+
const sellHoldings = (condition, amount = 100, type = "percent of current positions", options = {}) => ({ type: "Sell", targetAsset: (0, exports.stockAsset)("__PLACEHOLDER__"),
|
|
398
|
+
holdingCondition: condition, amount: { type, amount }, ...options });
|
|
399
|
+
exports.sellHoldings = sellHoldings;
|
|
391
400
|
const alert = (message) => ({ type: "Alert", message });
|
|
392
401
|
exports.alert = alert;
|
|
393
402
|
const launchAgent = (config) => compact({ type: "LaunchAgent", ...config });
|
|
@@ -752,10 +761,13 @@ function ConsecutiveIncrease(indicator, period, lookback) {
|
|
|
752
761
|
* @param condition Condition evaluated over the window.
|
|
753
762
|
* @param length Length of time
|
|
754
763
|
* @param interval Unit of time
|
|
764
|
+
* @param checkCadenceMinutes Optional. Counts completed regular-session checks instead of elapsed time. Window length is the required count; resets each session. Missing checks reset the count.
|
|
755
765
|
*/
|
|
756
|
-
function ConsecutiveTrue(condition, length = 1, interval = "Day") {
|
|
766
|
+
function ConsecutiveTrue(condition, length = 1, interval = "Day", checkCadenceMinutes) {
|
|
757
767
|
const d = { type: "ConsecutiveTrue" };
|
|
758
768
|
d.condition = condition;
|
|
769
|
+
if (checkCadenceMinutes !== undefined)
|
|
770
|
+
d["checkCadenceMinutes"] = checkCadenceMinutes;
|
|
759
771
|
d.window = { length: length, interval: interval };
|
|
760
772
|
return d;
|
|
761
773
|
}
|
|
@@ -1078,17 +1090,34 @@ function Index(metric = "VIX") {
|
|
|
1078
1090
|
d["metric"] = metric;
|
|
1079
1091
|
return d;
|
|
1080
1092
|
}
|
|
1093
|
+
/**
|
|
1094
|
+
* IndicatorAtCondition indicator.
|
|
1095
|
+
* @param condition Condition evaluated over the window.
|
|
1096
|
+
*/
|
|
1097
|
+
function IndicatorAtCondition(operand, condition, selection = "First", clock = "Calendar", initialValue, length, interval) {
|
|
1098
|
+
const d = { type: "IndicatorAtCondition" };
|
|
1099
|
+
d.condition = condition;
|
|
1100
|
+
d["selection"] = selection;
|
|
1101
|
+
d["clock"] = clock;
|
|
1102
|
+
if (initialValue !== undefined)
|
|
1103
|
+
d["initialValue"] = initialValue;
|
|
1104
|
+
d.indicators = [operand];
|
|
1105
|
+
if (length !== undefined || interval !== undefined)
|
|
1106
|
+
d.window = { length: length, interval: interval };
|
|
1107
|
+
return d;
|
|
1108
|
+
}
|
|
1081
1109
|
/**
|
|
1082
1110
|
* IndicatorAtEntry indicator.
|
|
1083
1111
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
1084
1112
|
* @param side The side of the fill the value is anchored to
|
|
1085
1113
|
* @param orderStatus Matches order events with this status
|
|
1086
1114
|
*/
|
|
1087
|
-
function IndicatorAtEntry(operand, asset, side, orderStatus = "Filled") {
|
|
1115
|
+
function IndicatorAtEntry(operand, asset, side, orderStatus = "Filled", anchor = "LatestFill") {
|
|
1088
1116
|
const d = { type: "IndicatorAtEntry" };
|
|
1089
1117
|
setAsset(d, "targetAsset", asset);
|
|
1090
1118
|
d["side"] = side;
|
|
1091
1119
|
d["orderStatus"] = orderStatus;
|
|
1120
|
+
d["anchor"] = anchor;
|
|
1092
1121
|
d.indicators = [operand];
|
|
1093
1122
|
return d;
|
|
1094
1123
|
}
|
|
@@ -1162,16 +1191,20 @@ function IndicatorStandardDeviation(operand, length = 30, interval = "Day") {
|
|
|
1162
1191
|
* @param length Length of time
|
|
1163
1192
|
* @param interval Unit of time
|
|
1164
1193
|
*/
|
|
1165
|
-
function IndicatorWindowAgo(operand, length, interval) {
|
|
1194
|
+
function IndicatorWindowAgo(operand, length, interval, sampling, initialValue) {
|
|
1166
1195
|
const d = { type: "IndicatorWindowAgo" };
|
|
1196
|
+
if (sampling !== undefined)
|
|
1197
|
+
d["sampling"] = sampling;
|
|
1198
|
+
if (initialValue !== undefined)
|
|
1199
|
+
d["initialValue"] = initialValue;
|
|
1167
1200
|
d.indicators = [operand];
|
|
1168
1201
|
d.window = { length: length, interval: interval };
|
|
1169
1202
|
return d;
|
|
1170
1203
|
}
|
|
1171
1204
|
/**
|
|
1172
|
-
* News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines.
|
|
1205
|
+
* News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset.
|
|
1173
1206
|
* @param industry Canonical industry tag whose news to read, as IsIndustry lists it. Legacy aliases are separate news series and are rejected, never mapped.
|
|
1174
|
-
* @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value
|
|
1207
|
+
* @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
|
|
1175
1208
|
* @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest and about 20 is the usual window. The same value for every asset.
|
|
1176
1209
|
*/
|
|
1177
1210
|
function IndustryNewsSentiment(industry, measure = "Mean", lookbackDays = 1) {
|
|
@@ -1513,12 +1546,15 @@ function MinutesSinceOptionOrder(underlying, optionType, direction, spreadType,
|
|
|
1513
1546
|
* MinutesSinceOrder indicator.
|
|
1514
1547
|
* @param assets Ticker(s) whose orders are counted. One string or an array.
|
|
1515
1548
|
* @param side Buy or Sell
|
|
1549
|
+
* @param clock Optional elapsed-time clock; omitted retains calendar minutes.
|
|
1516
1550
|
*/
|
|
1517
|
-
function MinutesSinceOrder(assets, side, orderStatus = "Filled") {
|
|
1551
|
+
function MinutesSinceOrder(assets, side, orderStatus = "Filled", clock) {
|
|
1518
1552
|
const d = { type: "MinutesSinceOrder" };
|
|
1519
1553
|
setAssets(d, "targetAssets", assets);
|
|
1520
1554
|
d["side"] = side;
|
|
1521
1555
|
d["orderStatus"] = orderStatus;
|
|
1556
|
+
if (clock !== undefined)
|
|
1557
|
+
d["clock"] = clock;
|
|
1522
1558
|
return d;
|
|
1523
1559
|
}
|
|
1524
1560
|
/**
|
|
@@ -1624,9 +1660,9 @@ function NewPoliticalDisclosure(memberId, instrument, disclosureAction) {
|
|
|
1624
1660
|
return d;
|
|
1625
1661
|
}
|
|
1626
1662
|
/**
|
|
1627
|
-
* News sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that names the company: whether it is really about the company, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the asset had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the company count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines.
|
|
1663
|
+
* News sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that names the company: whether it is really about the company, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the asset had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the company count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. Headlines are matched to the issuer, so every listed share class reads the same news and META reads Facebook-era headlines.
|
|
1628
1664
|
* @param asset Pass CANDIDATE in a dynamic rebalance pipeline.
|
|
1629
|
-
* @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value
|
|
1665
|
+
* @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
|
|
1630
1666
|
* @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest. A row is visible from the snapshot the lake assigned it, the same time in backtests and live trading.
|
|
1631
1667
|
*/
|
|
1632
1668
|
function NewsSentiment(asset, measure = "Mean", lookbackDays = 1) {
|
|
@@ -1922,6 +1958,15 @@ function PortfolioValue() {
|
|
|
1922
1958
|
const d = { type: "PortfolioValue" };
|
|
1923
1959
|
return d;
|
|
1924
1960
|
}
|
|
1961
|
+
/**
|
|
1962
|
+
* PositionEntryPrice indicator.
|
|
1963
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1964
|
+
*/
|
|
1965
|
+
function PositionEntryPrice(asset) {
|
|
1966
|
+
const d = { type: "PositionEntryPrice" };
|
|
1967
|
+
setAsset(d, "targetAsset", asset);
|
|
1968
|
+
return d;
|
|
1969
|
+
}
|
|
1925
1970
|
/**
|
|
1926
1971
|
* PositionMaxDrawdown indicator.
|
|
1927
1972
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1940,6 +1985,24 @@ function PositionMaxDrawup(asset) {
|
|
|
1940
1985
|
setAsset(d, "targetAsset", asset);
|
|
1941
1986
|
return d;
|
|
1942
1987
|
}
|
|
1988
|
+
/**
|
|
1989
|
+
* PositionMinutesSinceHigh indicator.
|
|
1990
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1991
|
+
*/
|
|
1992
|
+
function PositionMinutesSinceHigh(asset) {
|
|
1993
|
+
const d = { type: "PositionMinutesSinceHigh" };
|
|
1994
|
+
setAsset(d, "targetAsset", asset);
|
|
1995
|
+
return d;
|
|
1996
|
+
}
|
|
1997
|
+
/**
|
|
1998
|
+
* PositionPeakPrice indicator.
|
|
1999
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
2000
|
+
*/
|
|
2001
|
+
function PositionPeakPrice(asset) {
|
|
2002
|
+
const d = { type: "PositionPeakPrice" };
|
|
2003
|
+
setAsset(d, "targetAsset", asset);
|
|
2004
|
+
return d;
|
|
2005
|
+
}
|
|
1943
2006
|
/**
|
|
1944
2007
|
* PositionPercentChange indicator.
|
|
1945
2008
|
* @param assets Ticker name (ex. SPY, BTC)
|
|
@@ -2394,6 +2457,14 @@ const geneAllocationPct = (strategyIndex, values) => ({
|
|
|
2394
2457
|
values: values,
|
|
2395
2458
|
});
|
|
2396
2459
|
exports.geneAllocationPct = geneAllocationPct;
|
|
2460
|
+
/** Sweep AllocationDollars (Action scope) over a value set. */
|
|
2461
|
+
const geneAllocationDollars = (strategyIndex, values) => ({
|
|
2462
|
+
field: "AllocationDollars",
|
|
2463
|
+
scope: "Action",
|
|
2464
|
+
target: { scope: "Action", field: "AllocationDollars", strategyIndex },
|
|
2465
|
+
values: values,
|
|
2466
|
+
});
|
|
2467
|
+
exports.geneAllocationDollars = geneAllocationDollars;
|
|
2397
2468
|
/** Sweep TotalBudgetPct (Action scope) over a value set. */
|
|
2398
2469
|
const geneTotalBudgetPct = (strategyIndex, values) => ({
|
|
2399
2470
|
field: "TotalBudgetPct",
|
|
@@ -2491,10 +2562,10 @@ const geneMaxSpreadPct = (strategyIndex, legIndex, values) => ({
|
|
|
2491
2562
|
});
|
|
2492
2563
|
exports.geneMaxSpreadPct = geneMaxSpreadPct;
|
|
2493
2564
|
/** Sweep SelectTopLimit (UniversePipeline scope) over a value set. */
|
|
2494
|
-
const geneSelectTopLimit = (strategyIndex,
|
|
2565
|
+
const geneSelectTopLimit = (strategyIndex, values, sleeveName) => ({
|
|
2495
2566
|
field: "SelectTopLimit",
|
|
2496
2567
|
scope: "UniversePipeline",
|
|
2497
|
-
target: { scope: "UniversePipeline", field: "SelectTopLimit", strategyIndex,
|
|
2568
|
+
target: { scope: "UniversePipeline", field: "SelectTopLimit", strategyIndex, ...(sleeveName === undefined ? {} : { sleeveName }) },
|
|
2498
2569
|
values: values,
|
|
2499
2570
|
});
|
|
2500
2571
|
exports.geneSelectTopLimit = geneSelectTopLimit;
|
|
@@ -2506,3 +2577,11 @@ const geneUniversePipelineFilter = (strategyIndex, stageIndex, values) => ({
|
|
|
2506
2577
|
values: values,
|
|
2507
2578
|
});
|
|
2508
2579
|
exports.geneUniversePipelineFilter = geneUniversePipelineFilter;
|
|
2580
|
+
/** Sweep UniversePipelineFilter (UniversePipeline scope) by adding a Filter stage to a pipeline that has none to replace. The stage goes ahead of the first SelectTop/SelectPercentile, so it narrows the universe before ranking. */
|
|
2581
|
+
const geneAppendUniversePipelineFilter = (strategyIndex, values, sleeveName) => ({
|
|
2582
|
+
field: "UniversePipelineFilter",
|
|
2583
|
+
scope: "UniversePipeline",
|
|
2584
|
+
target: { scope: "UniversePipeline", field: "UniversePipelineFilter", strategyIndex, ...(sleeveName === undefined ? {} : { sleeveName }), append: true },
|
|
2585
|
+
values: values,
|
|
2586
|
+
});
|
|
2587
|
+
exports.geneAppendUniversePipelineFilter = geneAppendUniversePipelineFilter;
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -75,7 +75,9 @@ export interface ReplaceStrategiesOperation {
|
|
|
75
75
|
/** Complete finished authored patch; omitted fields retain their saved values. */
|
|
76
76
|
export interface UpdatePortfolioOperation {
|
|
77
77
|
type: "updatePortfolio";
|
|
78
|
-
portfolio: Partial<Pick<Portfolio, "name" | "initialValue" | "strategies" | "deployment" | "policy" | "dividendPolicy" | "alertsEnabled" | "supportsFractionalShares" | "supportsCrypto"
|
|
78
|
+
portfolio: Partial<Pick<Portfolio, "name" | "initialValue" | "strategies" | "deployment" | "policy" | "dividendPolicy" | "alertsEnabled" | "supportsFractionalShares" | "supportsCrypto">> & {
|
|
79
|
+
cashSettlement?: Portfolio["cashSettlement"] | null;
|
|
80
|
+
};
|
|
79
81
|
}
|
|
80
82
|
/** All operations in one call for this portfolio are validated and saved atomically. */
|
|
81
83
|
export type PortfolioEditOperation = UpdatePortfolioOperation | PortfolioRenameOperation | AddStrategiesOperation | RemoveStrategiesOperation | ReplaceStrategyOperation | ReplaceStrategiesOperation;
|
|
@@ -18,17 +18,27 @@ export type PortfolioWide = {
|
|
|
18
18
|
/** Concrete assets must be built with stockAsset() / cryptoAsset() — no bare ticker strings. */
|
|
19
19
|
export type AssetArg = Asset | Candidate | PortfolioWide;
|
|
20
20
|
/**
|
|
21
|
-
* Opaque: indicators are only ever constructed through the
|
|
22
|
-
*
|
|
23
|
-
* defeated by the `[key: string]: unknown` index signature
|
|
24
|
-
*
|
|
21
|
+
* Opaque: indicators and conditions are only ever constructed through the
|
|
22
|
+
* builders below. Brands use unique symbols (not string keys) so they are not
|
|
23
|
+
* defeated by the `[key: string]: unknown` index signature.
|
|
24
|
+
*
|
|
25
|
+
* nodeKind keeps the two nominally distinct. Without it both interfaces are the
|
|
26
|
+
* same structure, so a bare `IsIndustry(CANDIDATE, "technology")` inside
|
|
27
|
+
* `and(...)` (or cast `as CandidateCondition`) typechecked and only failed at
|
|
28
|
+
* save time. The literal values are the text the typecheck error shows.
|
|
29
|
+
*
|
|
30
|
+
* candidateBound lets strategy() reject candidate-bound gates while
|
|
31
|
+
* filter()/eligibility still accept them.
|
|
25
32
|
*/
|
|
33
|
+
declare const nodeKind: unique symbol;
|
|
26
34
|
export interface Indicator {
|
|
27
35
|
type: string;
|
|
36
|
+
readonly [nodeKind]: "Indicator (a number, not a condition): compare it to get a condition, e.g. gt(IsIndustry(CANDIDATE, 'technology'), Value(0)) or lt(RSI(CANDIDATE, 14), Value(30))";
|
|
28
37
|
[key: string]: unknown;
|
|
29
38
|
}
|
|
30
39
|
export interface Condition {
|
|
31
40
|
type: string;
|
|
41
|
+
readonly [nodeKind]: "Condition (true/false, not an indicator)";
|
|
32
42
|
[key: string]: unknown;
|
|
33
43
|
}
|
|
34
44
|
declare const candidateBound: unique symbol;
|
|
@@ -254,10 +264,21 @@ export type CloseOptionTrigger = {
|
|
|
254
264
|
minSpreadTheta?: number;
|
|
255
265
|
maxSpreadTheta?: number;
|
|
256
266
|
};
|
|
267
|
+
export type ExecutionPriority = number;
|
|
268
|
+
export interface PurchaseFunding {
|
|
269
|
+
executionPriority?: number;
|
|
270
|
+
condition: Condition;
|
|
271
|
+
rankBy: Indicator;
|
|
272
|
+
direction: SelectDirection;
|
|
273
|
+
amount: Allocation;
|
|
274
|
+
}
|
|
257
275
|
export interface BuyOrSellAction {
|
|
258
276
|
type: "Buy" | "Sell";
|
|
259
277
|
targetAsset: Asset;
|
|
260
278
|
amount: Allocation;
|
|
279
|
+
executionPriority?: ExecutionPriority;
|
|
280
|
+
funding?: PurchaseFunding;
|
|
281
|
+
holdingCondition?: Condition;
|
|
261
282
|
}
|
|
262
283
|
export interface DepositOrWithdrawAction {
|
|
263
284
|
type: "Deposit" | "Withdraw";
|
|
@@ -524,7 +545,7 @@ export interface Strategy {
|
|
|
524
545
|
/** Omitted means Market. Limit always requires an explicit price policy. */
|
|
525
546
|
orderExecution?: StrategyOrderExecutionPolicy;
|
|
526
547
|
/** Backtest-only exit priority. CancelConflictingBuys cannot deploy to paper/live trading. */
|
|
527
|
-
pendingOrderPolicy?: "Wait" | "CancelConflictingBuys";
|
|
548
|
+
pendingOrderPolicy?: "Wait" | "WaitForTarget" | "CancelConflictingBuys";
|
|
528
549
|
}
|
|
529
550
|
export interface AuthoredIndustryFilter {
|
|
530
551
|
mode: "ALL" | "INCLUDE_ONLY";
|
|
@@ -567,6 +588,8 @@ export interface Portfolio {
|
|
|
567
588
|
alertsEnabled?: boolean;
|
|
568
589
|
/** "cash" (default when omitted) or "reinvest" into the paying stock. */
|
|
569
590
|
dividendPolicy?: DividendPolicy;
|
|
591
|
+
/** Cash-only T+1 proceeds. Missing live cash-cap evidence blocks purchases. */
|
|
592
|
+
cashSettlement?: "T1" | null;
|
|
570
593
|
policy?: AuthoredPortfolioPolicy;
|
|
571
594
|
deployment?: AuthoredDeploymentTiming;
|
|
572
595
|
}
|
|
@@ -595,6 +618,7 @@ export type Period = "Year" | "Quarter" | "Month";
|
|
|
595
618
|
export type PositionEffect = "open" | "close";
|
|
596
619
|
export type OrderStatus = "Pending" | "Accepted" | "Pending User Approval" | "Canceled" | "Filled" | "Partially Filled";
|
|
597
620
|
export type Side = "Buy" | "Sell";
|
|
621
|
+
export type Clock = "Calendar" | "Trading";
|
|
598
622
|
export type Measure = "Mean" | "Median" | "NetCount" | "ArticleCount";
|
|
599
623
|
export type Role = "Any" | "Officer" | "Director" | "TenPercentOwner" | "OfficerOrDirector";
|
|
600
624
|
export type Instrument = "Equity" | "Call" | "Put";
|
|
@@ -662,8 +686,17 @@ export declare function universe(source: "ALL_US_STOCKS" | "SP500" | "NASDAQ100"
|
|
|
662
686
|
export declare function universe(source: "SPECIFIC_ASSETS", assets: AssetArg[]): Universe;
|
|
663
687
|
/** The latest revision of the list an updateWatchlist producer in this portfolio maintains. */
|
|
664
688
|
export declare const watchlistUniverse: (watchlistKey: string) => Universe;
|
|
665
|
-
export declare const buy: (target: AssetArg, amount: number, type?: AllocationType
|
|
666
|
-
|
|
689
|
+
export declare const buy: (target: AssetArg, amount: number, type?: AllocationType, options?: {
|
|
690
|
+
executionPriority?: ExecutionPriority;
|
|
691
|
+
funding?: PurchaseFunding;
|
|
692
|
+
}) => BuyOrSellAction;
|
|
693
|
+
export declare const sell: (target: AssetArg, amount: number, type?: AllocationType, options?: {
|
|
694
|
+
executionPriority?: ExecutionPriority;
|
|
695
|
+
}) => BuyOrSellAction;
|
|
696
|
+
/** Sell only actual holdings that pass a candidate-bound condition. */
|
|
697
|
+
export declare const sellHoldings: (condition: Condition, amount?: number, type?: AllocationType, options?: {
|
|
698
|
+
executionPriority?: ExecutionPriority;
|
|
699
|
+
}) => BuyOrSellAction;
|
|
667
700
|
export declare const alert: (message: string) => AlertAction;
|
|
668
701
|
export declare const launchAgent: (config: {
|
|
669
702
|
planningModel: string;
|
|
@@ -845,6 +878,8 @@ export declare const portfolio: (name: string, strategies: Strategy[], options?:
|
|
|
845
878
|
supportsCrypto?: boolean;
|
|
846
879
|
alertsEnabled?: boolean;
|
|
847
880
|
dividendPolicy?: DividendPolicy;
|
|
881
|
+
/** Cash-only T+1 proceeds. Missing live cash-cap evidence blocks purchases. */
|
|
882
|
+
cashSettlement?: "T1" | null;
|
|
848
883
|
policy?: AuthoredPortfolioPolicy;
|
|
849
884
|
deployment?: AuthoredDeploymentTiming;
|
|
850
885
|
}) => PortfolioHandle;
|
|
@@ -912,7 +947,7 @@ export declare function ChaikinMoneyFlow(asset: AssetArg, length?: number, inter
|
|
|
912
947
|
* @param offsetBars Skip this many latest completed candles. 1 selects the previous window.
|
|
913
948
|
* @param minutePolicy strict requires every minute. observed aggregates actual eligible-trade prints, skips empty candles, and publishes after the clock bucket closes. No synthetic prices; source coverage is a separate check.
|
|
914
949
|
*/
|
|
915
|
-
export declare function ChartBar(asset: AssetArg, barMinutes?: number, line?: "open" | "high" | "low" | "close" | "sma", bars?: number, offsetBars?: number, minutePolicy?: "strict" | "observed"): Indicator;
|
|
950
|
+
export declare function ChartBar(asset: AssetArg, barMinutes?: number, line?: "open" | "high" | "low" | "close" | "sma" | "endTime", bars?: number, offsetBars?: number, minutePolicy?: "strict" | "observed"): Indicator;
|
|
916
951
|
/**
|
|
917
952
|
* CommodityChannelIndex indicator.
|
|
918
953
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -947,8 +982,9 @@ export declare function ConsecutiveIncrease(indicator: Indicator, period: Period
|
|
|
947
982
|
* @param condition Condition evaluated over the window.
|
|
948
983
|
* @param length Length of time
|
|
949
984
|
* @param interval Unit of time
|
|
985
|
+
* @param checkCadenceMinutes Optional. Counts completed regular-session checks instead of elapsed time. Window length is the required count; resets each session. Missing checks reset the count.
|
|
950
986
|
*/
|
|
951
|
-
export declare function ConsecutiveTrue(condition: Condition, length?: number, interval?: Interval): Indicator;
|
|
987
|
+
export declare function ConsecutiveTrue(condition: Condition, length?: number, interval?: Interval, checkCadenceMinutes?: number): Indicator;
|
|
952
988
|
/**
|
|
953
989
|
* Correlation indicator.
|
|
954
990
|
* @param operands Sub-indicators this compound operates on.
|
|
@@ -1125,13 +1161,18 @@ export declare function ImpliedVolatility(asset: AssetArg, dte?: number): Indica
|
|
|
1125
1161
|
* @param metric Ticker key matching hydrated index price data (add more in BigQuery + rehydrate as needed)
|
|
1126
1162
|
*/
|
|
1127
1163
|
export declare function Index(metric?: "VIX" | "SPX" | "NDX" | "DJI" | "RUT" | "SKEW" | "VVIX" | "USDBROAD" | "TNX"): Indicator;
|
|
1164
|
+
/**
|
|
1165
|
+
* IndicatorAtCondition indicator.
|
|
1166
|
+
* @param condition Condition evaluated over the window.
|
|
1167
|
+
*/
|
|
1168
|
+
export declare function IndicatorAtCondition(operand: Indicator, condition: Condition, selection?: "First" | "Latest" | "Maximum" | "Minimum", clock?: Clock, initialValue?: number, length?: number, interval?: "Minute" | "Day"): Indicator;
|
|
1128
1169
|
/**
|
|
1129
1170
|
* IndicatorAtEntry indicator.
|
|
1130
1171
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
1131
1172
|
* @param side The side of the fill the value is anchored to
|
|
1132
1173
|
* @param orderStatus Matches order events with this status
|
|
1133
1174
|
*/
|
|
1134
|
-
export declare function IndicatorAtEntry(operand: Indicator, asset: AssetArg, side: Side, orderStatus?: OrderStatus): Indicator;
|
|
1175
|
+
export declare function IndicatorAtEntry(operand: Indicator, asset: AssetArg, side: Side, orderStatus?: OrderStatus, anchor?: "LatestFill" | "HoldingEntry"): Indicator;
|
|
1135
1176
|
/**
|
|
1136
1177
|
* IndicatorAtMinutesAfterOpen indicator.
|
|
1137
1178
|
* @param minutesAfterOpen The number of minutes after market open to capture the indicator value
|
|
@@ -1172,11 +1213,11 @@ export declare function IndicatorStandardDeviation(operand: Indicator, length?:
|
|
|
1172
1213
|
* @param length Length of time
|
|
1173
1214
|
* @param interval Unit of time
|
|
1174
1215
|
*/
|
|
1175
|
-
export declare function IndicatorWindowAgo(operand: Indicator, length: number, interval: Interval): Indicator;
|
|
1216
|
+
export declare function IndicatorWindowAgo(operand: Indicator, length: number, interval: Interval, sampling?: "Calendar" | "Observation" | "Session", initialValue?: number): Indicator;
|
|
1176
1217
|
/**
|
|
1177
|
-
* News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines.
|
|
1218
|
+
* News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset.
|
|
1178
1219
|
* @param industry Canonical industry tag whose news to read, as IsIndustry lists it. Legacy aliases are separate news series and are rejected, never mapped.
|
|
1179
|
-
* @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value
|
|
1220
|
+
* @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
|
|
1180
1221
|
* @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest and about 20 is the usual window. The same value for every asset.
|
|
1181
1222
|
*/
|
|
1182
1223
|
export declare function IndustryNewsSentiment(industry: "technology" | "financialServices" | "healthcare" | "energy" | "consumerGoods" | "entertainmentAndMedia" | "manufacturing" | "transportation" | "realEstate" | "utilities" | "agriculture" | "education" | "retail" | "artificialIntelligence" | "aiInfrastructure" | "analytics" | "cloudComputing" | "dataCenter" | "database" | "cybersecurity" | "developerTools" | "software" | "saas" | "enterpriseSoftware" | "customerExperienceSoftware" | "productivityTools" | "collaborationSoftware" | "digitalSignatureAndAuthentication" | "hardware" | "consumerElectronics" | "networking" | "semiconductor" | "chipDesign" | "chipManufacturing" | "semiconductorEquipment" | "gpuAndAccelerators" | "memoryAndStorage" | "quantumComputing" | "robotics" | "industrialAutomation" | "iot" | "smartDevices" | "wearable" | "3dPrinting" | "augmentedReality" | "virtualReality" | "space" | "satellites" | "aerospace" | "defense" | "drones" | "financialInfrastructure" | "capitalMarketsTechnology" | "banking" | "assetManagement" | "brokerage" | "payments" | "fintech" | "insurance" | "autoInsurance" | "homeInsurance" | "lifeInsurance" | "healthInsurance" | "blockchain" | "cryptocurrency" | "biotechnology" | "pharmaceuticals" | "medicalDevices" | "digitalHealth" | "lifeSciencesSoftware" | "bioinformatics" | "computationalBiology" | "computationalDrugDiscovery" | "oncology" | "immunotherapy" | "vaccines" | "veterinary" | "oil" | "gas" | "oilfieldServices" | "cleanEnergy" | "renewableEnergy" | "solarEnergy" | "windEnergy" | "nuclearEnergy" | "hydrogen" | "batteryTechnology" | "miningAndNaturalResources" | "gold" | "silver" | "chemicals" | "advancedMaterials" | "waterInfrastructure" | "wasteManagementAndRecycling" | "forestry" | "construction" | "buildingMaterials" | "electricalAndGridInfrastructure" | "logisticsAndSupplyChain" | "airline" | "maritime" | "railroads" | "automotive" | "electricVehicle" | "autonomousTransportation" | "recreationalVehicle" | "cruise" | "rideShare" | "printing" | "packaging" | "householdProducts" | "ecommerce" | "digitalMarketplace" | "fashionAndApparel" | "luxuryGoods" | "jewelry" | "foodAndBeverage" | "foodDelivery" | "nutrition" | "petCare" | "outdoorAndRecreationalEquipment" | "sportsAndFitness" | "cannabis" | "hospitalityAndTravel" | "homeSecurity" | "advertising" | "gaming" | "gambling" | "sportsBetting" | "socialMedia" | "streaming" | "movies" | "musicAndAudio" | "publishing" | "telecommunications" | "edtech" | "proptech", measure?: Measure, lookbackDays?: number): Indicator;
|
|
@@ -1361,8 +1402,9 @@ export declare function MinutesSinceOptionOrder(underlying: string, optionType:
|
|
|
1361
1402
|
* MinutesSinceOrder indicator.
|
|
1362
1403
|
* @param assets Ticker(s) whose orders are counted. One string or an array.
|
|
1363
1404
|
* @param side Buy or Sell
|
|
1405
|
+
* @param clock Optional elapsed-time clock; omitted retains calendar minutes.
|
|
1364
1406
|
*/
|
|
1365
|
-
export declare function MinutesSinceOrder(assets: AssetArg | AssetArg[], side: Side, orderStatus?: OrderStatus): Indicator;
|
|
1407
|
+
export declare function MinutesSinceOrder(assets: AssetArg | AssetArg[], side: Side, orderStatus?: OrderStatus, clock?: Clock): Indicator;
|
|
1366
1408
|
/**
|
|
1367
1409
|
* MinutesUntilClose indicator.
|
|
1368
1410
|
*/
|
|
@@ -1418,9 +1460,9 @@ export declare function NewInstitutionalFiling(manager: string): Indicator;
|
|
|
1418
1460
|
*/
|
|
1419
1461
|
export declare function NewPoliticalDisclosure(memberId: string, instrument: Instrument2, disclosureAction: "Any" | "Purchase" | "Sale"): Indicator;
|
|
1420
1462
|
/**
|
|
1421
|
-
* News sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that names the company: whether it is really about the company, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the asset had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the company count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines.
|
|
1463
|
+
* News sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that names the company: whether it is really about the company, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the asset had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the company count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. Headlines are matched to the issuer, so every listed share class reads the same news and META reads Facebook-era headlines.
|
|
1422
1464
|
* @param asset Pass CANDIDATE in a dynamic rebalance pipeline.
|
|
1423
|
-
* @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value
|
|
1465
|
+
* @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
|
|
1424
1466
|
* @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest. A row is visible from the snapshot the lake assigned it, the same time in backtests and live trading.
|
|
1425
1467
|
*/
|
|
1426
1468
|
export declare function NewsSentiment(asset: AssetArg, measure?: Measure, lookbackDays?: number): Indicator;
|
|
@@ -1576,6 +1618,11 @@ export declare function PoliticalTrades(asset: AssetArg, filer: string, metric?:
|
|
|
1576
1618
|
* PortfolioValue indicator.
|
|
1577
1619
|
*/
|
|
1578
1620
|
export declare function PortfolioValue(): Indicator;
|
|
1621
|
+
/**
|
|
1622
|
+
* PositionEntryPrice indicator.
|
|
1623
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1624
|
+
*/
|
|
1625
|
+
export declare function PositionEntryPrice(asset: AssetArg): Indicator;
|
|
1579
1626
|
/**
|
|
1580
1627
|
* PositionMaxDrawdown indicator.
|
|
1581
1628
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1586,6 +1633,16 @@ export declare function PositionMaxDrawdown(asset: AssetArg): Indicator;
|
|
|
1586
1633
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
1587
1634
|
*/
|
|
1588
1635
|
export declare function PositionMaxDrawup(asset: AssetArg): Indicator;
|
|
1636
|
+
/**
|
|
1637
|
+
* PositionMinutesSinceHigh indicator.
|
|
1638
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1639
|
+
*/
|
|
1640
|
+
export declare function PositionMinutesSinceHigh(asset: AssetArg): Indicator;
|
|
1641
|
+
/**
|
|
1642
|
+
* PositionPeakPrice indicator.
|
|
1643
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1644
|
+
*/
|
|
1645
|
+
export declare function PositionPeakPrice(asset: AssetArg): Indicator;
|
|
1589
1646
|
/**
|
|
1590
1647
|
* PositionPercentChange indicator.
|
|
1591
1648
|
* @param assets Ticker name (ex. SPY, BTC)
|
|
@@ -1802,7 +1859,7 @@ export interface BacktestConfig {
|
|
|
1802
1859
|
baselineSymbol?: string;
|
|
1803
1860
|
/** Typed buy-and-hold benchmark for comparisonValue. Use {type:'Cryptocurrency',symbol:'BTC-USD',name:'BTC-USD'} for BTC or {type:'Stock',symbol:'SPY',name:'SPY'} for a stock/ETF. Symbol text never determines asset type. Omit baseline_symbol when using this field. */
|
|
1804
1861
|
baselineAsset?: Record<string, unknown>;
|
|
1805
|
-
/** Time interval: Day or Minute (default Day). Minute is a daytrade tape. 730 days of minute data (selected range plus warmup) is the HARD CAP; 90 days is only the DEFAULT when you name no dates. Name the dates you actually want — certifying a candidate on a full year or two is a normal second backtest, not an escalation. */
|
|
1862
|
+
/** Time interval: Day or Minute (default Day). Day uses fixed OHLC decision/fill snapshots and overrides the portfolio deployment frequency, openDelayMinutes, closeLeadMinutes and intervalSeconds. Use Minute when the authored intraday schedule matters. Minute is a daytrade tape. 730 days of minute data (selected range plus warmup) is the HARD CAP; 90 days is only the DEFAULT when you name no dates. Name the dates you actually want — certifying a candidate on a full year or two is a normal second backtest, not an escalation. */
|
|
1806
1863
|
interval?: "Day" | "Minute";
|
|
1807
1864
|
/** Starting portfolio value (default 10000) Range 1..inf. */
|
|
1808
1865
|
initialValue?: number;
|
|
@@ -1812,7 +1869,7 @@ export interface BacktestConfig {
|
|
|
1812
1869
|
forceNewRun?: boolean;
|
|
1813
1870
|
/** 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. OptionSlippageFraction is supported: 0 fills at quote mid, 1 at ask for buys/bid for sells; omitted uses the engine default 0.5. Fills require a current executable quote; this does not enable last-trade fallback pricing. */
|
|
1814
1871
|
feeConfig?: FeeConfig;
|
|
1815
|
-
/** 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
|
|
1872
|
+
/** 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 while that stock is still held. A fully exited position receives its locked dividend entitlement as cash without reopening the position. Reinvest is what a buy-and-hold comparison against the SPY total-return baseline needs. */
|
|
1816
1873
|
dividendPolicy?: "cash" | "reinvest";
|
|
1817
1874
|
}
|
|
1818
1875
|
export interface WalkForwardConfig {
|
|
@@ -1963,6 +2020,8 @@ export declare const geneRankSignal: (strategyIndex: number, values: {
|
|
|
1963
2020
|
export declare const geneBuyingPowerPct: (strategyIndex: number, values: number[]) => Gene;
|
|
1964
2021
|
/** Sweep AllocationPct (Action scope) over a value set. */
|
|
1965
2022
|
export declare const geneAllocationPct: (strategyIndex: number, values: number[]) => Gene;
|
|
2023
|
+
/** Sweep AllocationDollars (Action scope) over a value set. */
|
|
2024
|
+
export declare const geneAllocationDollars: (strategyIndex: number, values: number[]) => Gene;
|
|
1966
2025
|
/** Sweep TotalBudgetPct (Action scope) over a value set. */
|
|
1967
2026
|
export declare const geneTotalBudgetPct: (strategyIndex: number, values: number[]) => Gene;
|
|
1968
2027
|
/** Sweep DeploymentPct (Action scope) over a value set. */
|
|
@@ -1997,10 +2056,15 @@ export declare const geneDteBracket: (strategyIndex: number, legIndex: number, v
|
|
|
1997
2056
|
/** Sweep MaxSpreadPct (OptionLeg scope) over a value set. */
|
|
1998
2057
|
export declare const geneMaxSpreadPct: (strategyIndex: number, legIndex: number, values: number[]) => Gene;
|
|
1999
2058
|
/** Sweep SelectTopLimit (UniversePipeline scope) over a value set. */
|
|
2000
|
-
export declare const geneSelectTopLimit: (strategyIndex: number,
|
|
2059
|
+
export declare const geneSelectTopLimit: (strategyIndex: number, values: number[], sleeveName?: string) => Gene;
|
|
2001
2060
|
/** Sweep UniversePipelineFilter (UniversePipeline scope) over a value set. */
|
|
2002
2061
|
export declare const geneUniversePipelineFilter: (strategyIndex: number, stageIndex: number, values: {
|
|
2003
2062
|
label: string;
|
|
2004
2063
|
condition: Condition;
|
|
2005
2064
|
}[]) => Gene;
|
|
2065
|
+
/** Sweep UniversePipelineFilter (UniversePipeline scope) by adding a Filter stage to a pipeline that has none to replace. The stage goes ahead of the first SelectTop/SelectPercentile, so it narrows the universe before ranking. */
|
|
2066
|
+
export declare const geneAppendUniversePipelineFilter: (strategyIndex: number, values: {
|
|
2067
|
+
label: string;
|
|
2068
|
+
condition: Condition;
|
|
2069
|
+
}[], sleeveName?: string) => Gene;
|
|
2006
2070
|
export {};
|
|
@@ -107,6 +107,7 @@ function compact(obj) {
|
|
|
107
107
|
}
|
|
108
108
|
function compare(lhs, rhs, comparison) {
|
|
109
109
|
const right = typeof rhs === "number" ? Value(rhs) : rhs;
|
|
110
|
+
// Wire nodes carry no brand at runtime; nodeKind exists only in the types.
|
|
110
111
|
return { type: "Base", lhs, comparison, rhs: right };
|
|
111
112
|
}
|
|
112
113
|
export const gt = (l, r) => compare(l, r, "greaterThan");
|
|
@@ -203,8 +204,11 @@ export function universe(source, assets) {
|
|
|
203
204
|
/** The latest revision of the list an updateWatchlist producer in this portfolio maintains. */
|
|
204
205
|
export const watchlistUniverse = (watchlistKey) => ({ source: "WATCHLIST", watchlistKey });
|
|
205
206
|
// ---- equity + cash actions ----
|
|
206
|
-
export const buy = (target, amount, type = "percent of portfolio") => ({ type: "Buy", targetAsset: toAsset(target), amount: { type, amount } });
|
|
207
|
-
export const sell = (target, amount, type = "percent of portfolio") => ({ type: "Sell", targetAsset: toAsset(target), amount: { type, amount } });
|
|
207
|
+
export const buy = (target, amount, type = "percent of portfolio", options = {}) => ({ type: "Buy", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
208
|
+
export const sell = (target, amount, type = "percent of portfolio", options = {}) => ({ type: "Sell", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
209
|
+
/** Sell only actual holdings that pass a candidate-bound condition. */
|
|
210
|
+
export const sellHoldings = (condition, amount = 100, type = "percent of current positions", options = {}) => ({ type: "Sell", targetAsset: stockAsset("__PLACEHOLDER__"),
|
|
211
|
+
holdingCondition: condition, amount: { type, amount }, ...options });
|
|
208
212
|
export const alert = (message) => ({ type: "Alert", message });
|
|
209
213
|
export const launchAgent = (config) => compact({ type: "LaunchAgent", ...config });
|
|
210
214
|
export const updateWatchlist = (config) => ({
|
|
@@ -530,10 +534,13 @@ export function ConsecutiveIncrease(indicator, period, lookback) {
|
|
|
530
534
|
* @param condition Condition evaluated over the window.
|
|
531
535
|
* @param length Length of time
|
|
532
536
|
* @param interval Unit of time
|
|
537
|
+
* @param checkCadenceMinutes Optional. Counts completed regular-session checks instead of elapsed time. Window length is the required count; resets each session. Missing checks reset the count.
|
|
533
538
|
*/
|
|
534
|
-
export function ConsecutiveTrue(condition, length = 1, interval = "Day") {
|
|
539
|
+
export function ConsecutiveTrue(condition, length = 1, interval = "Day", checkCadenceMinutes) {
|
|
535
540
|
const d = { type: "ConsecutiveTrue" };
|
|
536
541
|
d.condition = condition;
|
|
542
|
+
if (checkCadenceMinutes !== undefined)
|
|
543
|
+
d["checkCadenceMinutes"] = checkCadenceMinutes;
|
|
537
544
|
d.window = { length: length, interval: interval };
|
|
538
545
|
return d;
|
|
539
546
|
}
|
|
@@ -856,17 +863,34 @@ export function Index(metric = "VIX") {
|
|
|
856
863
|
d["metric"] = metric;
|
|
857
864
|
return d;
|
|
858
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* IndicatorAtCondition indicator.
|
|
868
|
+
* @param condition Condition evaluated over the window.
|
|
869
|
+
*/
|
|
870
|
+
export function IndicatorAtCondition(operand, condition, selection = "First", clock = "Calendar", initialValue, length, interval) {
|
|
871
|
+
const d = { type: "IndicatorAtCondition" };
|
|
872
|
+
d.condition = condition;
|
|
873
|
+
d["selection"] = selection;
|
|
874
|
+
d["clock"] = clock;
|
|
875
|
+
if (initialValue !== undefined)
|
|
876
|
+
d["initialValue"] = initialValue;
|
|
877
|
+
d.indicators = [operand];
|
|
878
|
+
if (length !== undefined || interval !== undefined)
|
|
879
|
+
d.window = { length: length, interval: interval };
|
|
880
|
+
return d;
|
|
881
|
+
}
|
|
859
882
|
/**
|
|
860
883
|
* IndicatorAtEntry indicator.
|
|
861
884
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
862
885
|
* @param side The side of the fill the value is anchored to
|
|
863
886
|
* @param orderStatus Matches order events with this status
|
|
864
887
|
*/
|
|
865
|
-
export function IndicatorAtEntry(operand, asset, side, orderStatus = "Filled") {
|
|
888
|
+
export function IndicatorAtEntry(operand, asset, side, orderStatus = "Filled", anchor = "LatestFill") {
|
|
866
889
|
const d = { type: "IndicatorAtEntry" };
|
|
867
890
|
setAsset(d, "targetAsset", asset);
|
|
868
891
|
d["side"] = side;
|
|
869
892
|
d["orderStatus"] = orderStatus;
|
|
893
|
+
d["anchor"] = anchor;
|
|
870
894
|
d.indicators = [operand];
|
|
871
895
|
return d;
|
|
872
896
|
}
|
|
@@ -940,16 +964,20 @@ export function IndicatorStandardDeviation(operand, length = 30, interval = "Day
|
|
|
940
964
|
* @param length Length of time
|
|
941
965
|
* @param interval Unit of time
|
|
942
966
|
*/
|
|
943
|
-
export function IndicatorWindowAgo(operand, length, interval) {
|
|
967
|
+
export function IndicatorWindowAgo(operand, length, interval, sampling, initialValue) {
|
|
944
968
|
const d = { type: "IndicatorWindowAgo" };
|
|
969
|
+
if (sampling !== undefined)
|
|
970
|
+
d["sampling"] = sampling;
|
|
971
|
+
if (initialValue !== undefined)
|
|
972
|
+
d["initialValue"] = initialValue;
|
|
945
973
|
d.indicators = [operand];
|
|
946
974
|
d.window = { length: length, interval: interval };
|
|
947
975
|
return d;
|
|
948
976
|
}
|
|
949
977
|
/**
|
|
950
|
-
* News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines.
|
|
978
|
+
* News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset.
|
|
951
979
|
* @param industry Canonical industry tag whose news to read, as IsIndustry lists it. Legacy aliases are separate news series and are rejected, never mapped.
|
|
952
|
-
* @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value
|
|
980
|
+
* @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
|
|
953
981
|
* @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest and about 20 is the usual window. The same value for every asset.
|
|
954
982
|
*/
|
|
955
983
|
export function IndustryNewsSentiment(industry, measure = "Mean", lookbackDays = 1) {
|
|
@@ -1291,12 +1319,15 @@ export function MinutesSinceOptionOrder(underlying, optionType, direction, sprea
|
|
|
1291
1319
|
* MinutesSinceOrder indicator.
|
|
1292
1320
|
* @param assets Ticker(s) whose orders are counted. One string or an array.
|
|
1293
1321
|
* @param side Buy or Sell
|
|
1322
|
+
* @param clock Optional elapsed-time clock; omitted retains calendar minutes.
|
|
1294
1323
|
*/
|
|
1295
|
-
export function MinutesSinceOrder(assets, side, orderStatus = "Filled") {
|
|
1324
|
+
export function MinutesSinceOrder(assets, side, orderStatus = "Filled", clock) {
|
|
1296
1325
|
const d = { type: "MinutesSinceOrder" };
|
|
1297
1326
|
setAssets(d, "targetAssets", assets);
|
|
1298
1327
|
d["side"] = side;
|
|
1299
1328
|
d["orderStatus"] = orderStatus;
|
|
1329
|
+
if (clock !== undefined)
|
|
1330
|
+
d["clock"] = clock;
|
|
1300
1331
|
return d;
|
|
1301
1332
|
}
|
|
1302
1333
|
/**
|
|
@@ -1402,9 +1433,9 @@ export function NewPoliticalDisclosure(memberId, instrument, disclosureAction) {
|
|
|
1402
1433
|
return d;
|
|
1403
1434
|
}
|
|
1404
1435
|
/**
|
|
1405
|
-
* News sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that names the company: whether it is really about the company, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the asset had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the company count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines.
|
|
1436
|
+
* News sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that names the company: whether it is really about the company, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the asset had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the company count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. Headlines are matched to the issuer, so every listed share class reads the same news and META reads Facebook-era headlines.
|
|
1406
1437
|
* @param asset Pass CANDIDATE in a dynamic rebalance pipeline.
|
|
1407
|
-
* @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value
|
|
1438
|
+
* @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
|
|
1408
1439
|
* @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest. A row is visible from the snapshot the lake assigned it, the same time in backtests and live trading.
|
|
1409
1440
|
*/
|
|
1410
1441
|
export function NewsSentiment(asset, measure = "Mean", lookbackDays = 1) {
|
|
@@ -1700,6 +1731,15 @@ export function PortfolioValue() {
|
|
|
1700
1731
|
const d = { type: "PortfolioValue" };
|
|
1701
1732
|
return d;
|
|
1702
1733
|
}
|
|
1734
|
+
/**
|
|
1735
|
+
* PositionEntryPrice indicator.
|
|
1736
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1737
|
+
*/
|
|
1738
|
+
export function PositionEntryPrice(asset) {
|
|
1739
|
+
const d = { type: "PositionEntryPrice" };
|
|
1740
|
+
setAsset(d, "targetAsset", asset);
|
|
1741
|
+
return d;
|
|
1742
|
+
}
|
|
1703
1743
|
/**
|
|
1704
1744
|
* PositionMaxDrawdown indicator.
|
|
1705
1745
|
* @param asset Ticker name (ex. SPY, BTC)
|
|
@@ -1718,6 +1758,24 @@ export function PositionMaxDrawup(asset) {
|
|
|
1718
1758
|
setAsset(d, "targetAsset", asset);
|
|
1719
1759
|
return d;
|
|
1720
1760
|
}
|
|
1761
|
+
/**
|
|
1762
|
+
* PositionMinutesSinceHigh indicator.
|
|
1763
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1764
|
+
*/
|
|
1765
|
+
export function PositionMinutesSinceHigh(asset) {
|
|
1766
|
+
const d = { type: "PositionMinutesSinceHigh" };
|
|
1767
|
+
setAsset(d, "targetAsset", asset);
|
|
1768
|
+
return d;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* PositionPeakPrice indicator.
|
|
1772
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1773
|
+
*/
|
|
1774
|
+
export function PositionPeakPrice(asset) {
|
|
1775
|
+
const d = { type: "PositionPeakPrice" };
|
|
1776
|
+
setAsset(d, "targetAsset", asset);
|
|
1777
|
+
return d;
|
|
1778
|
+
}
|
|
1721
1779
|
/**
|
|
1722
1780
|
* PositionPercentChange indicator.
|
|
1723
1781
|
* @param assets Ticker name (ex. SPY, BTC)
|
|
@@ -2158,6 +2216,13 @@ export const geneAllocationPct = (strategyIndex, values) => ({
|
|
|
2158
2216
|
target: { scope: "Action", field: "AllocationPct", strategyIndex },
|
|
2159
2217
|
values: values,
|
|
2160
2218
|
});
|
|
2219
|
+
/** Sweep AllocationDollars (Action scope) over a value set. */
|
|
2220
|
+
export const geneAllocationDollars = (strategyIndex, values) => ({
|
|
2221
|
+
field: "AllocationDollars",
|
|
2222
|
+
scope: "Action",
|
|
2223
|
+
target: { scope: "Action", field: "AllocationDollars", strategyIndex },
|
|
2224
|
+
values: values,
|
|
2225
|
+
});
|
|
2161
2226
|
/** Sweep TotalBudgetPct (Action scope) over a value set. */
|
|
2162
2227
|
export const geneTotalBudgetPct = (strategyIndex, values) => ({
|
|
2163
2228
|
field: "TotalBudgetPct",
|
|
@@ -2243,10 +2308,10 @@ export const geneMaxSpreadPct = (strategyIndex, legIndex, values) => ({
|
|
|
2243
2308
|
values: values,
|
|
2244
2309
|
});
|
|
2245
2310
|
/** Sweep SelectTopLimit (UniversePipeline scope) over a value set. */
|
|
2246
|
-
export const geneSelectTopLimit = (strategyIndex,
|
|
2311
|
+
export const geneSelectTopLimit = (strategyIndex, values, sleeveName) => ({
|
|
2247
2312
|
field: "SelectTopLimit",
|
|
2248
2313
|
scope: "UniversePipeline",
|
|
2249
|
-
target: { scope: "UniversePipeline", field: "SelectTopLimit", strategyIndex,
|
|
2314
|
+
target: { scope: "UniversePipeline", field: "SelectTopLimit", strategyIndex, ...(sleeveName === undefined ? {} : { sleeveName }) },
|
|
2250
2315
|
values: values,
|
|
2251
2316
|
});
|
|
2252
2317
|
/** Sweep UniversePipelineFilter (UniversePipeline scope) over a value set. */
|
|
@@ -2256,3 +2321,10 @@ export const geneUniversePipelineFilter = (strategyIndex, stageIndex, values) =>
|
|
|
2256
2321
|
target: { scope: "UniversePipeline", field: "UniversePipelineFilter", strategyIndex, stageIndex },
|
|
2257
2322
|
values: values,
|
|
2258
2323
|
});
|
|
2324
|
+
/** Sweep UniversePipelineFilter (UniversePipeline scope) by adding a Filter stage to a pipeline that has none to replace. The stage goes ahead of the first SelectTop/SelectPercentile, so it narrows the universe before ranking. */
|
|
2325
|
+
export const geneAppendUniversePipelineFilter = (strategyIndex, values, sleeveName) => ({
|
|
2326
|
+
field: "UniversePipelineFilter",
|
|
2327
|
+
scope: "UniversePipeline",
|
|
2328
|
+
target: { scope: "UniversePipeline", field: "UniversePipelineFilter", strategyIndex, ...(sleeveName === undefined ? {} : { sleeveName }), append: true },
|
|
2329
|
+
values: values,
|
|
2330
|
+
});
|