nexustrade 0.1.0 → 0.3.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.
@@ -5,7 +5,9 @@
5
5
  * surfaces stay identical. Transport-generic: callers pass an API key/base URL,
6
6
  * or set NEXUSTRADE_API_KEY / NEXUSTRADE_API_BASE_URL.
7
7
  */
8
+ import { AgentRun } from "./agent.ts";
8
9
  import type { JobRequest, Portfolio } from "./generated/ntSdk.generated.js";
10
+ import { PortfolioHandle, type DeployResult, type PortfolioListResult } from "./portfolio.ts";
9
11
  export type JsonValue = string | number | boolean | null | JsonValue[] | {
10
12
  [key: string]: JsonValue;
11
13
  };
@@ -24,6 +26,22 @@ export type JsonObject = {
24
26
  */
25
27
  export type PortfolioInput = Portfolio | JsonObject;
26
28
  export type JobInput = JobRequest | JsonObject;
29
+ export interface ListPortfoliosOptions {
30
+ portfolioIds?: string[];
31
+ includeInactive?: boolean;
32
+ includePaper?: boolean;
33
+ includeLive?: boolean;
34
+ includeChatPortfolios?: boolean;
35
+ includePositions?: boolean;
36
+ search?: string;
37
+ limit?: number;
38
+ page?: number;
39
+ }
40
+ export declare const NO_HTTP_STATUS = 0;
41
+ export declare const DEFAULT_POLL_TIMEOUT_SECONDS = 900;
42
+ export declare const DEFAULT_POLL_INTERVAL_SECONDS = 2;
43
+ export declare const MAX_POLL_INTERVAL_SECONDS = 15;
44
+ export declare const POLL_BACKOFF_FACTOR = 1.5;
27
45
  export declare class NexusTradeApiError extends Error {
28
46
  readonly status: number;
29
47
  readonly code: string;
@@ -92,6 +110,17 @@ export declare class NexusTradeClient {
92
110
  createPortfolio(portfolio: PortfolioInput, options: {
93
111
  idempotencyKey: string;
94
112
  }): Promise<JsonObject>;
113
+ /**
114
+ * List portfolios. Mirrors MCP `fetch_portfolios` (boolean includes, page/limit).
115
+ * `includePositions` defaults off when `search` is set.
116
+ */
117
+ listPortfolios(options?: ListPortfoliosOptions): Promise<PortfolioListResult>;
118
+ getPortfolio(portfolioId: string): Promise<PortfolioHandle>;
119
+ /** Mint/activate a paper portfolio from a chat draft (or re-activate). */
120
+ deploy(portfolioId: string, options?: {
121
+ frequency?: string;
122
+ }): Promise<DeployResult>;
123
+ undeploy(portfolioId: string): Promise<JsonObject>;
95
124
  createBacktests(backtests: ReadonlyArray<JobInput>, options: {
96
125
  idempotencyKey: string;
97
126
  }): Promise<JsonObject[]>;
@@ -99,6 +128,27 @@ export declare class NexusTradeClient {
99
128
  createBacktest(backtest: JobInput, options: {
100
129
  idempotencyKey: string;
101
130
  }): Promise<JsonObject>;
131
+ /**
132
+ * Start an agent run and return an iterable handle.
133
+ *
134
+ * Unlike the other job kinds this is not fire-and-poll: iterate the run to
135
+ * receive its events, and answer it when it asks. See `AgentRun`.
136
+ */
137
+ createAgent(prompt: string, options: {
138
+ idempotencyKey: string;
139
+ maxIterations?: number;
140
+ }): Promise<AgentRun>;
141
+ /**
142
+ * Reattach to a run already in flight.
143
+ *
144
+ * The run lives server-side and bills whether or not anyone is listening, so
145
+ * a dropped connection must not orphan it. Omit `cursor` to replay from the
146
+ * beginning; events are durable, so replay is exact.
147
+ */
148
+ attachAgent(agentId: string, options?: {
149
+ cursor?: string;
150
+ }): Promise<AgentRun>;
151
+ getAgent(agentId: string): Promise<JsonObject>;
102
152
  getBacktest(backtestId: string): Promise<JsonObject>;
103
153
  createOptimization(handle: JobInput, options: {
104
154
  idempotencyKey: string;
@@ -133,6 +183,8 @@ export declare class NexusTradeClient {
133
183
  waitForBacktests(operations: ReadonlyArray<JsonObject>, options?: WaitOptions): Promise<JsonObject[]>;
134
184
  private createPortfolioJob;
135
185
  }
186
+ /** @internal PortfolioHandle lazy-client attachment. */
187
+ export declare function clientTransport(client: NexusTradeClient): Transport;
136
188
  /** Convenience wrapper for scripts that do not need a persistent client. */
137
189
  export declare function createPortfolio(portfolio: JsonObject, options: {
138
190
  idempotencyKey: string;
@@ -5,11 +5,29 @@
5
5
  * surfaces stay identical. Transport-generic: callers pass an API key/base URL,
6
6
  * or set NEXUSTRADE_API_KEY / NEXUSTRADE_API_BASE_URL.
7
7
  */
8
- import { environmentValue, loadDotenvValues } from "./env.js";
8
+ import { AgentRun } from "./agent.js";
9
+ import { LazyDotenv, environmentValue } from "./env.js";
10
+ import { portfolioHandleFromWire, } from "./portfolio.js";
9
11
  /** Boundary adapter: builder output is JSON by construction. */
10
12
  function asJsonObject(value) {
13
+ // PortfolioHandle.toJSON() omits `id`; a bare cast would leak it.
14
+ if (value && typeof value === "object" && "toJSON" in value) {
15
+ const candidate = value;
16
+ if (typeof candidate.toJSON === "function") {
17
+ return candidate.toJSON();
18
+ }
19
+ }
11
20
  return value;
12
21
  }
22
+ function encodeQuery(params) {
23
+ const search = new URLSearchParams();
24
+ for (const [key, value] of Object.entries(params)) {
25
+ if (value !== undefined && value !== "")
26
+ search.set(key, value);
27
+ }
28
+ const encoded = search.toString();
29
+ return encoded ? `?${encoded}` : "";
30
+ }
13
31
  const MAX_RESPONSE_BYTES = 16 * 1024 * 1024;
14
32
  const MAX_ERROR_BYTES = 64 * 1024;
15
33
  // Keep in lockstep with _MAX_REDIRECTS in sdk/python/nexustrade/client.py —
@@ -18,16 +36,16 @@ const MAX_REDIRECTS = 5;
18
36
  // `status` for errors no HTTP status describes: the request never reached the
19
37
  // API, or it returned 2xx with an envelope the client could not use. Reporting
20
38
  // a literal 200 there would misattribute a 201 response.
21
- const NO_HTTP_STATUS = 0;
39
+ export const NO_HTTP_STATUS = 0;
22
40
  // Polling defaults. Every NexusTrade job — backtest, optimization,
23
41
  // walk-forward, and any future operation kind — reports through the same
24
42
  // envelope, so one poller serves all of them. Kept in lockstep with the Python
25
43
  // SDK by checkSdkClientParity.ts; the backoff is deterministic (no jitter) so
26
44
  // both languages issue the identical request sequence.
27
- const DEFAULT_POLL_TIMEOUT_SECONDS = 900;
28
- const DEFAULT_POLL_INTERVAL_SECONDS = 2;
29
- const MAX_POLL_INTERVAL_SECONDS = 15;
30
- const POLL_BACKOFF_FACTOR = 1.5;
45
+ export const DEFAULT_POLL_TIMEOUT_SECONDS = 900;
46
+ export const DEFAULT_POLL_INTERVAL_SECONDS = 2;
47
+ export const MAX_POLL_INTERVAL_SECONDS = 15;
48
+ export const POLL_BACKOFF_FACTOR = 1.5;
31
49
  const TERMINAL_STATUSES = ["cancelled", "completed", "failed"];
32
50
  export class NexusTradeApiError extends Error {
33
51
  status;
@@ -335,9 +353,10 @@ export class NexusTradeClient {
335
353
  this.transport = options.transport;
336
354
  return;
337
355
  }
338
- // Read the file once, so a two-variable lookup does not walk the tree
339
- // twice and cannot see two different files mid-resolution.
340
- const dotenv = loadDotenvValues();
356
+ // Lazy and memoized: the tree is walked at most once, and not at all when
357
+ // the environment already answers — which is always true inside
358
+ // run_compute, where the platform injects both variables.
359
+ const dotenv = new LazyDotenv();
341
360
  const apiKey = options.apiKey ?? environmentValue("NEXUSTRADE_API_KEY", dotenv);
342
361
  const baseUrl = options.baseUrl ?? environmentValue("NEXUSTRADE_API_BASE_URL", dotenv);
343
362
  if (!apiKey || !baseUrl) {
@@ -365,6 +384,86 @@ export class NexusTradeClient {
365
384
  }
366
385
  return result;
367
386
  }
387
+ /**
388
+ * List portfolios. Mirrors MCP `fetch_portfolios` (boolean includes, page/limit).
389
+ * `includePositions` defaults off when `search` is set.
390
+ */
391
+ async listPortfolios(options = {}) {
392
+ const query = encodeQuery({
393
+ portfolioIds: options.portfolioIds?.join(","),
394
+ includeInactive: options.includeInactive === undefined
395
+ ? undefined
396
+ : String(options.includeInactive),
397
+ includePaper: options.includePaper === undefined
398
+ ? undefined
399
+ : String(options.includePaper),
400
+ includeLive: options.includeLive === undefined
401
+ ? undefined
402
+ : String(options.includeLive),
403
+ includeChatPortfolios: options.includeChatPortfolios === undefined
404
+ ? undefined
405
+ : String(options.includeChatPortfolios),
406
+ includePositions: options.includePositions === undefined
407
+ ? undefined
408
+ : String(options.includePositions),
409
+ search: options.search,
410
+ limit: options.limit === undefined ? undefined : String(options.limit),
411
+ page: options.page === undefined ? undefined : String(options.page),
412
+ });
413
+ const response = await this.transport.request("GET", `portfolios${query}`);
414
+ const rows = response.portfolios;
415
+ if (!Array.isArray(rows)) {
416
+ throw new NexusTradeApiError(NO_HTTP_STATUS, "invalid_response", "Portfolio list response is missing portfolios.");
417
+ }
418
+ return {
419
+ portfolios: rows.map((row) => portfolioHandleFromWire(row, { transport: this.transport })),
420
+ page: typeof response.page === "number" ? response.page : 1,
421
+ limit: typeof response.limit === "number" ? response.limit : 20,
422
+ total: typeof response.total === "number" ? response.total : rows.length,
423
+ totalPages: typeof response.totalPages === "number" ? response.totalPages : 1,
424
+ scopes: isJsonObject(response.scopes) ? response.scopes : undefined,
425
+ };
426
+ }
427
+ async getPortfolio(portfolioId) {
428
+ const response = await this.transport.request("GET", `portfolios/${encodePathSegment(portfolioId)}`);
429
+ const portfolio = response.portfolio;
430
+ if (!isJsonObject(portfolio)) {
431
+ throw new NexusTradeApiError(NO_HTTP_STATUS, "invalid_response", "Portfolio response is missing portfolio.");
432
+ }
433
+ return portfolioHandleFromWire(portfolio, {
434
+ transport: this.transport,
435
+ });
436
+ }
437
+ /** Mint/activate a paper portfolio from a chat draft (or re-activate). */
438
+ async deploy(portfolioId, options = {}) {
439
+ const body = {};
440
+ if (options.frequency !== undefined)
441
+ body.frequency = options.frequency;
442
+ const response = await this.transport.request("POST", `portfolios/${encodePathSegment(portfolioId)}/deploy`, { body });
443
+ const result = response.deployment ?? response;
444
+ if (!isJsonObject(result) || typeof result.portfolioId !== "string") {
445
+ throw new NexusTradeApiError(NO_HTTP_STATUS, "invalid_response", "Deploy response is missing portfolioId.");
446
+ }
447
+ return {
448
+ portfolioId: String(result.portfolioId),
449
+ chatPortfolioId: typeof result.chatPortfolioId === "string"
450
+ ? result.chatPortfolioId
451
+ : undefined,
452
+ name: typeof result.name === "string" ? result.name : "",
453
+ outcome: typeof result.outcome === "string" ? result.outcome : "",
454
+ deploymentType: typeof result.deploymentType === "string"
455
+ ? result.deploymentType
456
+ : undefined,
457
+ };
458
+ }
459
+ async undeploy(portfolioId) {
460
+ const response = await this.transport.request("POST", `portfolios/${encodePathSegment(portfolioId)}/undeploy`, { body: {} });
461
+ const result = response.undeployment ?? response;
462
+ if (!isJsonObject(result)) {
463
+ throw new NexusTradeApiError(NO_HTTP_STATUS, "invalid_response", "Undeploy response is missing body.");
464
+ }
465
+ return result;
466
+ }
368
467
  async createBacktests(backtests, options) {
369
468
  const inputs = backtests.map((item) => backtestInput(asJsonObject(item)));
370
469
  const response = await this.transport.request("POST", "backtests/batch", {
@@ -386,6 +485,49 @@ export class NexusTradeClient {
386
485
  }
387
486
  return operations[0];
388
487
  }
488
+ /**
489
+ * Start an agent run and return an iterable handle.
490
+ *
491
+ * Unlike the other job kinds this is not fire-and-poll: iterate the run to
492
+ * receive its events, and answer it when it asks. See `AgentRun`.
493
+ */
494
+ async createAgent(prompt, options) {
495
+ const body = { prompt };
496
+ if (options.maxIterations !== undefined) {
497
+ body.maxIterations = options.maxIterations;
498
+ }
499
+ const response = await this.transport.request("POST", "agents", {
500
+ body,
501
+ idempotencyKey: options.idempotencyKey,
502
+ });
503
+ const agent = response.agent;
504
+ if (!isJsonObject(agent) || !agent.id) {
505
+ throw new NexusTradeApiError(NO_HTTP_STATUS, "invalid_response", "Agent response is missing agent.");
506
+ }
507
+ return new AgentRun(String(agent.id), this.transport, typeof agent.status === "string" ? agent.status : "initializing");
508
+ }
509
+ /**
510
+ * Reattach to a run already in flight.
511
+ *
512
+ * The run lives server-side and bills whether or not anyone is listening, so
513
+ * a dropped connection must not orphan it. Omit `cursor` to replay from the
514
+ * beginning; events are durable, so replay is exact.
515
+ */
516
+ async attachAgent(agentId, options = {}) {
517
+ const agent = await this.getAgent(agentId);
518
+ const run = new AgentRun(typeof agent.id === "string" ? agent.id : agentId, this.transport, typeof agent.status === "string" ? agent.status : "initializing");
519
+ run.terminal = Boolean(agent.terminal);
520
+ run.setCursor(options.cursor ?? null);
521
+ return run;
522
+ }
523
+ async getAgent(agentId) {
524
+ const response = await this.transport.request("GET", `agents/${encodeURIComponent(agentId)}`);
525
+ const agent = response.agent;
526
+ if (!isJsonObject(agent)) {
527
+ throw new NexusTradeApiError(NO_HTTP_STATUS, "invalid_response", "Agent response is missing agent.");
528
+ }
529
+ return agent;
530
+ }
389
531
  async getBacktest(backtestId) {
390
532
  const response = await this.transport.request("GET", `backtests/${encodePathSegment(backtestId)}`);
391
533
  return operationOf(response);
@@ -484,6 +626,11 @@ export class NexusTradeClient {
484
626
  function backtestInput(item) {
485
627
  const tool = item.tool;
486
628
  if (tool === undefined || tool === null) {
629
+ // Prefer portfolioId over an inline body when both are present.
630
+ if (typeof item.portfolioId === "string" && item.portfolioId) {
631
+ const { portfolio: _ignored, ...rest } = item;
632
+ return { ...rest, portfolioId: item.portfolioId };
633
+ }
487
634
  return { ...item };
488
635
  }
489
636
  if (tool !== "backtest_portfolio") {
@@ -510,6 +657,10 @@ function operationOf(response) {
510
657
  }
511
658
  return operation;
512
659
  }
660
+ /** @internal PortfolioHandle lazy-client attachment. */
661
+ export function clientTransport(client) {
662
+ return client.transport;
663
+ }
513
664
  /** Convenience wrapper for scripts that do not need a persistent client. */
514
665
  export async function createPortfolio(portfolio, options) {
515
666
  const client = options.client ?? NexusTradeClient.fromEnvironment();
package/dist/esm/env.d.ts CHANGED
@@ -45,5 +45,20 @@ export declare function parseDotenv(text: string): Record<string, string>;
45
45
  export declare function findDotenv(start?: string): string | null;
46
46
  /** Values from the nearest `.env`. Never throws; unreadable means empty. */
47
47
  export declare function loadDotenvValues(start?: string): Record<string, string>;
48
+ /**
49
+ * Reads the `.env` at most once, and only if something actually needs it.
50
+ *
51
+ * The file walk is skipped entirely when the environment already answers —
52
+ * which is always the case inside `run_compute`, where the platform injects the
53
+ * variables. Constructing a client should not stat up to 32 directories to
54
+ * discover a file it was never going to consult.
55
+ */
56
+ export declare class LazyDotenv {
57
+ #private;
58
+ constructor(start?: string);
59
+ get(name: string): string | undefined;
60
+ /** True once the file has actually been read. Used by tests. */
61
+ get loaded(): boolean;
62
+ }
48
63
  /** `process.env` first, then `.env`. Blank is treated as absent. */
49
- export declare function environmentValue(name: string, dotenv?: Record<string, string>): string | undefined;
64
+ export declare function environmentValue(name: string, dotenv?: LazyDotenv | Record<string, string>): string | undefined;
package/dist/esm/env.js CHANGED
@@ -140,12 +140,36 @@ export function loadDotenvValues(start) {
140
140
  return {};
141
141
  }
142
142
  }
143
+ /**
144
+ * Reads the `.env` at most once, and only if something actually needs it.
145
+ *
146
+ * The file walk is skipped entirely when the environment already answers —
147
+ * which is always the case inside `run_compute`, where the platform injects the
148
+ * variables. Constructing a client should not stat up to 32 directories to
149
+ * discover a file it was never going to consult.
150
+ */
151
+ export class LazyDotenv {
152
+ #values = null;
153
+ #start;
154
+ constructor(start) {
155
+ this.#start = start;
156
+ }
157
+ get(name) {
158
+ if (this.#values === null)
159
+ this.#values = loadDotenvValues(this.#start);
160
+ return this.#values[name];
161
+ }
162
+ /** True once the file has actually been read. Used by tests. */
163
+ get loaded() {
164
+ return this.#values !== null;
165
+ }
166
+ }
143
167
  /** `process.env` first, then `.env`. Blank is treated as absent. */
144
168
  export function environmentValue(name, dotenv) {
145
169
  const live = process.env[name];
146
170
  if (live && live.trim())
147
171
  return live;
148
- const values = dotenv ?? loadDotenvValues();
149
- const fallback = values[name];
172
+ const source = dotenv ?? new LazyDotenv();
173
+ const fallback = source instanceof LazyDotenv ? source.get(name) : source[name];
150
174
  return fallback && fallback.trim() ? fallback : undefined;
151
175
  }
@@ -1,3 +1,4 @@
1
+ import { PortfolioHandle } from "../portfolio.ts";
1
2
  export interface Asset {
2
3
  type: AssetType;
3
4
  symbol: string;
@@ -527,7 +528,7 @@ export declare const portfolio: (name: string, strategies: Strategy[], options?:
527
528
  supportsFractionalShares?: boolean;
528
529
  supportsCrypto?: boolean;
529
530
  alertsEnabled?: boolean;
530
- }) => Portfolio;
531
+ }) => PortfolioHandle;
531
532
  /**
532
533
  * AbsoluteValue indicator.
533
534
  */
@@ -1,6 +1,4 @@
1
- /* eslint-disable */
2
- // GENERATED by src/scripts/codegen/generateNtSdk.ts — do not edit by hand.
3
- // Regenerate: cd server && npx ts-node src/scripts/codegen/generateNtSdk.ts
1
+ import { PortfolioHandle } from "../portfolio.js";
4
2
  export const CANDIDATE = { __candidate: true };
5
3
  /** Portfolio-wide targetAssets: [] — rebalance cadence, not per-ticker DCA. */
6
4
  export const PORTFOLIO_WIDE = { __portfolioWide: true };
@@ -213,7 +211,7 @@ export const strategy = (name, condition, action, options = {}) => compact({ nam
213
211
  * Book-level only — CandidateCondition is rejected (same as strategy when).
214
212
  */
215
213
  export const sessionFlatten = (condition, config = {}, name = "Session flatten") => strategy(name, condition, closeOption({ ...config }));
216
- export const portfolio = (name, strategies, options = {}) => compact({ name, initialValue: 10000, ...options, strategies });
214
+ export const portfolio = (name, strategies, options = {}) => new PortfolioHandle(compact({ name, initialValue: 10000, ...options, strategies }));
217
215
  // ---- generated indicator builders ----
218
216
  /**
219
217
  * AbsoluteValue indicator.
@@ -1,3 +1,7 @@
1
+ export { AgentRun } from "./agent.js";
2
+ export type { AgentEvent, AgentRunOptions } from "./agent.js";
1
3
  export { HttpTransport, NexusTradeApiError, NexusTradeClient, createPortfolio, waitForOperation, } from "./client.js";
2
- export type { HttpTransportOptions, JsonObject, JsonValue, NexusTradeClientOptions, RequestOptions, Transport, WaitOptions, } from "./client.js";
4
+ export type { HttpTransportOptions, JsonObject, JsonValue, ListPortfoliosOptions, NexusTradeClientOptions, RequestOptions, Transport, WaitOptions, } from "./client.js";
5
+ export { PortfolioHandle, portfolioHandleFromWire, } from "./portfolio.js";
6
+ export type { DeployOutcome, DeployResult, PortfolioHandleOptions, PortfolioListResult, PortfolioType, } from "./portfolio.js";
3
7
  export * from "./generated/ntSdk.generated.js";
package/dist/esm/index.js CHANGED
@@ -1,2 +1,4 @@
1
+ export { AgentRun } from "./agent.js";
1
2
  export { HttpTransport, NexusTradeApiError, NexusTradeClient, createPortfolio, waitForOperation, } from "./client.js";
3
+ export { PortfolioHandle, portfolioHandleFromWire, } from "./portfolio.js";
2
4
  export * from "./generated/ntSdk.generated.js";
@@ -0,0 +1,89 @@
1
+ /**
2
+ * PortfolioHandle — one object you author, save, deploy, fetch, and backtest.
3
+ *
4
+ * Keeps the generated `Portfolio` interface as the shape; this class adds
5
+ * lifecycle methods. `toJSON()` omits `id` so request bodies never leak
6
+ * `"id": null`. Mirrors `portfolio_handle.py`.
7
+ *
8
+ * Holds a `Transport` (same pattern as `AgentRun`) so the generated builder can
9
+ * import this module without a cycle through `client.ts`.
10
+ *
11
+ * See designs/2026-07-26-sdk-portfolio-objects.md.
12
+ */
13
+ import { type JsonObject, type Transport } from "./client.ts";
14
+ import type { Portfolio, Strategy } from "./generated/ntSdk.generated.js";
15
+ export type PortfolioType = "paper" | "live" | "chat";
16
+ export type DeployOutcome = "minted" | "reactivated" | "already_active" | "seed_recovered";
17
+ export interface DeployResult {
18
+ /** Real paper/live id — different from the draft id set by `save()`. */
19
+ portfolioId: string;
20
+ chatPortfolioId?: string;
21
+ name: string;
22
+ outcome: DeployOutcome | string;
23
+ deploymentType?: string;
24
+ }
25
+ export interface PortfolioListResult {
26
+ portfolios: PortfolioHandle[];
27
+ page: number;
28
+ limit: number;
29
+ total: number;
30
+ totalPages: number;
31
+ scopes?: JsonObject;
32
+ }
33
+ export interface PortfolioHandleOptions {
34
+ id?: string | null;
35
+ transport?: Transport;
36
+ }
37
+ /** Runtime portfolio object. Implements the generated `Portfolio` shape. */
38
+ export declare class PortfolioHandle implements Portfolio {
39
+ #private;
40
+ name: string;
41
+ initialValue?: number;
42
+ strategies: Strategy[];
43
+ main?: boolean;
44
+ supportsFractionalShares?: boolean;
45
+ supportsCrypto?: boolean;
46
+ alertsEnabled?: boolean;
47
+ /** Chat draft id after `save()`, or fetched portfolio id. Not serialized. */
48
+ id: string | null;
49
+ /** Present on list/get summaries: paper | live | chat. */
50
+ type?: PortfolioType;
51
+ isActive?: boolean;
52
+ strategyNames?: string[];
53
+ createdAt?: string;
54
+ updatedAt?: string;
55
+ brokerage?: string;
56
+ constructor(data: Portfolio | JsonObject, options?: PortfolioHandleOptions);
57
+ static from(data: Portfolio | JsonObject, options?: PortfolioHandleOptions): PortfolioHandle;
58
+ /** Omit `id` — class fields would otherwise serialize as `"id": null`. */
59
+ toJSON(): JsonObject;
60
+ /** Persist as a chat draft. Sets `.id` to the ChatPortfolio id. */
61
+ save(options: {
62
+ idempotencyKey: string;
63
+ transport?: Transport;
64
+ }): Promise<PortfolioHandle>;
65
+ /**
66
+ * Mint/activate the real paper portfolio.
67
+ * Returns a *different* id than `save()` — see `DeployResult.portfolioId`.
68
+ */
69
+ deploy(options?: {
70
+ frequency?: string;
71
+ transport?: Transport;
72
+ }): Promise<DeployResult>;
73
+ undeploy(options?: {
74
+ transport?: Transport;
75
+ }): Promise<JsonObject>;
76
+ /** By id once saved; inline body before. */
77
+ backtest(options: {
78
+ startDate: string;
79
+ endDate: string;
80
+ idempotencyKey: string;
81
+ baseline?: string;
82
+ interval?: string;
83
+ initialValue?: number;
84
+ generateEvents?: boolean;
85
+ feeConfig?: JsonObject;
86
+ transport?: Transport;
87
+ }): Promise<JsonObject>;
88
+ }
89
+ export declare function portfolioHandleFromWire(data: unknown, options?: PortfolioHandleOptions): PortfolioHandle;