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