@adaptic/utils 0.0.963 → 0.0.965

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.
Files changed (58) hide show
  1. package/dist/index.cjs +120 -56
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.mjs +120 -56
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/test.js +15 -2
  6. package/dist/test.js.map +1 -1
  7. package/dist/types/adaptic.d.ts.map +1 -1
  8. package/dist/types/alpaca/client.d.ts.map +1 -1
  9. package/dist/types/alpaca/crypto/data.d.ts.map +1 -1
  10. package/dist/types/alpaca/crypto/orders.d.ts.map +1 -1
  11. package/dist/types/alpaca/market-data/news.d.ts.map +1 -1
  12. package/dist/types/alpaca/streams/stream-manager.d.ts.map +1 -1
  13. package/dist/types/alpaca/trading/account.d.ts.map +1 -1
  14. package/dist/types/alpaca/trading/order-utils.d.ts.map +1 -1
  15. package/dist/types/alpaca/trading/orders.d.ts.map +1 -1
  16. package/dist/types/alpaca/trading/positions.d.ts.map +1 -1
  17. package/dist/types/alpaca/trading/smart-orders.d.ts.map +1 -1
  18. package/dist/types/alpaca/trading/trailing-stops.d.ts.map +1 -1
  19. package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
  20. package/dist/types/alpaca-trading-api.d.ts +4 -2
  21. package/dist/types/alpaca-trading-api.d.ts.map +1 -1
  22. package/dist/types/display-manager.d.ts.map +1 -1
  23. package/dist/types/index.d.ts +14 -14
  24. package/dist/types/index.d.ts.map +1 -1
  25. package/dist/types/logging.d.ts.map +1 -1
  26. package/dist/types/schemas/index.d.ts +4 -4
  27. package/dist/types/schemas/index.d.ts.map +1 -1
  28. package/dist/types/technical-analysis.d.ts.map +1 -1
  29. package/dist/types/trading-policy/defaults/default-trading-policy.d.ts +1 -1
  30. package/dist/types/trading-policy/defaults/default-trading-policy.d.ts.map +1 -1
  31. package/dist/types/trading-policy/index.d.ts +3 -3
  32. package/dist/types/trading-policy/schemas/asset-universe-prefs.schema.d.ts +1 -1
  33. package/dist/types/trading-policy/schemas/asset-universe-prefs.schema.d.ts.map +1 -1
  34. package/dist/types/trading-policy/schemas/audit-notification-prefs.schema.d.ts +1 -1
  35. package/dist/types/trading-policy/schemas/audit-notification-prefs.schema.d.ts.map +1 -1
  36. package/dist/types/trading-policy/schemas/autonomy-prefs.schema.d.ts +1 -1
  37. package/dist/types/trading-policy/schemas/autonomy-prefs.schema.d.ts.map +1 -1
  38. package/dist/types/trading-policy/schemas/effective-policy.schema.d.ts +2 -2
  39. package/dist/types/trading-policy/schemas/effective-policy.schema.d.ts.map +1 -1
  40. package/dist/types/trading-policy/schemas/execution-prefs.schema.d.ts +1 -1
  41. package/dist/types/trading-policy/schemas/execution-prefs.schema.d.ts.map +1 -1
  42. package/dist/types/trading-policy/schemas/index.d.ts +12 -12
  43. package/dist/types/trading-policy/schemas/index.d.ts.map +1 -1
  44. package/dist/types/trading-policy/schemas/model-prefs.schema.d.ts +2 -2
  45. package/dist/types/trading-policy/schemas/model-prefs.schema.d.ts.map +1 -1
  46. package/dist/types/trading-policy/schemas/overlay-response-prefs.schema.d.ts +2 -2
  47. package/dist/types/trading-policy/schemas/overlay-response-prefs.schema.d.ts.map +1 -1
  48. package/dist/types/trading-policy/schemas/policy-mutation.schema.d.ts +2 -2
  49. package/dist/types/trading-policy/schemas/policy-mutation.schema.d.ts.map +1 -1
  50. package/dist/types/trading-policy/schemas/portfolio-construction-prefs.schema.d.ts +1 -1
  51. package/dist/types/trading-policy/schemas/portfolio-construction-prefs.schema.d.ts.map +1 -1
  52. package/dist/types/trading-policy/schemas/position-management-prefs.schema.d.ts +1 -1
  53. package/dist/types/trading-policy/schemas/position-management-prefs.schema.d.ts.map +1 -1
  54. package/dist/types/trading-policy/schemas/risk-budget-prefs.schema.d.ts +1 -1
  55. package/dist/types/trading-policy/schemas/signal-consumption-prefs.schema.d.ts +1 -1
  56. package/dist/types/trading-policy/schemas/signal-consumption-prefs.schema.d.ts.map +1 -1
  57. package/dist/types/types/alpaca-types.d.ts.map +1 -1
  58. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -2185,7 +2185,18 @@ const log$l = (message, options = { type: "info" }) => {
2185
2185
  };
