nexustrade 3.0.0 → 3.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
|
@@ -1138,6 +1138,15 @@ fixed on later crossings unless an expiry was configured.
|
|
|
1138
1138
|
narrow position measurements. Reuse `MinutesSinceOrder` for purchase cadence.
|
|
1139
1139
|
Settlement accounting remains on the portfolio.
|
|
1140
1140
|
|
|
1141
|
+
`short` (Python `short`) sells one stock to open a short of exactly the sized
|
|
1142
|
+
shares; it defaults to `"number of assets"` and cannot be sized as a percent of
|
|
1143
|
+
current positions. `cover` buys the short back; its default is 100 percent of
|
|
1144
|
+
the open short, and every size is capped at the short, so it never goes long.
|
|
1145
|
+
A Short is refused while the book is long that stock, is capped by Reg-T initial
|
|
1146
|
+
margin, and is always whole shares. Backtests and paper books always support
|
|
1147
|
+
them; a live book needs a brokerage that can short stock (Alpaca, Tradier,
|
|
1148
|
+
TradeStation or Public, on a margin account).
|
|
1149
|
+
|
|
1141
1150
|
`sellHoldings` (Python `sell_holdings`) is a Sell action with a candidate-bound
|
|
1142
1151
|
holding condition. Its strategy condition supplies the account/market gate;
|
|
1143
1152
|
only actual qualifying stock holdings are sold. Ordinary fixed-asset Sell
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.geneAppendUniversePipelineFilter = exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneMaxSpreadPct = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = exports.geneExposurePolicy = void 0;
|
|
3
|
+
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.cover = exports.short = 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.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.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 = exports.screenTop = void 0;
|
|
5
|
+
exports.geneAppendUniversePipelineFilter = exports.geneUniversePipelineFilter = exports.geneSelectTopLimit = exports.geneMaxSpreadPct = exports.geneDteBracket = exports.geneStrikeDistance = exports.geneOptionDelta = exports.geneExposurePolicy = exports.geneAllocationPolicy = exports.geneStructureKind = void 0;
|
|
6
6
|
exports.andThen = andThen;
|
|
7
7
|
exports.universe = universe;
|
|
8
8
|
exports.AbsoluteValue = AbsoluteValue;
|
|
@@ -384,6 +384,20 @@ const buy = (target, amount, type = "percent of portfolio", options = {}) => ({
|
|
|
384
384
|
exports.buy = buy;
|
|
385
385
|
const sell = (target, amount, type = "percent of portfolio", options = {}) => ({ type: "Sell", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
386
386
|
exports.sell = sell;
|
|
387
|
+
/**
|
|
388
|
+
* Sell-to-open one stock: hold a short of exactly the sized shares. Sizing is
|
|
389
|
+
* "number of assets" (shares), "dollars", "percent of portfolio" or "percent of
|
|
390
|
+
* buying power"; capped by Reg-T initial margin. Refused while the book is long
|
|
391
|
+
* the stock. Needs a brokerage that can short stock (backtests and paper can).
|
|
392
|
+
*/
|
|
393
|
+
const short = (target, amount, type = "number of assets", options = {}) => ({ type: "Short", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
394
|
+
exports.short = short;
|
|
395
|
+
/**
|
|
396
|
+
* Buy back an open stock short. "percent of current positions" is a percent of
|
|
397
|
+
* the open short; every size is capped at the short, so Cover never goes long.
|
|
398
|
+
*/
|
|
399
|
+
const cover = (target, amount = 100, type = "percent of current positions", options = {}) => ({ type: "Cover", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
400
|
+
exports.cover = cover;
|
|
387
401
|
/** Sell only actual holdings that pass a candidate-bound condition. */
|
|
388
402
|
const sellHoldings = (condition, amount = 100, type = "percent of current positions", options = {}) => ({ type: "Sell", targetAsset: (0, exports.stockAsset)("__PLACEHOLDER__"),
|
|
389
403
|
holdingCondition: condition, amount: { type, amount }, ...options });
|
|
@@ -284,7 +284,7 @@ export interface PurchaseFunding {
|
|
|
284
284
|
amount: Allocation;
|
|
285
285
|
}
|
|
286
286
|
export interface BuyOrSellAction {
|
|
287
|
-
type: "Buy" | "Sell";
|
|
287
|
+
type: "Buy" | "Sell" | "Short" | "Cover";
|
|
288
288
|
targetAsset: Asset;
|
|
289
289
|
amount: Allocation;
|
|
290
290
|
executionPriority?: ExecutionPriority;
|
|
@@ -438,10 +438,12 @@ export interface DynamicRebalanceAction {
|
|
|
438
438
|
*/
|
|
439
439
|
canSell?: Condition | CandidateCondition;
|
|
440
440
|
/**
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
441
|
+
* Permits negative rebalance targets (equity short legs, whole shares).
|
|
442
|
+
* Backtests and paper assume shares were available to short each morning
|
|
443
|
+
* and accrue a modeled borrow fee. Live deploy needs a brokerage that can
|
|
444
|
+
* short stock (Alpaca, Tradier, TradeStation, Public; margin account);
|
|
445
|
+
* elsewhere deploy is rejected. For a fixed-size short of one stock use
|
|
446
|
+
* short() / cover() instead.
|
|
445
447
|
*/
|
|
446
448
|
allowShorts?: boolean;
|
|
447
449
|
allocationPolicy?: AllocationPolicy;
|
|
@@ -705,6 +707,22 @@ export declare const buy: (target: AssetArg, amount: number, type?: AllocationTy
|
|
|
705
707
|
export declare const sell: (target: AssetArg, amount: number, type?: AllocationType, options?: {
|
|
706
708
|
executionPriority?: ExecutionPriority;
|
|
707
709
|
}) => BuyOrSellAction;
|
|
710
|
+
/**
|
|
711
|
+
* Sell-to-open one stock: hold a short of exactly the sized shares. Sizing is
|
|
712
|
+
* "number of assets" (shares), "dollars", "percent of portfolio" or "percent of
|
|
713
|
+
* buying power"; capped by Reg-T initial margin. Refused while the book is long
|
|
714
|
+
* the stock. Needs a brokerage that can short stock (backtests and paper can).
|
|
715
|
+
*/
|
|
716
|
+
export declare const short: (target: AssetArg, amount: number, type?: AllocationType, options?: {
|
|
717
|
+
executionPriority?: ExecutionPriority;
|
|
718
|
+
}) => BuyOrSellAction;
|
|
719
|
+
/**
|
|
720
|
+
* Buy back an open stock short. "percent of current positions" is a percent of
|
|
721
|
+
* the open short; every size is capped at the short, so Cover never goes long.
|
|
722
|
+
*/
|
|
723
|
+
export declare const cover: (target: AssetArg, amount?: number, type?: AllocationType, options?: {
|
|
724
|
+
executionPriority?: ExecutionPriority;
|
|
725
|
+
}) => BuyOrSellAction;
|
|
708
726
|
/** Sell only actual holdings that pass a candidate-bound condition. */
|
|
709
727
|
export declare const sellHoldings: (condition: Condition, amount?: number, type?: AllocationType, options?: {
|
|
710
728
|
executionPriority?: ExecutionPriority;
|
|
@@ -193,6 +193,18 @@ export const watchlistUniverse = (watchlistKey) => ({ source: "WATCHLIST", watch
|
|
|
193
193
|
// ---- equity + cash actions ----
|
|
194
194
|
export const buy = (target, amount, type = "percent of portfolio", options = {}) => ({ type: "Buy", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
195
195
|
export const sell = (target, amount, type = "percent of portfolio", options = {}) => ({ type: "Sell", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
196
|
+
/**
|
|
197
|
+
* Sell-to-open one stock: hold a short of exactly the sized shares. Sizing is
|
|
198
|
+
* "number of assets" (shares), "dollars", "percent of portfolio" or "percent of
|
|
199
|
+
* buying power"; capped by Reg-T initial margin. Refused while the book is long
|
|
200
|
+
* the stock. Needs a brokerage that can short stock (backtests and paper can).
|
|
201
|
+
*/
|
|
202
|
+
export const short = (target, amount, type = "number of assets", options = {}) => ({ type: "Short", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
203
|
+
/**
|
|
204
|
+
* Buy back an open stock short. "percent of current positions" is a percent of
|
|
205
|
+
* the open short; every size is capped at the short, so Cover never goes long.
|
|
206
|
+
*/
|
|
207
|
+
export const cover = (target, amount = 100, type = "percent of current positions", options = {}) => ({ type: "Cover", targetAsset: toAsset(target), amount: { type, amount }, ...options });
|
|
196
208
|
/** Sell only actual holdings that pass a candidate-bound condition. */
|
|
197
209
|
export const sellHoldings = (condition, amount = 100, type = "percent of current positions", options = {}) => ({ type: "Sell", targetAsset: stockAsset("__PLACEHOLDER__"),
|
|
198
210
|
holdingCondition: condition, amount: { type, amount }, ...options });
|