@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.
- package/dist/index.cjs +118 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +118 -62
- 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/rate-limiter.d.ts +6 -3
- package/dist/types/rate-limiter.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}`, {
|
|
@@ -7845,24 +7855,27 @@ const rateLimiters = {
|
|
|
7845
7855
|
/**
|
|
7846
7856
|
* Alpaca API rate limiter
|
|
7847
7857
|
*
|
|
7848
|
-
* Configured for
|
|
7858
|
+
* Configured for 1000 requests per minute (paid tier).
|
|
7859
|
+
* The token bucket allows burst up to maxTokens, then refills at the steady rate.
|
|
7849
7860
|
* See: https://alpaca.markets/docs/api-references/trading-api/#rate-limit
|
|
7850
7861
|
*/
|
|
7851
7862
|
alpaca: new TokenBucketRateLimiter({
|
|
7852
|
-
maxTokens:
|
|
7853
|
-
refillRate:
|
|
7863
|
+
maxTokens: 1000,
|
|
7864
|
+
refillRate: 1000 / 60, // 1000 requests per 60 seconds (~16.67/sec)
|
|
7854
7865
|
label: "alpaca",
|
|
7855
7866
|
timeoutMs: 60000,
|
|
7856
7867
|
}),
|
|
7857
7868
|
/**
|
|
7858
7869
|
* Massive.com API rate limiter
|
|
7859
7870
|
*
|
|
7860
|
-
* Configured for
|
|
7861
|
-
*
|
|
7871
|
+
* Configured generously for paid unlimited tier. The bucket exists only as a
|
|
7872
|
+
* safety net against runaway loops — the 1000 token burst and 500/sec refill
|
|
7873
|
+
* should never be hit under normal operation. If the paid plan truly has no
|
|
7874
|
+
* hard limit, this just prevents accidental self-DDoS.
|
|
7862
7875
|
*/
|
|
7863
7876
|
massive: new TokenBucketRateLimiter({
|
|
7864
|
-
maxTokens:
|
|
7865
|
-
refillRate:
|
|
7877
|
+
maxTokens: 1000,
|
|
7878
|
+
refillRate: 500, // 500 tokens/sec refill — effectively unlimited for paid tier
|
|
7866
7879
|
label: "massive",
|
|
7867
7880
|
timeoutMs: 30000,
|
|
7868
7881
|
}),
|
|
@@ -58790,12 +58803,14 @@ async function getPositionSide(client, symbol) {
|
|
|
58790
58803
|
async function closePosition(client, symbol, options) {
|
|
58791
58804
|
// Normalize crypto symbols: Alpaca positions endpoint rejects hyphenated
|
|
58792
58805
|
// format (e.g., "SOL-USD") but accepts concatenated form (e.g., "SOLUSD").
|
|
58793
|
-
const isCrypto = symbol.includes("/") ||
|
|
58806
|
+
const isCrypto = symbol.includes("/") ||
|
|
58807
|
+
symbol.includes("-") ||
|
|
58794
58808
|
/^[A-Z]{2,}USD[TC]?$/i.test(symbol);
|
|
58795
|
-
const normalizedSymbol = isCrypto
|
|
58796
|
-
|
|
58797
|
-
:
|
|
58798
|
-
|
|
58809
|
+
const normalizedSymbol = isCrypto ? symbol.replace(/[-/]/g, "") : symbol;
|
|
58810
|
+
log(`Closing position for ${normalizedSymbol}`, {
|
|
58811
|
+
type: "info",
|
|
58812
|
+
symbol: normalizedSymbol,
|
|
58813
|
+
});
|
|
58799
58814
|
try {
|
|
58800
58815
|
const sdk = client.getSDK();
|
|
58801
58816
|
// Build query params for partial closes
|
|
@@ -58815,7 +58830,10 @@ async function closePosition(client, symbol, options) {
|
|
|
58815
58830
|
});
|
|
58816
58831
|
}
|
|
58817
58832
|
else {
|
|
58818
|
-
log(`Closing entire position for ${normalizedSymbol}`, {
|
|
58833
|
+
log(`Closing entire position for ${normalizedSymbol}`, {
|
|
58834
|
+
type: "info",
|
|
58835
|
+
symbol: normalizedSymbol,
|
|
58836
|
+
});
|
|
58819
58837
|
}
|
|
58820
58838
|
// Use sendRequest for parameterized close, closePosition for full close
|
|
58821
58839
|
let order;
|
|
@@ -67337,7 +67355,8 @@ const RequireHumanApprovalSchema = objectType({
|
|
|
67337
67355
|
closeAllOrdersAndPositions: booleanType().default(true),
|
|
67338
67356
|
policyMutations: booleanType().default(true),
|
|
67339
67357
|
advancedModelEscalations: booleanType().default(false),
|
|
67340
|
-
})
|
|
67358
|
+
})
|
|
67359
|
+
.default({});
|
|
67341
67360
|
/**
|
|
67342
67361
|
* Schema for allowed trading session windows.
|
|
67343
67362
|
* Controls which market sessions the system may trade during.
|
|
@@ -67348,7 +67367,8 @@ const AllowedSessionsSchema = objectType({
|
|
|
67348
67367
|
afterHours: booleanType().default(false),
|
|
67349
67368
|
overnight: booleanType().default(false),
|
|
67350
67369
|
weekends: booleanType().default(false),
|
|
67351
|
-
})
|
|
67370
|
+
})
|
|
67371
|
+
.default({});
|
|
67352
67372
|
/**
|
|
67353
67373
|
* Autonomy preferences schema (section 7.1).
|
|
67354
67374
|
* Governs the level of automated decision-making, human approval gates,
|
|
@@ -67372,7 +67392,7 @@ const AutonomyPrefsObjectSchema = objectType({
|
|
|
67372
67392
|
});
|
|
67373
67393
|
const AutonomyPrefsSchema = AutonomyPrefsObjectSchema.default({});
|
|
67374
67394
|
|
|
67375
|
-
const DirectionSchema = enumType([
|
|
67395
|
+
const DirectionSchema = enumType(["long_only", "long_short", "market_neutral"]);
|
|
67376
67396
|
/**
|
|
67377
67397
|
* Asset universe preferences schema (section 7.2).
|
|
67378
67398
|
* Defines which instruments, exchanges, sectors, and market segments
|
|
@@ -67382,10 +67402,10 @@ const DirectionSchema = enumType(['long_only', 'long_short', 'market_neutral']);
|
|
|
67382
67402
|
* for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
|
|
67383
67403
|
*/
|
|
67384
67404
|
const AssetUniversePrefsObjectSchema = objectType({
|
|
67385
|
-
equitiesDirection: DirectionSchema.default(
|
|
67386
|
-
etfsDirection: enumType([
|
|
67387
|
-
cryptoDirection: enumType([
|
|
67388
|
-
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"),
|
|
67389
67409
|
allowedExchanges: arrayType(stringType()).default([]),
|
|
67390
67410
|
deniedExchanges: arrayType(stringType()).default([]),
|
|
67391
67411
|
allowedCountries: arrayType(stringType()).default([]),
|
|
@@ -67440,15 +67460,15 @@ const RiskBudgetPrefsObjectSchema = objectType({
|
|
|
67440
67460
|
overnightExposureCapPct: numberType().min(0).max(100).default(50),
|
|
67441
67461
|
weekendExposureCapPct: numberType().min(0).max(100).default(30),
|
|
67442
67462
|
eventRiskExposureCapPct: numberType().min(0).max(100).default(40),
|
|
67443
|
-
gapRiskSensitivity: enumType([
|
|
67463
|
+
gapRiskSensitivity: enumType(["low", "medium", "high"]).default("medium"),
|
|
67444
67464
|
/** Per-trade equity allocation as % of account equity. Replaces legacy AlpacaAccount.tradeAllocationPct. */
|
|
67445
67465
|
perTradeAllocationPct: numberType().min(0).max(100).default(5),
|
|
67446
67466
|
/** Per-trade crypto allocation as % of account equity. Replaces legacy AlpacaAccount.cryptoTradeAllocationPct. */
|
|
67447
67467
|
perTradeCryptoAllocationPct: numberType().min(0).max(100).default(5),
|
|
67448
67468
|
/** Alpaca day-trading buying power check enforcement. Synced to Alpaca API. */
|
|
67449
|
-
dtbpCheck: enumType([
|
|
67469
|
+
dtbpCheck: enumType(["both", "entry", "exit"]).default("both"),
|
|
67450
67470
|
/** Alpaca pattern day trader rule enforcement. Synced to Alpaca API. */
|
|
67451
|
-
pdtCheck: enumType([
|
|
67471
|
+
pdtCheck: enumType(["both", "entry", "exit"]).default("both"),
|
|
67452
67472
|
/** Strict PDT enforcement — block all violations without exception. Synced to Alpaca API. */
|
|
67453
67473
|
ptpNoExceptionEntry: booleanType().default(false),
|
|
67454
67474
|
});
|
|
@@ -67490,14 +67510,21 @@ const SignalConsumptionPrefsObjectSchema = objectType({
|
|
|
67490
67510
|
cooldownAfterFailedTradeSeconds: numberType().min(0).default(180),
|
|
67491
67511
|
duplicateSignalSuppressionWindowSeconds: numberType().min(0).default(300),
|
|
67492
67512
|
reversalHandlingPolicy: enumType([
|
|
67493
|
-
|
|
67494
|
-
|
|
67513
|
+
"ignore_reversal",
|
|
67514
|
+
"close_only",
|
|
67515
|
+
"flatten_then_reverse",
|
|
67516
|
+
"allow_full_reversal",
|
|
67517
|
+
])
|
|
67518
|
+
.default("close_only"),
|
|
67495
67519
|
conflictHandlingOpenOrders: enumType([
|
|
67496
|
-
|
|
67497
|
-
|
|
67498
|
-
|
|
67499
|
-
|
|
67500
|
-
])
|
|
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"),
|
|
67501
67528
|
minConvictionDeltaToModify: numberType().min(0).max(100).default(10),
|
|
67502
67529
|
strategyPriorityRules: arrayType(StrategyPriorityRuleSchema).default([]),
|
|
67503
67530
|
noTradeWindows: arrayType(NoTradeWindowSchema).default([]),
|
|
@@ -67511,7 +67538,13 @@ const SignalConsumptionPrefsObjectSchema = objectType({
|
|
|
67511
67538
|
});
|
|
67512
67539
|
const SignalConsumptionPrefsSchema = SignalConsumptionPrefsObjectSchema.default({});
|
|
67513
67540
|
|
|
67514
|
-
const OrderTypeEnum = enumType([
|
|
67541
|
+
const OrderTypeEnum = enumType([
|
|
67542
|
+
"market",
|
|
67543
|
+
"limit",
|
|
67544
|
+
"stop",
|
|
67545
|
+
"stop_limit",
|
|
67546
|
+
"trailing_stop",
|
|
67547
|
+
]);
|
|
67515
67548
|
/**
|
|
67516
67549
|
* Execution preferences schema (section 7.5).
|
|
67517
67550
|
* Governs order routing behavior including order types, time-in-force,
|
|
@@ -67521,11 +67554,14 @@ const OrderTypeEnum = enumType(['market', 'limit', 'stop', 'stop_limit', 'traili
|
|
|
67521
67554
|
* for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
|
|
67522
67555
|
*/
|
|
67523
67556
|
const ExecutionPrefsObjectSchema = objectType({
|
|
67524
|
-
allowedOrderTypes: arrayType(OrderTypeEnum)
|
|
67525
|
-
|
|
67526
|
-
|
|
67527
|
-
|
|
67528
|
-
|
|
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"),
|
|
67529
67565
|
maxSlippageTolerancePct: numberType().min(0).max(100).default(1.0),
|
|
67530
67566
|
priceCollarEnabled: booleanType().default(true),
|
|
67531
67567
|
priceCollarPct: numberType().min(0).default(2),
|
|
@@ -67533,11 +67569,14 @@ const ExecutionPrefsObjectSchema = objectType({
|
|
|
67533
67569
|
repriceMaxAttempts: numberType().min(0).default(3),
|
|
67534
67570
|
repriceIntervalSeconds: numberType().min(0).default(30),
|
|
67535
67571
|
cancelReplaceTimeoutSeconds: numberType().min(0).default(60),
|
|
67536
|
-
partialFillPolicy: enumType([
|
|
67537
|
-
|
|
67538
|
-
|
|
67539
|
-
|
|
67540
|
-
|
|
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"),
|
|
67541
67580
|
});
|
|
67542
67581
|
const ExecutionPrefsSchema = ExecutionPrefsObjectSchema.default({});
|
|
67543
67582
|
|
|
@@ -67555,10 +67594,12 @@ const TrailingStopTighteningRuleSchema = objectType({
|
|
|
67555
67594
|
* for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
|
|
67556
67595
|
*/
|
|
67557
67596
|
const PositionManagementPrefsObjectSchema = objectType({
|
|
67558
|
-
defaultStopLossMethod: enumType([
|
|
67597
|
+
defaultStopLossMethod: enumType(["fixed_percent", "atr_based", "structure_based", "trailing_stop"])
|
|
67598
|
+
.default("trailing_stop"),
|
|
67559
67599
|
defaultStopLossPct: numberType().min(0).max(100).default(4),
|
|
67560
67600
|
atrStopMultiplier: numberType().min(0).default(2),
|
|
67561
|
-
defaultTakeProfitMethod: enumType([
|
|
67601
|
+
defaultTakeProfitMethod: enumType(["fixed_percent", "atr_based", "risk_reward_ratio", "none"])
|
|
67602
|
+
.default("risk_reward_ratio"),
|
|
67562
67603
|
defaultTakeProfitPct: numberType().min(0).max(100).default(3),
|
|
67563
67604
|
defaultRiskRewardRatio: numberType().min(0).default(2),
|
|
67564
67605
|
breakEvenStopEnabled: booleanType().default(true),
|
|
@@ -67579,7 +67620,8 @@ const PositionManagementPrefsObjectSchema = objectType({
|
|
|
67579
67620
|
addToLosersAllowed: booleanType().default(false),
|
|
67580
67621
|
stopWideningAllowed: booleanType().default(false),
|
|
67581
67622
|
trailingStopTighteningEnabled: booleanType().default(true),
|
|
67582
|
-
trailingStopTighteningRules: arrayType(TrailingStopTighteningRuleSchema)
|
|
67623
|
+
trailingStopTighteningRules: arrayType(TrailingStopTighteningRuleSchema)
|
|
67624
|
+
.default([
|
|
67583
67625
|
{ profitThresholdPct: 3, newTrailPct: 2.0 },
|
|
67584
67626
|
{ profitThresholdPct: 6, newTrailPct: 1.5 },
|
|
67585
67627
|
{ profitThresholdPct: 10, newTrailPct: 1.0 },
|
|
@@ -67618,13 +67660,21 @@ const PortfolioConstructionPrefsObjectSchema = objectType({
|
|
|
67618
67660
|
targetAllocationByAssetClass: recordType(stringType(), numberType()).default({}),
|
|
67619
67661
|
tacticalAllocationBands: recordType(stringType(), TacticalBandSchema).default({}),
|
|
67620
67662
|
driftThresholdPct: numberType().min(0).max(100).default(5),
|
|
67621
|
-
rebalanceTrigger: enumType([
|
|
67663
|
+
rebalanceTrigger: enumType(["threshold", "calendar", "both"])
|
|
67664
|
+
.default("threshold"),
|
|
67622
67665
|
rebalanceFrequencyDays: numberType().min(0).default(30),
|
|
67623
67666
|
autonomousRebalancing: booleanType().default(false),
|
|
67624
67667
|
rebalanceDuringRiskOff: booleanType().default(false),
|
|
67625
67668
|
maxTurnoverPerRebalancePct: numberType().min(0).max(100).default(20),
|
|
67626
|
-
preferredWeighting: enumType([
|
|
67627
|
-
|
|
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({}),
|
|
67628
67678
|
cashTargetPct: numberType().min(0).max(100).default(10),
|
|
67629
67679
|
defensiveCashEscalationEnabled: booleanType().default(false),
|
|
67630
67680
|
defensiveCashEscalationRules: arrayType(DefensiveCashRuleSchema).default([]),
|
|
@@ -67671,7 +67721,8 @@ const OverlayResponseConfigSchema = objectType({
|
|
|
67671
67721
|
* for use with `deepPartial()`, which requires a ZodObject (not ZodDefault).
|
|
67672
67722
|
*/
|
|
67673
67723
|
const OverlayResponsePrefsObjectSchema = objectType({
|
|
67674
|
-
overlayResponses: recordType(nativeEnumType(OverlayType), OverlayResponseConfigSchema)
|
|
67724
|
+
overlayResponses: recordType(nativeEnumType(OverlayType), OverlayResponseConfigSchema)
|
|
67725
|
+
.default({}),
|
|
67675
67726
|
});
|
|
67676
67727
|
const OverlayResponsePrefsSchema = OverlayResponsePrefsObjectSchema.default({});
|
|
67677
67728
|
|
|
@@ -67707,14 +67758,16 @@ const ModelPrefsObjectSchema = objectType({
|
|
|
67707
67758
|
latencyTargetMs: numberType().min(0).default(5000),
|
|
67708
67759
|
timeoutMs: numberType().min(0).default(30000),
|
|
67709
67760
|
maxRetries: numberType().min(0).default(2),
|
|
67710
|
-
toolUsePermissionsByTier: recordType(stringType(), ToolUsePermissionsSchema)
|
|
67761
|
+
toolUsePermissionsByTier: recordType(stringType(), ToolUsePermissionsSchema)
|
|
67762
|
+
.default({
|
|
67711
67763
|
mini: { readTools: true, writeTools: false },
|
|
67712
67764
|
normal: { readTools: true, writeTools: false },
|
|
67713
67765
|
advanced: { readTools: true, writeTools: true },
|
|
67714
67766
|
}),
|
|
67715
67767
|
memorySummaryCadenceMinutes: numberType().min(0).default(60),
|
|
67716
67768
|
maxMemorySummariesRetained: numberType().min(0).default(50),
|
|
67717
|
-
excludedProvidersForWorkflows: recordType(stringType(), arrayType(stringType()))
|
|
67769
|
+
excludedProvidersForWorkflows: recordType(stringType(), arrayType(stringType()))
|
|
67770
|
+
.default({}),
|
|
67718
67771
|
quantModelWeight: numberType().min(0).max(1).default(0.7),
|
|
67719
67772
|
});
|
|
67720
67773
|
const ModelPrefsSchema = ModelPrefsObjectSchema.default({});
|
|
@@ -67734,16 +67787,18 @@ const AuditNotificationPrefsObjectSchema = objectType({
|
|
|
67734
67787
|
notifyOnPolicyMutation: booleanType().default(true),
|
|
67735
67788
|
dailySummaryEnabled: booleanType().default(true),
|
|
67736
67789
|
eventSummaryEnabled: booleanType().default(true),
|
|
67737
|
-
auditDetailLevel: enumType([
|
|
67790
|
+
auditDetailLevel: enumType(["minimal", "standard", "verbose"])
|
|
67791
|
+
.default("standard"),
|
|
67738
67792
|
saveRationaleSummaries: booleanType().default(true),
|
|
67739
67793
|
saveToolCallTraces: booleanType().default(false),
|
|
67740
67794
|
saveContextSnapshots: booleanType().default(true),
|
|
67741
|
-
incidentAlertChannel: enumType([
|
|
67742
|
-
|
|
67795
|
+
incidentAlertChannel: enumType(["email", "slack", "discord", "webhook", "none"])
|
|
67796
|
+
.default("none"),
|
|
67797
|
+
incidentAlertEndpoint: stringType().default(""),
|
|
67743
67798
|
requirePostActionExplanation: booleanType().default(true),
|
|
67744
67799
|
retainDecisionArtifactsDays: numberType().min(0).default(90),
|
|
67745
67800
|
/** Trade confirmation email preference. Synced to Alpaca API. */
|
|
67746
|
-
tradeConfirmEmail: enumType([
|
|
67801
|
+
tradeConfirmEmail: enumType(["all", "none"]).default("all"),
|
|
67747
67802
|
});
|
|
67748
67803
|
const AuditNotificationPrefsSchema = AuditNotificationPrefsObjectSchema.default({});
|
|
67749
67804
|
|
|
@@ -67793,7 +67848,8 @@ const PolicyMutationSchema = objectType({
|
|
|
67793
67848
|
overlayResponsePrefs: OverlayResponsePrefsObjectSchema.deepPartial().optional(),
|
|
67794
67849
|
modelPrefs: ModelPrefsObjectSchema.deepPartial().optional(),
|
|
67795
67850
|
auditNotificationPrefs: AuditNotificationPrefsObjectSchema.deepPartial().optional(),
|
|
67796
|
-
})
|
|
67851
|
+
})
|
|
67852
|
+
.passthrough();
|
|
67797
67853
|
|
|
67798
67854
|
/**
|
|
67799
67855
|
* Effective trading policy schema representing the fully-resolved policy
|