2186
2186
  // Default settings for market data API
2187
2187
  const DEFAULT_ADJUSTMENT = "all";
2188
- const DEFAULT_FEED$1 = "sip";
2188
+ // Data feed tier. SIP is full US-market-consolidated feed (requires a paid
2189
+ // Alpaca market-data subscription). IEX is the free tier — single-exchange,
2190
+ // delayed. Engine deploys running on IEX-only accounts hit chronic HTTP 403
2191
+ // ("subscription does not permit querying recent SIP data") at ~100/min when
2192
+ // this defaulted to "sip", which saturated Railway's per-replica log ingest
2193
+ // and hid steady-state signal. The ALPACA_MARKET_DATA_FEED env var overrides
2194
+ // the default. Fall back to "iex" so the free tier is safe by default; LIVE
2195
+ // deployments with SIP entitlements set ALPACA_MARKET_DATA_FEED=sip in their
2196
+ // environment to restore full data access. Per-call overrides (the optional
2197
+ // `feed` argument on getOptions*/getLatestBars/etc.) still win.
2198
+ const DEFAULT_FEED$1 = (process.env.ALPACA_MARKET_DATA_FEED ||
2199
+ "iex");
2189
2200
  const DEFAULT_CURRENCY$1 = "USD";
2190
2201
  /**
2191
2202
  * Singleton class for interacting with Alpaca Market Data API
@@ -2364,7 +2375,9 @@ class AlpacaMarketDataAPI extends EventEmitter {
2364
2375
  }
2365
2376
  });
2366
2377
  ws.on("close", (code) => {
2367
- log$l(`${streamType} stream disconnected (code: ${code})`, { type: "warn" });
2378
+ log$l(`${streamType} stream disconnected (code: ${code})`, {
2379
+ type: "warn",
2380
+ });
2368
2381
  if (streamType === "stock") {
2369
2382
  this.stockWs = null;
2370
2383
  }
@@ -3684,13 +3697,14 @@ class AlpacaTradingAPI {
3684
3697
  * @param side (string) - the side of the order
3685
3698
  * @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
3686
3699
  * @param position_intent (string) - the position intent of the order
3700
+ * @returns The created AlpacaOrder with order ID and details
3687
3701
  */
