nexustrade 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -194,6 +194,21 @@ nt.strategy("Sell the spread for $1.50 or better", nt.always(), optionAction, {
|
|
|
194
194
|
});
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
+
An option net limit can also follow a position the strategy holds. Pass an
|
|
198
|
+
indicator instead of a number and the engine evaluates it when the strategy
|
|
199
|
+
fires. If it has no positive value at that moment, no order is placed:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
nt.strategy("Sell the credit spread for the debit fill plus $0.50", whenDebitSpreadHeld, creditSpreadAction, {
|
|
203
|
+
orderExecution: nt.limitOrder({
|
|
204
|
+
price: nt.minimumNetCredit(
|
|
205
|
+
nt.Plus(nt.OptionSpreadEntryPrice("SPX", "call", "long", "vertical"), nt.Value(0.5)),
|
|
206
|
+
),
|
|
207
|
+
workingTime: nt.goodForDay(),
|
|
208
|
+
}),
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
197
212
|
`currentLimit()` creates a quote-relative Limit for dynamic rebalance strategies.
|
|
198
213
|
It keeps the no-worse-than-current-quote protection, but it is not a resting
|
|
199
214
|
price target. Live option strategies must choose an explicit Limit policy.
|
|
@@ -208,7 +223,7 @@ price target. Live option strategies must choose an explicit Limit policy.
|
|
|
208
223
|
| **Position state** | `PositionValue` `PositionPercentChange` `PositionMaxDrawdown` |
|
|
209
224
|
| **Portfolio state** | `PortfolioValue` `BuyingPower` `MaxDrawdown` `InitialValue` |
|
|
210
225
|
| **Fundamentals** | `Fundamental` `Economic` `DaysUntilEarnings` `IsIndexMember` `IsIndustry` |
|
|
211
|
-
| **Options** | `OptionDaysToExpiration` `OptionCollateral` `OptionUnrealizedPnL` `openOption` `closeOption` |
|
|
226
|
+
| **Options** | `OptionDaysToExpiration` `OptionCollateral` `OptionSpreadEntryPrice` `OptionUnrealizedPnL` `openOption` `closeOption` |
|
|
212
227
|
| **Actions** | `buy` `sell` `alert` `dynamicRebalance` `rebalanceOption` |
|
|
213
228
|
| **Selection** | `filter` `selectTop` `selectPercentile` `universe` |
|
|
214
229
|
| **Logic** | `always` `atLeast` `atMost` `exactly` `fewerThan` `multi` `and` `or` `sequence` |
|
|
@@ -87,6 +87,7 @@ exports.OptionPositionValue = OptionPositionValue;
|
|
|
87
87
|
exports.OptionRealizedPnL = OptionRealizedPnL;
|
|
88
88
|
exports.OptionRealizedPremium = OptionRealizedPremium;
|
|
89
89
|
exports.OptionSpreadCount = OptionSpreadCount;
|
|
90
|
+
exports.OptionSpreadEntryPrice = OptionSpreadEntryPrice;
|
|
90
91
|
exports.OptionUnrealizedPnL = OptionUnrealizedPnL;
|
|
91
92
|
exports.Plus = Plus;
|
|
92
93
|
exports.PortfolioValue = PortfolioValue;
|
|
@@ -438,11 +439,13 @@ const unitPriceLimit = (amount) => ({
|
|
|
438
439
|
amount,
|
|
439
440
|
});
|
|
440
441
|
exports.unitPriceLimit = unitPriceLimit;
|
|
442
|
+
/** Dollars per share, or an indicator evaluated when the strategy fires. */
|
|
441
443
|
const maximumNetDebit = (amount) => ({
|
|
442
444
|
type: "MaximumNetDebit",
|
|
443
445
|
amount,
|
|
444
446
|
});
|
|
445
447
|
exports.maximumNetDebit = maximumNetDebit;
|
|
448
|
+
/** Dollars per share, or an indicator evaluated when the strategy fires. */
|
|
446
449
|
const minimumNetCredit = (amount) => ({
|
|
447
450
|
type: "MinimumNetCredit",
|
|
448
451
|
amount,
|
|
@@ -1384,6 +1387,21 @@ function OptionSpreadCount(underlying, optionType, direction, spreadType) {
|
|
|
1384
1387
|
d["spreadType"] = spreadType;
|
|
1385
1388
|
return d;
|
|
1386
1389
|
}
|
|
1390
|
+
/**
|
|
1391
|
+
* OptionSpreadEntryPrice indicator.
|
|
1392
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1393
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1394
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1395
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1396
|
+
*/
|
|
1397
|
+
function OptionSpreadEntryPrice(underlying, optionType, direction, spreadType) {
|
|
1398
|
+
const d = { type: "OptionSpreadEntryPrice" };
|
|
1399
|
+
d["underlying"] = underlying;
|
|
1400
|
+
d["optionType"] = optionType;
|
|
1401
|
+
d["direction"] = direction;
|
|
1402
|
+
d["spreadType"] = spreadType;
|
|
1403
|
+
return d;
|
|
1404
|
+
}
|
|
1387
1405
|
/**
|
|
1388
1406
|
* OptionUnrealizedPnL indicator.
|
|
1389
1407
|
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
@@ -407,10 +407,10 @@ export type StrategyLimitPricePolicy = {
|
|
|
407
407
|
amount: number;
|
|
408
408
|
} | {
|
|
409
409
|
type: "MaximumNetDebit";
|
|
410
|
-
amount: number;
|
|
410
|
+
amount: number | Indicator;
|
|
411
411
|
} | {
|
|
412
412
|
type: "MinimumNetCredit";
|
|
413
|
-
amount: number;
|
|
413
|
+
amount: number | Indicator;
|
|
414
414
|
};
|
|
415
415
|
export type StrategyOrderExecutionPolicy = {
|
|
416
416
|
type: "Market";
|
|
@@ -636,8 +636,10 @@ export declare const limitOrder: (config: {
|
|
|
636
636
|
}) => StrategyOrderExecutionPolicy;
|
|
637
637
|
export declare const currentLimit: () => StrategyLimitPricePolicy;
|
|
638
638
|
export declare const unitPriceLimit: (amount: number) => StrategyLimitPricePolicy;
|
|
639
|
-
|
|
640
|
-
export declare const
|
|
639
|
+
/** Dollars per share, or an indicator evaluated when the strategy fires. */
|
|
640
|
+
export declare const maximumNetDebit: (amount: number | Indicator) => StrategyLimitPricePolicy;
|
|
641
|
+
/** Dollars per share, or an indicator evaluated when the strategy fires. */
|
|
642
|
+
export declare const minimumNetCredit: (amount: number | Indicator) => StrategyLimitPricePolicy;
|
|
641
643
|
export declare const goodForDay: () => StrategyLimitWorkingTime;
|
|
642
644
|
export declare const goodForMinutes: (minutes: number) => StrategyLimitWorkingTime;
|
|
643
645
|
export declare const strategy: (name: string, condition: StrategyCondition, action: Action, options?: {
|
|
@@ -1154,6 +1156,14 @@ export declare function OptionRealizedPremium(underlying: string, lookbackDays?:
|
|
|
1154
1156
|
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1155
1157
|
*/
|
|
1156
1158
|
export declare function OptionSpreadCount(underlying: string, optionType: OptionType, direction: OptionDirection, spreadType: OptionSpreadType): Indicator;
|
|
1159
|
+
/**
|
|
1160
|
+
* OptionSpreadEntryPrice indicator.
|
|
1161
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1162
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1163
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1164
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1165
|
+
*/
|
|
1166
|
+
export declare function OptionSpreadEntryPrice(underlying: string, optionType: OptionType, direction: OptionDirection, spreadType: OptionSpreadType): Indicator;
|
|
1157
1167
|
/**
|
|
1158
1168
|
* OptionUnrealizedPnL indicator.
|
|
1159
1169
|
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
@@ -273,10 +273,12 @@ export const unitPriceLimit = (amount) => ({
|
|
|
273
273
|
type: "UnitPrice",
|
|
274
274
|
amount,
|
|
275
275
|
});
|
|
276
|
+
/** Dollars per share, or an indicator evaluated when the strategy fires. */
|
|
276
277
|
export const maximumNetDebit = (amount) => ({
|
|
277
278
|
type: "MaximumNetDebit",
|
|
278
279
|
amount,
|
|
279
280
|
});
|
|
281
|
+
/** Dollars per share, or an indicator evaluated when the strategy fires. */
|
|
280
282
|
export const minimumNetCredit = (amount) => ({
|
|
281
283
|
type: "MinimumNetCredit",
|
|
282
284
|
amount,
|
|
@@ -1212,6 +1214,21 @@ export function OptionSpreadCount(underlying, optionType, direction, spreadType)
|
|
|
1212
1214
|
d["spreadType"] = spreadType;
|
|
1213
1215
|
return d;
|
|
1214
1216
|
}
|
|
1217
|
+
/**
|
|
1218
|
+
* OptionSpreadEntryPrice indicator.
|
|
1219
|
+
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|
|
1220
|
+
* @param optionType Filter by Call or Put. Leave empty for all.
|
|
1221
|
+
* @param direction Filter by Long or Short. Leave empty for all.
|
|
1222
|
+
* @param spreadType Filter by spread type. Leave empty for all.
|
|
1223
|
+
*/
|
|
1224
|
+
export function OptionSpreadEntryPrice(underlying, optionType, direction, spreadType) {
|
|
1225
|
+
const d = { type: "OptionSpreadEntryPrice" };
|
|
1226
|
+
d["underlying"] = underlying;
|
|
1227
|
+
d["optionType"] = optionType;
|
|
1228
|
+
d["direction"] = direction;
|
|
1229
|
+
d["spreadType"] = spreadType;
|
|
1230
|
+
return d;
|
|
1231
|
+
}
|
|
1215
1232
|
/**
|
|
1216
1233
|
* OptionUnrealizedPnL indicator.
|
|
1217
1234
|
* @param underlying Filter by underlying (e.g., AAPL, SPY). Leave empty for all.
|