nexustrade 0.1.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/AGENTS.md +256 -0
- package/CLAUDE.md +7 -0
- package/LICENSE +21 -0
- package/README.md +283 -0
- package/dist/cjs/client.js +527 -0
- package/dist/cjs/env.js +158 -0
- package/dist/cjs/generated/ntSdk.generated.js +1656 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/client.d.ts +140 -0
- package/dist/esm/client.js +519 -0
- package/dist/esm/env.d.ts +49 -0
- package/dist/esm/env.js +151 -0
- package/dist/esm/generated/ntSdk.generated.d.ts +1328 -0
- package/dist/esm/generated/ntSdk.generated.js +1487 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +2 -0
- package/package.json +53 -0
|
@@ -0,0 +1,1656 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// GENERATED by src/scripts/codegen/generateNtSdk.ts — do not edit by hand.
|
|
4
|
+
// Regenerate: cd server && npx ts-node src/scripts/codegen/generateNtSdk.ts
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.walkForward = exports.backtest = exports.SMA = exports.RSI = exports.PriceStdDev = exports.EMA = exports.BBand = exports.portfolio = exports.sessionFlatten = exports.strategy = 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.launchAgent = exports.alert = exports.withdraw = exports.deposit = exports.sell = exports.buy = exports.selectPercentile = exports.selectTop = exports.filter = exports.always = 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;
|
|
7
|
+
exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = exports.geneStructureKind = exports.geneTakeProfitPct = exports.geneRollTriggerDte = exports.geneDeploymentPct = exports.geneTotalBudgetPct = exports.geneAllocationPct = exports.geneBuyingPowerPct = exports.geneRankSignal = exports.geneEntryCooldownDays = exports.geneExitCondition = exports.geneEntryCondition = exports.geneSubject = exports.optimization = void 0;
|
|
8
|
+
exports.universe = universe;
|
|
9
|
+
exports.AbsoluteValue = AbsoluteValue;
|
|
10
|
+
exports.AverageTrueRange = AverageTrueRange;
|
|
11
|
+
exports.BearishFairValueGap = BearishFairValueGap;
|
|
12
|
+
exports.BollingerBand = BollingerBand;
|
|
13
|
+
exports.BullishFairValueGap = BullishFairValueGap;
|
|
14
|
+
exports.BuyingPower = BuyingPower;
|
|
15
|
+
exports.CompoundAnnualGrowthRate = CompoundAnnualGrowthRate;
|
|
16
|
+
exports.ConsecutiveTrue = ConsecutiveTrue;
|
|
17
|
+
exports.CountTrue = CountTrue;
|
|
18
|
+
exports.CrossAbove = CrossAbove;
|
|
19
|
+
exports.CrossBelow = CrossBelow;
|
|
20
|
+
exports.CurrentTimeHours = CurrentTimeHours;
|
|
21
|
+
exports.CurrentTimeMinutes = CurrentTimeMinutes;
|
|
22
|
+
exports.CurrentTimeSeconds = CurrentTimeSeconds;
|
|
23
|
+
exports.CustomIndicator = CustomIndicator;
|
|
24
|
+
exports.Date = Date;
|
|
25
|
+
exports.Day = Day;
|
|
26
|
+
exports.DaysSinceAgent = DaysSinceAgent;
|
|
27
|
+
exports.DaysSinceAlert = DaysSinceAlert;
|
|
28
|
+
exports.DaysSinceEarnings = DaysSinceEarnings;
|
|
29
|
+
exports.DaysSinceLastRebalanceOptionOrder = DaysSinceLastRebalanceOptionOrder;
|
|
30
|
+
exports.DaysSinceOptionOrder = DaysSinceOptionOrder;
|
|
31
|
+
exports.DaysSinceOrder = DaysSinceOrder;
|
|
32
|
+
exports.DaysSinceStrategyFired = DaysSinceStrategyFired;
|
|
33
|
+
exports.DaysSinceTransaction = DaysSinceTransaction;
|
|
34
|
+
exports.DaysUntilEarnings = DaysUntilEarnings;
|
|
35
|
+
exports.Divide = Divide;
|
|
36
|
+
exports.Economic = Economic;
|
|
37
|
+
exports.ExponentialMovingAverage = ExponentialMovingAverage;
|
|
38
|
+
exports.Exponentiation = Exponentiation;
|
|
39
|
+
exports.Fundamental = Fundamental;
|
|
40
|
+
exports.GapPercentage = GapPercentage;
|
|
41
|
+
exports.GapSize = GapSize;
|
|
42
|
+
exports.HighOfDay = HighOfDay;
|
|
43
|
+
exports.Index = Index;
|
|
44
|
+
exports.IndicatorAtMinutesAfterOpen = IndicatorAtMinutesAfterOpen;
|
|
45
|
+
exports.IndicatorExponentialMovingAverage = IndicatorExponentialMovingAverage;
|
|
46
|
+
exports.IndicatorMeanAbsoluteDeviation = IndicatorMeanAbsoluteDeviation;
|
|
47
|
+
exports.IndicatorRateOfChange = IndicatorRateOfChange;
|
|
48
|
+
exports.IndicatorSimpleMovingAverage = IndicatorSimpleMovingAverage;
|
|
49
|
+
exports.IndicatorStandardDeviation = IndicatorStandardDeviation;
|
|
50
|
+
exports.IndicatorWindowAgo = IndicatorWindowAgo;
|
|
51
|
+
exports.InitialValue = InitialValue;
|
|
52
|
+
exports.IsAsset = IsAsset;
|
|
53
|
+
exports.IsAssetType = IsAssetType;
|
|
54
|
+
exports.IsIndexMember = IsIndexMember;
|
|
55
|
+
exports.IsIndustry = IsIndustry;
|
|
56
|
+
exports.IsNotAsset = IsNotAsset;
|
|
57
|
+
exports.LastOrderPrice = LastOrderPrice;
|
|
58
|
+
exports.Log = Log;
|
|
59
|
+
exports.LowOfDay = LowOfDay;
|
|
60
|
+
exports.Max = Max;
|
|
61
|
+
exports.MaxDrawdown = MaxDrawdown;
|
|
62
|
+
exports.MaxDrawup = MaxDrawup;
|
|
63
|
+
exports.MaximumPrice = MaximumPrice;
|
|
64
|
+
exports.Min = Min;
|
|
65
|
+
exports.MinimumPrice = MinimumPrice;
|
|
66
|
+
exports.Minus = Minus;
|
|
67
|
+
exports.MinutesAfterOpen = MinutesAfterOpen;
|
|
68
|
+
exports.MinutesSinceAgent = MinutesSinceAgent;
|
|
69
|
+
exports.MinutesSinceAlert = MinutesSinceAlert;
|
|
70
|
+
exports.MinutesSinceOptionOrder = MinutesSinceOptionOrder;
|
|
71
|
+
exports.MinutesSinceOrder = MinutesSinceOrder;
|
|
72
|
+
exports.MinutesUntilClose = MinutesUntilClose;
|
|
73
|
+
exports.Month = Month;
|
|
74
|
+
exports.Multiply = Multiply;
|
|
75
|
+
exports.Negative = Negative;
|
|
76
|
+
exports.OpeningPrice = OpeningPrice;
|
|
77
|
+
exports.OptionCollateral = OptionCollateral;
|
|
78
|
+
exports.OptionDaysHeld = OptionDaysHeld;
|
|
79
|
+
exports.OptionDaysToExpiration = OptionDaysToExpiration;
|
|
80
|
+
exports.OptionGrossExposurePercent = OptionGrossExposurePercent;
|
|
81
|
+
exports.OptionPositionCount = OptionPositionCount;
|
|
82
|
+
exports.OptionPositionMaxDrawdown = OptionPositionMaxDrawdown;
|
|
83
|
+
exports.OptionPositionPercentChange = OptionPositionPercentChange;
|
|
84
|
+
exports.OptionPositionValue = OptionPositionValue;
|
|
85
|
+
exports.OptionSpreadCount = OptionSpreadCount;
|
|
86
|
+
exports.OptionUnrealizedPnL = OptionUnrealizedPnL;
|
|
87
|
+
exports.Plus = Plus;
|
|
88
|
+
exports.PortfolioValue = PortfolioValue;
|
|
89
|
+
exports.PositionMaxDrawdown = PositionMaxDrawdown;
|
|
90
|
+
exports.PositionMaxDrawup = PositionMaxDrawup;
|
|
91
|
+
exports.PositionPercentChange = PositionPercentChange;
|
|
92
|
+
exports.PositionValue = PositionValue;
|
|
93
|
+
exports.PreviousClosingPrice = PreviousClosingPrice;
|
|
94
|
+
exports.Price = Price;
|
|
95
|
+
exports.PriceChangeSinceOpen = PriceChangeSinceOpen;
|
|
96
|
+
exports.PriceMeanAbsoluteDeviation = PriceMeanAbsoluteDeviation;
|
|
97
|
+
exports.PriceRateOfChange = PriceRateOfChange;
|
|
98
|
+
exports.PriceStandardDeviation = PriceStandardDeviation;
|
|
99
|
+
exports.RelativeStrengthIndex = RelativeStrengthIndex;
|
|
100
|
+
exports.SimpleMovingAverage = SimpleMovingAverage;
|
|
101
|
+
exports.SquareRoot = SquareRoot;
|
|
102
|
+
exports.StockReport = StockReport;
|
|
103
|
+
exports.SumOrderAmount = SumOrderAmount;
|
|
104
|
+
exports.SumOrderQuantity = SumOrderQuantity;
|
|
105
|
+
exports.TrailingSum = TrailingSum;
|
|
106
|
+
exports.TrueRange = TrueRange;
|
|
107
|
+
exports.UnderlyingMaxDrawdown = UnderlyingMaxDrawdown;
|
|
108
|
+
exports.Value = Value;
|
|
109
|
+
exports.Volume = Volume;
|
|
110
|
+
exports.VWAP = VWAP;
|
|
111
|
+
exports.Year = Year;
|
|
112
|
+
exports.CANDIDATE = { __candidate: true };
|
|
113
|
+
/** Portfolio-wide targetAssets: [] — rebalance cadence, not per-ticker DCA. */
|
|
114
|
+
exports.PORTFOLIO_WIDE = { __portfolioWide: true };
|
|
115
|
+
function isCandidate(a) {
|
|
116
|
+
return typeof a === "object" && a !== null && a.__candidate === true;
|
|
117
|
+
}
|
|
118
|
+
function isPortfolioWide(a) {
|
|
119
|
+
return typeof a === "object" && a !== null && a.__portfolioWide === true;
|
|
120
|
+
}
|
|
121
|
+
/** Crypto ticker aliases for cryptoAsset() (BTC → BTC-USD). */
|
|
122
|
+
const CRYPTO_SYMBOL_ALIASES = {
|
|
123
|
+
BTC: "BTC-USD",
|
|
124
|
+
ETH: "ETH-USD",
|
|
125
|
+
SOL: "SOL-USD",
|
|
126
|
+
DOGE: "DOGE-USD",
|
|
127
|
+
ADA: "ADA-USD",
|
|
128
|
+
XRP: "XRP-USD",
|
|
129
|
+
AVAX: "AVAX-USD",
|
|
130
|
+
LINK: "LINK-USD",
|
|
131
|
+
DOT: "DOT-USD",
|
|
132
|
+
MATIC: "MATIC-USD",
|
|
133
|
+
"BTC-USD": "BTC-USD",
|
|
134
|
+
"ETH-USD": "ETH-USD",
|
|
135
|
+
"SOL-USD": "SOL-USD",
|
|
136
|
+
"DOGE-USD": "DOGE-USD",
|
|
137
|
+
"ADA-USD": "ADA-USD",
|
|
138
|
+
"XRP-USD": "XRP-USD",
|
|
139
|
+
"AVAX-USD": "AVAX-USD",
|
|
140
|
+
"LINK-USD": "LINK-USD",
|
|
141
|
+
"DOT-USD": "DOT-USD",
|
|
142
|
+
"MATIC-USD": "MATIC-USD",
|
|
143
|
+
};
|
|
144
|
+
function normalizeCryptoSymbol(symbol) {
|
|
145
|
+
const key = symbol.trim().toUpperCase();
|
|
146
|
+
if (CRYPTO_SYMBOL_ALIASES[key])
|
|
147
|
+
return CRYPTO_SYMBOL_ALIASES[key];
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* FormGroup.targetAssets reads `asset.name` (plural); targetAsset reads `symbol`
|
|
152
|
+
* (singular). Always set both so PositionValue / DaysSinceOrder round-trip.
|
|
153
|
+
* Bare ticker strings are rejected — use stockAsset() / cryptoAsset().
|
|
154
|
+
*/
|
|
155
|
+
function toAsset(a) {
|
|
156
|
+
if (typeof a === "string") {
|
|
157
|
+
throw new Error('Bare ticker strings are not allowed (got ' +
|
|
158
|
+
JSON.stringify(a) +
|
|
159
|
+
'). Use stockAsset("AAPL") or cryptoAsset("BTC").');
|
|
160
|
+
}
|
|
161
|
+
if (isCandidate(a) || isPortfolioWide(a)) {
|
|
162
|
+
throw new Error("CANDIDATE / PORTFOLIO_WIDE are not concrete assets");
|
|
163
|
+
}
|
|
164
|
+
const asset = a;
|
|
165
|
+
const ticker = (asset.symbol || asset.name || "").trim().toUpperCase();
|
|
166
|
+
if (asset.type === "Cryptocurrency") {
|
|
167
|
+
const sym = normalizeCryptoSymbol(ticker) ?? (ticker.endsWith("-USD") ? ticker : ticker + "-USD");
|
|
168
|
+
return { type: "Cryptocurrency", symbol: sym, name: sym };
|
|
169
|
+
}
|
|
170
|
+
return { type: asset.type, symbol: ticker, name: asset.name || ticker };
|
|
171
|
+
}
|
|
172
|
+
/** Equity/ETF asset — required for stock/ETF buy/sell/indicators. */
|
|
173
|
+
const stockAsset = (symbol) => {
|
|
174
|
+
const sym = symbol.trim().toUpperCase();
|
|
175
|
+
return { type: "Stock", symbol: sym, name: sym };
|
|
176
|
+
};
|
|
177
|
+
exports.stockAsset = stockAsset;
|
|
178
|
+
/** Cryptocurrency asset (BTC → BTC-USD) — required for crypto buy/sell/indicators. */
|
|
179
|
+
const cryptoAsset = (symbol) => {
|
|
180
|
+
const cryptoSym = normalizeCryptoSymbol(symbol) ?? (symbol.trim().toUpperCase() + "-USD");
|
|
181
|
+
return { type: "Cryptocurrency", symbol: cryptoSym, name: cryptoSym };
|
|
182
|
+
};
|
|
183
|
+
exports.cryptoAsset = cryptoAsset;
|
|
184
|
+
/** Attach an asset field, or omit it entirely when bound to the pipeline candidate. */
|
|
185
|
+
function setAsset(target, key, a) {
|
|
186
|
+
if (isCandidate(a) || isPortfolioWide(a))
|
|
187
|
+
return;
|
|
188
|
+
target[key] = toAsset(a);
|
|
189
|
+
}
|
|
190
|
+
function setAssets(target, key, list) {
|
|
191
|
+
if (list === undefined)
|
|
192
|
+
return;
|
|
193
|
+
// Explicit portfolio-wide: empty array on the wire (YAML targetAssets: []).
|
|
194
|
+
if (isPortfolioWide(list) || (Array.isArray(list) && list.length === 0)) {
|
|
195
|
+
target[key] = [];
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const arr = Array.isArray(list) ? list : [list];
|
|
199
|
+
if (arr.some(isPortfolioWide)) {
|
|
200
|
+
target[key] = [];
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
target[key] = arr.filter((a) => !isCandidate(a)).map(toAsset);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Drop undefined keys so optional args never serialise as explicit nulls.
|
|
207
|
+
* Constrained to `object`, not `Record<string, unknown>`: declared interfaces
|
|
208
|
+
* have no index signature, so the stricter bound rejects any typed config
|
|
209
|
+
* (e.g. againstParent(OptionPositionSelector)) that is not an object literal.
|
|
210
|
+
*/
|
|
211
|
+
function compact(obj) {
|
|
212
|
+
const source = obj;
|
|
213
|
+
const out = {};
|
|
214
|
+
for (const key of Object.keys(source)) {
|
|
215
|
+
if (source[key] !== undefined)
|
|
216
|
+
out[key] = source[key];
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
function compare(lhs, rhs, comparison) {
|
|
221
|
+
const right = typeof rhs === "number" ? Value(rhs) : rhs;
|
|
222
|
+
return { type: "Base", lhs, comparison, rhs: right };
|
|
223
|
+
}
|
|
224
|
+
const gt = (l, r) => compare(l, r, "greaterThan");
|
|
225
|
+
exports.gt = gt;
|
|
226
|
+
const lt = (l, r) => compare(l, r, "lessThan");
|
|
227
|
+
exports.lt = lt;
|
|
228
|
+
const gte = (l, r) => compare(l, r, "greaterThanOrEqual");
|
|
229
|
+
exports.gte = gte;
|
|
230
|
+
const lte = (l, r) => compare(l, r, "lessThanOrEqual");
|
|
231
|
+
exports.lte = lte;
|
|
232
|
+
const eq = (l, r) => compare(l, r, "equal");
|
|
233
|
+
exports.eq = eq;
|
|
234
|
+
const neq = (l, r) => compare(l, r, "notEqual");
|
|
235
|
+
exports.neq = neq;
|
|
236
|
+
const and = (...conditions) => ({ type: "And", conditions });
|
|
237
|
+
exports.and = and;
|
|
238
|
+
const or = (...conditions) => ({ type: "Or", conditions });
|
|
239
|
+
exports.or = or;
|
|
240
|
+
/** Multi: true when at least `count` of `conditions` hold. */
|
|
241
|
+
const atLeast = (count, ...conditions) => ({ type: "Multi", comparison: "greaterThanOrEqual", value: count, conditions });
|
|
242
|
+
exports.atLeast = atLeast;
|
|
243
|
+
/** Multi: true when at most `count` of `conditions` hold. */
|
|
244
|
+
const atMost = (count, ...conditions) => ({ type: "Multi", comparison: "lessThanOrEqual", value: count, conditions });
|
|
245
|
+
exports.atMost = atMost;
|
|
246
|
+
/** Multi: true when fewer than `count` of `conditions` hold. */
|
|
247
|
+
const fewerThan = (count, ...conditions) => ({ type: "Multi", comparison: "lessThan", value: count, conditions });
|
|
248
|
+
exports.fewerThan = fewerThan;
|
|
249
|
+
/** Multi: true when exactly `count` of `conditions` hold. */
|
|
250
|
+
const exactly = (count, ...conditions) => ({ type: "Multi", comparison: "equal", value: count, conditions });
|
|
251
|
+
exports.exactly = exactly;
|
|
252
|
+
/** Multi with an explicit Comparator (same wire shape as YAML Multi). */
|
|
253
|
+
const multi = (count, comparison, ...conditions) => ({ type: "Multi", comparison, value: count, conditions });
|
|
254
|
+
exports.multi = multi;
|
|
255
|
+
/** Always-true gate for strategies whose cadence lives in the pipeline. */
|
|
256
|
+
const always = () => compare(Value(1), Value(0), "greaterThan");
|
|
257
|
+
exports.always = always;
|
|
258
|
+
const filter = (condition) => ({ type: "Filter", condition });
|
|
259
|
+
exports.filter = filter;
|
|
260
|
+
const selectTop = (metric, limit, direction = "Highest") => ({ type: "SelectTop", metric, limit, direction });
|
|
261
|
+
exports.selectTop = selectTop;
|
|
262
|
+
const selectPercentile = (metric, percentile, direction = "Highest") => ({ type: "SelectPercentile", metric, percentile, direction });
|
|
263
|
+
exports.selectPercentile = selectPercentile;
|
|
264
|
+
function universe(source, assets) {
|
|
265
|
+
if (source === "SPECIFIC_ASSETS") {
|
|
266
|
+
return { source, assets: (assets ?? []).map(toAsset) };
|
|
267
|
+
}
|
|
268
|
+
return { source };
|
|
269
|
+
}
|
|
270
|
+
// ---- equity + cash actions ----
|
|
271
|
+
const buy = (target, amount, type = "percent of portfolio") => ({ type: "Buy", targetAsset: toAsset(target), amount: { type, amount } });
|
|
272
|
+
exports.buy = buy;
|
|
273
|
+
const sell = (target, amount, type = "percent of portfolio") => ({ type: "Sell", targetAsset: toAsset(target), amount: { type, amount } });
|
|
274
|
+
exports.sell = sell;
|
|
275
|
+
const deposit = (amount, type = "dollars") => ({ type: "Deposit", amount: { type, amount } });
|
|
276
|
+
exports.deposit = deposit;
|
|
277
|
+
const withdraw = (amount, type = "dollars") => ({ type: "Withdraw", amount: { type, amount } });
|
|
278
|
+
exports.withdraw = withdraw;
|
|
279
|
+
const alert = (message) => ({ type: "Alert", message });
|
|
280
|
+
exports.alert = alert;
|
|
281
|
+
const launchAgent = (config) => compact({ type: "LaunchAgent", ...config });
|
|
282
|
+
exports.launchAgent = launchAgent;
|
|
283
|
+
const dynamicRebalance = (config) => compact({ type: "DynamicRebalance", ...config });
|
|
284
|
+
exports.dynamicRebalance = dynamicRebalance;
|
|
285
|
+
// ---- options ----
|
|
286
|
+
/**
|
|
287
|
+
* One leg of a spread. Distance is signed from ATM; 0 is ATM.
|
|
288
|
+
* Delta targeting is a discriminated union: distanceType: "delta" requires
|
|
289
|
+
* fallbackDistance+fallbackDistanceType OR fallbackStrikeSelector.
|
|
290
|
+
*/
|
|
291
|
+
const leg = (config) => {
|
|
292
|
+
const distanceType = config.distanceType ?? "percent";
|
|
293
|
+
if (distanceType === "delta") {
|
|
294
|
+
const hasFallback = config.fallbackStrikeSelector !== undefined ||
|
|
295
|
+
(config.fallbackDistance !== undefined && config.fallbackDistanceType !== undefined);
|
|
296
|
+
if (!hasFallback) {
|
|
297
|
+
throw new Error('leg({ distanceType: "delta" }) requires fallbackDistance+fallbackDistanceType or fallbackStrikeSelector');
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const strikeSelector = {
|
|
301
|
+
distanceType,
|
|
302
|
+
distance: config.distance,
|
|
303
|
+
};
|
|
304
|
+
const fallbackStrikeSelector = config.fallbackStrikeSelector ??
|
|
305
|
+
(config.fallbackDistance !== undefined
|
|
306
|
+
? {
|
|
307
|
+
distanceType: config.fallbackDistanceType ?? "percent",
|
|
308
|
+
distance: config.fallbackDistance,
|
|
309
|
+
}
|
|
310
|
+
: undefined);
|
|
311
|
+
return compact({
|
|
312
|
+
optionType: config.optionType,
|
|
313
|
+
direction: config.direction,
|
|
314
|
+
expirationSelector: {
|
|
315
|
+
minDaysToExpiration: config.minDaysToExpiration,
|
|
316
|
+
maxDaysToExpiration: config.maxDaysToExpiration,
|
|
317
|
+
preference: config.preference ?? "nearest",
|
|
318
|
+
},
|
|
319
|
+
strikeSelector,
|
|
320
|
+
fallbackStrikeSelector,
|
|
321
|
+
strikeRange: config.strikeRange,
|
|
322
|
+
expirationRange: config.expirationRange,
|
|
323
|
+
ratio: config.ratio,
|
|
324
|
+
greekFilter: config.greekFilter,
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
exports.leg = leg;
|
|
328
|
+
const optionsBuilder = (config) => compact(config);
|
|
329
|
+
exports.optionsBuilder = optionsBuilder;
|
|
330
|
+
const againstParent = (config) => compact(config);
|
|
331
|
+
exports.againstParent = againstParent;
|
|
332
|
+
const openOption = (config) => compact({ type: "OpenOption", ...config });
|
|
333
|
+
exports.openOption = openOption;
|
|
334
|
+
const structureTemplate = (config) => compact(config);
|
|
335
|
+
exports.structureTemplate = structureTemplate;
|
|
336
|
+
const sleeve = (config) => compact(config);
|
|
337
|
+
exports.sleeve = sleeve;
|
|
338
|
+
/**
|
|
339
|
+
* Rank a universe and rotate an option book. Keep take-profit / stop-loss / DTE
|
|
340
|
+
* exits in separate closeOption strategies, not here.
|
|
341
|
+
*/
|
|
342
|
+
const rebalanceOption = (config) => compact({ type: "RebalanceOption", ...config });
|
|
343
|
+
exports.rebalanceOption = rebalanceOption;
|
|
344
|
+
const pnlTrigger = (bounds) => compact({ type: "pnl", ...bounds });
|
|
345
|
+
exports.pnlTrigger = pnlTrigger;
|
|
346
|
+
const dteTrigger = (bounds) => compact({ type: "dte", ...bounds });
|
|
347
|
+
exports.dteTrigger = dteTrigger;
|
|
348
|
+
const daysHeldTrigger = (bounds) => compact({ type: "daysHeld", ...bounds });
|
|
349
|
+
exports.daysHeldTrigger = daysHeldTrigger;
|
|
350
|
+
const greeksTrigger = (bounds) => compact({ type: "greeks", ...bounds });
|
|
351
|
+
exports.greeksTrigger = greeksTrigger;
|
|
352
|
+
const closeOption = (config = {}) => compact({ type: "CloseOption", ...config });
|
|
353
|
+
exports.closeOption = closeOption;
|
|
354
|
+
// ---- assembly ----
|
|
355
|
+
const strategy = (name, condition, action, options = {}) => compact({ name, condition, action, ...options });
|
|
356
|
+
exports.strategy = strategy;
|
|
357
|
+
/**
|
|
358
|
+
* Session / clock flatten — condition carries the gate (MinutesAfterOpen, Day, …).
|
|
359
|
+
* Never pairs with always(); PnL/DTE/daysHeld exits use closeOption({ triggers }).
|
|
360
|
+
* Book-level only — CandidateCondition is rejected (same as strategy when).
|
|
361
|
+
*/
|
|
362
|
+
const sessionFlatten = (condition, config = {}, name = "Session flatten") => (0, exports.strategy)(name, condition, (0, exports.closeOption)({ ...config }));
|
|
363
|
+
exports.sessionFlatten = sessionFlatten;
|
|
364
|
+
const portfolio = (name, strategies, options = {}) => compact({ name, initialValue: 10000, ...options, strategies });
|
|
365
|
+
exports.portfolio = portfolio;
|
|
366
|
+
// ---- generated indicator builders ----
|
|
367
|
+
/**
|
|
368
|
+
* AbsoluteValue indicator.
|
|
369
|
+
*/
|
|
370
|
+
function AbsoluteValue(operand) {
|
|
371
|
+
const d = { type: "AbsoluteValue" };
|
|
372
|
+
d.indicators = [operand];
|
|
373
|
+
return d;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* AverageTrueRange indicator.
|
|
377
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
378
|
+
* @param length Length of time
|
|
379
|
+
* @param interval Unit of time
|
|
380
|
+
*/
|
|
381
|
+
function AverageTrueRange(asset, length = 14, interval = "Day") {
|
|
382
|
+
const d = { type: "AverageTrueRange" };
|
|
383
|
+
setAsset(d, "targetAsset", asset);
|
|
384
|
+
d.window = { length: length, interval: interval };
|
|
385
|
+
return d;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* BearishFairValueGap indicator.
|
|
389
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
390
|
+
*/
|
|
391
|
+
function BearishFairValueGap(asset) {
|
|
392
|
+
const d = { type: "BearishFairValueGap" };
|
|
393
|
+
setAsset(d, "targetAsset", asset);
|
|
394
|
+
return d;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* BollingerBand indicator.
|
|
398
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
399
|
+
* @param length Length of time
|
|
400
|
+
* @param interval Unit of time
|
|
401
|
+
* @param numStandardDeviations How many standard deviations from the mean
|
|
402
|
+
*/
|
|
403
|
+
function BollingerBand(asset, length = 30, interval = "Day", numStandardDeviations = 1) {
|
|
404
|
+
const d = { type: "BollingerBand" };
|
|
405
|
+
setAsset(d, "targetAsset", asset);
|
|
406
|
+
d["numStandardDeviations"] = numStandardDeviations;
|
|
407
|
+
d.window = { length: length, interval: interval };
|
|
408
|
+
return d;
|
|
409
|
+
}
|
|
410
|
+
exports.BBand = BollingerBand;
|
|
411
|
+
/**
|
|
412
|
+
* BullishFairValueGap indicator.
|
|
413
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
414
|
+
*/
|
|
415
|
+
function BullishFairValueGap(asset) {
|
|
416
|
+
const d = { type: "BullishFairValueGap" };
|
|
417
|
+
setAsset(d, "targetAsset", asset);
|
|
418
|
+
return d;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* BuyingPower indicator.
|
|
422
|
+
*/
|
|
423
|
+
function BuyingPower() {
|
|
424
|
+
const d = { type: "BuyingPower" };
|
|
425
|
+
return d;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* CompoundAnnualGrowthRate indicator.
|
|
429
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
430
|
+
* @param metric The fundamental metric to use
|
|
431
|
+
* @param years Floating point years value
|
|
432
|
+
*/
|
|
433
|
+
function CompoundAnnualGrowthRate(asset, metric, years) {
|
|
434
|
+
const d = { type: "CompoundAnnualGrowthRate" };
|
|
435
|
+
setAsset(d, "targetAsset", asset);
|
|
436
|
+
d["metric"] = metric;
|
|
437
|
+
d["years"] = years;
|
|
438
|
+
return d;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* ConsecutiveTrue indicator.
|
|
442
|
+
* @param condition Condition evaluated over the window.
|
|
443
|
+
* @param length Length of time
|
|
444
|
+
* @param interval Unit of time
|
|
445
|
+
*/
|
|
446
|
+
function ConsecutiveTrue(condition, length = 1, interval = "Day") {
|
|
447
|
+
const d = { type: "ConsecutiveTrue" };
|
|
448
|
+
d.condition = condition;
|
|
449
|
+
d.window = { length: length, interval: interval };
|
|
450
|
+
return d;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* CountTrue indicator.
|
|
454
|
+
* @param condition Condition evaluated over the window.
|
|
455
|
+
* @param length Length of time
|
|
456
|
+
* @param interval Unit of time
|
|
457
|
+
*/
|
|
458
|
+
function CountTrue(condition, length = 1, interval = "Day") {
|
|
459
|
+
const d = { type: "CountTrue" };
|
|
460
|
+
d.condition = condition;
|
|
461
|
+
d.window = { length: length, interval: interval };
|
|
462
|
+
return d;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* CrossAbove indicator.
|
|
466
|
+
*/
|
|
467
|
+
function CrossAbove(left, right) {
|
|
468
|
+
const d = { type: "CrossAbove" };
|
|
469
|
+
d.indicators = [left, right];
|
|
470
|
+
return d;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* CrossBelow indicator.
|
|
474
|
+
*/
|
|
475
|
+
function CrossBelow(left, right) {
|
|
476
|
+
const d = { type: "CrossBelow" };
|
|
477
|
+
d.indicators = [left, right];
|
|
478
|
+
return d;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* CurrentTimeHours indicator.
|
|
482
|
+
*/
|
|
483
|
+
function CurrentTimeHours() {
|
|
484
|
+
const d = { type: "CurrentTimeHours" };
|
|
485
|
+
return d;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* CurrentTimeMinutes indicator.
|
|
489
|
+
*/
|
|
490
|
+
function CurrentTimeMinutes() {
|
|
491
|
+
const d = { type: "CurrentTimeMinutes" };
|
|
492
|
+
return d;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* CurrentTimeSeconds indicator.
|
|
496
|
+
*/
|
|
497
|
+
function CurrentTimeSeconds() {
|
|
498
|
+
const d = { type: "CurrentTimeSeconds" };
|
|
499
|
+
return d;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* CustomIndicator indicator.
|
|
503
|
+
* @param asset Pass CANDIDATE inside a rebalance pipeline to bind per candidate.
|
|
504
|
+
* @param customIndicatorId 24-char hex ObjectId of the owned series (list_custom_indicators).
|
|
505
|
+
*/
|
|
506
|
+
function CustomIndicator(asset, customIndicatorId) {
|
|
507
|
+
const d = { type: "CustomIndicator" };
|
|
508
|
+
setAsset(d, "targetAsset", asset);
|
|
509
|
+
d["customIndicatorId"] = customIndicatorId;
|
|
510
|
+
return d;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Date indicator.
|
|
514
|
+
*/
|
|
515
|
+
function Date() {
|
|
516
|
+
const d = { type: "Date" };
|
|
517
|
+
return d;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Day indicator.
|
|
521
|
+
*/
|
|
522
|
+
function Day() {
|
|
523
|
+
const d = { type: "Day" };
|
|
524
|
+
return d;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* DaysSinceAgent indicator.
|
|
528
|
+
*/
|
|
529
|
+
function DaysSinceAgent() {
|
|
530
|
+
const d = { type: "DaysSinceAgent" };
|
|
531
|
+
return d;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* DaysSinceAlert indicator.
|
|
535
|
+
* @param message (Optional) Message to display when the indicator is triggered
|
|
536
|
+
*/
|
|
537
|
+
function DaysSinceAlert(message) {
|
|
538
|
+
const d = { type: "DaysSinceAlert" };
|
|
539
|
+
d["message"] = message;
|
|
540
|
+
return d;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* DaysSinceEarnings indicator.
|
|
544
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
545
|
+
*/
|
|
546
|
+
function DaysSinceEarnings(asset) {
|
|
547
|
+
const d = { type: "DaysSinceEarnings" };
|
|
548
|
+
setAsset(d, "targetAsset", asset);
|
|
549
|
+
return d;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* DaysSinceLastRebalanceOptionOrder indicator.
|
|
553
|
+
*/
|
|
554
|
+
function DaysSinceLastRebalanceOptionOrder() {
|
|
555
|
+
const d = { type: "DaysSinceLastRebalanceOptionOrder" };
|
|
556
|
+
return d;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* DaysSinceOptionOrder indicator.
|
|
560
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
561
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
562
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
563
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
564
|
+
* @param positionEffect Filter by Open (entering position) or Close (exiting). Leave empty for all.
|
|
565
|
+
* @param minDte Minimum days to expiration at order time. Leave empty for no minimum.
|
|
566
|
+
* @param maxDte Maximum days to expiration at order time. Leave empty for no maximum.
|
|
567
|
+
* @param orderStatus Matches option order events with this status
|
|
568
|
+
*/
|
|
569
|
+
function DaysSinceOptionOrder(underlying, optionType, direction, spreadType, positionEffect, minDte, maxDte, orderStatus = "Filled") {
|
|
570
|
+
const d = { type: "DaysSinceOptionOrder" };
|
|
571
|
+
d["underlying"] = underlying;
|
|
572
|
+
d["optionType"] = optionType;
|
|
573
|
+
d["direction"] = direction;
|
|
574
|
+
d["spreadType"] = spreadType;
|
|
575
|
+
d["positionEffect"] = positionEffect;
|
|
576
|
+
d["minDte"] = minDte;
|
|
577
|
+
d["maxDte"] = maxDte;
|
|
578
|
+
d["orderStatus"] = orderStatus;
|
|
579
|
+
return d;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* DaysSinceOrder indicator.
|
|
583
|
+
* @param assets Ticker(s) whose orders are counted. One string or an array.
|
|
584
|
+
* @param side Buy or Sell
|
|
585
|
+
*/
|
|
586
|
+
function DaysSinceOrder(assets, side, orderStatus = "Filled") {
|
|
587
|
+
const d = { type: "DaysSinceOrder" };
|
|
588
|
+
setAssets(d, "targetAssets", assets);
|
|
589
|
+
d["side"] = side;
|
|
590
|
+
d["orderStatus"] = orderStatus;
|
|
591
|
+
return d;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* DaysSinceStrategyFired indicator.
|
|
595
|
+
*/
|
|
596
|
+
function DaysSinceStrategyFired() {
|
|
597
|
+
const d = { type: "DaysSinceStrategyFired" };
|
|
598
|
+
return d;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* DaysSinceTransaction indicator.
|
|
602
|
+
* @param transactionType Matches transaction events with this type (deposit or withdraw)
|
|
603
|
+
* @param transactionStatus Matches transaction events with this status
|
|
604
|
+
*/
|
|
605
|
+
function DaysSinceTransaction(transactionType, transactionStatus = "Completed") {
|
|
606
|
+
const d = { type: "DaysSinceTransaction" };
|
|
607
|
+
d["transactionType"] = transactionType;
|
|
608
|
+
d["transactionStatus"] = transactionStatus;
|
|
609
|
+
return d;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* DaysUntilEarnings indicator.
|
|
613
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
614
|
+
*/
|
|
615
|
+
function DaysUntilEarnings(asset) {
|
|
616
|
+
const d = { type: "DaysUntilEarnings" };
|
|
617
|
+
setAsset(d, "targetAsset", asset);
|
|
618
|
+
return d;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Divide indicator.
|
|
622
|
+
*/
|
|
623
|
+
function Divide(left, right) {
|
|
624
|
+
const d = { type: "Divide" };
|
|
625
|
+
d.indicators = [left, right];
|
|
626
|
+
return d;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Economic indicator.
|
|
630
|
+
* @param metric The economic indicator to use
|
|
631
|
+
*/
|
|
632
|
+
function Economic(metric) {
|
|
633
|
+
const d = { type: "Economic" };
|
|
634
|
+
d["metric"] = metric;
|
|
635
|
+
return d;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* ExponentialMovingAverage indicator.
|
|
639
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
640
|
+
* @param length Length of time
|
|
641
|
+
* @param interval Unit of time
|
|
642
|
+
*/
|
|
643
|
+
function ExponentialMovingAverage(asset, length, interval = "Day") {
|
|
644
|
+
const d = { type: "ExponentialMovingAverage" };
|
|
645
|
+
setAsset(d, "targetAsset", asset);
|
|
646
|
+
d.window = { length: length, interval: interval };
|
|
647
|
+
return d;
|
|
648
|
+
}
|
|
649
|
+
exports.EMA = ExponentialMovingAverage;
|
|
650
|
+
/**
|
|
651
|
+
* Exponentiation indicator.
|
|
652
|
+
* @param exponent The exponent to raise the value to
|
|
653
|
+
*/
|
|
654
|
+
function Exponentiation(operand, exponent = 2) {
|
|
655
|
+
const d = { type: "Exponentiation" };
|
|
656
|
+
d["exponent"] = exponent;
|
|
657
|
+
d.indicators = [operand];
|
|
658
|
+
return d;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Fundamental indicator.
|
|
662
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
663
|
+
* @param metric The fundamental metric to use
|
|
664
|
+
*/
|
|
665
|
+
function Fundamental(asset, metric) {
|
|
666
|
+
const d = { type: "Fundamental" };
|
|
667
|
+
setAsset(d, "targetAsset", asset);
|
|
668
|
+
d["metric"] = metric;
|
|
669
|
+
return d;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* GapPercentage indicator.
|
|
673
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
674
|
+
*/
|
|
675
|
+
function GapPercentage(asset) {
|
|
676
|
+
const d = { type: "GapPercentage" };
|
|
677
|
+
setAsset(d, "targetAsset", asset);
|
|
678
|
+
return d;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* GapSize indicator.
|
|
682
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
683
|
+
*/
|
|
684
|
+
function GapSize(asset) {
|
|
685
|
+
const d = { type: "GapSize" };
|
|
686
|
+
setAsset(d, "targetAsset", asset);
|
|
687
|
+
return d;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* HighOfDay indicator.
|
|
691
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
692
|
+
*/
|
|
693
|
+
function HighOfDay(asset) {
|
|
694
|
+
const d = { type: "HighOfDay" };
|
|
695
|
+
setAsset(d, "targetAsset", asset);
|
|
696
|
+
return d;
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Index indicator.
|
|
700
|
+
* @param metric Ticker key matching hydrated index price data (add more in BigQuery + rehydrate as needed)
|
|
701
|
+
*/
|
|
702
|
+
function Index(metric = "VIX") {
|
|
703
|
+
const d = { type: "Index" };
|
|
704
|
+
d["metric"] = metric;
|
|
705
|
+
return d;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* IndicatorAtMinutesAfterOpen indicator.
|
|
709
|
+
* @param minutesAfterOpen The number of minutes after market open to capture the indicator value
|
|
710
|
+
*/
|
|
711
|
+
function IndicatorAtMinutesAfterOpen(operand, minutesAfterOpen = 30) {
|
|
712
|
+
const d = { type: "IndicatorAtMinutesAfterOpen" };
|
|
713
|
+
d["minutesAfterOpen"] = minutesAfterOpen;
|
|
714
|
+
d.indicators = [operand];
|
|
715
|
+
return d;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* IndicatorExponentialMovingAverage indicator.
|
|
719
|
+
* @param length Length of time
|
|
720
|
+
* @param interval Unit of time
|
|
721
|
+
*/
|
|
722
|
+
function IndicatorExponentialMovingAverage(operand, length = 30, interval = "Day") {
|
|
723
|
+
const d = { type: "IndicatorExponentialMovingAverage" };
|
|
724
|
+
d.indicators = [operand];
|
|
725
|
+
d.window = { length: length, interval: interval };
|
|
726
|
+
return d;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* IndicatorMeanAbsoluteDeviation indicator.
|
|
730
|
+
* @param length Length of time
|
|
731
|
+
* @param interval Unit of time
|
|
732
|
+
*/
|
|
733
|
+
function IndicatorMeanAbsoluteDeviation(operand, length = 30, interval = "Day") {
|
|
734
|
+
const d = { type: "IndicatorMeanAbsoluteDeviation" };
|
|
735
|
+
d.indicators = [operand];
|
|
736
|
+
d.window = { length: length, interval: interval };
|
|
737
|
+
return d;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* IndicatorRateOfChange indicator.
|
|
741
|
+
* @param length Length of time
|
|
742
|
+
* @param interval Unit of time
|
|
743
|
+
*/
|
|
744
|
+
function IndicatorRateOfChange(operand, length = 30, interval = "Day") {
|
|
745
|
+
const d = { type: "IndicatorRateOfChange" };
|
|
746
|
+
d.indicators = [operand];
|
|
747
|
+
d.window = { length: length, interval: interval };
|
|
748
|
+
return d;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* IndicatorSimpleMovingAverage indicator.
|
|
752
|
+
* @param length Length of time
|
|
753
|
+
* @param interval Unit of time
|
|
754
|
+
*/
|
|
755
|
+
function IndicatorSimpleMovingAverage(operand, length = 30, interval = "Day") {
|
|
756
|
+
const d = { type: "IndicatorSimpleMovingAverage" };
|
|
757
|
+
d.indicators = [operand];
|
|
758
|
+
d.window = { length: length, interval: interval };
|
|
759
|
+
return d;
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* IndicatorStandardDeviation indicator.
|
|
763
|
+
* @param length Length of time
|
|
764
|
+
* @param interval Unit of time
|
|
765
|
+
*/
|
|
766
|
+
function IndicatorStandardDeviation(operand, length = 30, interval = "Day") {
|
|
767
|
+
const d = { type: "IndicatorStandardDeviation" };
|
|
768
|
+
d.indicators = [operand];
|
|
769
|
+
d.window = { length: length, interval: interval };
|
|
770
|
+
return d;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* IndicatorWindowAgo indicator.
|
|
774
|
+
* @param length Length of time
|
|
775
|
+
* @param interval Unit of time
|
|
776
|
+
*/
|
|
777
|
+
function IndicatorWindowAgo(operand, length, interval) {
|
|
778
|
+
const d = { type: "IndicatorWindowAgo" };
|
|
779
|
+
d.indicators = [operand];
|
|
780
|
+
d.window = { length: length, interval: interval };
|
|
781
|
+
return d;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* InitialValue indicator.
|
|
785
|
+
*/
|
|
786
|
+
function InitialValue() {
|
|
787
|
+
const d = { type: "InitialValue" };
|
|
788
|
+
return d;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* IsAsset indicator.
|
|
792
|
+
* @param matchAsset The specific asset to compare against (ex. UPRO, GLD)
|
|
793
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
794
|
+
*/
|
|
795
|
+
function IsAsset(matchAsset, asset) {
|
|
796
|
+
const d = { type: "IsAsset" };
|
|
797
|
+
setAsset(d, "matchAsset", matchAsset);
|
|
798
|
+
setAsset(d, "targetAsset", asset);
|
|
799
|
+
return d;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* IsAssetType indicator.
|
|
803
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
804
|
+
* @param assetType The asset type to check against
|
|
805
|
+
*/
|
|
806
|
+
function IsAssetType(asset, assetType = "Stock") {
|
|
807
|
+
const d = { type: "IsAssetType" };
|
|
808
|
+
setAsset(d, "targetAsset", asset);
|
|
809
|
+
d["assetType"] = assetType;
|
|
810
|
+
return d;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* IsIndexMember indicator.
|
|
814
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
815
|
+
* @param index The index to check membership against
|
|
816
|
+
*/
|
|
817
|
+
function IsIndexMember(asset, index = "SP500") {
|
|
818
|
+
const d = { type: "IsIndexMember" };
|
|
819
|
+
setAsset(d, "targetAsset", asset);
|
|
820
|
+
d["index"] = index;
|
|
821
|
+
return d;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* IsIndustry indicator.
|
|
825
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
826
|
+
* @param industry The industry to check membership against
|
|
827
|
+
*/
|
|
828
|
+
function IsIndustry(asset, industry) {
|
|
829
|
+
const d = { type: "IsIndustry" };
|
|
830
|
+
setAsset(d, "targetAsset", asset);
|
|
831
|
+
d["industry"] = { "informationTechnology": "technology", "personalAndHouseholdGoods": "householdProducts", "investing": "assetManagement", "spaceExploration": "space", "alternativeEnergy": "cleanEnergy", "clothesAndApparal": "fashionAndApparel", "computationalChemistry": "computationalDrugDiscovery", "customerEngagement": "customerExperienceSoftware", "dataVisualization": "analytics", "graphicsCard": "gpuAndAccelerators", "materialScience": "advancedMaterials", "medicine": "pharmaceuticals", "messaging": "collaborationSoftware", "phones": "consumerElectronics", "security": "cybersecurity", "socialNetwork": "socialMedia", "television": "streaming", "videoConferencing": "collaborationSoftware", "videos": "streaming", "waterPurifaction": "waterInfrastructure", "waterTreatment": "waterInfrastructure" }[industry] ?? industry;
|
|
832
|
+
return d;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* IsNotAsset indicator.
|
|
836
|
+
* @param matchAsset The specific asset to compare against (ex. UPRO, GLD)
|
|
837
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
838
|
+
*/
|
|
839
|
+
function IsNotAsset(matchAsset, asset) {
|
|
840
|
+
const d = { type: "IsNotAsset" };
|
|
841
|
+
setAsset(d, "matchAsset", matchAsset);
|
|
842
|
+
setAsset(d, "targetAsset", asset);
|
|
843
|
+
return d;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* LastOrderPrice indicator.
|
|
847
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
848
|
+
* @param side Matches order events with this side (buy or sell)
|
|
849
|
+
* @param orderStatus Matches order events with this status
|
|
850
|
+
*/
|
|
851
|
+
function LastOrderPrice(asset, side, orderStatus = "Filled") {
|
|
852
|
+
const d = { type: "LastOrderPrice" };
|
|
853
|
+
setAsset(d, "targetAsset", asset);
|
|
854
|
+
d["side"] = side;
|
|
855
|
+
d["orderStatus"] = orderStatus;
|
|
856
|
+
return d;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Log indicator.
|
|
860
|
+
* @param base The base for the logarithm
|
|
861
|
+
*/
|
|
862
|
+
function Log(operand, base = 10) {
|
|
863
|
+
const d = { type: "Log" };
|
|
864
|
+
d["base"] = base;
|
|
865
|
+
d.indicators = [operand];
|
|
866
|
+
return d;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* LowOfDay indicator.
|
|
870
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
871
|
+
*/
|
|
872
|
+
function LowOfDay(asset) {
|
|
873
|
+
const d = { type: "LowOfDay" };
|
|
874
|
+
setAsset(d, "targetAsset", asset);
|
|
875
|
+
return d;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Max indicator.
|
|
879
|
+
*/
|
|
880
|
+
function Max(left, right) {
|
|
881
|
+
const d = { type: "Max" };
|
|
882
|
+
d.indicators = [left, right];
|
|
883
|
+
return d;
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* MaxDrawdown indicator.
|
|
887
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
888
|
+
* @param length Length of time
|
|
889
|
+
* @param interval Unit of time
|
|
890
|
+
*/
|
|
891
|
+
function MaxDrawdown(asset, length = 30, interval = "Day") {
|
|
892
|
+
const d = { type: "MaxDrawdown" };
|
|
893
|
+
setAsset(d, "targetAsset", asset);
|
|
894
|
+
d.window = { length: length, interval: interval };
|
|
895
|
+
return d;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* MaxDrawup indicator.
|
|
899
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
900
|
+
* @param length Length of time
|
|
901
|
+
* @param interval Unit of time
|
|
902
|
+
*/
|
|
903
|
+
function MaxDrawup(asset, length = 30, interval = "Day") {
|
|
904
|
+
const d = { type: "MaxDrawup" };
|
|
905
|
+
setAsset(d, "targetAsset", asset);
|
|
906
|
+
d.window = { length: length, interval: interval };
|
|
907
|
+
return d;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* MaximumPrice indicator.
|
|
911
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
912
|
+
* @param length Length of time
|
|
913
|
+
* @param interval Unit of time
|
|
914
|
+
*/
|
|
915
|
+
function MaximumPrice(asset, length = 30, interval = "Day") {
|
|
916
|
+
const d = { type: "MaximumPrice" };
|
|
917
|
+
setAsset(d, "targetAsset", asset);
|
|
918
|
+
d.window = { length: length, interval: interval };
|
|
919
|
+
return d;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Min indicator.
|
|
923
|
+
*/
|
|
924
|
+
function Min(left, right) {
|
|
925
|
+
const d = { type: "Min" };
|
|
926
|
+
d.indicators = [left, right];
|
|
927
|
+
return d;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* MinimumPrice indicator.
|
|
931
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
932
|
+
* @param length Length of time
|
|
933
|
+
* @param interval Unit of time
|
|
934
|
+
*/
|
|
935
|
+
function MinimumPrice(asset, length = 30, interval = "Day") {
|
|
936
|
+
const d = { type: "MinimumPrice" };
|
|
937
|
+
setAsset(d, "targetAsset", asset);
|
|
938
|
+
d.window = { length: length, interval: interval };
|
|
939
|
+
return d;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Minus indicator.
|
|
943
|
+
*/
|
|
944
|
+
function Minus(left, right) {
|
|
945
|
+
const d = { type: "Minus" };
|
|
946
|
+
d.indicators = [left, right];
|
|
947
|
+
return d;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* MinutesAfterOpen indicator.
|
|
951
|
+
*/
|
|
952
|
+
function MinutesAfterOpen() {
|
|
953
|
+
const d = { type: "MinutesAfterOpen" };
|
|
954
|
+
return d;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* MinutesSinceAgent indicator.
|
|
958
|
+
*/
|
|
959
|
+
function MinutesSinceAgent() {
|
|
960
|
+
const d = { type: "MinutesSinceAgent" };
|
|
961
|
+
return d;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* MinutesSinceAlert indicator.
|
|
965
|
+
* @param message (Optional) Message to display when the indicator is triggered
|
|
966
|
+
*/
|
|
967
|
+
function MinutesSinceAlert(message) {
|
|
968
|
+
const d = { type: "MinutesSinceAlert" };
|
|
969
|
+
d["message"] = message;
|
|
970
|
+
return d;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* MinutesSinceOptionOrder indicator.
|
|
974
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
975
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
976
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
977
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
978
|
+
* @param positionEffect Filter by Open (entering position) or Close (exiting). Leave empty for all.
|
|
979
|
+
* @param minDte Minimum days to expiration at order time. Leave empty for no minimum.
|
|
980
|
+
* @param maxDte Maximum days to expiration at order time. Leave empty for no maximum.
|
|
981
|
+
* @param orderStatus Matches option order events with this status
|
|
982
|
+
*/
|
|
983
|
+
function MinutesSinceOptionOrder(underlying, optionType, direction, spreadType, positionEffect, minDte, maxDte, orderStatus = "Filled") {
|
|
984
|
+
const d = { type: "MinutesSinceOptionOrder" };
|
|
985
|
+
d["underlying"] = underlying;
|
|
986
|
+
d["optionType"] = optionType;
|
|
987
|
+
d["direction"] = direction;
|
|
988
|
+
d["spreadType"] = spreadType;
|
|
989
|
+
d["positionEffect"] = positionEffect;
|
|
990
|
+
d["minDte"] = minDte;
|
|
991
|
+
d["maxDte"] = maxDte;
|
|
992
|
+
d["orderStatus"] = orderStatus;
|
|
993
|
+
return d;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* MinutesSinceOrder indicator.
|
|
997
|
+
* @param assets Ticker(s) whose orders are counted. One string or an array.
|
|
998
|
+
* @param side Buy or Sell
|
|
999
|
+
*/
|
|
1000
|
+
function MinutesSinceOrder(assets, side, orderStatus = "Filled") {
|
|
1001
|
+
const d = { type: "MinutesSinceOrder" };
|
|
1002
|
+
setAssets(d, "targetAssets", assets);
|
|
1003
|
+
d["side"] = side;
|
|
1004
|
+
d["orderStatus"] = orderStatus;
|
|
1005
|
+
return d;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* MinutesUntilClose indicator.
|
|
1009
|
+
*/
|
|
1010
|
+
function MinutesUntilClose() {
|
|
1011
|
+
const d = { type: "MinutesUntilClose" };
|
|
1012
|
+
return d;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Month indicator.
|
|
1016
|
+
*/
|
|
1017
|
+
function Month() {
|
|
1018
|
+
const d = { type: "Month" };
|
|
1019
|
+
return d;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Multiply indicator.
|
|
1023
|
+
*/
|
|
1024
|
+
function Multiply(left, right) {
|
|
1025
|
+
const d = { type: "Multiply" };
|
|
1026
|
+
d.indicators = [left, right];
|
|
1027
|
+
return d;
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Negative indicator.
|
|
1031
|
+
*/
|
|
1032
|
+
function Negative(operand) {
|
|
1033
|
+
const d = { type: "Negative" };
|
|
1034
|
+
d.indicators = [operand];
|
|
1035
|
+
return d;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* OpeningPrice indicator.
|
|
1039
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1040
|
+
*/
|
|
1041
|
+
function OpeningPrice(asset) {
|
|
1042
|
+
const d = { type: "OpeningPrice" };
|
|
1043
|
+
setAsset(d, "targetAsset", asset);
|
|
1044
|
+
return d;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* OptionCollateral indicator.
|
|
1048
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1049
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1050
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1051
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1052
|
+
*/
|
|
1053
|
+
function OptionCollateral(underlying, optionType, direction, spreadType) {
|
|
1054
|
+
const d = { type: "OptionCollateral" };
|
|
1055
|
+
d["underlying"] = underlying;
|
|
1056
|
+
d["optionType"] = optionType;
|
|
1057
|
+
d["direction"] = direction;
|
|
1058
|
+
d["spreadType"] = spreadType;
|
|
1059
|
+
return d;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* OptionDaysHeld indicator.
|
|
1063
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1064
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1065
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1066
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1067
|
+
* @param minOrMax Return minimum or maximum value across matching spreads.
|
|
1068
|
+
*/
|
|
1069
|
+
function OptionDaysHeld(underlying, optionType, direction, spreadType, minOrMax = "min") {
|
|
1070
|
+
const d = { type: "OptionDaysHeld" };
|
|
1071
|
+
d["underlying"] = underlying;
|
|
1072
|
+
d["optionType"] = optionType;
|
|
1073
|
+
d["direction"] = direction;
|
|
1074
|
+
d["spreadType"] = spreadType;
|
|
1075
|
+
d["minOrMax"] = minOrMax;
|
|
1076
|
+
return d;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* OptionDaysToExpiration indicator.
|
|
1080
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1081
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1082
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1083
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1084
|
+
* @param minOrMax Return minimum or maximum value across matching spreads.
|
|
1085
|
+
*/
|
|
1086
|
+
function OptionDaysToExpiration(underlying, optionType, direction, spreadType, minOrMax = "min") {
|
|
1087
|
+
const d = { type: "OptionDaysToExpiration" };
|
|
1088
|
+
d["underlying"] = underlying;
|
|
1089
|
+
d["optionType"] = optionType;
|
|
1090
|
+
d["direction"] = direction;
|
|
1091
|
+
d["spreadType"] = spreadType;
|
|
1092
|
+
d["minOrMax"] = minOrMax;
|
|
1093
|
+
return d;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* OptionGrossExposurePercent indicator.
|
|
1097
|
+
*/
|
|
1098
|
+
function OptionGrossExposurePercent() {
|
|
1099
|
+
const d = { type: "OptionGrossExposurePercent" };
|
|
1100
|
+
return d;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* OptionPositionCount indicator.
|
|
1104
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1105
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1106
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1107
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1108
|
+
*/
|
|
1109
|
+
function OptionPositionCount(underlying, optionType, direction, spreadType) {
|
|
1110
|
+
const d = { type: "OptionPositionCount" };
|
|
1111
|
+
d["underlying"] = underlying;
|
|
1112
|
+
d["optionType"] = optionType;
|
|
1113
|
+
d["direction"] = direction;
|
|
1114
|
+
d["spreadType"] = spreadType;
|
|
1115
|
+
return d;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* OptionPositionMaxDrawdown indicator.
|
|
1119
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1120
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1121
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1122
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1123
|
+
*/
|
|
1124
|
+
function OptionPositionMaxDrawdown(underlying, optionType, direction, spreadType) {
|
|
1125
|
+
const d = { type: "OptionPositionMaxDrawdown" };
|
|
1126
|
+
d["underlying"] = underlying;
|
|
1127
|
+
d["optionType"] = optionType;
|
|
1128
|
+
d["direction"] = direction;
|
|
1129
|
+
d["spreadType"] = spreadType;
|
|
1130
|
+
return d;
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* OptionPositionPercentChange indicator.
|
|
1134
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1135
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1136
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1137
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1138
|
+
*/
|
|
1139
|
+
function OptionPositionPercentChange(underlying, optionType, direction, spreadType) {
|
|
1140
|
+
const d = { type: "OptionPositionPercentChange" };
|
|
1141
|
+
d["underlying"] = underlying;
|
|
1142
|
+
d["optionType"] = optionType;
|
|
1143
|
+
d["direction"] = direction;
|
|
1144
|
+
d["spreadType"] = spreadType;
|
|
1145
|
+
return d;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* OptionPositionValue indicator.
|
|
1149
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1150
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1151
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1152
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1153
|
+
*/
|
|
1154
|
+
function OptionPositionValue(underlying, optionType, direction, spreadType) {
|
|
1155
|
+
const d = { type: "OptionPositionValue" };
|
|
1156
|
+
d["underlying"] = underlying;
|
|
1157
|
+
d["optionType"] = optionType;
|
|
1158
|
+
d["direction"] = direction;
|
|
1159
|
+
d["spreadType"] = spreadType;
|
|
1160
|
+
return d;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* OptionSpreadCount indicator.
|
|
1164
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1165
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1166
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1167
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1168
|
+
*/
|
|
1169
|
+
function OptionSpreadCount(underlying, optionType, direction, spreadType) {
|
|
1170
|
+
const d = { type: "OptionSpreadCount" };
|
|
1171
|
+
d["underlying"] = underlying;
|
|
1172
|
+
d["optionType"] = optionType;
|
|
1173
|
+
d["direction"] = direction;
|
|
1174
|
+
d["spreadType"] = spreadType;
|
|
1175
|
+
return d;
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* OptionUnrealizedPnL indicator.
|
|
1179
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1180
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1181
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1182
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1183
|
+
*/
|
|
1184
|
+
function OptionUnrealizedPnL(underlying, optionType, direction, spreadType) {
|
|
1185
|
+
const d = { type: "OptionUnrealizedPnL" };
|
|
1186
|
+
d["underlying"] = underlying;
|
|
1187
|
+
d["optionType"] = optionType;
|
|
1188
|
+
d["direction"] = direction;
|
|
1189
|
+
d["spreadType"] = spreadType;
|
|
1190
|
+
return d;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Plus indicator.
|
|
1194
|
+
*/
|
|
1195
|
+
function Plus(left, right) {
|
|
1196
|
+
const d = { type: "Plus" };
|
|
1197
|
+
d.indicators = [left, right];
|
|
1198
|
+
return d;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* PortfolioValue indicator.
|
|
1202
|
+
*/
|
|
1203
|
+
function PortfolioValue() {
|
|
1204
|
+
const d = { type: "PortfolioValue" };
|
|
1205
|
+
return d;
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* PositionMaxDrawdown indicator.
|
|
1209
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1210
|
+
*/
|
|
1211
|
+
function PositionMaxDrawdown(asset) {
|
|
1212
|
+
const d = { type: "PositionMaxDrawdown" };
|
|
1213
|
+
setAsset(d, "targetAsset", asset);
|
|
1214
|
+
return d;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* PositionMaxDrawup indicator.
|
|
1218
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1219
|
+
*/
|
|
1220
|
+
function PositionMaxDrawup(asset) {
|
|
1221
|
+
const d = { type: "PositionMaxDrawup" };
|
|
1222
|
+
setAsset(d, "targetAsset", asset);
|
|
1223
|
+
return d;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* PositionPercentChange indicator.
|
|
1227
|
+
* @param assets Ticker name (ex. SPY, BTC)
|
|
1228
|
+
*/
|
|
1229
|
+
function PositionPercentChange(assets) {
|
|
1230
|
+
const d = { type: "PositionPercentChange" };
|
|
1231
|
+
setAssets(d, "targetAssets", assets);
|
|
1232
|
+
return d;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* PositionValue indicator.
|
|
1236
|
+
* @param assets Ticker name (ex. SPY, BTC)
|
|
1237
|
+
*/
|
|
1238
|
+
function PositionValue(assets) {
|
|
1239
|
+
const d = { type: "PositionValue" };
|
|
1240
|
+
setAssets(d, "targetAssets", assets);
|
|
1241
|
+
return d;
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* PreviousClosingPrice indicator.
|
|
1245
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1246
|
+
*/
|
|
1247
|
+
function PreviousClosingPrice(asset) {
|
|
1248
|
+
const d = { type: "PreviousClosingPrice" };
|
|
1249
|
+
setAsset(d, "targetAsset", asset);
|
|
1250
|
+
return d;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Price indicator.
|
|
1254
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1255
|
+
*/
|
|
1256
|
+
function Price(asset) {
|
|
1257
|
+
const d = { type: "Price" };
|
|
1258
|
+
setAsset(d, "targetAsset", asset);
|
|
1259
|
+
return d;
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* PriceChangeSinceOpen indicator.
|
|
1263
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1264
|
+
*/
|
|
1265
|
+
function PriceChangeSinceOpen(asset) {
|
|
1266
|
+
const d = { type: "PriceChangeSinceOpen" };
|
|
1267
|
+
setAsset(d, "targetAsset", asset);
|
|
1268
|
+
return d;
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* PriceMeanAbsoluteDeviation indicator.
|
|
1272
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1273
|
+
* @param length Length of time
|
|
1274
|
+
* @param interval Unit of time
|
|
1275
|
+
*/
|
|
1276
|
+
function PriceMeanAbsoluteDeviation(asset, length = 30, interval = "Day") {
|
|
1277
|
+
const d = { type: "PriceMeanAbsoluteDeviation" };
|
|
1278
|
+
setAsset(d, "targetAsset", asset);
|
|
1279
|
+
d.window = { length: length, interval: interval };
|
|
1280
|
+
return d;
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* PriceRateOfChange indicator.
|
|
1284
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1285
|
+
* @param length Length of time
|
|
1286
|
+
* @param interval Unit of time
|
|
1287
|
+
*/
|
|
1288
|
+
function PriceRateOfChange(asset, length = 30, interval = "Day") {
|
|
1289
|
+
const d = { type: "PriceRateOfChange" };
|
|
1290
|
+
setAsset(d, "targetAsset", asset);
|
|
1291
|
+
d.window = { length: length, interval: interval };
|
|
1292
|
+
return d;
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* PriceStandardDeviation indicator.
|
|
1296
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1297
|
+
* @param length Length of time
|
|
1298
|
+
* @param interval Unit of time
|
|
1299
|
+
*/
|
|
1300
|
+
function PriceStandardDeviation(asset, length = 30, interval = "Day") {
|
|
1301
|
+
const d = { type: "PriceStandardDeviation" };
|
|
1302
|
+
setAsset(d, "targetAsset", asset);
|
|
1303
|
+
d.window = { length: length, interval: interval };
|
|
1304
|
+
return d;
|
|
1305
|
+
}
|
|
1306
|
+
exports.PriceStdDev = PriceStandardDeviation;
|
|
1307
|
+
/**
|
|
1308
|
+
* RelativeStrengthIndex indicator.
|
|
1309
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1310
|
+
* @param length Length of time
|
|
1311
|
+
* @param interval Unit of time
|
|
1312
|
+
*/
|
|
1313
|
+
function RelativeStrengthIndex(asset, length = 30, interval = "Day") {
|
|
1314
|
+
const d = { type: "RelativeStrengthIndex" };
|
|
1315
|
+
setAsset(d, "targetAsset", asset);
|
|
1316
|
+
d.window = { length: length, interval: interval };
|
|
1317
|
+
return d;
|
|
1318
|
+
}
|
|
1319
|
+
exports.RSI = RelativeStrengthIndex;
|
|
1320
|
+
/**
|
|
1321
|
+
* SimpleMovingAverage indicator.
|
|
1322
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1323
|
+
* @param length Length of time
|
|
1324
|
+
* @param interval Unit of time
|
|
1325
|
+
*/
|
|
1326
|
+
function SimpleMovingAverage(asset, length = 30, interval = "Day") {
|
|
1327
|
+
const d = { type: "SimpleMovingAverage" };
|
|
1328
|
+
setAsset(d, "targetAsset", asset);
|
|
1329
|
+
d.window = { length: length, interval: interval };
|
|
1330
|
+
return d;
|
|
1331
|
+
}
|
|
1332
|
+
exports.SMA = SimpleMovingAverage;
|
|
1333
|
+
/**
|
|
1334
|
+
* SquareRoot indicator.
|
|
1335
|
+
*/
|
|
1336
|
+
function SquareRoot(operand) {
|
|
1337
|
+
const d = { type: "SquareRoot" };
|
|
1338
|
+
d.indicators = [operand];
|
|
1339
|
+
return d;
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* StockReport indicator.
|
|
1343
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1344
|
+
*/
|
|
1345
|
+
function StockReport(asset) {
|
|
1346
|
+
const d = { type: "StockReport" };
|
|
1347
|
+
setAsset(d, "targetAsset", asset);
|
|
1348
|
+
return d;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* SumOrderAmount indicator.
|
|
1352
|
+
* @param side Matches order events with this side (buy or sell)
|
|
1353
|
+
* @param orderStatus Matches order events with this status
|
|
1354
|
+
* @param length Length of time
|
|
1355
|
+
* @param interval Unit of time
|
|
1356
|
+
* @param assets Ticker name (ex. SPY, BTC)
|
|
1357
|
+
*/
|
|
1358
|
+
function SumOrderAmount(side, orderStatus = "Filled", length = 1, interval = "Day", assets) {
|
|
1359
|
+
const d = { type: "SumOrderAmount" };
|
|
1360
|
+
d["side"] = side;
|
|
1361
|
+
d["orderStatus"] = orderStatus;
|
|
1362
|
+
setAssets(d, "targetAssets", assets);
|
|
1363
|
+
d.window = { length: length, interval: interval };
|
|
1364
|
+
return d;
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* SumOrderQuantity indicator.
|
|
1368
|
+
* @param side Matches order events with this side (buy or sell)
|
|
1369
|
+
* @param orderStatus Matches order events with this status
|
|
1370
|
+
* @param length Length of time
|
|
1371
|
+
* @param interval Unit of time
|
|
1372
|
+
* @param assets Ticker name (ex. SPY, BTC)
|
|
1373
|
+
*/
|
|
1374
|
+
function SumOrderQuantity(side, orderStatus = "Filled", length = 1, interval = "Day", assets) {
|
|
1375
|
+
const d = { type: "SumOrderQuantity" };
|
|
1376
|
+
d["side"] = side;
|
|
1377
|
+
d["orderStatus"] = orderStatus;
|
|
1378
|
+
setAssets(d, "targetAssets", assets);
|
|
1379
|
+
d.window = { length: length, interval: interval };
|
|
1380
|
+
return d;
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* TrailingSum indicator.
|
|
1384
|
+
* @param length Length of the rolling window
|
|
1385
|
+
*/
|
|
1386
|
+
function TrailingSum(operand, length = 4) {
|
|
1387
|
+
const d = { type: "TrailingSum" };
|
|
1388
|
+
d["length"] = length;
|
|
1389
|
+
d.indicators = [operand];
|
|
1390
|
+
return d;
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* TrueRange indicator.
|
|
1394
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1395
|
+
*/
|
|
1396
|
+
function TrueRange(asset) {
|
|
1397
|
+
const d = { type: "TrueRange" };
|
|
1398
|
+
setAsset(d, "targetAsset", asset);
|
|
1399
|
+
return d;
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* UnderlyingMaxDrawdown indicator.
|
|
1403
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1404
|
+
*/
|
|
1405
|
+
function UnderlyingMaxDrawdown(asset) {
|
|
1406
|
+
const d = { type: "UnderlyingMaxDrawdown" };
|
|
1407
|
+
setAsset(d, "targetAsset", asset);
|
|
1408
|
+
return d;
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Value indicator.
|
|
1412
|
+
* @param value Constant value
|
|
1413
|
+
*/
|
|
1414
|
+
function Value(value = 0) {
|
|
1415
|
+
const d = { type: "Value" };
|
|
1416
|
+
d["value"] = value;
|
|
1417
|
+
return d;
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Volume indicator.
|
|
1421
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1422
|
+
* @param metric The fundamental metric to use
|
|
1423
|
+
*/
|
|
1424
|
+
function Volume(asset, metric = "volume") {
|
|
1425
|
+
const d = { type: "Volume" };
|
|
1426
|
+
setAsset(d, "targetAsset", asset);
|
|
1427
|
+
d["metric"] = metric;
|
|
1428
|
+
return d;
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* VWAP indicator.
|
|
1432
|
+
* @param asset Ticker name (ex. SPY, BTC)
|
|
1433
|
+
*/
|
|
1434
|
+
function VWAP(asset) {
|
|
1435
|
+
const d = { type: "VWAP" };
|
|
1436
|
+
setAsset(d, "targetAsset", asset);
|
|
1437
|
+
return d;
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Year indicator.
|
|
1441
|
+
*/
|
|
1442
|
+
function Year() {
|
|
1443
|
+
const d = { type: "Year" };
|
|
1444
|
+
return d;
|
|
1445
|
+
}
|
|
1446
|
+
/** Submit a backtest. Returns a handle; results are read after it completes. */
|
|
1447
|
+
const backtest = (portfolio, config) => ({
|
|
1448
|
+
tool: "backtest_portfolio",
|
|
1449
|
+
portfolio,
|
|
1450
|
+
args: compact({
|
|
1451
|
+
"start_date": config.startDate,
|
|
1452
|
+
"end_date": config.endDate,
|
|
1453
|
+
"baseline_symbol": config.baselineSymbol,
|
|
1454
|
+
"interval": config.interval,
|
|
1455
|
+
"initial_value": config.initialValue,
|
|
1456
|
+
"generate_events": config.generateEvents,
|
|
1457
|
+
"fee_config": config.feeConfig,
|
|
1458
|
+
}),
|
|
1459
|
+
});
|
|
1460
|
+
exports.backtest = backtest;
|
|
1461
|
+
/** Submit a walk-forward study (anchored or rolling folds, GA or sweep engine). */
|
|
1462
|
+
const walkForward = (portfolio, config) => ({
|
|
1463
|
+
tool: "run_walk_forward_study",
|
|
1464
|
+
portfolio,
|
|
1465
|
+
args: compact({
|
|
1466
|
+
"global_start_date": config.globalStartDate,
|
|
1467
|
+
"global_end_date": config.globalEndDate,
|
|
1468
|
+
"fold_count": config.foldCount,
|
|
1469
|
+
"engine_kind": config.engineKind,
|
|
1470
|
+
"walk_forward_mode": config.walkForwardMode,
|
|
1471
|
+
"oos_width_days": config.oosWidthDays,
|
|
1472
|
+
"validation_percent": config.validationPercent,
|
|
1473
|
+
"embargo_days": config.embargoDays,
|
|
1474
|
+
"population_size": config.populationSize,
|
|
1475
|
+
"num_generations": config.numGenerations,
|
|
1476
|
+
"num_windows": config.numWindows,
|
|
1477
|
+
"training_percent": config.trainingPercent,
|
|
1478
|
+
"window_overlap_percent": config.windowOverlapPercent,
|
|
1479
|
+
"fitness_functions": config.fitnessFunctions,
|
|
1480
|
+
"selection_policy": config.selectionPolicy,
|
|
1481
|
+
"fold_selection_policy": config.foldSelectionPolicy,
|
|
1482
|
+
"fee_config": config.feeConfig,
|
|
1483
|
+
"degradation_penalty": config.degradationPenalty,
|
|
1484
|
+
"leaderboard_size": config.leaderboardSize,
|
|
1485
|
+
"search_mode": config.searchMode,
|
|
1486
|
+
"preview_only": config.previewOnly,
|
|
1487
|
+
"interval": config.interval,
|
|
1488
|
+
"auto_run": config.autoRun,
|
|
1489
|
+
"name": config.name,
|
|
1490
|
+
"mode": config.mode,
|
|
1491
|
+
"oos_stride_days": config.oosStrideDays,
|
|
1492
|
+
"adaptive_config": config.adaptiveConfig,
|
|
1493
|
+
"inner_mode": config.innerMode,
|
|
1494
|
+
"certification": config.certification,
|
|
1495
|
+
"allow_ga_certification": config.allowGaCertification,
|
|
1496
|
+
"use_certification_selection_policy": config.useCertificationSelectionPolicy,
|
|
1497
|
+
"genes": config.genes,
|
|
1498
|
+
}),
|
|
1499
|
+
});
|
|
1500
|
+
exports.walkForward = walkForward;
|
|
1501
|
+
/** Submit a genetic optimization over the portfolio's tunable genes. */
|
|
1502
|
+
const optimization = (portfolio, config) => ({
|
|
1503
|
+
tool: "optimize_portfolio",
|
|
1504
|
+
portfolio,
|
|
1505
|
+
args: compact({
|
|
1506
|
+
"start_date": config.startDate,
|
|
1507
|
+
"end_date": config.endDate,
|
|
1508
|
+
"fitness_functions": config.fitnessFunctions,
|
|
1509
|
+
"population_size": config.populationSize,
|
|
1510
|
+
"num_generations": config.numGenerations,
|
|
1511
|
+
"num_windows": config.numWindows,
|
|
1512
|
+
"training_percent": config.trainingPercent,
|
|
1513
|
+
"window_overlap_percent": config.windowOverlapPercent,
|
|
1514
|
+
"interval": config.interval,
|
|
1515
|
+
"selection_policy": config.selectionPolicy,
|
|
1516
|
+
"fee_config": config.feeConfig,
|
|
1517
|
+
"genes": config.genes,
|
|
1518
|
+
}),
|
|
1519
|
+
});
|
|
1520
|
+
exports.optimization = optimization;
|
|
1521
|
+
/** Sweep Subject (Portfolio scope) over a value set. */
|
|
1522
|
+
const geneSubject = (values) => ({
|
|
1523
|
+
field: "Subject",
|
|
1524
|
+
scope: "Portfolio",
|
|
1525
|
+
target: { scope: "Portfolio", field: "Subject" },
|
|
1526
|
+
values: values,
|
|
1527
|
+
});
|
|
1528
|
+
exports.geneSubject = geneSubject;
|
|
1529
|
+
/** Sweep EntryCondition (Strategy scope) over a value set. */
|
|
1530
|
+
const geneEntryCondition = (strategyIndex, values) => ({
|
|
1531
|
+
field: "EntryCondition",
|
|
1532
|
+
scope: "Strategy",
|
|
1533
|
+
target: { scope: "Strategy", field: "EntryCondition", strategyIndex },
|
|
1534
|
+
values: values,
|
|
1535
|
+
});
|
|
1536
|
+
exports.geneEntryCondition = geneEntryCondition;
|
|
1537
|
+
/** Sweep ExitCondition (Strategy scope) over a value set. */
|
|
1538
|
+
const geneExitCondition = (strategyIndex, values) => ({
|
|
1539
|
+
field: "ExitCondition",
|
|
1540
|
+
scope: "Strategy",
|
|
1541
|
+
target: { scope: "Strategy", field: "ExitCondition", strategyIndex },
|
|
1542
|
+
values: values,
|
|
1543
|
+
});
|
|
1544
|
+
exports.geneExitCondition = geneExitCondition;
|
|
1545
|
+
/** Sweep EntryCooldownDays (Strategy scope) over a value set. */
|
|
1546
|
+
const geneEntryCooldownDays = (strategyIndex, values) => ({
|
|
1547
|
+
field: "EntryCooldownDays",
|
|
1548
|
+
scope: "Strategy",
|
|
1549
|
+
target: { scope: "Strategy", field: "EntryCooldownDays", strategyIndex },
|
|
1550
|
+
values: values,
|
|
1551
|
+
});
|
|
1552
|
+
exports.geneEntryCooldownDays = geneEntryCooldownDays;
|
|
1553
|
+
/** Sweep RankSignal (Action scope) over a value set. */
|
|
1554
|
+
const geneRankSignal = (strategyIndex, values) => ({
|
|
1555
|
+
field: "RankSignal",
|
|
1556
|
+
scope: "Action",
|
|
1557
|
+
target: { scope: "Action", field: "RankSignal", strategyIndex },
|
|
1558
|
+
values: values,
|
|
1559
|
+
});
|
|
1560
|
+
exports.geneRankSignal = geneRankSignal;
|
|
1561
|
+
/** Sweep BuyingPowerPct (Action scope) over a value set. */
|
|
1562
|
+
const geneBuyingPowerPct = (strategyIndex, values) => ({
|
|
1563
|
+
field: "BuyingPowerPct",
|
|
1564
|
+
scope: "Action",
|
|
1565
|
+
target: { scope: "Action", field: "BuyingPowerPct", strategyIndex },
|
|
1566
|
+
values: values,
|
|
1567
|
+
});
|
|
1568
|
+
exports.geneBuyingPowerPct = geneBuyingPowerPct;
|
|
1569
|
+
/** Sweep AllocationPct (Action scope) over a value set. */
|
|
1570
|
+
const geneAllocationPct = (strategyIndex, values) => ({
|
|
1571
|
+
field: "AllocationPct",
|
|
1572
|
+
scope: "Action",
|
|
1573
|
+
target: { scope: "Action", field: "AllocationPct", strategyIndex },
|
|
1574
|
+
values: values,
|
|
1575
|
+
});
|
|
1576
|
+
exports.geneAllocationPct = geneAllocationPct;
|
|
1577
|
+
/** Sweep TotalBudgetPct (Action scope) over a value set. */
|
|
1578
|
+
const geneTotalBudgetPct = (strategyIndex, values) => ({
|
|
1579
|
+
field: "TotalBudgetPct",
|
|
1580
|
+
scope: "Action",
|
|
1581
|
+
target: { scope: "Action", field: "TotalBudgetPct", strategyIndex },
|
|
1582
|
+
values: values,
|
|
1583
|
+
});
|
|
1584
|
+
exports.geneTotalBudgetPct = geneTotalBudgetPct;
|
|
1585
|
+
/** Sweep DeploymentPct (Action scope) over a value set. */
|
|
1586
|
+
const geneDeploymentPct = (strategyIndex, values) => ({
|
|
1587
|
+
field: "DeploymentPct",
|
|
1588
|
+
scope: "Action",
|
|
1589
|
+
target: { scope: "Action", field: "DeploymentPct", strategyIndex },
|
|
1590
|
+
values: values,
|
|
1591
|
+
});
|
|
1592
|
+
exports.geneDeploymentPct = geneDeploymentPct;
|
|
1593
|
+
/** Sweep RollTriggerDte (Action scope) over a value set. */
|
|
1594
|
+
const geneRollTriggerDte = (strategyIndex, values) => ({
|
|
1595
|
+
field: "RollTriggerDte",
|
|
1596
|
+
scope: "Action",
|
|
1597
|
+
target: { scope: "Action", field: "RollTriggerDte", strategyIndex },
|
|
1598
|
+
values: values,
|
|
1599
|
+
});
|
|
1600
|
+
exports.geneRollTriggerDte = geneRollTriggerDte;
|
|
1601
|
+
/** Sweep TakeProfitPct (Action scope) over a value set. */
|
|
1602
|
+
const geneTakeProfitPct = (strategyIndex, values) => ({
|
|
1603
|
+
field: "TakeProfitPct",
|
|
1604
|
+
scope: "Action",
|
|
1605
|
+
target: { scope: "Action", field: "TakeProfitPct", strategyIndex },
|
|
1606
|
+
values: values,
|
|
1607
|
+
});
|
|
1608
|
+
exports.geneTakeProfitPct = geneTakeProfitPct;
|
|
1609
|
+
/** Sweep StructureKind (Action scope) over a value set. */
|
|
1610
|
+
const geneStructureKind = (strategyIndex, values) => ({
|
|
1611
|
+
field: "StructureKind",
|
|
1612
|
+
scope: "Action",
|
|
1613
|
+
target: { scope: "Action", field: "StructureKind", strategyIndex },
|
|
1614
|
+
values: values,
|
|
1615
|
+
});
|
|
1616
|
+
exports.geneStructureKind = geneStructureKind;
|
|
1617
|
+
/** Sweep OptionDelta (OptionLeg scope) over a value set. */
|
|
1618
|
+
const geneOptionDelta = (strategyIndex, legIndex, values) => ({
|
|
1619
|
+
field: "OptionDelta",
|
|
1620
|
+
scope: "OptionLeg",
|
|
1621
|
+
target: { scope: "OptionLeg", field: "OptionDelta", strategyIndex, legIndex },
|
|
1622
|
+
values: values,
|
|
1623
|
+
});
|
|
1624
|
+
exports.geneOptionDelta = geneOptionDelta;
|
|
1625
|
+
/** Sweep StrikeDistance (OptionLeg scope) over a value set. */
|
|
1626
|
+
const geneStrikeDistance = (strategyIndex, legIndex, values) => ({
|
|
1627
|
+
field: "StrikeDistance",
|
|
1628
|
+
scope: "OptionLeg",
|
|
1629
|
+
target: { scope: "OptionLeg", field: "StrikeDistance", strategyIndex, legIndex },
|
|
1630
|
+
values: values,
|
|
1631
|
+
});
|
|
1632
|
+
exports.geneStrikeDistance = geneStrikeDistance;
|
|
1633
|
+
/** Sweep DteBracket (OptionLeg scope) over a value set. */
|
|
1634
|
+
const geneDteBracket = (strategyIndex, legIndex, values) => ({
|
|
1635
|
+
field: "DteBracket",
|
|
1636
|
+
scope: "OptionLeg",
|
|
1637
|
+
target: { scope: "OptionLeg", field: "DteBracket", strategyIndex, legIndex },
|
|
1638
|
+
values: values,
|
|
1639
|
+
});
|
|
1640
|
+
exports.geneDteBracket = geneDteBracket;
|
|
1641
|
+
/** Sweep SelectTopLimit (UniversePipeline scope) over a value set. */
|
|
1642
|
+
const geneSelectTopLimit = (strategyIndex, stageIndex, values) => ({
|
|
1643
|
+
field: "SelectTopLimit",
|
|
1644
|
+
scope: "UniversePipeline",
|
|
1645
|
+
target: { scope: "UniversePipeline", field: "SelectTopLimit", strategyIndex, stageIndex },
|
|
1646
|
+
values: values,
|
|
1647
|
+
});
|
|
1648
|
+
exports.geneSelectTopLimit = geneSelectTopLimit;
|
|
1649
|
+
/** Sweep UniversePipelineFilter (UniversePipeline scope) over a value set. */
|
|
1650
|
+
const geneUniversePipelineFilter = (strategyIndex, stageIndex, values) => ({
|
|
1651
|
+
field: "UniversePipelineFilter",
|
|
1652
|
+
scope: "UniversePipeline",
|
|
1653
|
+
target: { scope: "UniversePipeline", field: "UniversePipelineFilter", strategyIndex, stageIndex },
|
|
1654
|
+
values: values,
|
|
1655
|
+
});
|
|
1656
|
+
exports.geneUniversePipelineFilter = geneUniversePipelineFilter;
|