nexustrade 1.42.0 → 1.52.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
@@ -394,9 +394,15 @@ await client.updatePortfolio(portfolioId, operations, {
394
394
  });
395
395
  ```
396
396
 
397
- The five edits are `rename`, `addStrategies`, `removeStrategies`,
398
- `replaceStrategy`, and `replaceStrategies`. Deploy, undeploy, delete,
399
- scheduling, and trading-policy operations are not reachable on this route.
397
+ Prefer one `updatePortfolio` operation with a finished `portfolio` patch.
398
+ It can combine `strategies`, `deployment` (frequency and timing), `name`,
399
+ `policy.stockEligibility`, `dividendPolicy`, and alerts. Omitted fields retain
400
+ their saved values. Draft starting capital and capabilities can change only
401
+ before deployment. The existing strategy and rename operations remain supported.
402
+ Every authored operation for the target in one call commits together; validation
403
+ failure saves none of them. Reusing the same idempotency key replays the saved
404
+ result. Deploy, undeploy, delete and automated approval remain separate account
405
+ operations.
400
406
 
401
407
  **`replaceStrategies` replaces the whole set**, so a strategy left out of the
402
408
  array is deleted. Carry unchanged strategies through verbatim, including the
@@ -827,7 +833,7 @@ is missing here, so this list cannot drift from the code.
827
833
  | `createPortfolio(book, { idempotencyKey })` | Persist a portfolio definition |
828
834
  | `listPortfolios(options)` | List portfolios, with filters and pagination |
829
835
  | `getPortfolio(portfolioId)` | Read one portfolio |
830
- | `updatePortfolio(id, operations, { idempotencyKey })` | Rename or edit strategies deterministically |
836
+ | `updatePortfolio(id, operations, { idempotencyKey })` | Atomically save a finished authored portfolio patch |
831
837
  | `forkPublicPortfolio(sharedId, { idempotencyKey })` | Fork a public portfolio into the workspace |
832
838
  | `deploy(portfolioId, { frequency })` | Start paper trading it |
833
839
  | `undeploy(portfolioId)` | Stop it |
@@ -867,8 +867,8 @@ class NexusTradeClient {
867
867
  }
868
868
  /**
869
869
  * Apply deterministic no-code portfolio edits without invoking Aurora.
870
- * Guest workspaces may rename and add/remove/replace strategies; deployment,
871
- * scheduling, policy, and trading operations remain account-only.
870
+ * Finished authored patches can combine strategies, evaluation timing and
871
+ * stock eligibility in one save. Activation and automated approval remain separate.
872
872
  */
873
873
  async updatePortfolio(portfolioId, operations, options) {
874
874
  if (operations.length === 0) {
@@ -13,6 +13,7 @@ exports.BollingerBand = BollingerBand;
13
13
  exports.BullishFairValueGap = BullishFairValueGap;
14
14
  exports.BuyingPower = BuyingPower;
15
15
  exports.ChaikinMoneyFlow = ChaikinMoneyFlow;
16
+ exports.ChartBar = ChartBar;
16
17
  exports.CommodityChannelIndex = CommodityChannelIndex;
17
18
  exports.CompoundAnnualGrowthRate = CompoundAnnualGrowthRate;
18
19
  exports.ConsecutiveDecrease = ConsecutiveDecrease;
@@ -672,6 +673,23 @@ function ChaikinMoneyFlow(asset, length = 20, interval = "Day") {
672
673
  d.window = { length: length, interval: interval };
673
674
  return d;
674
675
  }
676
+ /**
677
+ * ChartBar indicator.
678
+ * @param asset Ticker name (ex. SPY, BTC)
679
+ * @param barMinutes Completed candles aligned to 9:30 ET for stocks. Must divide the 390-minute regular session.
680
+ * @param line open: oldest selected candle; close: newest; high/low: range; sma: mean candle closes.
681
+ * @param bars Number of chart candles, not elapsed minutes. SMA20 on five-minute candles: barMinutes=5, bars=20.
682
+ * @param offsetBars Skip this many latest completed candles. 1 selects the previous window.
683
+ */
684
+ function ChartBar(asset, barMinutes = 5, line = "close", bars = 1, offsetBars = 0) {
685
+ const d = { type: "ChartBar" };
686
+ setAsset(d, "targetAsset", asset);
687
+ d["barMinutes"] = barMinutes;
688
+ d["line"] = line;
689
+ d["bars"] = bars;
690
+ d["offsetBars"] = offsetBars;
691
+ return d;
692
+ }
675
693
  /**
676
694
  * CommodityChannelIndex indicator.
677
695
  * @param asset Ticker name (ex. SPY, BTC)
@@ -72,12 +72,13 @@ export interface ReplaceStrategiesOperation {
72
72
  type: "replaceStrategies";
73
73
  strategyObjects: Strategy[];
74
74
  }
75
- /**
76
- * The edits `updatePortfolio` accepts. Deploy, undeploy, delete, scheduling and
77
- * trading-policy operations are deliberately absent: they are not reachable on
78
- * this route, so typing them here would only compile a guaranteed 403.
79
- */
80
- export type PortfolioEditOperation = PortfolioRenameOperation | AddStrategiesOperation | RemoveStrategiesOperation | ReplaceStrategyOperation | ReplaceStrategiesOperation;
75
+ /** Complete finished authored patch; omitted fields retain their saved values. */
76
+ export interface UpdatePortfolioOperation {
77
+ type: "updatePortfolio";
78
+ portfolio: Partial<Pick<Portfolio, "name" | "initialValue" | "strategies" | "deployment" | "policy" | "dividendPolicy" | "alertsEnabled" | "supportsFractionalShares" | "supportsCrypto">>;
79
+ }
80
+ /** All operations in one call for this portfolio are validated and saved atomically. */
81
+ export type PortfolioEditOperation = UpdatePortfolioOperation | PortfolioRenameOperation | AddStrategiesOperation | RemoveStrategiesOperation | ReplaceStrategyOperation | ReplaceStrategiesOperation;
81
82
  export interface ListOrdersOptions {
82
83
  portfolioId?: string;
83
84
  statuses?: ReadonlyArray<OrderStatus>;
@@ -268,8 +269,8 @@ export declare class NexusTradeClient {
268
269
  getPortfolio(portfolioId: string): Promise<PortfolioHandle>;
269
270
  /**
270
271
  * Apply deterministic no-code portfolio edits without invoking Aurora.
271
- * Guest workspaces may rename and add/remove/replace strategies; deployment,
272
- * scheduling, policy, and trading operations remain account-only.
272
+ * Finished authored patches can combine strategies, evaluation timing and
273
+ * stock eligibility in one save. Activation and automated approval remain separate.
273
274
  */
274
275
  updatePortfolio(portfolioId: string, operations: ReadonlyArray<PortfolioEditOperation>, options: {
275
276
  idempotencyKey: string;
@@ -857,8 +857,8 @@ export class NexusTradeClient {
857
857
  }
858
858
  /**
859
859
  * Apply deterministic no-code portfolio edits without invoking Aurora.
860
- * Guest workspaces may rename and add/remove/replace strategies; deployment,
861
- * scheduling, policy, and trading operations remain account-only.
860
+ * Finished authored patches can combine strategies, evaluation timing and
861
+ * stock eligibility in one save. Activation and automated approval remain separate.
862
862
  */
863
863
  async updatePortfolio(portfolioId, operations, options) {
864
864
  if (operations.length === 0) {
@@ -547,6 +547,12 @@ export interface AuthoredStockEligibility {
547
547
  export interface AuthoredPortfolioPolicy {
548
548
  stockEligibility: AuthoredStockEligibility;
549
549
  }
550
+ export interface AuthoredDeploymentTiming {
551
+ frequency: "Constant" | "OpenClose";
552
+ openDelayMinutes?: number;
553
+ closeLeadMinutes?: number;
554
+ intervalSeconds?: number;
555
+ }
550
556
  export interface Portfolio {
551
557
  name: string;
552
558
  initialValue?: number;
@@ -560,6 +566,7 @@ export interface Portfolio {
560
566
  /** "cash" (default when omitted) or "reinvest" into the paying stock. */
561
567
  dividendPolicy?: DividendPolicy;
562
568
  policy?: AuthoredPortfolioPolicy;
569
+ deployment?: AuthoredDeploymentTiming;
563
570
  }
564
571
  export type DividendPolicy = "cash" | "reinvest";
565
572
  export type AssetType = "Stock" | "Cryptocurrency" | "Option" | "Other";
@@ -848,6 +855,7 @@ export declare const portfolio: (name: string, strategies: Strategy[], options?:
848
855
  alertsEnabled?: boolean;
849
856
  dividendPolicy?: DividendPolicy;
850
857
  policy?: AuthoredPortfolioPolicy;
858
+ deployment?: AuthoredDeploymentTiming;
851
859
  }) => PortfolioHandle;
852
860
  /**
853
861
  * AbsoluteValue indicator.
@@ -904,6 +912,15 @@ export declare function BuyingPower(): Indicator;
904
912
  * @param interval Unit of time
905
913
  */
906
914
  export declare function ChaikinMoneyFlow(asset: AssetArg, length?: number, interval?: Interval): Indicator;
915
+ /**
916
+ * ChartBar indicator.
917
+ * @param asset Ticker name (ex. SPY, BTC)
918
+ * @param barMinutes Completed candles aligned to 9:30 ET for stocks. Must divide the 390-minute regular session.
919
+ * @param line open: oldest selected candle; close: newest; high/low: range; sma: mean candle closes.
920
+ * @param bars Number of chart candles, not elapsed minutes. SMA20 on five-minute candles: barMinutes=5, bars=20.
921
+ * @param offsetBars Skip this many latest completed candles. 1 selects the previous window.
922
+ */
923
+ export declare function ChartBar(asset: AssetArg, barMinutes?: number, line?: "open" | "high" | "low" | "close" | "sma", bars?: number, offsetBars?: number): Indicator;
907
924
  /**
908
925
  * CommodityChannelIndex indicator.
909
926
  * @param asset Ticker name (ex. SPY, BTC)
@@ -453,6 +453,23 @@ export function ChaikinMoneyFlow(asset, length = 20, interval = "Day") {
453
453
  d.window = { length: length, interval: interval };
454
454
  return d;
455
455
  }
456
+ /**
457
+ * ChartBar indicator.
458
+ * @param asset Ticker name (ex. SPY, BTC)
459
+ * @param barMinutes Completed candles aligned to 9:30 ET for stocks. Must divide the 390-minute regular session.
460
+ * @param line open: oldest selected candle; close: newest; high/low: range; sma: mean candle closes.
461
+ * @param bars Number of chart candles, not elapsed minutes. SMA20 on five-minute candles: barMinutes=5, bars=20.
462
+ * @param offsetBars Skip this many latest completed candles. 1 selects the previous window.
463
+ */
464
+ export function ChartBar(asset, barMinutes = 5, line = "close", bars = 1, offsetBars = 0) {
465
+ const d = { type: "ChartBar" };
466
+ setAsset(d, "targetAsset", asset);
467
+ d["barMinutes"] = barMinutes;
468
+ d["line"] = line;
469
+ d["bars"] = bars;
470
+ d["offsetBars"] = offsetBars;
471
+ return d;
472
+ }
456
473
  /**
457
474
  * CommodityChannelIndex indicator.
458
475
  * @param asset Ticker name (ex. SPY, BTC)
@@ -1,7 +1,7 @@
1
1
  export { AgentRun } from "./agent.js";
2
2
  export type { AgentEvent, AgentRunOptions } from "./agent.js";
3
3
  export { HttpTransport, NexusTradeApiError, NexusTradeClient, NexusTradeWorkspaceSessionExpiredError, createCustomIndicator, createPortfolio, waitForOperation, } from "./client.js";
4
- export type { AddStrategiesOperation, BacktestCollateralStatistics, CustomIndicatorInput, CustomIndicatorPointInput, HttpTransportOptions, JsonObject, JsonValue, ListOrdersOptions, ListPortfoliosOptions, NexusTradeClientOptions, PortfolioEditOperation, PortfolioRenameOperation, RemoveStrategiesOperation, ReplaceStrategiesOperation, ReplaceStrategyOperation, RequestOptions, Transport, UploadTransport, WaitOptions, WorkspaceSessionTransport, } from "./client.js";
4
+ export type { AddStrategiesOperation, BacktestCollateralStatistics, CustomIndicatorInput, CustomIndicatorPointInput, HttpTransportOptions, JsonObject, JsonValue, ListOrdersOptions, ListPortfoliosOptions, NexusTradeClientOptions, PortfolioEditOperation, UpdatePortfolioOperation, PortfolioRenameOperation, RemoveStrategiesOperation, ReplaceStrategiesOperation, ReplaceStrategyOperation, RequestOptions, Transport, UploadTransport, WaitOptions, WorkspaceSessionTransport, } from "./client.js";
5
5
  export { PortfolioHandle, portfolioHandleFromWire, } from "./portfolio.js";
6
6
  export type { DeployOutcome, DeployResult, PortfolioHandleOptions, PortfolioListResult, PortfolioType, ReadonlyPortfolioPolicy, } from "./portfolio.js";
7
7
  export * from "./generated/ntSdk.generated.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexustrade",
3
- "version": "1.42.0",
3
+ "version": "1.52.0",
4
4
  "description": "Typed TypeScript SDK for NexusTrade portfolio authoring, backtesting, and optimization",
5
5
  "license": "MIT",
6
6
  "author": "Starks Technology",