@adaptic/utils 0.0.990 → 0.0.991
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 +250 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +250 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +25 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/misc-utils.d.ts +37 -0
- package/dist/types/misc-utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6042,6 +6042,202 @@ async function createLimitOrder(auth, params = {
|
|
|
6042
6042
|
}
|
|
6043
6043
|
|
|
6044
6044
|
// Utility function for debug logging
|
|
6045
|
+
/** Sliding-window size (number of recent outcomes tracked per host). */
|
|
6046
|
+
const CIRCUIT_WINDOW_SIZE = 20;
|
|
6047
|
+
/** Maximum age (ms) of an outcome before it is dropped from the window. */
|
|
6048
|
+
const CIRCUIT_WINDOW_TTL_MS = 30_000;
|
|
6049
|
+
/**
|
|
6050
|
+
* Failure ratio (0..1) at which the breaker trips when the window
|
|
6051
|
+
* is full (i.e. CIRCUIT_WINDOW_SIZE outcomes recorded).
|
|
6052
|
+
*
|
|
6053
|
+
* Tuned to be permissive enough that a few transient failures during
|
|
6054
|
+
* normal operation do not trip the breaker, but tight enough that a
|
|
6055
|
+
* persistent upstream outage (where >= half of recent calls are
|
|
6056
|
+
* failing) is detected quickly. With WINDOW=20 and threshold=0.6 we
|
|
6057
|
+
* need 12 failures within the most recent 20 attempts to trip.
|
|
6058
|
+
*/
|
|
6059
|
+
const CIRCUIT_TRIP_FAILURE_RATIO = 0.6;
|
|
6060
|
+
/**
|
|
6061
|
+
* Minimum number of recent outcomes required before the failure-ratio
|
|
6062
|
+
* gate is even evaluated. Without this guard, a single failure on a
|
|
6063
|
+
* cold host would give a 100 % ratio and trip the breaker on the
|
|
6064
|
+
* second attempt — which would be useless protection while also being
|
|
6065
|
+
* highly destructive.
|
|
6066
|
+
*/
|
|
6067
|
+
const CIRCUIT_MIN_SAMPLES = 8;
|
|
6068
|
+
/**
|
|
6069
|
+
* How long the breaker stays open before transitioning to half-open
|
|
6070
|
+
* (i.e. allowing the next request through as a probe). The next
|
|
6071
|
+
* outcome — success or failure — fully recloses or re-opens the
|
|
6072
|
+
* breaker. 5 s aligns with typical upstream recovery times and is
|
|
6073
|
+
* short enough that the next caller drives the probe.
|
|
6074
|
+
*/
|
|
6075
|
+
const CIRCUIT_OPEN_COOLDOWN_MS = 5_000;
|
|
6076
|
+
/**
|
|
6077
|
+
* Fail-fast latency. We sleep a short, deterministic amount before
|
|
6078
|
+
* rejecting so the upstream caller's outer timeout (commonly 10–25 s)
|
|
6079
|
+
* sees a clean rejection rather than a synchronous reject-storm that
|
|
6080
|
+
* could starve other event-loop work. 100 ms aligns with the user's
|
|
6081
|
+
* G1 analysis target: "cap per-symbol fallback latency at 100 ms
|
|
6082
|
+
* during outages — eliminating the 25 s × N-concurrent-symbols
|
|
6083
|
+
* event-loop hog."
|
|
6084
|
+
*/
|
|
6085
|
+
const CIRCUIT_FAIL_FAST_LATENCY_MS = 100;
|
|
6086
|
+
const circuitStates = new Map();
|
|
6087
|
+
function getCircuitState(host) {
|
|
6088
|
+
let state = circuitStates.get(host);
|
|
6089
|
+
if (!state) {
|
|
6090
|
+
state = {
|
|
6091
|
+
host,
|
|
6092
|
+
recent: [],
|
|
6093
|
+
openedAt: 0,
|
|
6094
|
+
lastTripFailureRatio: 0,
|
|
6095
|
+
};
|
|
6096
|
+
circuitStates.set(host, state);
|
|
6097
|
+
}
|
|
6098
|
+
return state;
|
|
6099
|
+
}
|
|
6100
|
+
function pruneStaleSamples(state, now) {
|
|
6101
|
+
const cutoff = now - CIRCUIT_WINDOW_TTL_MS;
|
|
6102
|
+
// Remove entries older than the TTL. Window is small so a simple
|
|
6103
|
+
// filter is fine — no need for a deque structure.
|
|
6104
|
+
if (state.recent.length === 0)
|
|
6105
|
+
return;
|
|
6106
|
+
let firstFreshIndex = 0;
|
|
6107
|
+
while (firstFreshIndex < state.recent.length &&
|
|
6108
|
+
state.recent[firstFreshIndex].atMs < cutoff) {
|
|
6109
|
+
firstFreshIndex += 1;
|
|
6110
|
+
}
|
|
6111
|
+
if (firstFreshIndex > 0) {
|
|
6112
|
+
state.recent.splice(0, firstFreshIndex);
|
|
6113
|
+
}
|
|
6114
|
+
}
|
|
6115
|
+
function recordOutcome(host, ok) {
|
|
6116
|
+
const now = Date.now();
|
|
6117
|
+
const state = getCircuitState(host);
|
|
6118
|
+
pruneStaleSamples(state, now);
|
|
6119
|
+
state.recent.push({ atMs: now, ok });
|
|
6120
|
+
if (state.recent.length > CIRCUIT_WINDOW_SIZE) {
|
|
6121
|
+
state.recent.shift();
|
|
6122
|
+
}
|
|
6123
|
+
// If we are in the open or half-open window and just received an
|
|
6124
|
+
// outcome, decide whether to close or re-open.
|
|
6125
|
+
if (state.openedAt > 0) {
|
|
6126
|
+
if (now - state.openedAt >= CIRCUIT_OPEN_COOLDOWN_MS) {
|
|
6127
|
+
// Half-open probe outcome arrived.
|
|
6128
|
+
if (ok) {
|
|
6129
|
+
// Recovered. Close the breaker.
|
|
6130
|
+
state.openedAt = 0;
|
|
6131
|
+
state.lastTripFailureRatio = 0;
|
|
6132
|
+
getLogger().info(`Circuit breaker for ${host} closed — upstream recovered`, { host });
|
|
6133
|
+
}
|
|
6134
|
+
else {
|
|
6135
|
+
// Probe failed. Re-open the breaker for another cooldown.
|
|
6136
|
+
state.openedAt = now;
|
|
6137
|
+
}
|
|
6138
|
+
return;
|
|
6139
|
+
}
|
|
6140
|
+
// Still inside the cooldown window — outcomes are recorded for
|
|
6141
|
+
// statistics but the breaker stays open regardless.
|
|
6142
|
+
return;
|
|
6143
|
+
}
|
|
6144
|
+
// Closed breaker — evaluate whether the failure ratio has tripped.
|
|
6145
|
+
if (state.recent.length < CIRCUIT_MIN_SAMPLES)
|
|
6146
|
+
return;
|
|
6147
|
+
const failures = state.recent.reduce((acc, entry) => acc + (entry.ok ? 0 : 1), 0);
|
|
6148
|
+
const ratio = failures / state.recent.length;
|
|
6149
|
+
if (ratio >= CIRCUIT_TRIP_FAILURE_RATIO) {
|
|
6150
|
+
state.openedAt = now;
|
|
6151
|
+
state.lastTripFailureRatio = ratio;
|
|
6152
|
+
getLogger().warn(`Circuit breaker for ${host} opened — ${failures}/${state.recent.length} recent attempts failed (${(ratio * 100).toFixed(0)}%); fail-fast for ${CIRCUIT_OPEN_COOLDOWN_MS}ms`, {
|
|
6153
|
+
host,
|
|
6154
|
+
recentFailures: failures,
|
|
6155
|
+
recentSamples: state.recent.length,
|
|
6156
|
+
failureRatio: ratio,
|
|
6157
|
+
cooldownMs: CIRCUIT_OPEN_COOLDOWN_MS,
|
|
6158
|
+
});
|
|
6159
|
+
}
|
|
6160
|
+
}
|
|
6161
|
+
function isCircuitOpen(host, now) {
|
|
6162
|
+
const state = circuitStates.get(host);
|
|
6163
|
+
if (!state || state.openedAt === 0)
|
|
6164
|
+
return false;
|
|
6165
|
+
pruneStaleSamples(state, now);
|
|
6166
|
+
return now - state.openedAt < CIRCUIT_OPEN_COOLDOWN_MS;
|
|
6167
|
+
}
|
|
6168
|
+
/**
|
|
6169
|
+
* Error thrown by {@link fetchWithRetry} when the per-host circuit
|
|
6170
|
+
* breaker is open and fail-fast suppression is in effect.
|
|
6171
|
+
*
|
|
6172
|
+
* Carries the host, the failure ratio that tripped the breaker, and
|
|
6173
|
+
* the remaining cooldown so callers can render an actionable log.
|
|
6174
|
+
*/
|
|
6175
|
+
class CircuitOpenError extends Error {
|
|
6176
|
+
code = "MASSIVE_CIRCUIT_OPEN";
|
|
6177
|
+
host;
|
|
6178
|
+
tripFailureRatio;
|
|
6179
|
+
cooldownRemainingMs;
|
|
6180
|
+
constructor(host, tripFailureRatio, cooldownRemainingMs) {
|
|
6181
|
+
super(`Circuit open for ${host} — fail-fast (recent failure ratio ${(tripFailureRatio * 100).toFixed(0)}%, retry in ${cooldownRemainingMs}ms)`);
|
|
6182
|
+
this.name = "CircuitOpenError";
|
|
6183
|
+
this.host = host;
|
|
6184
|
+
this.tripFailureRatio = tripFailureRatio;
|
|
6185
|
+
this.cooldownRemainingMs = cooldownRemainingMs;
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
/**
|
|
6189
|
+
* Force-close the breaker for a given host. Exposed for tests and
|
|
6190
|
+
* operator-runbook scripts so a stuck-open breaker can be reset
|
|
6191
|
+
* without bouncing the process. Not intended for hot-path use.
|
|
6192
|
+
*
|
|
6193
|
+
* @param host The hostname whose breaker should be reset.
|
|
6194
|
+
*/
|
|
6195
|
+
function resetCircuitBreaker(host) {
|
|
6196
|
+
const state = circuitStates.get(host);
|
|
6197
|
+
if (!state)
|
|
6198
|
+
return;
|
|
6199
|
+
state.openedAt = 0;
|
|
6200
|
+
state.lastTripFailureRatio = 0;
|
|
6201
|
+
state.recent = [];
|
|
6202
|
+
}
|
|
6203
|
+
/**
|
|
6204
|
+
* Snapshot of all known per-host circuit-breaker states. Intended for
|
|
6205
|
+
* an operational-truth / status endpoint to surface upstream health.
|
|
6206
|
+
*
|
|
6207
|
+
* @returns Map of host → {open, openedAt, recentSamples, failureRatio,
|
|
6208
|
+
* lastTripFailureRatio}.
|
|
6209
|
+
*/
|
|
6210
|
+
function getCircuitBreakerSnapshot() {
|
|
6211
|
+
const now = Date.now();
|
|
6212
|
+
const snapshot = {};
|
|
6213
|
+
for (const [host, state] of circuitStates) {
|
|
6214
|
+
pruneStaleSamples(state, now);
|
|
6215
|
+
const failures = state.recent.reduce((acc, entry) => acc + (entry.ok ? 0 : 1), 0);
|
|
6216
|
+
const ratio = state.recent.length > 0 ? failures / state.recent.length : 0;
|
|
6217
|
+
snapshot[host] = {
|
|
6218
|
+
open: state.openedAt > 0 && now - state.openedAt < CIRCUIT_OPEN_COOLDOWN_MS,
|
|
6219
|
+
openedAt: state.openedAt,
|
|
6220
|
+
cooldownRemainingMs: state.openedAt > 0
|
|
6221
|
+
? Math.max(0, CIRCUIT_OPEN_COOLDOWN_MS - (now - state.openedAt))
|
|
6222
|
+
: 0,
|
|
6223
|
+
recentSamples: state.recent.length,
|
|
6224
|
+
failureRatio: ratio,
|
|
6225
|
+
lastTripFailureRatio: state.lastTripFailureRatio,
|
|
6226
|
+
};
|
|
6227
|
+
}
|
|
6228
|
+
return snapshot;
|
|
6229
|
+
}
|
|
6230
|
+
function hostnameFromUrl(url) {
|
|
6231
|
+
try {
|
|
6232
|
+
return new URL(url).hostname;
|
|
6233
|
+
}
|
|
6234
|
+
catch {
|
|
6235
|
+
return null;
|
|
6236
|
+
}
|
|
6237
|
+
}
|
|
6238
|
+
function sleep(ms) {
|
|
6239
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
6240
|
+
}
|
|
6045
6241
|
/**
|
|
6046
6242
|
* Debug logging utility that respects environment debug flags.
|
|
6047
6243
|
* Logs messages through the configured structured logger when LUMIC_DEBUG
|
|
@@ -6153,9 +6349,46 @@ function hideApiKeyFromurl(url) {
|
|
|
6153
6349
|
* @throws Will throw an error if the fetch fails after the specified number of retries.
|
|
6154
6350
|
*/
|
|
6155
6351
|
async function fetchWithRetry(url, options = {}, retries = 3, initialBackoff = 1000) {
|
|
6352
|
+
// Per-host circuit-breaker check. When upstream is failing
|
|
6353
|
+
// pervasively (e.g. Massive REST in an outage), short-circuit to a
|
|
6354
|
+
// 100 ms fail-fast rejection so the caller's outer timeout (25 s,
|
|
6355
|
+
// 10 s, etc.) does not pile concurrent symbol fetches against a
|
|
6356
|
+
// dead host. Without this, an upstream outage during a screener tick
|
|
6357
|
+
// can lock up the event loop for up to (timeout × N-concurrent-symbols).
|
|
6358
|
+
const host = hostnameFromUrl(url);
|
|
6359
|
+
if (host) {
|
|
6360
|
+
const now = Date.now();
|
|
6361
|
+
if (isCircuitOpen(host, now)) {
|
|
6362
|
+
const state = getCircuitState(host);
|
|
6363
|
+
const cooldownRemainingMs = Math.max(0, CIRCUIT_OPEN_COOLDOWN_MS - (now - state.openedAt));
|
|
6364
|
+
await sleep(CIRCUIT_FAIL_FAST_LATENCY_MS);
|
|
6365
|
+
throw new CircuitOpenError(host, state.lastTripFailureRatio, cooldownRemainingMs);
|
|
6366
|
+
}
|
|
6367
|
+
}
|
|
6156
6368
|
return withRetry(async () => {
|
|
6157
|
-
|
|
6369
|
+
let response;
|
|
6370
|
+
try {
|
|
6371
|
+
response = await fetch(url, options);
|
|
6372
|
+
}
|
|
6373
|
+
catch (networkError) {
|
|
6374
|
+
// Network failure (e.g. DNS, connection refused, TLS abort).
|
|
6375
|
+
// Record against the breaker so a sustained outage trips it
|
|
6376
|
+
// for subsequent calls; then re-throw so withRetry handles
|
|
6377
|
+
// its own retry policy.
|
|
6378
|
+
if (host)
|
|
6379
|
+
recordOutcome(host, false);
|
|
6380
|
+
throw networkError;
|
|
6381
|
+
}
|
|
6158
6382
|
if (!response.ok) {
|
|
6383
|
+
// Classify the outcome for the circuit breaker. 5xx and 429
|
|
6384
|
+
// are upstream-health signals (record as failure). 4xx client
|
|
6385
|
+
// errors are caller-side and should NOT affect the breaker —
|
|
6386
|
+
// a request with a bad API key shouldn't trip the host's
|
|
6387
|
+
// breaker for everyone else.
|
|
6388
|
+
const upstreamUnhealthy = response.status === 429 ||
|
|
6389
|
+
(response.status >= 500 && response.status < 600);
|
|
6390
|
+
if (host)
|
|
6391
|
+
recordOutcome(host, !upstreamUnhealthy);
|
|
6159
6392
|
// Enhanced HTTP error handling with specific error types
|
|
6160
6393
|
if (response.status === 429) {
|
|
6161
6394
|
// Check for Retry-After header
|
|
@@ -6187,6 +6420,10 @@ async function fetchWithRetry(url, options = {}, retries = 3, initialBackoff = 1
|
|
|
6187
6420
|
error.response = response;
|
|
6188
6421
|
throw error;
|
|
6189
6422
|
}
|
|
6423
|
+
// Success — record against the breaker so a healthy upstream
|
|
6424
|
+
// closes any half-open state cleanly.
|
|
6425
|
+
if (host)
|
|
6426
|
+
recordOutcome(host, true);
|
|
6190
6427
|
return response;
|
|
6191
6428
|
}, {
|
|
6192
6429
|
maxRetries: retries,
|
|
@@ -69377,6 +69614,17 @@ const adaptic = {
|
|
|
69377
69614
|
logIfDebug: logIfDebug,
|
|
69378
69615
|
fetchWithRetry: fetchWithRetry,
|
|
69379
69616
|
validateMassiveApiKey: validateMassiveApiKey,
|
|
69617
|
+
/**
|
|
69618
|
+
* Force-close a stuck-open per-host circuit breaker. Operator
|
|
69619
|
+
* runbook utility — see {@link misc.resetCircuitBreaker}.
|
|
69620
|
+
*/
|
|
69621
|
+
resetCircuitBreaker: resetCircuitBreaker,
|
|
69622
|
+
/**
|
|
69623
|
+
* Read-only snapshot of all per-host circuit-breaker states for
|
|
69624
|
+
* use in operational-truth endpoints. See
|
|
69625
|
+
* {@link misc.getCircuitBreakerSnapshot}.
|
|
69626
|
+
*/
|
|
69627
|
+
getCircuitBreakerSnapshot: getCircuitBreakerSnapshot,
|
|
69380
69628
|
},
|
|
69381
69629
|
rateLimiter: {
|
|
69382
69630
|
TokenBucketRateLimiter,
|
|
@@ -69385,5 +69633,5 @@ const adaptic = {
|
|
|
69385
69633
|
};
|
|
69386
69634
|
const adptc = adaptic;
|
|
69387
69635
|
|
|
69388
|
-
export { API_RETRY_CONFIGS, AVNewsArticleSchema, AVNewsResponseSchema, AdapticUtilsError, AlpacaAccountDetailsSchema, AlpacaApiError, AlpacaBarSchema, AlpacaClient, AlpacaCryptoBarsResponseSchema, AlpacaHistoricalBarsResponseSchema, AlpacaLatestBarsResponseSchema, AlpacaLatestQuotesResponseSchema, AlpacaLatestTradesResponseSchema, AlpacaMarketDataAPI, AlpacaNewsArticleSchema, AlpacaNewsResponseSchema, AlpacaOrderSchema, AlpacaOrdersArraySchema, AlpacaPortfolioHistoryResponseSchema, AlpacaPositionSchema, AlpacaPositionsArraySchema, AlpacaQuoteSchema, AlpacaTradeSchema, AlpacaTradingAPI, AlphaVantageError, AlphaVantageQuoteResponseSchema, AssetAllocationEngine, AuthenticationError, AutonomyMode, BTC_PAIRS, BarError, CryptoDataError, CryptoOrderError, DEFAULT_CACHE_OPTIONS, DEFAULT_RISK_FREE_RATE, DEFAULT_TIMEOUTS, DEFAULT_TRADING_POLICY, DataFormatError, DecisionMemoryOutcome, DecisionOutcome, DecisionRecordStatus, HttpClientError, HttpServerError, KEEP_ALIVE_DEFAULTS, LlmProvider, MARKET_DATA_API, MassiveAggregatesResponseSchema, MassiveApiError, MassiveDailyOpenCloseSchema, MassiveErrorResponseSchema, MassiveGroupedDailyResponseSchema, MassiveLastTradeResponseSchema, MassiveTickerDetailsResponseSchema, MassiveTickerInfoSchema, MassiveTradeSchema as MassiveTradeZodSchema, MassiveTradesResponseSchema, NetworkError, NewsError, OptionStrategyError, OptionsDataError, OverlaySeverity, OverlayStatus, OverlayType, QuoteError, RISK_FREE_RATE_TTL_MS, RateLimitError, RawMassivePriceDataSchema, StampedeProtectedCache, TRADING_API, TimeoutError, TokenBucketRateLimiter, TradeError, TrailingStopValidationError, USDC_PAIRS, USDT_PAIRS, USD_PAIRS, ValidationError, ValidationResponseError, WEBSOCKET_STREAMS, WebSocketError, account, adaptic, adptc, alpaca, analyzeBars, approximateImpliedVolatility, atrNs as atr, bracketOrders, buildOCCSymbol, buildOptionSymbol, buyCryptoNotional, buyToClose, buyToOpen, buyWithStopLoss, buyWithTrailingStop, calculateMoneyness, calculateOrderValue, calculatePeriodPerformance, calculatePutCallRatio, calculateTotalFilledValue, cancelAllCryptoOrders, cancelOCOOrder, cancelOTOOrder, cancelTrailingStop, cancelTrailingStopsForSymbol, checkTradingEligibility, clearClientCache, clock, closeAllOptionPositions, closeOptionPosition, createAlpacaClient, createAlpacaMarketDataAPI, createAlpacaTradingAPI, createBracketOrder, createButterflySpread, createClientFromEnv, createCoveredCall, createCryptoLimitOrder, createCryptoMarketOrder, createCryptoOrder, createCryptoStopLimitOrder, createCryptoStopOrder, createExecutorFromTradingAPI, createIronCondor$1 as createIronCondor, createIronCondor as createIronCondorAdvanced, createMultiLegOptionOrder, createOCOOrder, createOTOOrder, createOptionOrder, createPortfolioTrailingStops, createProtectiveBracket, createStampedeProtectedCache, createStraddle$1 as createStraddle, createStraddle as createStraddleAdvanced, createStrangle$1 as createStrangle, createStrangle as createStrangleAdvanced, createStreamManager, createTimeoutSignal, createTrailingStop, createVerticalSpread$1 as createVerticalSpread, createVerticalSpread as createVerticalSpreadAdvanced, entryWithPercentStopLoss, exerciseOption, extractGreeks, filterByExpiration, filterByStrike, filterByType, filterOrdersByDateRange, findATMOptions, findATMStrikes, findNearestExpiration, findOptionsByDelta, formatOrderForLog, formatOrderSummary, generateOptimalAllocation, getAccountConfiguration, getAccountDetails, getAccountSummary, getAgentPoolStatus, getAllOrders, getAlpacaCalendar, getAlpacaClock, getAverageDailyVolume, getBars, getBuyingPower, getCachedRiskFreeRateSync, getCachedRiskFreeRateSyncWithProvenance, getCrypto24HourChange, getCryptoBars, getCryptoDailyPrices, getCryptoPairsByQuote, getCryptoPrice, getCryptoSnapshots, getCryptoSpread, getCryptoStreamUrl, getCryptoTrades, getCurrentPrice, getCurrentPrices, getDailyPrices, getDailyReturns, getDaysToExpiration, getDefaultRiskProfile, getEquityCurve, getExpirationDates, getFilledOrders, getGroupedOptionChain, getHistoricalOptionsBars, getHistoricalTrades, getIntradayPrices, getLatestBars, getLatestCryptoQuotes, getLatestCryptoTrades, getLatestNews, getLatestOptionsQuotes, getLatestOptionsTrades, getLatestQuote, getLatestQuotes, getLatestTrade, getLatestTrades, getLogger, getMarginInfo, getNews, getNewsForSymbols, getOCOOrderStatus, getOTOOrderStatus, getOpenCryptoOrders, getOpenOrders$1 as getOpenOrdersQuery, getOpenTrailingStops, getOptionChain, getOptionContract, getOptionContracts, getOptionSpread, getOptionsChain, getOptionsSnapshots, getOptionsStreamUrl, getOptionsTradingLevel, getOrderHistory, getOrdersBySymbol, getPDTStatus, getPopularCryptoPairs, getPortfolioHistory, getPreviousClose, getPriceRange, getRiskFreeRate, getRiskFreeRateWithProvenance, getSpread, getSpreads, getStockStreamUrl, getStrikePrices, getSupportedCryptoPairs, getSymbolSentiment, getTimeout, getTradeVolume, getTradingApiUrl, getTradingWebSocketUrl, getTrailingStopHWM, groupOrdersByStatus, groupOrdersBySymbol, hasActiveTrailingStop, hasGoodLiquidity as hasOptionLiquidity, hasGoodLiquidity$1 as hasStockLiquidity, hasSufficientVolume, httpAgent, httpsAgent, isContractTradable, isCryptoPair, isExpiringWithin, isMarginAccount, isOptionOrderCancelable, isOptionOrderTerminal, isOrderFillable, isOrderFilled, isOrderOpen, isOrderTerminal$1 as isOrderTerminalStatus, isSupportedCryptoPair, isTransientNetworkError, index$1 as legacyApi, limitBuyWithTakeProfit, ocoOrders, orderUtils, otoOrders, paginate, paginateAll, parseOCCSymbol, protectLongPosition, protectShortPosition, rateLimiters, resetLogger, resetRiskFreeRateCache, riskNs as risk, rollOptionPosition, roundPriceForAlpaca$3 as roundPriceForAlpaca, roundPriceForAlpacaNumber, safeValidateResponse, searchNews, sellAllCrypto, sellCryptoNotional, sellToClose, sellToOpen, setLogger, setRiskFreeRate, shortWithStopLoss, sortOrdersByDate, strategyNs as strategy, index as tradingPolicy, trailingStops, updateAccountConfiguration, updateTrailingStop, validateAlpacaCredentials, validateAlphaVantageApiKey, validateMassiveApiKey$1 as validateMassiveApiKey, validateMultiLegOrder, validateResponse, verifyFetchKeepAlive, volatilityNs as volatility, waitForOrderFill, withRetry, withTimeout };
|
|
69636
|
+
export { API_RETRY_CONFIGS, AVNewsArticleSchema, AVNewsResponseSchema, AdapticUtilsError, AlpacaAccountDetailsSchema, AlpacaApiError, AlpacaBarSchema, AlpacaClient, AlpacaCryptoBarsResponseSchema, AlpacaHistoricalBarsResponseSchema, AlpacaLatestBarsResponseSchema, AlpacaLatestQuotesResponseSchema, AlpacaLatestTradesResponseSchema, AlpacaMarketDataAPI, AlpacaNewsArticleSchema, AlpacaNewsResponseSchema, AlpacaOrderSchema, AlpacaOrdersArraySchema, AlpacaPortfolioHistoryResponseSchema, AlpacaPositionSchema, AlpacaPositionsArraySchema, AlpacaQuoteSchema, AlpacaTradeSchema, AlpacaTradingAPI, AlphaVantageError, AlphaVantageQuoteResponseSchema, AssetAllocationEngine, AuthenticationError, AutonomyMode, BTC_PAIRS, BarError, CircuitOpenError, CryptoDataError, CryptoOrderError, DEFAULT_CACHE_OPTIONS, DEFAULT_RISK_FREE_RATE, DEFAULT_TIMEOUTS, DEFAULT_TRADING_POLICY, DataFormatError, DecisionMemoryOutcome, DecisionOutcome, DecisionRecordStatus, HttpClientError, HttpServerError, KEEP_ALIVE_DEFAULTS, LlmProvider, MARKET_DATA_API, MassiveAggregatesResponseSchema, MassiveApiError, MassiveDailyOpenCloseSchema, MassiveErrorResponseSchema, MassiveGroupedDailyResponseSchema, MassiveLastTradeResponseSchema, MassiveTickerDetailsResponseSchema, MassiveTickerInfoSchema, MassiveTradeSchema as MassiveTradeZodSchema, MassiveTradesResponseSchema, NetworkError, NewsError, OptionStrategyError, OptionsDataError, OverlaySeverity, OverlayStatus, OverlayType, QuoteError, RISK_FREE_RATE_TTL_MS, RateLimitError, RawMassivePriceDataSchema, StampedeProtectedCache, TRADING_API, TimeoutError, TokenBucketRateLimiter, TradeError, TrailingStopValidationError, USDC_PAIRS, USDT_PAIRS, USD_PAIRS, ValidationError, ValidationResponseError, WEBSOCKET_STREAMS, WebSocketError, account, adaptic, adptc, alpaca, analyzeBars, approximateImpliedVolatility, atrNs as atr, bracketOrders, buildOCCSymbol, buildOptionSymbol, buyCryptoNotional, buyToClose, buyToOpen, buyWithStopLoss, buyWithTrailingStop, calculateMoneyness, calculateOrderValue, calculatePeriodPerformance, calculatePutCallRatio, calculateTotalFilledValue, cancelAllCryptoOrders, cancelOCOOrder, cancelOTOOrder, cancelTrailingStop, cancelTrailingStopsForSymbol, checkTradingEligibility, clearClientCache, clock, closeAllOptionPositions, closeOptionPosition, createAlpacaClient, createAlpacaMarketDataAPI, createAlpacaTradingAPI, createBracketOrder, createButterflySpread, createClientFromEnv, createCoveredCall, createCryptoLimitOrder, createCryptoMarketOrder, createCryptoOrder, createCryptoStopLimitOrder, createCryptoStopOrder, createExecutorFromTradingAPI, createIronCondor$1 as createIronCondor, createIronCondor as createIronCondorAdvanced, createMultiLegOptionOrder, createOCOOrder, createOTOOrder, createOptionOrder, createPortfolioTrailingStops, createProtectiveBracket, createStampedeProtectedCache, createStraddle$1 as createStraddle, createStraddle as createStraddleAdvanced, createStrangle$1 as createStrangle, createStrangle as createStrangleAdvanced, createStreamManager, createTimeoutSignal, createTrailingStop, createVerticalSpread$1 as createVerticalSpread, createVerticalSpread as createVerticalSpreadAdvanced, entryWithPercentStopLoss, exerciseOption, extractGreeks, filterByExpiration, filterByStrike, filterByType, filterOrdersByDateRange, findATMOptions, findATMStrikes, findNearestExpiration, findOptionsByDelta, formatOrderForLog, formatOrderSummary, generateOptimalAllocation, getAccountConfiguration, getAccountDetails, getAccountSummary, getAgentPoolStatus, getAllOrders, getAlpacaCalendar, getAlpacaClock, getAverageDailyVolume, getBars, getBuyingPower, getCachedRiskFreeRateSync, getCachedRiskFreeRateSyncWithProvenance, getCrypto24HourChange, getCryptoBars, getCryptoDailyPrices, getCryptoPairsByQuote, getCryptoPrice, getCryptoSnapshots, getCryptoSpread, getCryptoStreamUrl, getCryptoTrades, getCurrentPrice, getCurrentPrices, getDailyPrices, getDailyReturns, getDaysToExpiration, getDefaultRiskProfile, getEquityCurve, getExpirationDates, getFilledOrders, getGroupedOptionChain, getHistoricalOptionsBars, getHistoricalTrades, getIntradayPrices, getLatestBars, getLatestCryptoQuotes, getLatestCryptoTrades, getLatestNews, getLatestOptionsQuotes, getLatestOptionsTrades, getLatestQuote, getLatestQuotes, getLatestTrade, getLatestTrades, getLogger, getMarginInfo, getNews, getNewsForSymbols, getOCOOrderStatus, getOTOOrderStatus, getOpenCryptoOrders, getOpenOrders$1 as getOpenOrdersQuery, getOpenTrailingStops, getOptionChain, getOptionContract, getOptionContracts, getOptionSpread, getOptionsChain, getOptionsSnapshots, getOptionsStreamUrl, getOptionsTradingLevel, getOrderHistory, getOrdersBySymbol, getPDTStatus, getPopularCryptoPairs, getPortfolioHistory, getPreviousClose, getPriceRange, getRiskFreeRate, getRiskFreeRateWithProvenance, getSpread, getSpreads, getStockStreamUrl, getStrikePrices, getSupportedCryptoPairs, getSymbolSentiment, getTimeout, getTradeVolume, getTradingApiUrl, getTradingWebSocketUrl, getTrailingStopHWM, groupOrdersByStatus, groupOrdersBySymbol, hasActiveTrailingStop, hasGoodLiquidity as hasOptionLiquidity, hasGoodLiquidity$1 as hasStockLiquidity, hasSufficientVolume, httpAgent, httpsAgent, isContractTradable, isCryptoPair, isExpiringWithin, isMarginAccount, isOptionOrderCancelable, isOptionOrderTerminal, isOrderFillable, isOrderFilled, isOrderOpen, isOrderTerminal$1 as isOrderTerminalStatus, isSupportedCryptoPair, isTransientNetworkError, index$1 as legacyApi, limitBuyWithTakeProfit, ocoOrders, orderUtils, otoOrders, paginate, paginateAll, parseOCCSymbol, protectLongPosition, protectShortPosition, rateLimiters, resetLogger, resetRiskFreeRateCache, riskNs as risk, rollOptionPosition, roundPriceForAlpaca$3 as roundPriceForAlpaca, roundPriceForAlpacaNumber, safeValidateResponse, searchNews, sellAllCrypto, sellCryptoNotional, sellToClose, sellToOpen, setLogger, setRiskFreeRate, shortWithStopLoss, sortOrdersByDate, strategyNs as strategy, index as tradingPolicy, trailingStops, updateAccountConfiguration, updateTrailingStop, validateAlpacaCredentials, validateAlphaVantageApiKey, validateMassiveApiKey$1 as validateMassiveApiKey, validateMultiLegOrder, validateResponse, verifyFetchKeepAlive, volatilityNs as volatility, waitForOrderFill, withRetry, withTimeout };
|
|
69389
69637
|
//# sourceMappingURL=index.mjs.map
|