3688
3702
  async createTrailingStop(symbol, qty, side, trailPercent100, position_intent) {
3689
3703
  this.log(`Creating trailing stop ${side.toUpperCase()} ${qty} shares for ${symbol} with trail percent ${trailPercent100}%`, {
3690
3704
  symbol,
3691
3705
  });
3692
3706
  try {
3693
- await this.makeRequest(`/orders`, "POST", {
3707
+ const order = await this.makeRequest(`/orders`, "POST", {
3694
3708
  symbol,
3695
3709
  qty: Math.abs(qty),
3696
3710
  side,
@@ -3700,6 +3714,8 @@ class AlpacaTradingAPI {
3700
3714
  trail_percent: trailPercent100, // Already in decimal form (e.g., 4 for 4%)
3701
3715
  time_in_force: "gtc",
3702
3716
  });
3717
+ this.log(`Trailing stop order created for ${symbol}: orderId=${order.id}, trailPercent=${trailPercent100}%`, { symbol });
3718
+ return order;
3703
3719
  }
3704
3720
  catch (error) {
3705
3721
  this.log(`Error creating trailing stop: ${error}`, {
@@ -3781,6 +3797,7 @@ class AlpacaTradingAPI {
3781
3797
  * Update the trail percent for a trailing stop order
3782
3798
  * @param symbol (string) - the symbol of the order
3783
3799
  * @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
3800
+ * @returns The updated/replaced order from Alpaca, or null if no order found or no update needed
3784
3801
  */
3785
3802
  async updateTrailingStop(symbol, trailPercent100) {
3786
3803
  // First get all open orders for this symbol
@@ -3795,7 +3812,7 @@ class AlpacaTradingAPI {
3795
3812
  type: "error",
3796
3813
  symbol,
3797
3814
  });
3798
- return;
3815
+ return null;
3799
3816
  }
3800
3817
  // Check if the trail_percent is already set to the desired value
3801
3818
  const currentTrailPercent = trailingStopOrder.trail_percent
@@ -3808,15 +3825,19 @@ class AlpacaTradingAPI {
3808
3825
  this.log(`Trailing stop for ${symbol} already set to ${trailPercent100}% (current: ${currentTrailPercent}%), skipping update`, {
3809
3826
  symbol,
3810
3827
  });
3811
- return;
3828
+ return null;
3812
3829
  }
3813
- this.log(`Updating trailing stop for ${symbol} from ${currentTrailPercent}% to ${trailPercent100}%`, {
3830
+ const originalOrderId = trailingStopOrder.id;
3831
+ this.log(`Updating trailing stop for ${symbol} from ${currentTrailPercent}% to ${trailPercent100}% (orderId=${originalOrderId})`, {
3814
3832
  symbol,
3815
3833
  });
3816
3834
  try {
3817
- await this.makeRequest(`/orders/${trailingStopOrder.id}`, "PATCH", {
3818
- trail: trailPercent100.toString(), // Changed from trail_percent to trail
3835
+ const updatedOrder = await this.makeRequest(`/orders/${trailingStopOrder.id}`, "PATCH", {
3836
+ trail: trailPercent100.toString(),
3819
3837
  });
3838
+ // Log the replacement: Alpaca replaces orders on PATCH, so new ID is returned
3839
+ this.log(`Trailing stop updated for ${symbol}: newOrderId=${updatedOrder.id}, replaces=${updatedOrder.replaces || originalOrderId}`, { symbol });
3840
+ return updatedOrder;
3820
3841
  }
3821
3842
  catch (error) {
3822
3843
  this.log(`Error updating trailing stop: ${error}`, {
@@ -58793,12 +58814,14 @@ async function getPositionSide(client, symbol) {
58793
58814
  async function closePosition(client, symbol, options) {
58794
58815
  // Normalize crypto symbols: Alpaca positions endpoint rejects hyphenated
58795
58816
  // format (e.g., "SOL-USD") but accepts concatenated form (e.g., "SOLUSD").
58796
- const isCrypto = symbol.includes("/") || symbol.includes("-") ||
58817
+ const isCrypto = symbol.includes("/") ||
58818
+ symbol.includes("-") ||
58797
58819
  /^[A-Z]{2,}USD[TC]?$/i.test(symbol);
58798
- const normalizedSymbol = isCrypto
58799
- ? symbol.replace(/[-/]/g, "")
58800
- : symbol;
58801
- log(`Closing position for ${normalizedSymbol}`, { type: "info", symbol: normalizedSymbol });
58820
+ const normalizedSymbol = isCrypto ? symbol.replace(/[-/]/g, "") : symbol;
58821
+ log(`Closing position for ${normalizedSymbol}`, {
58822
+ type: "info",
58823
+ symbol: normalizedSymbol,
58824
+ });
58802
58825
  try {
58803
58826
  const sdk = client.getSDK();
58804
58827
  // Build query params for partial closes
@@ -58818,7 +58841,10 @@ async function closePosition(client, symbol, options) {
58818
58841
  });
58819
58842
  }
58820
58843
  else {
58821
- log(`Closing entire position for ${normalizedSymbol}`, { type: "info", symbol: normalizedSymbol });
58844
+ log(`Closing entire position for ${normalizedSymbol}`, {
58845
+ type: "info",
58846
+ symbol: normalizedSymbol,
58847
+ });
58822
58848
  }
58823
58849
  // Use sendRequest for parameterized close, closePosition for full close
58824
58850
  let order;
@@ -67340,7 +67366,8 @@ const RequireHumanApprovalSchema = objectType({
67340
67366
  closeAllOrdersAndPositions: booleanType().default(true),
67341
67367
  policyMutations: booleanType().default(true),
67342
67368
  advancedModelEscalations: booleanType().default(false),
67343
- }).default({});
67369
+ })
67370
+ .default({});
67344
67371
  /**
67345
67372
  * Schema for allowed trading session windows.
67346
67373
  * Controls which market sessions the system may trade during.
@@ -67351,7 +67378,8 @@ const AllowedSessionsSchema = objectType({
67351
67378
  afterHours: booleanType().default(false),
67352
67379
  overnight: booleanType().default(false),
67353
67380
  weekends: booleanType().default(false),
67354
- }).default({});
67381
+ })
67382
+ .default({});
67355
67383
  /**
67356
67384
  * Autonomy preferences schema (section 7.1).
67357
67385
  * Governs the level of automated decision-making, human approval gates,
@@ -67375,7 +67403,7 @@ const AutonomyPrefsObjectSchema = objectType({
67375
67403
  });
67376
67404
  const AutonomyPrefsSchema = AutonomyPrefsObjectSchema.default({});
67377
67405
 
67378
- const DirectionSchema = enumType(['long_only', 'long_short', 'market_neutral']);
67406
+ const DirectionSchema = enumType(["long_only", "long_short", "market_neutral"]);
67379
67407
  /**
67380
67408
  * Asset universe preferences schema (section 7.2).
67381
67409
  * Defines which instruments, exchanges, sectors, and market segments
@@ -67385,10 +67413,10 @@ const DirectionSchema = enumType(['long_only', 'long_short', 'market_neutral']);
67385
67413
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67386
67414
  */
67387
67415
  const AssetUniversePrefsObjectSchema = objectType({
67388
- equitiesDirection: DirectionSchema.default('long_only'),
67389
- etfsDirection: enumType(['long_only', 'long_short']).default('long_only'),
67390
- cryptoDirection: enumType(['long_only', 'long_short']).default('long_only'),
67391
- optionsDirection: enumType(['long_only', 'long_short']).default('long_only'),
67416
+ equitiesDirection: DirectionSchema.default("long_only"),
67417
+ etfsDirection: enumType(["long_only", "long_short"]).default("long_only"),
67418
+ cryptoDirection: enumType(["long_only", "long_short"]).default("long_only"),
67419
+ optionsDirection: enumType(["long_only", "long_short"]).default("long_only"),
67392
67420
  allowedExchanges: arrayType(stringType()).default([]),
67393
67421
  deniedExchanges: arrayType(stringType()).default([]),
67394
67422
  allowedCountries: arrayType(stringType()).default([]),
@@ -67443,15 +67471,15 @@ const RiskBudgetPrefsObjectSchema = objectType({
67443
67471
  overnightExposureCapPct: numberType().min(0).max(100).default(50),
67444
67472
  weekendExposureCapPct: numberType().min(0).max(100).default(30),
67445
67473
  eventRiskExposureCapPct: numberType().min(0).max(100).default(40),
67446
- gapRiskSensitivity: enumType(['low', 'medium', 'high']).default('medium'),
67474
+ gapRiskSensitivity: enumType(["low", "medium", "high"]).default("medium"),
67447
67475
  /** Per-trade equity allocation as % of account equity. Replaces legacy AlpacaAccount.tradeAllocationPct. */
67448
67476
  perTradeAllocationPct: numberType().min(0).max(100).default(5),
67449
67477
  /** Per-trade crypto allocation as % of account equity. Replaces legacy AlpacaAccount.cryptoTradeAllocationPct. */
67450
67478
  perTradeCryptoAllocationPct: numberType().min(0).max(100).default(5),
67451
67479
  /** Alpaca day-trading buying power check enforcement. Synced to Alpaca API. */
67452
- dtbpCheck: enumType(['both', 'entry', 'exit']).default('both'),
67480
+ dtbpCheck: enumType(["both", "entry", "exit"]).default("both"),
67453
67481
  /** Alpaca pattern day trader rule enforcement. Synced to Alpaca API. */
67454
- pdtCheck: enumType(['both', 'entry', 'exit']).default('both'),
67482
+ pdtCheck: enumType(["both", "entry", "exit"]).default("both"),
67455
67483
  /** Strict PDT enforcement — block all violations without exception. Synced to Alpaca API. */
67456
67484
  ptpNoExceptionEntry: booleanType().default(false),
67457
67485
  });
@@ -67493,14 +67521,21 @@ const SignalConsumptionPrefsObjectSchema = objectType({
67493
67521
  cooldownAfterFailedTradeSeconds: numberType().min(0).default(180),
67494
67522
  duplicateSignalSuppressionWindowSeconds: numberType().min(0).default(300),
67495
67523
  reversalHandlingPolicy: enumType([
67496
- 'ignore_reversal', 'close_only', 'flatten_then_reverse', 'allow_full_reversal',
67497
- ]).default('close_only'),
67524
+ "ignore_reversal",
67525
+ "close_only",
67526
+ "flatten_then_reverse",
67527
+ "allow_full_reversal",
67528
+ ])
67529
+ .default("close_only"),
67498
67530
  conflictHandlingOpenOrders: enumType([
67499
- 'cancel_conflicting', 'replace_existing', 'keep_existing_skip', 'escalate',
67500
- ]).default('cancel_conflicting'),
67501
- conflictHandlingOpposingPosition: enumType([
67502
- 'reduce', 'close', 'flatten_then_reverse', 'hold',
67503
- ]).default('close'),
67531
+ "cancel_conflicting",
67532
+ "replace_existing",
67533
+ "keep_existing_skip",
67534
+ "escalate",
67535
+ ])
67536
+ .default("cancel_conflicting"),
67537
+ conflictHandlingOpposingPosition: enumType(["reduce", "close", "flatten_then_reverse", "hold"])
67538
+ .default("close"),
67504
67539
  minConvictionDeltaToModify: numberType().min(0).max(100).default(10),
67505
67540
  strategyPriorityRules: arrayType(StrategyPriorityRuleSchema).default([]),
67506
67541
  noTradeWindows: arrayType(NoTradeWindowSchema).default([]),
@@ -67514,7 +67549,13 @@ const SignalConsumptionPrefsObjectSchema = objectType({
67514
67549
  });
67515
67550
  const SignalConsumptionPrefsSchema = SignalConsumptionPrefsObjectSchema.default({});
67516
67551
 
67517
- const OrderTypeEnum = enumType(['market', 'limit', 'stop', 'stop_limit', 'trailing_stop']);
67552
+ const OrderTypeEnum = enumType([
67553
+ "market",
67554
+ "limit",
67555
+ "stop",
67556
+ "stop_limit",
67557
+ "trailing_stop",
67558
+ ]);
67518
67559
  /**
67519
67560
  * Execution preferences schema (section 7.5).
67520
67561
  * Governs order routing behavior including order types, time-in-force,
@@ -67524,11 +67565,14 @@ const OrderTypeEnum = enumType(['market', 'limit', 'stop', 'stop_limit', 'traili
67524
67565
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67525
67566
  */
67526
67567
  const ExecutionPrefsObjectSchema = objectType({
67527
- allowedOrderTypes: arrayType(OrderTypeEnum).default(['market', 'limit', 'stop', 'trailing_stop']),
67528
- preferredOrderType: OrderTypeEnum.default('limit'),
67529
- preferredOrderTypeByAssetClass: recordType(stringType(), stringType()).default({ crypto: 'market' }),
67530
- defaultTimeInForce: enumType(['day', 'gtc', 'ioc', 'fok']).default('day'),
67531
- executionBias: enumType(['passive', 'neutral', 'aggressive']).default('neutral'),
67568
+ allowedOrderTypes: arrayType(OrderTypeEnum)
67569
+ .default(["market", "limit", "stop", "trailing_stop"]),
67570
+ preferredOrderType: OrderTypeEnum.default("limit"),
67571
+ preferredOrderTypeByAssetClass: recordType(stringType(), stringType())
67572
+ .default({ crypto: "market" }),
67573
+ defaultTimeInForce: enumType(["day", "gtc", "ioc", "fok"]).default("day"),
67574
+ executionBias: enumType(["passive", "neutral", "aggressive"])
67575
+ .default("neutral"),
67532
67576
  maxSlippageTolerancePct: numberType().min(0).max(100).default(1.0),
67533
67577
  priceCollarEnabled: booleanType().default(true),
67534
67578
  priceCollarPct: numberType().min(0).default(2),
@@ -67536,11 +67580,14 @@ const ExecutionPrefsObjectSchema = objectType({
67536
67580
  repriceMaxAttempts: numberType().min(0).default(3),
67537
67581
  repriceIntervalSeconds: numberType().min(0).default(30),
67538
67582
  cancelReplaceTimeoutSeconds: numberType().min(0).default(60),
67539
- partialFillPolicy: enumType(['accept_partial', 'cancel_remainder', 'replace_to_fill']).default('accept_partial'),
67540
- sizingMethod: enumType(['notional', 'quantity']).default('notional'),
67541
- lotRoundingBehavior: enumType(['round_down', 'round_nearest', 'round_up']).default('round_down'),
67542
- afterHoursExecutionBehavior: enumType(['limit_only', 'no_execution', 'normal']).default('limit_only'),
67543
- failureBehavior: enumType(['fail_safe', 'fail_open']).default('fail_safe'),
67583
+ partialFillPolicy: enumType(["accept_partial", "cancel_remainder", "replace_to_fill"])
67584
+ .default("accept_partial"),
67585
+ sizingMethod: enumType(["notional", "quantity"]).default("notional"),
67586
+ lotRoundingBehavior: enumType(["round_down", "round_nearest", "round_up"])
67587
+ .default("round_down"),
67588
+ afterHoursExecutionBehavior: enumType(["limit_only", "no_execution", "normal"])
67589
+ .default("limit_only"),
67590
+ failureBehavior: enumType(["fail_safe", "fail_open"]).default("fail_safe"),
67544
67591
  });
67545
67592
  const ExecutionPrefsSchema = ExecutionPrefsObjectSchema.default({});
67546
67593
 
@@ -67558,10 +67605,12 @@ const TrailingStopTighteningRuleSchema = objectType({
67558
67605
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67559
67606
  */
67560
67607
  const PositionManagementPrefsObjectSchema = objectType({
67561
- defaultStopLossMethod: enumType(['fixed_percent', 'atr_based', 'structure_based', 'trailing_stop']).default('trailing_stop'),
67608
+ defaultStopLossMethod: enumType(["fixed_percent", "atr_based", "structure_based", "trailing_stop"])
67609
+ .default("trailing_stop"),
67562
67610
  defaultStopLossPct: numberType().min(0).max(100).default(4),
67563
67611
  atrStopMultiplier: numberType().min(0).default(2),
67564
- defaultTakeProfitMethod: enumType(['fixed_percent', 'atr_based', 'risk_reward_ratio', 'none']).default('risk_reward_ratio'),
67612
+ defaultTakeProfitMethod: enumType(["fixed_percent", "atr_based", "risk_reward_ratio", "none"])
67613
+ .default("risk_reward_ratio"),
67565
67614
  defaultTakeProfitPct: numberType().min(0).max(100).default(3),
67566
67615
  defaultRiskRewardRatio: numberType().min(0).default(2),
67567
67616
  breakEvenStopEnabled: booleanType().default(true),
@@ -67582,7 +67631,8 @@ const PositionManagementPrefsObjectSchema = objectType({
67582
67631
  addToLosersAllowed: booleanType().default(false),
67583
67632
  stopWideningAllowed: booleanType().default(false),
67584
67633
  trailingStopTighteningEnabled: booleanType().default(true),
67585
- trailingStopTighteningRules: arrayType(TrailingStopTighteningRuleSchema).default([
67634
+ trailingStopTighteningRules: arrayType(TrailingStopTighteningRuleSchema)
67635
+ .default([
67586
67636
  { profitThresholdPct: 3, newTrailPct: 2.0 },
67587
67637
  { profitThresholdPct: 6, newTrailPct: 1.5 },
67588
67638
  { profitThresholdPct: 10, newTrailPct: 1.0 },
@@ -67621,13 +67671,21 @@ const PortfolioConstructionPrefsObjectSchema = objectType({
67621
67671
  targetAllocationByAssetClass: recordType(stringType(), numberType()).default({}),
67622
67672
  tacticalAllocationBands: recordType(stringType(), TacticalBandSchema).default({}),
67623
67673
  driftThresholdPct: numberType().min(0).max(100).default(5),
67624
- rebalanceTrigger: enumType(['threshold', 'calendar', 'both']).default('threshold'),
67674
+ rebalanceTrigger: enumType(["threshold", "calendar", "both"])
67675
+ .default("threshold"),
67625
67676
  rebalanceFrequencyDays: numberType().min(0).default(30),
67626
67677
  autonomousRebalancing: booleanType().default(false),
67627
67678
  rebalanceDuringRiskOff: booleanType().default(false),
67628
67679
  maxTurnoverPerRebalancePct: numberType().min(0).max(100).default(20),
67629
- preferredWeighting: enumType(['equal_weight', 'risk_based', 'conviction_weighted', 'target_allocation']).default('equal_weight'),
67630
- strategySleeveBudgets: recordType(stringType(), StrategySleeveBudgetSchema).default({}),
67680
+ preferredWeighting: enumType([
67681
+ "equal_weight",
67682
+ "risk_based",
67683
+ "conviction_weighted",
67684
+ "target_allocation",
67685
+ ])
67686
+ .default("equal_weight"),
67687
+ strategySleeveBudgets: recordType(stringType(), StrategySleeveBudgetSchema)
67688
+ .default({}),
67631
67689
  cashTargetPct: numberType().min(0).max(100).default(10),
67632
67690
  defensiveCashEscalationEnabled: booleanType().default(false),
67633
67691
  defensiveCashEscalationRules: arrayType(DefensiveCashRuleSchema).default([]),
@@ -67674,7 +67732,8 @@ const OverlayResponseConfigSchema = objectType({
67674
67732
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67675
67733
  */
67676
67734
  const OverlayResponsePrefsObjectSchema = objectType({
67677
- overlayResponses: recordType(nativeEnumType(OverlayType), OverlayResponseConfigSchema).default({}),
67735
+ overlayResponses: recordType(nativeEnumType(OverlayType), OverlayResponseConfigSchema)
67736
+ .default({}),
67678
67737
  });
67679
67738
  const OverlayResponsePrefsSchema = OverlayResponsePrefsObjectSchema.default({});
67680
67739
 
@@ -67710,14 +67769,16 @@ const ModelPrefsObjectSchema = objectType({
67710
67769
  latencyTargetMs: numberType().min(0).default(5000),
67711
67770
  timeoutMs: numberType().min(0).default(30000),
67712
67771
  maxRetries: numberType().min(0).default(2),
67713
- toolUsePermissionsByTier: recordType(stringType(), ToolUsePermissionsSchema).default({
67772
+ toolUsePermissionsByTier: recordType(stringType(), ToolUsePermissionsSchema)
67773
+ .default({
67714
67774
  mini: { readTools: true, writeTools: false },
67715
67775
  normal: { readTools: true, writeTools: false },
67716
67776
  advanced: { readTools: true, writeTools: true },
67717
67777
  }),
67718
67778
  memorySummaryCadenceMinutes: numberType().min(0).default(60),
67719
67779
  maxMemorySummariesRetained: numberType().min(0).default(50),
67720
- excludedProvidersForWorkflows: recordType(stringType(), arrayType(stringType())).default({}),
67780
+ excludedProvidersForWorkflows: recordType(stringType(), arrayType(stringType()))
67781
+ .default({}),
67721
67782
  quantModelWeight: numberType().min(0).max(1).default(0.7),
67722
67783
  });
67723
67784
  const ModelPrefsSchema = ModelPrefsObjectSchema.default({});
@@ -67737,16 +67798,18 @@ const AuditNotificationPrefsObjectSchema = objectType({
67737
67798
  notifyOnPolicyMutation: booleanType().default(true),
67738
67799
  dailySummaryEnabled: booleanType().default(true),
67739
67800
  eventSummaryEnabled: booleanType().default(true),
67740
- auditDetailLevel: enumType(['minimal', 'standard', 'verbose']).default('standard'),
67801
+ auditDetailLevel: enumType(["minimal", "standard", "verbose"])
67802
+ .default("standard"),
67741
67803
  saveRationaleSummaries: booleanType().default(true),
67742
67804
  saveToolCallTraces: booleanType().default(false),
67743
67805
  saveContextSnapshots: booleanType().default(true),
67744
- incidentAlertChannel: enumType(['email', 'slack', 'discord', 'webhook', 'none']).default('none'),
67745
- incidentAlertEndpoint: stringType().default(''),
67806
+ incidentAlertChannel: enumType(["email", "slack", "discord", "webhook", "none"])
67807
+ .default("none"),
67808
+ incidentAlertEndpoint: stringType().default(""),
67746
67809
  requirePostActionExplanation: booleanType().default(true),
67747
67810
  retainDecisionArtifactsDays: numberType().min(0).default(90),
67748
67811
  /** Trade confirmation email preference. Synced to Alpaca API. */
67749
- tradeConfirmEmail: enumType(['all', 'none']).default('all'),
67812
+ tradeConfirmEmail: enumType(["all", "none"]).default("all"),
67750
67813
  });
67751
67814
  const AuditNotificationPrefsSchema = AuditNotificationPrefsObjectSchema.default({});
67752
67815
 
@@ -67796,7 +67859,8 @@ const PolicyMutationSchema = objectType({
67796
67859
  overlayResponsePrefs: OverlayResponsePrefsObjectSchema.deepPartial().optional(),
67797
67860
  modelPrefs: ModelPrefsObjectSchema.deepPartial().optional(),
67798
67861
  auditNotificationPrefs: AuditNotificationPrefsObjectSchema.deepPartial().optional(),
67799
- }).passthrough();
67862
+ })
67863
+ .passthrough();
67800
67864
 
67801
67865
  /**
67802
67866
  * Effective trading policy schema representing the fully-resolved policy