@adaptic/utils 0.0.963 → 0.0.964

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 +108 -55
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.mjs +108 -55
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/test.js +3 -1
  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 +1 -1
package/dist/index.cjs CHANGED
@@ -2366,7 +2366,9 @@ class AlpacaMarketDataAPI extends require$$0$1.EventEmitter {
2366
2366
  }
2367
2367
  });
2368
2368
  ws.on("close", (code) => {
2369
- log$l(`${streamType} stream disconnected (code: ${code})`, { type: "warn" });
2369
+ log$l(`${streamType} stream disconnected (code: ${code})`, {
2370
+ type: "warn",
2371
+ });
2370
2372
  if (streamType === "stock") {
2371
2373
  this.stockWs = null;
2372
2374
  }
@@ -3686,13 +3688,14 @@ class AlpacaTradingAPI {
3686
3688
  * @param side (string) - the side of the order
3687
3689
  * @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
3688
3690
  * @param position_intent (string) - the position intent of the order
3691
+ * @returns The created AlpacaOrder with order ID and details
3689
3692
  */
3690
3693
  async createTrailingStop(symbol, qty, side, trailPercent100, position_intent) {
3691
3694
  this.log(`Creating trailing stop ${side.toUpperCase()} ${qty} shares for ${symbol} with trail percent ${trailPercent100}%`, {
3692
3695
  symbol,
3693
3696
  });
3694
3697
  try {
3695
- await this.makeRequest(`/orders`, "POST", {
3698
+ const order = await this.makeRequest(`/orders`, "POST", {
3696
3699
  symbol,
3697
3700
  qty: Math.abs(qty),
3698
3701
  side,
@@ -3702,6 +3705,8 @@ class AlpacaTradingAPI {
3702
3705
  trail_percent: trailPercent100, // Already in decimal form (e.g., 4 for 4%)
3703
3706
  time_in_force: "gtc",
3704
3707
  });
3708
+ this.log(`Trailing stop order created for ${symbol}: orderId=${order.id}, trailPercent=${trailPercent100}%`, { symbol });
3709
+ return order;
3705
3710
  }
3706
3711
  catch (error) {
3707
3712
  this.log(`Error creating trailing stop: ${error}`, {
@@ -3783,6 +3788,7 @@ class AlpacaTradingAPI {
3783
3788
  * Update the trail percent for a trailing stop order
3784
3789
  * @param symbol (string) - the symbol of the order
3785
3790
  * @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
3791
+ * @returns The updated/replaced order from Alpaca, or null if no order found or no update needed
3786
3792
  */
3787
3793
  async updateTrailingStop(symbol, trailPercent100) {
3788
3794
  // First get all open orders for this symbol
@@ -3797,7 +3803,7 @@ class AlpacaTradingAPI {
3797
3803
  type: "error",
3798
3804
  symbol,
3799
3805
  });
3800
- return;
3806
+ return null;
3801
3807
  }
3802
3808
  // Check if the trail_percent is already set to the desired value
3803
3809
  const currentTrailPercent = trailingStopOrder.trail_percent
@@ -3810,15 +3816,19 @@ class AlpacaTradingAPI {
3810
3816
  this.log(`Trailing stop for ${symbol} already set to ${trailPercent100}% (current: ${currentTrailPercent}%), skipping update`, {
3811
3817
  symbol,
3812
3818
  });
3813
- return;
3819
+ return null;
3814
3820
  }
3815
- this.log(`Updating trailing stop for ${symbol} from ${currentTrailPercent}% to ${trailPercent100}%`, {
3821
+ const originalOrderId = trailingStopOrder.id;
3822
+ this.log(`Updating trailing stop for ${symbol} from ${currentTrailPercent}% to ${trailPercent100}% (orderId=${originalOrderId})`, {
3816
3823
  symbol,
3817
3824
  });
3818
3825
  try {
3819
- await this.makeRequest(`/orders/${trailingStopOrder.id}`, "PATCH", {
3820
- trail: trailPercent100.toString(), // Changed from trail_percent to trail
3826
+ const updatedOrder = await this.makeRequest(`/orders/${trailingStopOrder.id}`, "PATCH", {
3827
+ trail: trailPercent100.toString(),
3821
3828
  });
3829
+ // Log the replacement: Alpaca replaces orders on PATCH, so new ID is returned
3830
+ this.log(`Trailing stop updated for ${symbol}: newOrderId=${updatedOrder.id}, replaces=${updatedOrder.replaces || originalOrderId}`, { symbol });
3831
+ return updatedOrder;
3822
3832
  }
3823
3833
  catch (error) {
3824
3834
  this.log(`Error updating trailing stop: ${error}`, {
@@ -58795,12 +58805,14 @@ async function getPositionSide(client, symbol) {
58795
58805
  async function closePosition(client, symbol, options) {
58796
58806
  // Normalize crypto symbols: Alpaca positions endpoint rejects hyphenated
58797
58807
  // format (e.g., "SOL-USD") but accepts concatenated form (e.g., "SOLUSD").
58798
- const isCrypto = symbol.includes("/") || symbol.includes("-") ||
58808
+ const isCrypto = symbol.includes("/") ||
58809
+ symbol.includes("-") ||
58799
58810
  /^[A-Z]{2,}USD[TC]?$/i.test(symbol);
58800
- const normalizedSymbol = isCrypto
58801
- ? symbol.replace(/[-/]/g, "")
58802
- : symbol;
58803
- log(`Closing position for ${normalizedSymbol}`, { type: "info", symbol: normalizedSymbol });
58811
+ const normalizedSymbol = isCrypto ? symbol.replace(/[-/]/g, "") : symbol;
58812
+ log(`Closing position for ${normalizedSymbol}`, {
58813
+ type: "info",
58814
+ symbol: normalizedSymbol,
58815
+ });
58804
58816
  try {
58805
58817
  const sdk = client.getSDK();
58806
58818
  // Build query params for partial closes
@@ -58820,7 +58832,10 @@ async function closePosition(client, symbol, options) {
58820
58832
  });
58821
58833
  }
58822
58834
  else {
58823
- log(`Closing entire position for ${normalizedSymbol}`, { type: "info", symbol: normalizedSymbol });
58835
+ log(`Closing entire position for ${normalizedSymbol}`, {
58836
+ type: "info",
58837
+ symbol: normalizedSymbol,
58838
+ });
58824
58839
  }
58825
58840
  // Use sendRequest for parameterized close, closePosition for full close
58826
58841
  let order;
@@ -67342,7 +67357,8 @@ const RequireHumanApprovalSchema = objectType({
67342
67357
  closeAllOrdersAndPositions: booleanType().default(true),
67343
67358
  policyMutations: booleanType().default(true),
67344
67359
  advancedModelEscalations: booleanType().default(false),
67345
- }).default({});
67360
+ })
67361
+ .default({});
67346
67362
  /**
67347
67363
  * Schema for allowed trading session windows.
67348
67364
  * Controls which market sessions the system may trade during.
@@ -67353,7 +67369,8 @@ const AllowedSessionsSchema = objectType({
67353
67369
  afterHours: booleanType().default(false),
67354
67370
  overnight: booleanType().default(false),
67355
67371
  weekends: booleanType().default(false),
67356
- }).default({});
67372
+ })
67373
+ .default({});
67357
67374
  /**
67358
67375
  * Autonomy preferences schema (section 7.1).
67359
67376
  * Governs the level of automated decision-making, human approval gates,
@@ -67377,7 +67394,7 @@ const AutonomyPrefsObjectSchema = objectType({
67377
67394
  });
67378
67395
  const AutonomyPrefsSchema = AutonomyPrefsObjectSchema.default({});
67379
67396
 
67380
- const DirectionSchema = enumType(['long_only', 'long_short', 'market_neutral']);
67397
+ const DirectionSchema = enumType(["long_only", "long_short", "market_neutral"]);
67381
67398
  /**
67382
67399
  * Asset universe preferences schema (section 7.2).
67383
67400
  * Defines which instruments, exchanges, sectors, and market segments
@@ -67387,10 +67404,10 @@ const DirectionSchema = enumType(['long_only', 'long_short', 'market_neutral']);
67387
67404
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67388
67405
  */
67389
67406
  const AssetUniversePrefsObjectSchema = objectType({
67390
- equitiesDirection: DirectionSchema.default('long_only'),
67391
- etfsDirection: enumType(['long_only', 'long_short']).default('long_only'),
67392
- cryptoDirection: enumType(['long_only', 'long_short']).default('long_only'),
67393
- optionsDirection: enumType(['long_only', 'long_short']).default('long_only'),
67407
+ equitiesDirection: DirectionSchema.default("long_only"),
67408
+ etfsDirection: enumType(["long_only", "long_short"]).default("long_only"),
67409
+ cryptoDirection: enumType(["long_only", "long_short"]).default("long_only"),
67410
+ optionsDirection: enumType(["long_only", "long_short"]).default("long_only"),
67394
67411
  allowedExchanges: arrayType(stringType()).default([]),
67395
67412
  deniedExchanges: arrayType(stringType()).default([]),
67396
67413
  allowedCountries: arrayType(stringType()).default([]),
@@ -67445,15 +67462,15 @@ const RiskBudgetPrefsObjectSchema = objectType({
67445
67462
  overnightExposureCapPct: numberType().min(0).max(100).default(50),
67446
67463
  weekendExposureCapPct: numberType().min(0).max(100).default(30),
67447
67464
  eventRiskExposureCapPct: numberType().min(0).max(100).default(40),
67448
- gapRiskSensitivity: enumType(['low', 'medium', 'high']).default('medium'),
67465
+ gapRiskSensitivity: enumType(["low", "medium", "high"]).default("medium"),
67449
67466
  /** Per-trade equity allocation as % of account equity. Replaces legacy AlpacaAccount.tradeAllocationPct. */
67450
67467
  perTradeAllocationPct: numberType().min(0).max(100).default(5),
67451
67468
  /** Per-trade crypto allocation as % of account equity. Replaces legacy AlpacaAccount.cryptoTradeAllocationPct. */
67452
67469
  perTradeCryptoAllocationPct: numberType().min(0).max(100).default(5),
67453
67470
  /** Alpaca day-trading buying power check enforcement. Synced to Alpaca API. */
67454
- dtbpCheck: enumType(['both', 'entry', 'exit']).default('both'),
67471
+ dtbpCheck: enumType(["both", "entry", "exit"]).default("both"),
67455
67472
  /** Alpaca pattern day trader rule enforcement. Synced to Alpaca API. */
67456
- pdtCheck: enumType(['both', 'entry', 'exit']).default('both'),
67473
+ pdtCheck: enumType(["both", "entry", "exit"]).default("both"),
67457
67474
  /** Strict PDT enforcement — block all violations without exception. Synced to Alpaca API. */
67458
67475
  ptpNoExceptionEntry: booleanType().default(false),
67459
67476
  });
@@ -67495,14 +67512,21 @@ const SignalConsumptionPrefsObjectSchema = objectType({
67495
67512
  cooldownAfterFailedTradeSeconds: numberType().min(0).default(180),
67496
67513
  duplicateSignalSuppressionWindowSeconds: numberType().min(0).default(300),
67497
67514
  reversalHandlingPolicy: enumType([
67498
- 'ignore_reversal', 'close_only', 'flatten_then_reverse', 'allow_full_reversal',
67499
- ]).default('close_only'),
67515
+ "ignore_reversal",
67516
+ "close_only",
67517
+ "flatten_then_reverse",
67518
+ "allow_full_reversal",
67519
+ ])
67520
+ .default("close_only"),
67500
67521
  conflictHandlingOpenOrders: enumType([
67501
- 'cancel_conflicting', 'replace_existing', 'keep_existing_skip', 'escalate',
67502
- ]).default('cancel_conflicting'),
67503
- conflictHandlingOpposingPosition: enumType([
67504
- 'reduce', 'close', 'flatten_then_reverse', 'hold',
67505
- ]).default('close'),
67522
+ "cancel_conflicting",
67523
+ "replace_existing",
67524
+ "keep_existing_skip",
67525
+ "escalate",
67526
+ ])
67527
+ .default("cancel_conflicting"),
67528
+ conflictHandlingOpposingPosition: enumType(["reduce", "close", "flatten_then_reverse", "hold"])
67529
+ .default("close"),
67506
67530
  minConvictionDeltaToModify: numberType().min(0).max(100).default(10),
67507
67531
  strategyPriorityRules: arrayType(StrategyPriorityRuleSchema).default([]),
67508
67532
  noTradeWindows: arrayType(NoTradeWindowSchema).default([]),
@@ -67516,7 +67540,13 @@ const SignalConsumptionPrefsObjectSchema = objectType({
67516
67540
  });
67517
67541
  const SignalConsumptionPrefsSchema = SignalConsumptionPrefsObjectSchema.default({});
67518
67542
 
67519
- const OrderTypeEnum = enumType(['market', 'limit', 'stop', 'stop_limit', 'trailing_stop']);
67543
+ const OrderTypeEnum = enumType([
67544
+ "market",
67545
+ "limit",
67546
+ "stop",
67547
+ "stop_limit",
67548
+ "trailing_stop",
67549
+ ]);
67520
67550
  /**
67521
67551
  * Execution preferences schema (section 7.5).
67522
67552
  * Governs order routing behavior including order types, time-in-force,
@@ -67526,11 +67556,14 @@ const OrderTypeEnum = enumType(['market', 'limit', 'stop', 'stop_limit', 'traili
67526
67556
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67527
67557
  */
67528
67558
  const ExecutionPrefsObjectSchema = objectType({
67529
- allowedOrderTypes: arrayType(OrderTypeEnum).default(['market', 'limit', 'stop', 'trailing_stop']),
67530
- preferredOrderType: OrderTypeEnum.default('limit'),
67531
- preferredOrderTypeByAssetClass: recordType(stringType(), stringType()).default({ crypto: 'market' }),
67532
- defaultTimeInForce: enumType(['day', 'gtc', 'ioc', 'fok']).default('day'),
67533
- executionBias: enumType(['passive', 'neutral', 'aggressive']).default('neutral'),
67559
+ allowedOrderTypes: arrayType(OrderTypeEnum)
67560
+ .default(["market", "limit", "stop", "trailing_stop"]),
67561
+ preferredOrderType: OrderTypeEnum.default("limit"),
67562
+ preferredOrderTypeByAssetClass: recordType(stringType(), stringType())
67563
+ .default({ crypto: "market" }),
67564
+ defaultTimeInForce: enumType(["day", "gtc", "ioc", "fok"]).default("day"),
67565
+ executionBias: enumType(["passive", "neutral", "aggressive"])
67566
+ .default("neutral"),
67534
67567
  maxSlippageTolerancePct: numberType().min(0).max(100).default(1.0),
67535
67568
  priceCollarEnabled: booleanType().default(true),
67536
67569
  priceCollarPct: numberType().min(0).default(2),
@@ -67538,11 +67571,14 @@ const ExecutionPrefsObjectSchema = objectType({
67538
67571
  repriceMaxAttempts: numberType().min(0).default(3),
67539
67572
  repriceIntervalSeconds: numberType().min(0).default(30),
67540
67573
  cancelReplaceTimeoutSeconds: numberType().min(0).default(60),
67541
- partialFillPolicy: enumType(['accept_partial', 'cancel_remainder', 'replace_to_fill']).default('accept_partial'),
67542
- sizingMethod: enumType(['notional', 'quantity']).default('notional'),
67543
- lotRoundingBehavior: enumType(['round_down', 'round_nearest', 'round_up']).default('round_down'),
67544
- afterHoursExecutionBehavior: enumType(['limit_only', 'no_execution', 'normal']).default('limit_only'),
67545
- failureBehavior: enumType(['fail_safe', 'fail_open']).default('fail_safe'),
67574
+ partialFillPolicy: enumType(["accept_partial", "cancel_remainder", "replace_to_fill"])
67575
+ .default("accept_partial"),
67576
+ sizingMethod: enumType(["notional", "quantity"]).default("notional"),
67577
+ lotRoundingBehavior: enumType(["round_down", "round_nearest", "round_up"])
67578
+ .default("round_down"),
67579
+ afterHoursExecutionBehavior: enumType(["limit_only", "no_execution", "normal"])
67580
+ .default("limit_only"),
67581
+ failureBehavior: enumType(["fail_safe", "fail_open"]).default("fail_safe"),
67546
67582
  });
67547
67583
  const ExecutionPrefsSchema = ExecutionPrefsObjectSchema.default({});
67548
67584
 
@@ -67560,10 +67596,12 @@ const TrailingStopTighteningRuleSchema = objectType({
67560
67596
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67561
67597
  */
67562
67598
  const PositionManagementPrefsObjectSchema = objectType({
67563
- defaultStopLossMethod: enumType(['fixed_percent', 'atr_based', 'structure_based', 'trailing_stop']).default('trailing_stop'),
67599
+ defaultStopLossMethod: enumType(["fixed_percent", "atr_based", "structure_based", "trailing_stop"])
67600
+ .default("trailing_stop"),
67564
67601
  defaultStopLossPct: numberType().min(0).max(100).default(4),
67565
67602
  atrStopMultiplier: numberType().min(0).default(2),
67566
- defaultTakeProfitMethod: enumType(['fixed_percent', 'atr_based', 'risk_reward_ratio', 'none']).default('risk_reward_ratio'),
67603
+ defaultTakeProfitMethod: enumType(["fixed_percent", "atr_based", "risk_reward_ratio", "none"])
67604
+ .default("risk_reward_ratio"),
67567
67605
  defaultTakeProfitPct: numberType().min(0).max(100).default(3),
67568
67606
  defaultRiskRewardRatio: numberType().min(0).default(2),
67569
67607
  breakEvenStopEnabled: booleanType().default(true),
@@ -67584,7 +67622,8 @@ const PositionManagementPrefsObjectSchema = objectType({
67584
67622
  addToLosersAllowed: booleanType().default(false),
67585
67623
  stopWideningAllowed: booleanType().default(false),
67586
67624
  trailingStopTighteningEnabled: booleanType().default(true),
67587
- trailingStopTighteningRules: arrayType(TrailingStopTighteningRuleSchema).default([
67625
+ trailingStopTighteningRules: arrayType(TrailingStopTighteningRuleSchema)
67626
+ .default([
67588
67627
  { profitThresholdPct: 3, newTrailPct: 2.0 },
67589
67628
  { profitThresholdPct: 6, newTrailPct: 1.5 },
67590
67629
  { profitThresholdPct: 10, newTrailPct: 1.0 },
@@ -67623,13 +67662,21 @@ const PortfolioConstructionPrefsObjectSchema = objectType({
67623
67662
  targetAllocationByAssetClass: recordType(stringType(), numberType()).default({}),
67624
67663
  tacticalAllocationBands: recordType(stringType(), TacticalBandSchema).default({}),
67625
67664
  driftThresholdPct: numberType().min(0).max(100).default(5),
67626
- rebalanceTrigger: enumType(['threshold', 'calendar', 'both']).default('threshold'),
67665
+ rebalanceTrigger: enumType(["threshold", "calendar", "both"])
67666
+ .default("threshold"),
67627
67667
  rebalanceFrequencyDays: numberType().min(0).default(30),
67628
67668
  autonomousRebalancing: booleanType().default(false),
67629
67669
  rebalanceDuringRiskOff: booleanType().default(false),
67630
67670
  maxTurnoverPerRebalancePct: numberType().min(0).max(100).default(20),
67631
- preferredWeighting: enumType(['equal_weight', 'risk_based', 'conviction_weighted', 'target_allocation']).default('equal_weight'),
67632
- strategySleeveBudgets: recordType(stringType(), StrategySleeveBudgetSchema).default({}),
67671
+ preferredWeighting: enumType([
67672
+ "equal_weight",
67673
+ "risk_based",
67674
+ "conviction_weighted",
67675
+ "target_allocation",
67676
+ ])
67677
+ .default("equal_weight"),
67678
+ strategySleeveBudgets: recordType(stringType(), StrategySleeveBudgetSchema)
67679
+ .default({}),
67633
67680
  cashTargetPct: numberType().min(0).max(100).default(10),
67634
67681
  defensiveCashEscalationEnabled: booleanType().default(false),
67635
67682
  defensiveCashEscalationRules: arrayType(DefensiveCashRuleSchema).default([]),
@@ -67676,7 +67723,8 @@ const OverlayResponseConfigSchema = objectType({
67676
67723
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67677
67724
  */
67678
67725
  const OverlayResponsePrefsObjectSchema = objectType({
67679
- overlayResponses: recordType(nativeEnumType(exports.OverlayType), OverlayResponseConfigSchema).default({}),
67726
+ overlayResponses: recordType(nativeEnumType(exports.OverlayType), OverlayResponseConfigSchema)
67727
+ .default({}),
67680
67728
  });
67681
67729
  const OverlayResponsePrefsSchema = OverlayResponsePrefsObjectSchema.default({});
67682
67730
 
@@ -67712,14 +67760,16 @@ const ModelPrefsObjectSchema = objectType({
67712
67760
  latencyTargetMs: numberType().min(0).default(5000),
67713
67761
  timeoutMs: numberType().min(0).default(30000),
67714
67762
  maxRetries: numberType().min(0).default(2),
67715
- toolUsePermissionsByTier: recordType(stringType(), ToolUsePermissionsSchema).default({
67763
+ toolUsePermissionsByTier: recordType(stringType(), ToolUsePermissionsSchema)
67764
+ .default({
67716
67765
  mini: { readTools: true, writeTools: false },
67717
67766
  normal: { readTools: true, writeTools: false },
67718
67767
  advanced: { readTools: true, writeTools: true },
67719
67768
  }),
67720
67769
  memorySummaryCadenceMinutes: numberType().min(0).default(60),
67721
67770
  maxMemorySummariesRetained: numberType().min(0).default(50),
67722
- excludedProvidersForWorkflows: recordType(stringType(), arrayType(stringType())).default({}),
67771
+ excludedProvidersForWorkflows: recordType(stringType(), arrayType(stringType()))
67772
+ .default({}),
67723
67773
  quantModelWeight: numberType().min(0).max(1).default(0.7),
67724
67774
  });
67725
67775
  const ModelPrefsSchema = ModelPrefsObjectSchema.default({});
@@ -67739,16 +67789,18 @@ const AuditNotificationPrefsObjectSchema = objectType({
67739
67789
  notifyOnPolicyMutation: booleanType().default(true),
67740
67790
  dailySummaryEnabled: booleanType().default(true),
67741
67791
  eventSummaryEnabled: booleanType().default(true),
67742
- auditDetailLevel: enumType(['minimal', 'standard', 'verbose']).default('standard'),
67792
+ auditDetailLevel: enumType(["minimal", "standard", "verbose"])
67793
+ .default("standard"),
67743
67794
  saveRationaleSummaries: booleanType().default(true),
67744
67795
  saveToolCallTraces: booleanType().default(false),
67745
67796
  saveContextSnapshots: booleanType().default(true),
67746
- incidentAlertChannel: enumType(['email', 'slack', 'discord', 'webhook', 'none']).default('none'),
67747
- incidentAlertEndpoint: stringType().default(''),
67797
+ incidentAlertChannel: enumType(["email", "slack", "discord", "webhook", "none"])
67798
+ .default("none"),
67799
+ incidentAlertEndpoint: stringType().default(""),
67748
67800
  requirePostActionExplanation: booleanType().default(true),
67749
67801
  retainDecisionArtifactsDays: numberType().min(0).default(90),
67750
67802
  /** Trade confirmation email preference. Synced to Alpaca API. */
67751
- tradeConfirmEmail: enumType(['all', 'none']).default('all'),
67803
+ tradeConfirmEmail: enumType(["all", "none"]).default("all"),
67752
67804
  });
67753
67805
  const AuditNotificationPrefsSchema = AuditNotificationPrefsObjectSchema.default({});
67754
67806
 
@@ -67798,7 +67850,8 @@ const PolicyMutationSchema = objectType({
67798
67850
  overlayResponsePrefs: OverlayResponsePrefsObjectSchema.deepPartial().optional(),
67799
67851
  modelPrefs: ModelPrefsObjectSchema.deepPartial().optional(),
67800
67852
  auditNotificationPrefs: AuditNotificationPrefsObjectSchema.deepPartial().optional(),
67801
- }).passthrough();
67853
+ })
67854
+ .passthrough();
67802
67855
 
67803
67856
  /**
67804
67857
  * Effective trading policy schema representing the fully-resolved policy