@adaptic/utils 0.0.962 → 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 (60) hide show
  1. package/dist/index.cjs +118 -62
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.mjs +118 -62
  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/rate-limiter.d.ts +6 -3
  27. package/dist/types/rate-limiter.d.ts.map +1 -1
  28. package/dist/types/schemas/index.d.ts +4 -4
  29. package/dist/types/schemas/index.d.ts.map +1 -1
  30. package/dist/types/technical-analysis.d.ts.map +1 -1
  31. package/dist/types/trading-policy/defaults/default-trading-policy.d.ts +1 -1
  32. package/dist/types/trading-policy/defaults/default-trading-policy.d.ts.map +1 -1
  33. package/dist/types/trading-policy/index.d.ts +3 -3
  34. package/dist/types/trading-policy/schemas/asset-universe-prefs.schema.d.ts +1 -1
  35. package/dist/types/trading-policy/schemas/asset-universe-prefs.schema.d.ts.map +1 -1
  36. package/dist/types/trading-policy/schemas/audit-notification-prefs.schema.d.ts +1 -1
  37. package/dist/types/trading-policy/schemas/audit-notification-prefs.schema.d.ts.map +1 -1
  38. package/dist/types/trading-policy/schemas/autonomy-prefs.schema.d.ts +1 -1
  39. package/dist/types/trading-policy/schemas/autonomy-prefs.schema.d.ts.map +1 -1
  40. package/dist/types/trading-policy/schemas/effective-policy.schema.d.ts +2 -2
  41. package/dist/types/trading-policy/schemas/effective-policy.schema.d.ts.map +1 -1
  42. package/dist/types/trading-policy/schemas/execution-prefs.schema.d.ts +1 -1
  43. package/dist/types/trading-policy/schemas/execution-prefs.schema.d.ts.map +1 -1
  44. package/dist/types/trading-policy/schemas/index.d.ts +12 -12
  45. package/dist/types/trading-policy/schemas/index.d.ts.map +1 -1
  46. package/dist/types/trading-policy/schemas/model-prefs.schema.d.ts +2 -2
  47. package/dist/types/trading-policy/schemas/model-prefs.schema.d.ts.map +1 -1
  48. package/dist/types/trading-policy/schemas/overlay-response-prefs.schema.d.ts +2 -2
  49. package/dist/types/trading-policy/schemas/overlay-response-prefs.schema.d.ts.map +1 -1
  50. package/dist/types/trading-policy/schemas/policy-mutation.schema.d.ts +2 -2
  51. package/dist/types/trading-policy/schemas/policy-mutation.schema.d.ts.map +1 -1
  52. package/dist/types/trading-policy/schemas/portfolio-construction-prefs.schema.d.ts +1 -1
  53. package/dist/types/trading-policy/schemas/portfolio-construction-prefs.schema.d.ts.map +1 -1
  54. package/dist/types/trading-policy/schemas/position-management-prefs.schema.d.ts +1 -1
  55. package/dist/types/trading-policy/schemas/position-management-prefs.schema.d.ts.map +1 -1
  56. package/dist/types/trading-policy/schemas/risk-budget-prefs.schema.d.ts +1 -1
  57. package/dist/types/trading-policy/schemas/signal-consumption-prefs.schema.d.ts +1 -1
  58. package/dist/types/trading-policy/schemas/signal-consumption-prefs.schema.d.ts.map +1 -1
  59. package/dist/types/types/alpaca-types.d.ts.map +1 -1
  60. 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}`, {
@@ -7847,24 +7857,27 @@ const rateLimiters = {
7847
7857
  /**
7848
7858
  * Alpaca API rate limiter
7849
7859
  *
7850
- * Configured for 200 requests per minute.
7860
+ * Configured for 1000 requests per minute (paid tier).
7861
+ * The token bucket allows burst up to maxTokens, then refills at the steady rate.
7851
7862
  * See: https://alpaca.markets/docs/api-references/trading-api/#rate-limit
7852
7863
  */
7853
7864
  alpaca: new TokenBucketRateLimiter({
7854
- maxTokens: 200,
7855
- refillRate: 200 / 60, // 200 requests per 60 seconds (~3.33/sec)
7865
+ maxTokens: 1000,
7866
+ refillRate: 1000 / 60, // 1000 requests per 60 seconds (~16.67/sec)
7856
7867
  label: "alpaca",
7857
7868
  timeoutMs: 60000,
7858
7869
  }),
7859
7870
  /**
7860
7871
  * Massive.com API rate limiter
7861
7872
  *
7862
- * Configured for 100 requests per second (paid tier matches Massive.com recommended soft limit).
7863
- * See: https://massive.com/pricing
7873
+ * Configured generously for paid unlimited tier. The bucket exists only as a
7874
+ * safety net against runaway loops — the 1000 token burst and 500/sec refill
7875
+ * should never be hit under normal operation. If the paid plan truly has no
7876
+ * hard limit, this just prevents accidental self-DDoS.
7864
7877
  */
7865
7878
  massive: new TokenBucketRateLimiter({
7866
- maxTokens: 100,
7867
- refillRate: 100, // 100 requests per second (paid tier matches Massive.com recommended soft limit)
7879
+ maxTokens: 1000,
7880
+ refillRate: 500, // 500 tokens/sec refilleffectively unlimited for paid tier
7868
7881
  label: "massive",
7869
7882
  timeoutMs: 30000,
7870
7883
  }),
@@ -58792,12 +58805,14 @@ async function getPositionSide(client, symbol) {
58792
58805
  async function closePosition(client, symbol, options) {
58793
58806
  // Normalize crypto symbols: Alpaca positions endpoint rejects hyphenated
58794
58807
  // format (e.g., "SOL-USD") but accepts concatenated form (e.g., "SOLUSD").
58795
- const isCrypto = symbol.includes("/") || symbol.includes("-") ||
58808
+ const isCrypto = symbol.includes("/") ||
58809
+ symbol.includes("-") ||
58796
58810
  /^[A-Z]{2,}USD[TC]?$/i.test(symbol);
58797
- const normalizedSymbol = isCrypto
58798
- ? symbol.replace(/[-/]/g, "")
58799
- : symbol;
58800
- 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
+ });
58801
58816
  try {
58802
58817
  const sdk = client.getSDK();
58803
58818
  // Build query params for partial closes
@@ -58817,7 +58832,10 @@ async function closePosition(client, symbol, options) {
58817
58832
  });
58818
58833
  }
58819
58834
  else {
58820
- log(`Closing entire position for ${normalizedSymbol}`, { type: "info", symbol: normalizedSymbol });
58835
+ log(`Closing entire position for ${normalizedSymbol}`, {
58836
+ type: "info",
58837
+ symbol: normalizedSymbol,
58838
+ });
58821
58839
  }
58822
58840
  // Use sendRequest for parameterized close, closePosition for full close
58823
58841
  let order;
@@ -67339,7 +67357,8 @@ const RequireHumanApprovalSchema = objectType({
67339
67357
  closeAllOrdersAndPositions: booleanType().default(true),
67340
67358
  policyMutations: booleanType().default(true),
67341
67359
  advancedModelEscalations: booleanType().default(false),
67342
- }).default({});
67360
+ })
67361
+ .default({});
67343
67362
  /**
67344
67363
  * Schema for allowed trading session windows.
67345
67364
  * Controls which market sessions the system may trade during.
@@ -67350,7 +67369,8 @@ const AllowedSessionsSchema = objectType({
67350
67369
  afterHours: booleanType().default(false),
67351
67370
  overnight: booleanType().default(false),
67352
67371
  weekends: booleanType().default(false),
67353
- }).default({});
67372
+ })
67373
+ .default({});
67354
67374
  /**
67355
67375
  * Autonomy preferences schema (section 7.1).
67356
67376
  * Governs the level of automated decision-making, human approval gates,
@@ -67374,7 +67394,7 @@ const AutonomyPrefsObjectSchema = objectType({
67374
67394
  });
67375
67395
  const AutonomyPrefsSchema = AutonomyPrefsObjectSchema.default({});
67376
67396
 
67377
- const DirectionSchema = enumType(['long_only', 'long_short', 'market_neutral']);
67397
+ const DirectionSchema = enumType(["long_only", "long_short", "market_neutral"]);
67378
67398
  /**
67379
67399
  * Asset universe preferences schema (section 7.2).
67380
67400
  * Defines which instruments, exchanges, sectors, and market segments
@@ -67384,10 +67404,10 @@ const DirectionSchema = enumType(['long_only', 'long_short', 'market_neutral']);
67384
67404
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67385
67405
  */
67386
67406
  const AssetUniversePrefsObjectSchema = objectType({
67387
- equitiesDirection: DirectionSchema.default('long_only'),
67388
- etfsDirection: enumType(['long_only', 'long_short']).default('long_only'),
67389
- cryptoDirection: enumType(['long_only', 'long_short']).default('long_only'),
67390
- 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"),
67391
67411
  allowedExchanges: arrayType(stringType()).default([]),
67392
67412
  deniedExchanges: arrayType(stringType()).default([]),
67393
67413
  allowedCountries: arrayType(stringType()).default([]),
@@ -67442,15 +67462,15 @@ const RiskBudgetPrefsObjectSchema = objectType({
67442
67462
  overnightExposureCapPct: numberType().min(0).max(100).default(50),
67443
67463
  weekendExposureCapPct: numberType().min(0).max(100).default(30),
67444
67464
  eventRiskExposureCapPct: numberType().min(0).max(100).default(40),
67445
- gapRiskSensitivity: enumType(['low', 'medium', 'high']).default('medium'),
67465
+ gapRiskSensitivity: enumType(["low", "medium", "high"]).default("medium"),
67446
67466
  /** Per-trade equity allocation as % of account equity. Replaces legacy AlpacaAccount.tradeAllocationPct. */
67447
67467
  perTradeAllocationPct: numberType().min(0).max(100).default(5),
67448
67468
  /** Per-trade crypto allocation as % of account equity. Replaces legacy AlpacaAccount.cryptoTradeAllocationPct. */
67449
67469
  perTradeCryptoAllocationPct: numberType().min(0).max(100).default(5),
67450
67470
  /** Alpaca day-trading buying power check enforcement. Synced to Alpaca API. */
67451
- dtbpCheck: enumType(['both', 'entry', 'exit']).default('both'),
67471
+ dtbpCheck: enumType(["both", "entry", "exit"]).default("both"),
67452
67472
  /** Alpaca pattern day trader rule enforcement. Synced to Alpaca API. */
67453
- pdtCheck: enumType(['both', 'entry', 'exit']).default('both'),
67473
+ pdtCheck: enumType(["both", "entry", "exit"]).default("both"),
67454
67474
  /** Strict PDT enforcement — block all violations without exception. Synced to Alpaca API. */
67455
67475
  ptpNoExceptionEntry: booleanType().default(false),
67456
67476
  });
@@ -67492,14 +67512,21 @@ const SignalConsumptionPrefsObjectSchema = objectType({
67492
67512
  cooldownAfterFailedTradeSeconds: numberType().min(0).default(180),
67493
67513
  duplicateSignalSuppressionWindowSeconds: numberType().min(0).default(300),
67494
67514
  reversalHandlingPolicy: enumType([
67495
- 'ignore_reversal', 'close_only', 'flatten_then_reverse', 'allow_full_reversal',
67496
- ]).default('close_only'),
67515
+ "ignore_reversal",
67516
+ "close_only",
67517
+ "flatten_then_reverse",
67518
+ "allow_full_reversal",
67519
+ ])
67520
+ .default("close_only"),
67497
67521
  conflictHandlingOpenOrders: enumType([
67498
- 'cancel_conflicting', 'replace_existing', 'keep_existing_skip', 'escalate',
67499
- ]).default('cancel_conflicting'),
67500
- conflictHandlingOpposingPosition: enumType([
67501
- 'reduce', 'close', 'flatten_then_reverse', 'hold',
67502
- ]).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"),
67503
67530
  minConvictionDeltaToModify: numberType().min(0).max(100).default(10),
67504
67531
  strategyPriorityRules: arrayType(StrategyPriorityRuleSchema).default([]),
67505
67532
  noTradeWindows: arrayType(NoTradeWindowSchema).default([]),
@@ -67513,7 +67540,13 @@ const SignalConsumptionPrefsObjectSchema = objectType({
67513
67540
  });
67514
67541
  const SignalConsumptionPrefsSchema = SignalConsumptionPrefsObjectSchema.default({});
67515
67542
 
67516
- 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
+ ]);
67517
67550
  /**
67518
67551
  * Execution preferences schema (section 7.5).
67519
67552
  * Governs order routing behavior including order types, time-in-force,
@@ -67523,11 +67556,14 @@ const OrderTypeEnum = enumType(['market', 'limit', 'stop', 'stop_limit', 'traili
67523
67556
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67524
67557
  */
67525
67558
  const ExecutionPrefsObjectSchema = objectType({
67526
- allowedOrderTypes: arrayType(OrderTypeEnum).default(['market', 'limit', 'stop', 'trailing_stop']),
67527
- preferredOrderType: OrderTypeEnum.default('limit'),
67528
- preferredOrderTypeByAssetClass: recordType(stringType(), stringType()).default({ crypto: 'market' }),
67529
- defaultTimeInForce: enumType(['day', 'gtc', 'ioc', 'fok']).default('day'),
67530
- 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"),
67531
67567
  maxSlippageTolerancePct: numberType().min(0).max(100).default(1.0),
67532
67568
  priceCollarEnabled: booleanType().default(true),
67533
67569
  priceCollarPct: numberType().min(0).default(2),
@@ -67535,11 +67571,14 @@ const ExecutionPrefsObjectSchema = objectType({
67535
67571
  repriceMaxAttempts: numberType().min(0).default(3),
67536
67572
  repriceIntervalSeconds: numberType().min(0).default(30),
67537
67573
  cancelReplaceTimeoutSeconds: numberType().min(0).default(60),
67538
- partialFillPolicy: enumType(['accept_partial', 'cancel_remainder', 'replace_to_fill']).default('accept_partial'),
67539
- sizingMethod: enumType(['notional', 'quantity']).default('notional'),
67540
- lotRoundingBehavior: enumType(['round_down', 'round_nearest', 'round_up']).default('round_down'),
67541
- afterHoursExecutionBehavior: enumType(['limit_only', 'no_execution', 'normal']).default('limit_only'),
67542
- 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"),
67543
67582
  });
67544
67583
  const ExecutionPrefsSchema = ExecutionPrefsObjectSchema.default({});
67545
67584
 
@@ -67557,10 +67596,12 @@ const TrailingStopTighteningRuleSchema = objectType({
67557
67596
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67558
67597
  */
67559
67598
  const PositionManagementPrefsObjectSchema = objectType({
67560
- 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"),
67561
67601
  defaultStopLossPct: numberType().min(0).max(100).default(4),
67562
67602
  atrStopMultiplier: numberType().min(0).default(2),
67563
- 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"),
67564
67605
  defaultTakeProfitPct: numberType().min(0).max(100).default(3),
67565
67606
  defaultRiskRewardRatio: numberType().min(0).default(2),
67566
67607
  breakEvenStopEnabled: booleanType().default(true),
@@ -67581,7 +67622,8 @@ const PositionManagementPrefsObjectSchema = objectType({
67581
67622
  addToLosersAllowed: booleanType().default(false),
67582
67623
  stopWideningAllowed: booleanType().default(false),
67583
67624
  trailingStopTighteningEnabled: booleanType().default(true),
67584
- trailingStopTighteningRules: arrayType(TrailingStopTighteningRuleSchema).default([
67625
+ trailingStopTighteningRules: arrayType(TrailingStopTighteningRuleSchema)
67626
+ .default([
67585
67627
  { profitThresholdPct: 3, newTrailPct: 2.0 },
67586
67628
  { profitThresholdPct: 6, newTrailPct: 1.5 },
67587
67629
  { profitThresholdPct: 10, newTrailPct: 1.0 },
@@ -67620,13 +67662,21 @@ const PortfolioConstructionPrefsObjectSchema = objectType({
67620
67662
  targetAllocationByAssetClass: recordType(stringType(), numberType()).default({}),
67621
67663
  tacticalAllocationBands: recordType(stringType(), TacticalBandSchema).default({}),
67622
67664
  driftThresholdPct: numberType().min(0).max(100).default(5),
67623
- rebalanceTrigger: enumType(['threshold', 'calendar', 'both']).default('threshold'),
67665
+ rebalanceTrigger: enumType(["threshold", "calendar", "both"])
67666
+ .default("threshold"),
67624
67667
  rebalanceFrequencyDays: numberType().min(0).default(30),
67625
67668
  autonomousRebalancing: booleanType().default(false),
67626
67669
  rebalanceDuringRiskOff: booleanType().default(false),
67627
67670
  maxTurnoverPerRebalancePct: numberType().min(0).max(100).default(20),
67628
- preferredWeighting: enumType(['equal_weight', 'risk_based', 'conviction_weighted', 'target_allocation']).default('equal_weight'),
67629
- 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({}),
67630
67680
  cashTargetPct: numberType().min(0).max(100).default(10),
67631
67681
  defensiveCashEscalationEnabled: booleanType().default(false),
67632
67682
  defensiveCashEscalationRules: arrayType(DefensiveCashRuleSchema).default([]),
@@ -67673,7 +67723,8 @@ const OverlayResponseConfigSchema = objectType({
67673
67723
  * for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
67674
67724
  */
67675
67725
  const OverlayResponsePrefsObjectSchema = objectType({
67676
- overlayResponses: recordType(nativeEnumType(exports.OverlayType), OverlayResponseConfigSchema).default({}),
67726
+ overlayResponses: recordType(nativeEnumType(exports.OverlayType), OverlayResponseConfigSchema)
67727
+ .default({}),
67677
67728
  });
67678
67729
  const OverlayResponsePrefsSchema = OverlayResponsePrefsObjectSchema.default({});
67679
67730
 
@@ -67709,14 +67760,16 @@ const ModelPrefsObjectSchema = objectType({
67709
67760
  latencyTargetMs: numberType().min(0).default(5000),
67710
67761
  timeoutMs: numberType().min(0).default(30000),
67711
67762
  maxRetries: numberType().min(0).default(2),
67712
- toolUsePermissionsByTier: recordType(stringType(), ToolUsePermissionsSchema).default({
67763
+ toolUsePermissionsByTier: recordType(stringType(), ToolUsePermissionsSchema)
67764
+ .default({
67713
67765
  mini: { readTools: true, writeTools: false },
67714
67766
  normal: { readTools: true, writeTools: false },
67715
67767
  advanced: { readTools: true, writeTools: true },
67716
67768
  }),
67717
67769
  memorySummaryCadenceMinutes: numberType().min(0).default(60),
67718
67770
  maxMemorySummariesRetained: numberType().min(0).default(50),
67719
- excludedProvidersForWorkflows: recordType(stringType(), arrayType(stringType())).default({}),
67771
+ excludedProvidersForWorkflows: recordType(stringType(), arrayType(stringType()))
67772
+ .default({}),
67720
67773
  quantModelWeight: numberType().min(0).max(1).default(0.7),
67721
67774
  });
67722
67775
  const ModelPrefsSchema = ModelPrefsObjectSchema.default({});
@@ -67736,16 +67789,18 @@ const AuditNotificationPrefsObjectSchema = objectType({
67736
67789
  notifyOnPolicyMutation: booleanType().default(true),
67737
67790
  dailySummaryEnabled: booleanType().default(true),
67738
67791
  eventSummaryEnabled: booleanType().default(true),
67739
- auditDetailLevel: enumType(['minimal', 'standard', 'verbose']).default('standard'),
67792
+ auditDetailLevel: enumType(["minimal", "standard", "verbose"])
67793
+ .default("standard"),
67740
67794
  saveRationaleSummaries: booleanType().default(true),
67741
67795
  saveToolCallTraces: booleanType().default(false),
67742
67796
  saveContextSnapshots: booleanType().default(true),
67743
- incidentAlertChannel: enumType(['email', 'slack', 'discord', 'webhook', 'none']).default('none'),
67744
- incidentAlertEndpoint: stringType().default(''),
67797
+ incidentAlertChannel: enumType(["email", "slack", "discord", "webhook", "none"])
67798
+ .default("none"),
67799
+ incidentAlertEndpoint: stringType().default(""),
67745
67800
  requirePostActionExplanation: booleanType().default(true),
67746
67801
  retainDecisionArtifactsDays: numberType().min(0).default(90),
67747
67802
  /** Trade confirmation email preference. Synced to Alpaca API. */
67748
- tradeConfirmEmail: enumType(['all', 'none']).default('all'),
67803
+ tradeConfirmEmail: enumType(["all", "none"]).default("all"),
67749
67804
  });
67750
67805
  const AuditNotificationPrefsSchema = AuditNotificationPrefsObjectSchema.default({});
67751
67806
 
@@ -67795,7 +67850,8 @@ const PolicyMutationSchema = objectType({
67795
67850
  overlayResponsePrefs: OverlayResponsePrefsObjectSchema.deepPartial().optional(),
67796
67851
  modelPrefs: ModelPrefsObjectSchema.deepPartial().optional(),
67797
67852
  auditNotificationPrefs: AuditNotificationPrefsObjectSchema.deepPartial().optional(),
67798
- }).passthrough();
67853
+ })
67854
+ .passthrough();
67799
67855
 
67800
67856
  /**
67801
67857
  * Effective trading policy schema representing the fully-resolved policy