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