@adaptic/utils 0.1.4 → 0.1.42

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 CHANGED
@@ -12280,13 +12280,13 @@ class DisplayManager {
12280
12280
  * @param options.symbol The trading symbol associated with this log.
12281
12281
  * @param options.logToFile Force logging to a file even when no symbol is provided.
12282
12282
  */
12283
- function log$l(message, options = { source: "Server", type: "info" }) {
12283
+ function log$m(message, options = { source: "Server", type: "info" }) {
12284
12284
  const displayManager = DisplayManager.getInstance();
12285
12285
  displayManager.log(message, options);
12286
12286
  }
12287
12287
 
12288
- const log$k = (message, options = { type: "info" }) => {
12289
- log$l(message, { ...options, source: "AlpacaMarketDataAPI" });
12288
+ const log$l = (message, options = { type: "info" }) => {
12289
+ log$m(message, { ...options, source: "AlpacaMarketDataAPI" });
12290
12290
  };
12291
12291
  // Default settings for market data API
12292
12292
  const DEFAULT_ADJUSTMENT = "all";
@@ -12416,7 +12416,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12416
12416
  this.cryptoWs = ws;
12417
12417
  }
12418
12418
  ws.on("open", () => {
12419
- log$k(`${streamType} stream connected`, { type: "info" });
12419
+ log$l(`${streamType} stream connected`, { type: "info" });
12420
12420
  const authMessage = {
12421
12421
  action: "auth",
12422
12422
  key: process.env.ALPACA_API_KEY,
@@ -12431,36 +12431,36 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12431
12431
  messages = JSON.parse(rawData);
12432
12432
  }
12433
12433
  catch (e) {
12434
- log$k(`${streamType} stream received invalid JSON: ${rawData.substring(0, 200)}`, { type: "error" });
12434
+ log$l(`${streamType} stream received invalid JSON: ${rawData.substring(0, 200)}`, { type: "error" });
12435
12435
  return;
12436
12436
  }
12437
12437
  for (const message of messages) {
12438
12438
  if (message.T === "success" && message.msg === "authenticated") {
12439
- log$k(`${streamType} stream authenticated`, { type: "info" });
12439
+ log$l(`${streamType} stream authenticated`, { type: "info" });
12440
12440
  this.sendSubscription(streamType);
12441
12441
  }
12442
12442
  else if (message.T === "success" && message.msg === "connected") {
12443
- log$k(`${streamType} stream connected message received`, {
12443
+ log$l(`${streamType} stream connected message received`, {
12444
12444
  type: "debug",
12445
12445
  });
12446
12446
  }
12447
12447
  else if (message.T === "subscription") {
12448
- log$k(`${streamType} subscription confirmed: trades=${message.trades?.length || 0}, quotes=${message.quotes?.length || 0}, bars=${message.bars?.length || 0}`, { type: "info" });
12448
+ log$l(`${streamType} subscription confirmed: trades=${message.trades?.length || 0}, quotes=${message.quotes?.length || 0}, bars=${message.bars?.length || 0}`, { type: "info" });
12449
12449
  }
12450
12450
  else if (message.T === "error") {
12451
- log$k(`${streamType} stream error: ${message.msg} (code: ${message.code}, raw: ${JSON.stringify(message)})`, { type: "error" });
12451
+ log$l(`${streamType} stream error: ${message.msg} (code: ${message.code}, raw: ${JSON.stringify(message)})`, { type: "error" });
12452
12452
  }
12453
12453
  else if (message.S) {
12454
12454
  super.emit(`${streamType}-${message.T}`, message);
12455
12455
  super.emit(`${streamType}-data`, message);
12456
12456
  }
12457
12457
  else {
12458
- log$k(`${streamType} received unknown message type: ${JSON.stringify(message)}`, { type: "debug" });
12458
+ log$l(`${streamType} received unknown message type: ${JSON.stringify(message)}`, { type: "debug" });
12459
12459
  }
12460
12460
  }
12461
12461
  });
12462
12462
  ws.on("close", () => {
12463
- log$k(`${streamType} stream disconnected`, { type: "warn" });
12463
+ log$l(`${streamType} stream disconnected`, { type: "warn" });
12464
12464
  if (streamType === "stock") {
12465
12465
  this.stockWs = null;
12466
12466
  }
@@ -12473,7 +12473,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12473
12473
  // Optional: implement reconnect logic
12474
12474
  });
12475
12475
  ws.on("error", (error) => {
12476
- log$k(`${streamType} stream error: ${error.message}`, { type: "error" });
12476
+ log$l(`${streamType} stream error: ${error.message}`, { type: "error" });
12477
12477
  });
12478
12478
  }
12479
12479
  sendSubscription(streamType) {
@@ -12491,7 +12491,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12491
12491
  ws = this.cryptoWs;
12492
12492
  subscriptions = this.cryptoSubscriptions;
12493
12493
  }
12494
- log$k(`sendSubscription called for ${streamType} (wsReady=${ws?.readyState === WebSocket.OPEN}, trades=${subscriptions.trades?.length || 0}, quotes=${subscriptions.quotes?.length || 0}, bars=${subscriptions.bars?.length || 0})`, {
12494
+ log$l(`sendSubscription called for ${streamType} (wsReady=${ws?.readyState === WebSocket.OPEN}, trades=${subscriptions.trades?.length || 0}, quotes=${subscriptions.quotes?.length || 0}, bars=${subscriptions.bars?.length || 0})`, {
12495
12495
  type: "debug",
12496
12496
  });
12497
12497
  if (ws && ws.readyState === WebSocket.OPEN) {
@@ -12511,19 +12511,19 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12511
12511
  ...subMessagePayload,
12512
12512
  };
12513
12513
  const messageJson = JSON.stringify(subMessage);
12514
- log$k(`Sending ${streamType} subscription: ${messageJson}`, {
12514
+ log$l(`Sending ${streamType} subscription: ${messageJson}`, {
12515
12515
  type: "info",
12516
12516
  });
12517
12517
  ws.send(messageJson);
12518
12518
  }
12519
12519
  else {
12520
- log$k(`No ${streamType} subscriptions to send (all arrays empty)`, {
12520
+ log$l(`No ${streamType} subscriptions to send (all arrays empty)`, {
12521
12521
  type: "debug",
12522
12522
  });
12523
12523
  }
12524
12524
  }
12525
12525
  else {
12526
- log$k(`Cannot send ${streamType} subscription: WebSocket not ready`, {
12526
+ log$l(`Cannot send ${streamType} subscription: WebSocket not ready`, {
12527
12527
  type: "warn",
12528
12528
  });
12529
12529
  }
@@ -12653,7 +12653,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12653
12653
  });
12654
12654
  if (!response.ok) {
12655
12655
  const errorText = await response.text();
12656
- log$k(`Market Data API error (${response.status}): ${errorText}`, {
12656
+ log$l(`Market Data API error (${response.status}): ${errorText}`, {
12657
12657
  type: "error",
12658
12658
  });
12659
12659
  throw new Error(`Market Data API error (${response.status}): ${errorText}`);
@@ -12663,9 +12663,9 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12663
12663
  }
12664
12664
  catch (err) {
12665
12665
  const error = err;
12666
- log$k(`Error in makeRequest: ${error.message}. Endpoint: ${endpoint}. Url: ${url.toString()}`, { type: "error" });
12666
+ log$l(`Error in makeRequest: ${error.message}. Endpoint: ${endpoint}. Url: ${url.toString()}`, { type: "error" });
12667
12667
  if (error instanceof TypeError) {
12668
- log$k(`Network error details: ${error.stack}`, { type: "error" });
12668
+ log$l(`Network error details: ${error.stack}`, { type: "error" });
12669
12669
  }
12670
12670
  throw error;
12671
12671
  }
@@ -12689,7 +12689,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12689
12689
  symbols.forEach((symbol) => {
12690
12690
  allBars[symbol] = [];
12691
12691
  });
12692
- log$k(`Starting historical bars fetch for ${symbolsStr} (${params.timeframe}, ${params.start || "no start"} to ${params.end || "no end"})`, {
12692
+ log$l(`Starting historical bars fetch for ${symbolsStr} (${params.timeframe}, ${params.start || "no start"} to ${params.end || "no end"})`, {
12693
12693
  type: "info",
12694
12694
  });
12695
12695
  while (hasMorePages) {
@@ -12702,7 +12702,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12702
12702
  };
12703
12703
  const response = await this.makeRequest("/stocks/bars", "GET", requestParams);
12704
12704
  if (!response.bars) {
12705
- log$k(`No bars data found in response for ${symbolsStr}`, {
12705
+ log$l(`No bars data found in response for ${symbolsStr}`, {
12706
12706
  type: "warn",
12707
12707
  });
12708
12708
  break;
@@ -12738,12 +12738,12 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12738
12738
  const dateRangeStr = earliestTimestamp && latestTimestamp
12739
12739
  ? `${earliestTimestamp.toLocaleDateString("en-US", { timeZone: "America/New_York" })} to ${latestTimestamp.toLocaleDateString("en-US", { timeZone: "America/New_York" })}`
12740
12740
  : "unknown range";
12741
- log$k(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} bars (total: ${totalBarsCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ", more pages available" : ", complete"}`, {
12741
+ log$l(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} bars (total: ${totalBarsCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ", more pages available" : ", complete"}`, {
12742
12742
  type: "info",
12743
12743
  });
12744
12744
  // Prevent infinite loops
12745
12745
  if (pageCount > 1000) {
12746
- log$k(`Stopping pagination after ${pageCount} pages to prevent infinite loop`, { type: "warn" });
12746
+ log$l(`Stopping pagination after ${pageCount} pages to prevent infinite loop`, { type: "warn" });
12747
12747
  break;
12748
12748
  }
12749
12749
  }
@@ -12751,7 +12751,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12751
12751
  const symbolCounts = Object.entries(allBars)
12752
12752
  .map(([symbol, bars]) => `${symbol}: ${bars.length}`)
12753
12753
  .join(", ");
12754
- log$k(`Historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`, {
12754
+ log$l(`Historical bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`, {
12755
12755
  type: "info",
12756
12756
  });
12757
12757
  return {
@@ -12807,7 +12807,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12807
12807
  async getLatestQuotes(symbols, feed, currency) {
12808
12808
  // Return empty response if symbols array is empty to avoid API error
12809
12809
  if (!symbols || symbols.length === 0) {
12810
- log$k("No symbols provided to getLatestQuotes, returning empty response", {
12810
+ log$l("No symbols provided to getLatestQuotes, returning empty response", {
12811
12811
  type: "warn",
12812
12812
  });
12813
12813
  return {
@@ -12851,7 +12851,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
12851
12851
  limit: 1,
12852
12852
  });
12853
12853
  if (!response.bars[symbol] || response.bars[symbol].length === 0) {
12854
- log$k(`No previous close data available for ${symbol}`, {
12854
+ log$l(`No previous close data available for ${symbol}`, {
12855
12855
  type: "error",
12856
12856
  symbol,
12857
12857
  });
@@ -13028,7 +13028,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13028
13028
  symbols.forEach((symbol) => {
13029
13029
  allBars[symbol] = [];
13030
13030
  });
13031
- log$k(`Starting historical options bars fetch for ${symbolsStr} (${params.timeframe}, ${params.start || "no start"} to ${params.end || "no end"})`, {
13031
+ log$l(`Starting historical options bars fetch for ${symbolsStr} (${params.timeframe}, ${params.start || "no start"} to ${params.end || "no end"})`, {
13032
13032
  type: "info",
13033
13033
  });
13034
13034
  while (hasMorePages) {
@@ -13039,7 +13039,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13039
13039
  };
13040
13040
  const response = await this.makeRequest("/options/bars", "GET", requestParams, "v1beta1");
13041
13041
  if (!response.bars) {
13042
- log$k(`No options bars data found in response for ${symbolsStr}`, {
13042
+ log$l(`No options bars data found in response for ${symbolsStr}`, {
13043
13043
  type: "warn",
13044
13044
  });
13045
13045
  break;
@@ -13071,12 +13071,12 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13071
13071
  const dateRangeStr = earliestTimestamp && latestTimestamp
13072
13072
  ? `${earliestTimestamp.toLocaleDateString("en-US", { timeZone: "America/New_York" })} to ${latestTimestamp.toLocaleDateString("en-US", { timeZone: "America/New_York" })}`
13073
13073
  : "unknown range";
13074
- log$k(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} option bars (total: ${totalBarsCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ", more pages available" : ", complete"}`, {
13074
+ log$l(`Page ${pageCount}: Fetched ${pageBarsCount.toLocaleString()} option bars (total: ${totalBarsCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ", more pages available" : ", complete"}`, {
13075
13075
  type: "info",
13076
13076
  });
13077
13077
  // Prevent infinite loops
13078
13078
  if (pageCount > 1000) {
13079
- log$k(`Stopping options bars pagination after ${pageCount} pages to prevent infinite loop`, { type: "warn" });
13079
+ log$l(`Stopping options bars pagination after ${pageCount} pages to prevent infinite loop`, { type: "warn" });
13080
13080
  break;
13081
13081
  }
13082
13082
  }
@@ -13084,7 +13084,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13084
13084
  const symbolCounts = Object.entries(allBars)
13085
13085
  .map(([symbol, bars]) => `${symbol}: ${bars.length}`)
13086
13086
  .join(", ");
13087
- log$k(`Historical options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`, {
13087
+ log$l(`Historical options bars fetch complete: ${totalBarsCount.toLocaleString()} total bars across ${pageCount} pages (${symbolCounts})`, {
13088
13088
  type: "info",
13089
13089
  });
13090
13090
  return {
@@ -13112,7 +13112,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13112
13112
  symbols.forEach((symbol) => {
13113
13113
  allTrades[symbol] = [];
13114
13114
  });
13115
- log$k(`Starting historical options trades fetch for ${symbolsStr} (${params.start || "no start"} to ${params.end || "no end"})`, {
13115
+ log$l(`Starting historical options trades fetch for ${symbolsStr} (${params.start || "no start"} to ${params.end || "no end"})`, {
13116
13116
  type: "info",
13117
13117
  });
13118
13118
  while (hasMorePages) {
@@ -13123,7 +13123,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13123
13123
  };
13124
13124
  const response = await this.makeRequest("/options/trades", "GET", requestParams, "v1beta1");
13125
13125
  if (!response.trades) {
13126
- log$k(`No options trades data found in response for ${symbolsStr}`, {
13126
+ log$l(`No options trades data found in response for ${symbolsStr}`, {
13127
13127
  type: "warn",
13128
13128
  });
13129
13129
  break;
@@ -13155,12 +13155,12 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13155
13155
  const dateRangeStr = earliestTimestamp && latestTimestamp
13156
13156
  ? `${earliestTimestamp.toLocaleDateString("en-US", { timeZone: "America/New_York" })} to ${latestTimestamp.toLocaleDateString("en-US", { timeZone: "America/New_York" })}`
13157
13157
  : "unknown range";
13158
- log$k(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} option trades (total: ${totalTradesCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ", more pages available" : ", complete"}`, {
13158
+ log$l(`Page ${pageCount}: Fetched ${pageTradesCount.toLocaleString()} option trades (total: ${totalTradesCount.toLocaleString()}) for ${symbolsStr}, date range: ${dateRangeStr}${hasMorePages ? ", more pages available" : ", complete"}`, {
13159
13159
  type: "info",
13160
13160
  });
13161
13161
  // Prevent infinite loops
13162
13162
  if (pageCount > 1000) {
13163
- log$k(`Stopping options trades pagination after ${pageCount} pages to prevent infinite loop`, { type: "warn" });
13163
+ log$l(`Stopping options trades pagination after ${pageCount} pages to prevent infinite loop`, { type: "warn" });
13164
13164
  break;
13165
13165
  }
13166
13166
  }
@@ -13168,7 +13168,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13168
13168
  const symbolCounts = Object.entries(allTrades)
13169
13169
  .map(([symbol, trades]) => `${symbol}: ${trades.length}`)
13170
13170
  .join(", ");
13171
- log$k(`Historical options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`, {
13171
+ log$l(`Historical options trades fetch complete: ${totalTradesCount.toLocaleString()} total trades across ${pageCount} pages (${symbolCounts})`, {
13172
13172
  type: "info",
13173
13173
  });
13174
13174
  return {
@@ -13328,14 +13328,14 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13328
13328
  ...(pageToken && { page_token: pageToken }),
13329
13329
  });
13330
13330
  const url = `${this.v1beta1url}/news?${queryParams}`;
13331
- log$k(`Fetching news from: ${url}`, { type: "debug", symbol });
13331
+ log$l(`Fetching news from: ${url}`, { type: "debug", symbol });
13332
13332
  const response = await fetch(url, {
13333
13333
  method: "GET",
13334
13334
  headers: this.headers,
13335
13335
  });
13336
13336
  if (!response.ok) {
13337
13337
  const errorText = await response.text();
13338
- log$k(`Alpaca news API error (${response.status}): ${errorText}`, {
13338
+ log$l(`Alpaca news API error (${response.status}): ${errorText}`, {
13339
13339
  type: "error",
13340
13340
  symbol,
13341
13341
  });
@@ -13343,7 +13343,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13343
13343
  }
13344
13344
  const data = await response.json();
13345
13345
  if (!data.news || !Array.isArray(data.news)) {
13346
- log$k(`No news data found in Alpaca response for ${symbol}`, {
13346
+ log$l(`No news data found in Alpaca response for ${symbol}`, {
13347
13347
  type: "warn",
13348
13348
  symbol,
13349
13349
  });
@@ -13365,7 +13365,7 @@ class AlpacaMarketDataAPI extends require$$0$4.EventEmitter {
13365
13365
  fetchedCount = newsArticles.length;
13366
13366
  pageToken = data.next_page_token || null;
13367
13367
  hasMorePages = !!pageToken && (!maxLimit || fetchedCount < maxLimit);
13368
- log$k(`Fetched ${transformedNews.length} news articles (total: ${fetchedCount}) for ${symbol}. More pages: ${hasMorePages}`, { type: "debug", symbol });
13368
+ log$l(`Fetched ${transformedNews.length} news articles (total: ${fetchedCount}) for ${symbol}. More pages: ${hasMorePages}`, { type: "debug", symbol });
13369
13369
  if (maxLimit && fetchedCount >= maxLimit) {
13370
13370
  newsArticles = newsArticles.slice(0, maxLimit);
13371
13371
  break;
@@ -13442,7 +13442,7 @@ class AlpacaTradingAPI {
13442
13442
  if (this.debugLogging && options.type === "debug") {
13443
13443
  return;
13444
13444
  }
13445
- log$l(message, {
13445
+ log$m(message, {
13446
13446
  ...options,
13447
13447
  source: "AlpacaTradingAPI",
13448
13448
  account: this.credentials.accountName,
@@ -37026,19 +37026,19 @@ function requireCalendar () {
37026
37026
  return calendar;
37027
37027
  }
37028
37028
 
37029
- var clock;
37029
+ var clock$2;
37030
37030
  var hasRequiredClock;
37031
37031
 
37032
37032
  function requireClock () {
37033
- if (hasRequiredClock) return clock;
37033
+ if (hasRequiredClock) return clock$2;
37034
37034
  hasRequiredClock = 1;
37035
37035
  function get() {
37036
37036
  return this.sendRequest("/clock");
37037
37037
  }
37038
- clock = {
37038
+ clock$2 = {
37039
37039
  get,
37040
37040
  };
37041
- return clock;
37041
+ return clock$2;
37042
37042
  }
37043
37043
 
37044
37044
  var asset;
@@ -53245,8 +53245,8 @@ var Alpaca = /*@__PURE__*/getDefaultExportFromCjs(distExports);
53245
53245
  * Alpaca SDK Client Factory
53246
53246
  * Provides unified access to Alpaca Trading API using official SDK
53247
53247
  */
53248
- const log$j = (message, options = { type: "info" }) => {
53249
- log$l(message, { ...options, source: "AlpacaClient" });
53248
+ const log$k = (message, options = { type: "info" }) => {
53249
+ log$m(message, { ...options, source: "AlpacaClient" });
53250
53250
  };
53251
53251
  /**
53252
53252
  * AlpacaClient wraps the official SDK with additional features:
@@ -53277,7 +53277,7 @@ class AlpacaClient {
53277
53277
  "APCA-API-SECRET-KEY": config.apiSecret,
53278
53278
  "Content-Type": "application/json",
53279
53279
  };
53280
- log$j(`AlpacaClient initialized (${config.accountType} mode)`, {
53280
+ log$k(`AlpacaClient initialized (${config.accountType} mode)`, {
53281
53281
  type: "info",
53282
53282
  });
53283
53283
  }
@@ -53315,7 +53315,7 @@ class AlpacaClient {
53315
53315
  }
53316
53316
  catch (error) {
53317
53317
  this.isConnected = false;
53318
- log$j(`Credential validation failed: ${error.message}`, {
53318
+ log$k(`Credential validation failed: ${error.message}`, {
53319
53319
  type: "error",
53320
53320
  });
53321
53321
  throw error;
@@ -53375,7 +53375,7 @@ class AlpacaClient {
53375
53375
  }
53376
53376
  catch (error) {
53377
53377
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53378
- log$j(`API request to ${endpoint} failed: ${errorMessage}`, {
53378
+ log$k(`API request to ${endpoint} failed: ${errorMessage}`, {
53379
53379
  type: "error",
53380
53380
  });
53381
53381
  throw error;
@@ -53391,7 +53391,7 @@ const clientCache = new Map();
53391
53391
  function createAlpacaClient(config) {
53392
53392
  const cacheKey = `${config.apiKey}-${config.accountType}`;
53393
53393
  if (clientCache.has(cacheKey)) {
53394
- log$j(`Returning cached client for ${config.accountType}`, { type: "debug" });
53394
+ log$k(`Returning cached client for ${config.accountType}`, { type: "debug" });
53395
53395
  return clientCache.get(cacheKey);
53396
53396
  }
53397
53397
  const client = new AlpacaClient(config);
@@ -53419,7 +53419,7 @@ function createClientFromEnv() {
53419
53419
  */
53420
53420
  function clearClientCache() {
53421
53421
  clientCache.clear();
53422
- log$j("Client cache cleared", { type: "info" });
53422
+ log$k("Client cache cleared", { type: "info" });
53423
53423
  }
53424
53424
 
53425
53425
  // src/alpaca/trading/bracket-orders.ts
@@ -53429,8 +53429,8 @@ function clearClientCache() {
53429
53429
  * @param message - The message to log.
53430
53430
  * @param options - Optional logging options.
53431
53431
  */
53432
- const log$i = (message, options = { type: "info" }) => {
53433
- log$l(message, { ...options, source: "BracketOrders" });
53432
+ const log$j = (message, options = { type: "info" }) => {
53433
+ log$m(message, { ...options, source: "BracketOrders" });
53434
53434
  };
53435
53435
  /**
53436
53436
  * Validates bracket order parameters.
@@ -53459,13 +53459,13 @@ function validateBracketOrderParams(params) {
53459
53459
  // For a buy order, take profit should be higher than entry, stop loss lower
53460
53460
  params.limitPrice || params.takeProfit.limitPrice; // Use a reference price
53461
53461
  if (params.takeProfit.limitPrice <= params.stopLoss.stopPrice) {
53462
- log$i("Warning: Take profit price should typically be higher than stop loss price for buy orders", { type: "warn" });
53462
+ log$j("Warning: Take profit price should typically be higher than stop loss price for buy orders", { type: "warn" });
53463
53463
  }
53464
53464
  }
53465
53465
  else {
53466
53466
  // For a sell order, take profit should be lower than entry, stop loss higher
53467
53467
  if (params.takeProfit.limitPrice >= params.stopLoss.stopPrice) {
53468
- log$i("Warning: Take profit price should typically be lower than stop loss price for sell orders", { type: "warn" });
53468
+ log$j("Warning: Take profit price should typically be lower than stop loss price for sell orders", { type: "warn" });
53469
53469
  }
53470
53470
  }
53471
53471
  }
@@ -53512,12 +53512,12 @@ function roundPriceForAlpaca$4(price) {
53512
53512
  * ```
53513
53513
  */
53514
53514
  async function createBracketOrder(executor, params) {
53515
- log$i(`Creating bracket order: ${params.side} ${params.qty} ${params.symbol}`, {
53515
+ log$j(`Creating bracket order: ${params.side} ${params.qty} ${params.symbol}`, {
53516
53516
  type: "info",
53517
53517
  });
53518
- log$i(` Entry: ${params.type}${params.limitPrice ? ` @ $${params.limitPrice}` : ""}`, { type: "debug" });
53519
- log$i(` Take Profit: $${params.takeProfit.limitPrice}`, { type: "debug" });
53520
- log$i(` Stop Loss: $${params.stopLoss.stopPrice}${params.stopLoss.limitPrice ? ` (limit $${params.stopLoss.limitPrice})` : ""}`, { type: "debug" });
53518
+ log$j(` Entry: ${params.type}${params.limitPrice ? ` @ $${params.limitPrice}` : ""}`, { type: "debug" });
53519
+ log$j(` Take Profit: $${params.takeProfit.limitPrice}`, { type: "debug" });
53520
+ log$j(` Stop Loss: $${params.stopLoss.stopPrice}${params.stopLoss.limitPrice ? ` (limit $${params.stopLoss.limitPrice})` : ""}`, { type: "debug" });
53521
53521
  // Validate parameters
53522
53522
  validateBracketOrderParams(params);
53523
53523
  try {
@@ -53553,8 +53553,8 @@ async function createBracketOrder(executor, params) {
53553
53553
  }
53554
53554
  // Execute the order
53555
53555
  const order = await executor.createOrder(orderParams);
53556
- log$i(`Bracket order created successfully: ${order.id}`, { type: "info" });
53557
- log$i(` Order status: ${order.status}`, { type: "debug" });
53556
+ log$j(`Bracket order created successfully: ${order.id}`, { type: "info" });
53557
+ log$j(` Order status: ${order.status}`, { type: "debug" });
53558
53558
  // Parse the legs from the response
53559
53559
  const legs = order.legs || [];
53560
53560
  // Find take profit leg - it's a limit order at the take profit price
@@ -53563,10 +53563,10 @@ async function createBracketOrder(executor, params) {
53563
53563
  // Find stop loss leg - it's a stop or stop_limit order
53564
53564
  const stopLossLeg = legs.find((leg) => leg.type === "stop" || leg.type === "stop_limit") || null;
53565
53565
  if (takeProfitLeg) {
53566
- log$i(` Take profit leg ID: ${takeProfitLeg.id}`, { type: "debug" });
53566
+ log$j(` Take profit leg ID: ${takeProfitLeg.id}`, { type: "debug" });
53567
53567
  }
53568
53568
  if (stopLossLeg) {
53569
- log$i(` Stop loss leg ID: ${stopLossLeg.id}`, { type: "debug" });
53569
+ log$j(` Stop loss leg ID: ${stopLossLeg.id}`, { type: "debug" });
53570
53570
  }
53571
53571
  return {
53572
53572
  entryOrder: order,
@@ -53577,7 +53577,7 @@ async function createBracketOrder(executor, params) {
53577
53577
  }
53578
53578
  catch (error) {
53579
53579
  const err = error;
53580
- log$i(`Bracket order failed: ${err.message}`, { type: "error" });
53580
+ log$j(`Bracket order failed: ${err.message}`, { type: "error" });
53581
53581
  throw new Error(`Failed to create bracket order for ${params.symbol}: ${err.message}`);
53582
53582
  }
53583
53583
  }
@@ -53609,9 +53609,9 @@ async function createBracketOrder(executor, params) {
53609
53609
  * ```
53610
53610
  */
53611
53611
  async function createProtectiveBracket(executor, params) {
53612
- log$i(`Creating protective bracket for ${params.symbol}: ${params.qty} shares`, { type: "info" });
53613
- log$i(` Take Profit: $${params.takeProfit.limitPrice}`, { type: "debug" });
53614
- log$i(` Stop Loss: $${params.stopLoss.stopPrice}${params.stopLoss.limitPrice ? ` (limit $${params.stopLoss.limitPrice})` : ""}`, { type: "debug" });
53612
+ log$j(`Creating protective bracket for ${params.symbol}: ${params.qty} shares`, { type: "info" });
53613
+ log$j(` Take Profit: $${params.takeProfit.limitPrice}`, { type: "debug" });
53614
+ log$j(` Stop Loss: $${params.stopLoss.stopPrice}${params.stopLoss.limitPrice ? ` (limit $${params.stopLoss.limitPrice})` : ""}`, { type: "debug" });
53615
53615
  // Validate parameters
53616
53616
  if (!params.symbol || params.symbol.trim() === "") {
53617
53617
  throw new Error("Symbol is required for protective bracket");
@@ -53627,7 +53627,7 @@ async function createProtectiveBracket(executor, params) {
53627
53627
  }
53628
53628
  // For a protective sell bracket, take profit should be higher than stop loss
53629
53629
  if (params.takeProfit.limitPrice <= params.stopLoss.stopPrice) {
53630
- log$i("Warning: Take profit price should be higher than stop loss price for protective sell bracket", { type: "warn" });
53630
+ log$j("Warning: Take profit price should be higher than stop loss price for protective sell bracket", { type: "warn" });
53631
53631
  }
53632
53632
  try {
53633
53633
  // Build the OCO order parameters
@@ -53648,7 +53648,7 @@ async function createProtectiveBracket(executor, params) {
53648
53648
  };
53649
53649
  // Execute the order
53650
53650
  const order = await executor.createOrder(orderParams);
53651
- log$i(`Protective bracket created successfully: ${order.id}`, {
53651
+ log$j(`Protective bracket created successfully: ${order.id}`, {
53652
53652
  type: "info",
53653
53653
  });
53654
53654
  // Parse the legs from the response
@@ -53666,7 +53666,7 @@ async function createProtectiveBracket(executor, params) {
53666
53666
  }
53667
53667
  catch (error) {
53668
53668
  const err = error;
53669
- log$i(`Protective bracket failed: ${err.message}`, { type: "error" });
53669
+ log$j(`Protective bracket failed: ${err.message}`, { type: "error" });
53670
53670
  throw new Error(`Failed to create protective bracket for ${params.symbol}: ${err.message}`);
53671
53671
  }
53672
53672
  }
@@ -53704,8 +53704,8 @@ var bracketOrders$1 = /*#__PURE__*/Object.freeze({
53704
53704
  default: bracketOrders
53705
53705
  });
53706
53706
 
53707
- const log$h = (message, options = { type: "info" }) => {
53708
- log$l(message, { ...options, source: "Account" });
53707
+ const log$i = (message, options = { type: "info" }) => {
53708
+ log$m(message, { ...options, source: "Account" });
53709
53709
  };
53710
53710
  /**
53711
53711
  * Get account details from Alpaca
@@ -53713,16 +53713,16 @@ const log$h = (message, options = { type: "info" }) => {
53713
53713
  * @returns Promise resolving to account details
53714
53714
  */
53715
53715
  async function getAccountDetails(client) {
53716
- log$h("Fetching account details");
53716
+ log$i("Fetching account details");
53717
53717
  try {
53718
53718
  const sdk = client.getSDK();
53719
53719
  const account = await sdk.getAccount();
53720
- log$h(`Account details fetched successfully for account ${account.account_number}`);
53720
+ log$i(`Account details fetched successfully for account ${account.account_number}`);
53721
53721
  return account;
53722
53722
  }
53723
53723
  catch (error) {
53724
53724
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53725
- log$h(`Failed to fetch account details: ${errorMessage}`, { type: "error" });
53725
+ log$i(`Failed to fetch account details: ${errorMessage}`, { type: "error" });
53726
53726
  throw error;
53727
53727
  }
53728
53728
  }
@@ -53732,16 +53732,16 @@ async function getAccountDetails(client) {
53732
53732
  * @returns Promise resolving to account configuration
53733
53733
  */
53734
53734
  async function getAccountConfiguration(client) {
53735
- log$h("Fetching account configuration");
53735
+ log$i("Fetching account configuration");
53736
53736
  try {
53737
53737
  const sdk = client.getSDK();
53738
53738
  const config = await sdk.getAccountConfigurations();
53739
- log$h("Account configuration fetched successfully");
53739
+ log$i("Account configuration fetched successfully");
53740
53740
  return config;
53741
53741
  }
53742
53742
  catch (error) {
53743
53743
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53744
- log$h(`Failed to fetch account configuration: ${errorMessage}`, {
53744
+ log$i(`Failed to fetch account configuration: ${errorMessage}`, {
53745
53745
  type: "error",
53746
53746
  });
53747
53747
  throw error;
@@ -53754,16 +53754,16 @@ async function getAccountConfiguration(client) {
53754
53754
  * @returns Promise resolving to updated account configuration
53755
53755
  */
53756
53756
  async function updateAccountConfiguration(client, config) {
53757
- log$h("Updating account configuration");
53757
+ log$i("Updating account configuration");
53758
53758
  try {
53759
53759
  const sdk = client.getSDK();
53760
53760
  const updatedConfig = await sdk.updateAccountConfigurations(config);
53761
- log$h("Account configuration updated successfully");
53761
+ log$i("Account configuration updated successfully");
53762
53762
  return updatedConfig;
53763
53763
  }
53764
53764
  catch (error) {
53765
53765
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53766
- log$h(`Failed to update account configuration: ${errorMessage}`, {
53766
+ log$i(`Failed to update account configuration: ${errorMessage}`, {
53767
53767
  type: "error",
53768
53768
  });
53769
53769
  throw error;
@@ -53776,17 +53776,17 @@ async function updateAccountConfiguration(client, config) {
53776
53776
  * @returns Promise resolving to portfolio history response
53777
53777
  */
53778
53778
  async function getPortfolioHistory(client, params) {
53779
- log$h(`Fetching portfolio history with period: ${params.period || "default"}, timeframe: ${params.timeframe || "default"}`);
53779
+ log$i(`Fetching portfolio history with period: ${params.period || "default"}, timeframe: ${params.timeframe || "default"}`);
53780
53780
  try {
53781
53781
  const sdk = client.getSDK();
53782
53782
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
53783
53783
  const history = await sdk.getPortfolioHistory(params);
53784
- log$h(`Portfolio history fetched successfully with ${history.equity?.length || 0} data points`);
53784
+ log$i(`Portfolio history fetched successfully with ${history.equity?.length || 0} data points`);
53785
53785
  return history;
53786
53786
  }
53787
53787
  catch (error) {
53788
53788
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53789
- log$h(`Failed to fetch portfolio history: ${errorMessage}`, {
53789
+ log$i(`Failed to fetch portfolio history: ${errorMessage}`, {
53790
53790
  type: "error",
53791
53791
  });
53792
53792
  throw error;
@@ -53798,7 +53798,7 @@ async function getPortfolioHistory(client, params) {
53798
53798
  * @returns Promise resolving to trading eligibility status
53799
53799
  */
53800
53800
  async function checkTradingEligibility(client) {
53801
- log$h("Checking trading eligibility");
53801
+ log$i("Checking trading eligibility");
53802
53802
  try {
53803
53803
  const account = await getAccountDetails(client);
53804
53804
  const reasons = [];
@@ -53837,12 +53837,12 @@ async function checkTradingEligibility(client) {
53837
53837
  dayTradeCount: account.daytrade_count,
53838
53838
  isPatternDayTrader: account.pattern_day_trader,
53839
53839
  };
53840
- log$h(`Trading eligibility check complete: canTrade=${canTrade}${reasons.length > 0 ? `, reasons: ${reasons.join("; ")}` : ""}`);
53840
+ log$i(`Trading eligibility check complete: canTrade=${canTrade}${reasons.length > 0 ? `, reasons: ${reasons.join("; ")}` : ""}`);
53841
53841
  return eligibility;
53842
53842
  }
53843
53843
  catch (error) {
53844
53844
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53845
- log$h(`Failed to check trading eligibility: ${errorMessage}`, {
53845
+ log$i(`Failed to check trading eligibility: ${errorMessage}`, {
53846
53846
  type: "error",
53847
53847
  });
53848
53848
  throw error;
@@ -53854,7 +53854,7 @@ async function checkTradingEligibility(client) {
53854
53854
  * @returns Promise resolving to buying power breakdown
53855
53855
  */
53856
53856
  async function getBuyingPower(client) {
53857
- log$h("Fetching buying power breakdown");
53857
+ log$i("Fetching buying power breakdown");
53858
53858
  try {
53859
53859
  const account = await getAccountDetails(client);
53860
53860
  const breakdown = {
@@ -53866,12 +53866,12 @@ async function getBuyingPower(client) {
53866
53866
  // Crypto buying power is typically equal to cash for spot trading
53867
53867
  cryptoBuyingPower: parseFloat(account.cash),
53868
53868
  };
53869
- log$h(`Buying power breakdown: cash=$${breakdown.cash.toFixed(2)}, dayTrading=$${breakdown.dayTradingBuyingPower.toFixed(2)}, regT=$${breakdown.regtBuyingPower.toFixed(2)}`);
53869
+ log$i(`Buying power breakdown: cash=$${breakdown.cash.toFixed(2)}, dayTrading=$${breakdown.dayTradingBuyingPower.toFixed(2)}, regT=$${breakdown.regtBuyingPower.toFixed(2)}`);
53870
53870
  return breakdown;
53871
53871
  }
53872
53872
  catch (error) {
53873
53873
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53874
- log$h(`Failed to fetch buying power: ${errorMessage}`, { type: "error" });
53874
+ log$i(`Failed to fetch buying power: ${errorMessage}`, { type: "error" });
53875
53875
  throw error;
53876
53876
  }
53877
53877
  }
@@ -53881,16 +53881,16 @@ async function getBuyingPower(client) {
53881
53881
  * @returns Promise resolving to options trading level (0-3)
53882
53882
  */
53883
53883
  async function getOptionsTradingLevel(client) {
53884
- log$h("Fetching options trading level");
53884
+ log$i("Fetching options trading level");
53885
53885
  try {
53886
53886
  const account = await getAccountDetails(client);
53887
53887
  const level = account.options_trading_level || 0;
53888
- log$h(`Options trading level: ${level}`);
53888
+ log$i(`Options trading level: ${level}`);
53889
53889
  return level;
53890
53890
  }
53891
53891
  catch (error) {
53892
53892
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53893
- log$h(`Failed to fetch options trading level: ${errorMessage}`, {
53893
+ log$i(`Failed to fetch options trading level: ${errorMessage}`, {
53894
53894
  type: "error",
53895
53895
  });
53896
53896
  throw error;
@@ -53902,7 +53902,7 @@ async function getOptionsTradingLevel(client) {
53902
53902
  * @returns Promise resolving to PDT status
53903
53903
  */
53904
53904
  async function getPDTStatus(client) {
53905
- log$h("Fetching PDT status");
53905
+ log$i("Fetching PDT status");
53906
53906
  try {
53907
53907
  const account = await getAccountDetails(client);
53908
53908
  const equity = parseFloat(account.equity);
@@ -53935,12 +53935,12 @@ async function getPDTStatus(client) {
53935
53935
  dayTradesRemaining: dayTradesRemaining === Infinity ? -1 : dayTradesRemaining, // Use -1 for unlimited
53936
53936
  canDayTrade,
53937
53937
  };
53938
- log$h(`PDT status: isPDT=${isPDT}, dayTradeCount=${dayTradeCount}, remaining=${dayTradesRemaining === Infinity ? "unlimited" : dayTradesRemaining}`);
53938
+ log$i(`PDT status: isPDT=${isPDT}, dayTradeCount=${dayTradeCount}, remaining=${dayTradesRemaining === Infinity ? "unlimited" : dayTradesRemaining}`);
53939
53939
  return status;
53940
53940
  }
53941
53941
  catch (error) {
53942
53942
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53943
- log$h(`Failed to fetch PDT status: ${errorMessage}`, { type: "error" });
53943
+ log$i(`Failed to fetch PDT status: ${errorMessage}`, { type: "error" });
53944
53944
  throw error;
53945
53945
  }
53946
53946
  }
@@ -53952,7 +53952,7 @@ async function getPDTStatus(client) {
53952
53952
  * @returns Promise resolving to array of daily returns
53953
53953
  */
53954
53954
  async function getDailyReturns(client, period = "1M") {
53955
- log$h(`Calculating daily returns for period: ${period}`);
53955
+ log$i(`Calculating daily returns for period: ${period}`);
53956
53956
  try {
53957
53957
  const history = await getPortfolioHistory(client, {
53958
53958
  period,
@@ -53961,7 +53961,7 @@ async function getDailyReturns(client, period = "1M") {
53961
53961
  if (!history.timestamp ||
53962
53962
  !history.equity ||
53963
53963
  history.timestamp.length === 0) {
53964
- log$h("No portfolio history data available", { type: "warn" });
53964
+ log$i("No portfolio history data available", { type: "warn" });
53965
53965
  return [];
53966
53966
  }
53967
53967
  const dailyReturns = [];
@@ -53984,12 +53984,12 @@ async function getDailyReturns(client, period = "1M") {
53984
53984
  dailyReturn,
53985
53985
  });
53986
53986
  }
53987
- log$h(`Calculated ${dailyReturns.length} daily returns`);
53987
+ log$i(`Calculated ${dailyReturns.length} daily returns`);
53988
53988
  return dailyReturns;
53989
53989
  }
53990
53990
  catch (error) {
53991
53991
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
53992
- log$h(`Failed to calculate daily returns: ${errorMessage}`, {
53992
+ log$i(`Failed to calculate daily returns: ${errorMessage}`, {
53993
53993
  type: "error",
53994
53994
  });
53995
53995
  throw error;
@@ -54002,7 +54002,7 @@ async function getDailyReturns(client, period = "1M") {
54002
54002
  * @returns Promise resolving to period performance metrics
54003
54003
  */
54004
54004
  async function calculatePeriodPerformance(client, period = "1M") {
54005
- log$h(`Calculating period performance for: ${period}`);
54005
+ log$i(`Calculating period performance for: ${period}`);
54006
54006
  try {
54007
54007
  const dailyReturns = await getDailyReturns(client, period);
54008
54008
  if (dailyReturns.length < 2) {
@@ -54068,12 +54068,12 @@ async function calculatePeriodPerformance(client, period = "1M") {
54068
54068
  losingDays,
54069
54069
  winRate,
54070
54070
  };
54071
- log$h(`Period performance: totalReturn=${totalReturnPct.toFixed(2)}%, maxDrawdown=${maxDrawdownPct.toFixed(2)}%, sharpe=${sharpeRatio?.toFixed(2) || "N/A"}`);
54071
+ log$i(`Period performance: totalReturn=${totalReturnPct.toFixed(2)}%, maxDrawdown=${maxDrawdownPct.toFixed(2)}%, sharpe=${sharpeRatio?.toFixed(2) || "N/A"}`);
54072
54072
  return performance;
54073
54073
  }
54074
54074
  catch (error) {
54075
54075
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
54076
- log$h(`Failed to calculate period performance: ${errorMessage}`, {
54076
+ log$i(`Failed to calculate period performance: ${errorMessage}`, {
54077
54077
  type: "error",
54078
54078
  });
54079
54079
  throw error;
@@ -54086,13 +54086,13 @@ async function calculatePeriodPerformance(client, period = "1M") {
54086
54086
  * @returns Promise resolving to equity curve data points
54087
54087
  */
54088
54088
  async function getEquityCurve(client, params = { period: "1M", timeframe: "1D" }) {
54089
- log$h(`Fetching equity curve with period: ${params.period || "default"}`);
54089
+ log$i(`Fetching equity curve with period: ${params.period || "default"}`);
54090
54090
  try {
54091
54091
  const history = await getPortfolioHistory(client, params);
54092
54092
  if (!history.timestamp ||
54093
54093
  !history.equity ||
54094
54094
  history.timestamp.length === 0) {
54095
- log$h("No portfolio history data available for equity curve", {
54095
+ log$i("No portfolio history data available for equity curve", {
54096
54096
  type: "warn",
54097
54097
  });
54098
54098
  return [];
@@ -54114,12 +54114,12 @@ async function getEquityCurve(client, params = { period: "1M", timeframe: "1D" }
54114
54114
  cumulativeReturn,
54115
54115
  });
54116
54116
  }
54117
- log$h(`Generated equity curve with ${curve.length} data points`);
54117
+ log$i(`Generated equity curve with ${curve.length} data points`);
54118
54118
  return curve;
54119
54119
  }
54120
54120
  catch (error) {
54121
54121
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
54122
- log$h(`Failed to get equity curve: ${errorMessage}`, { type: "error" });
54122
+ log$i(`Failed to get equity curve: ${errorMessage}`, { type: "error" });
54123
54123
  throw error;
54124
54124
  }
54125
54125
  }
@@ -54129,7 +54129,7 @@ async function getEquityCurve(client, params = { period: "1M", timeframe: "1D" }
54129
54129
  * @returns Promise resolving to account summary
54130
54130
  */
54131
54131
  async function getAccountSummary(client) {
54132
- log$h("Fetching account summary");
54132
+ log$i("Fetching account summary");
54133
54133
  try {
54134
54134
  const account = await getAccountDetails(client);
54135
54135
  const equity = parseFloat(account.equity);
@@ -54146,12 +54146,12 @@ async function getAccountSummary(client) {
54146
54146
  todayProfitLoss,
54147
54147
  todayProfitLossPct,
54148
54148
  };
54149
- log$h(`Account summary: equity=$${summary.equity.toFixed(2)}, cash=$${summary.cash.toFixed(2)}, todayP/L=${summary.todayProfitLossPct.toFixed(2)}%`);
54149
+ log$i(`Account summary: equity=$${summary.equity.toFixed(2)}, cash=$${summary.cash.toFixed(2)}, todayP/L=${summary.todayProfitLossPct.toFixed(2)}%`);
54150
54150
  return summary;
54151
54151
  }
54152
54152
  catch (error) {
54153
54153
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
54154
- log$h(`Failed to get account summary: ${errorMessage}`, { type: "error" });
54154
+ log$i(`Failed to get account summary: ${errorMessage}`, { type: "error" });
54155
54155
  throw error;
54156
54156
  }
54157
54157
  }
@@ -54161,17 +54161,17 @@ async function getAccountSummary(client) {
54161
54161
  * @returns Promise resolving to boolean indicating margin status
54162
54162
  */
54163
54163
  async function isMarginAccount(client) {
54164
- log$h("Checking margin account status");
54164
+ log$i("Checking margin account status");
54165
54165
  try {
54166
54166
  const account = await getAccountDetails(client);
54167
54167
  // Multiplier > 1 indicates margin account
54168
54168
  const isMargin = account.multiplier !== "1";
54169
- log$h(`Margin account: ${isMargin} (multiplier: ${account.multiplier})`);
54169
+ log$i(`Margin account: ${isMargin} (multiplier: ${account.multiplier})`);
54170
54170
  return isMargin;
54171
54171
  }
54172
54172
  catch (error) {
54173
54173
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
54174
- log$h(`Failed to check margin account status: ${errorMessage}`, {
54174
+ log$i(`Failed to check margin account status: ${errorMessage}`, {
54175
54175
  type: "error",
54176
54176
  });
54177
54177
  throw error;
@@ -54183,7 +54183,7 @@ async function isMarginAccount(client) {
54183
54183
  * @returns Promise resolving to margin information
54184
54184
  */
54185
54185
  async function getMarginInfo(client) {
54186
- log$h("Fetching margin information");
54186
+ log$i("Fetching margin information");
54187
54187
  try {
54188
54188
  const account = await getAccountDetails(client);
54189
54189
  const initialMargin = parseFloat(account.initial_margin);
@@ -54199,12 +54199,12 @@ async function getMarginInfo(client) {
54199
54199
  sma: parseFloat(account.sma),
54200
54200
  marginCallAmount,
54201
54201
  };
54202
- log$h(`Margin info: multiplier=${marginInfo.multiplier}, initialMargin=$${marginInfo.initialMargin.toFixed(2)}, maintenanceMargin=$${marginInfo.maintenanceMargin.toFixed(2)}`);
54202
+ log$i(`Margin info: multiplier=${marginInfo.multiplier}, initialMargin=$${marginInfo.initialMargin.toFixed(2)}, maintenanceMargin=$${marginInfo.maintenanceMargin.toFixed(2)}`);
54203
54203
  return marginInfo;
54204
54204
  }
54205
54205
  catch (error) {
54206
54206
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
54207
- log$h(`Failed to get margin information: ${errorMessage}`, { type: "error" });
54207
+ log$i(`Failed to get margin information: ${errorMessage}`, { type: "error" });
54208
54208
  throw error;
54209
54209
  }
54210
54210
  }
@@ -54252,8 +54252,8 @@ var account$1 = /*#__PURE__*/Object.freeze({
54252
54252
  *
54253
54253
  * @module order-utils
54254
54254
  */
54255
- const log$g = (message, options = { type: "info" }) => {
54256
- log$l(message, { ...options, source: "OrderUtils" });
54255
+ const log$h = (message, options = { type: "info" }) => {
54256
+ log$m(message, { ...options, source: "OrderUtils" });
54257
54257
  };
54258
54258
  /**
54259
54259
  * Default delay between pagination requests to avoid rate limits (in milliseconds)
@@ -54347,7 +54347,7 @@ function buildOrderQueryParams(params) {
54347
54347
  async function getOrdersBySymbol(client, symbol, params = {}) {
54348
54348
  const sdk = client.getSDK();
54349
54349
  try {
54350
- log$g(`Fetching orders for symbol: ${symbol}`, {
54350
+ log$h(`Fetching orders for symbol: ${symbol}`, {
54351
54351
  type: "debug",
54352
54352
  metadata: { symbol, ...params },
54353
54353
  });
@@ -54370,14 +54370,14 @@ async function getOrdersBySymbol(client, symbol, params = {}) {
54370
54370
  if (params.side)
54371
54371
  queryParams.side = params.side;
54372
54372
  const orders = await sdk.getOrders(queryParams);
54373
- log$g(`Found ${orders.length} orders for ${symbol}`, {
54373
+ log$h(`Found ${orders.length} orders for ${symbol}`, {
54374
54374
  type: "debug",
54375
54375
  metadata: { symbol, count: orders.length },
54376
54376
  });
54377
54377
  return orders;
54378
54378
  }
54379
54379
  catch (error) {
54380
- log$g(`Error fetching orders for symbol ${symbol}: ${error.message}`, {
54380
+ log$h(`Error fetching orders for symbol ${symbol}: ${error.message}`, {
54381
54381
  type: "error",
54382
54382
  metadata: { symbol, error: error.message },
54383
54383
  });
@@ -54400,7 +54400,7 @@ async function getOrdersBySymbol(client, symbol, params = {}) {
54400
54400
  async function getOpenOrders$1(client, params = {}) {
54401
54401
  const sdk = client.getSDK();
54402
54402
  try {
54403
- log$g("Fetching open orders", { type: "debug" });
54403
+ log$h("Fetching open orders", { type: "debug" });
54404
54404
  // Build query parameters as Record<string, unknown> to match SDK expectations
54405
54405
  const queryParams = {
54406
54406
  status: "open",
@@ -54421,14 +54421,14 @@ async function getOpenOrders$1(client, params = {}) {
54421
54421
  if (params.side)
54422
54422
  queryParams.side = params.side;
54423
54423
  const orders = await sdk.getOrders(queryParams);
54424
- log$g(`Found ${orders.length} open orders`, {
54424
+ log$h(`Found ${orders.length} open orders`, {
54425
54425
  type: "debug",
54426
54426
  metadata: { count: orders.length },
54427
54427
  });
54428
54428
  return orders;
54429
54429
  }
54430
54430
  catch (error) {
54431
- log$g(`Error fetching open orders: ${error.message}`, {
54431
+ log$h(`Error fetching open orders: ${error.message}`, {
54432
54432
  type: "error",
54433
54433
  metadata: { error: error.message },
54434
54434
  });
@@ -54454,7 +54454,7 @@ async function getFilledOrders(client, params) {
54454
54454
  client.getSDK();
54455
54455
  const { startDate, endDate, symbols, side } = params;
54456
54456
  try {
54457
- log$g(`Fetching filled orders from ${startDate.toISOString()} to ${endDate.toISOString()}`, {
54457
+ log$h(`Fetching filled orders from ${startDate.toISOString()} to ${endDate.toISOString()}`, {
54458
54458
  type: "debug",
54459
54459
  metadata: {
54460
54460
  startDate: startDate.toISOString(),
@@ -54479,14 +54479,14 @@ async function getFilledOrders(client, params) {
54479
54479
  });
54480
54480
  // Filter to only filled orders
54481
54481
  const filledOrders = allOrders.filter((order) => FILLED_ORDER_STATUSES.includes(order.status));
54482
- log$g(`Found ${filledOrders.length} filled orders in date range`, {
54482
+ log$h(`Found ${filledOrders.length} filled orders in date range`, {
54483
54483
  type: "debug",
54484
54484
  metadata: { count: filledOrders.length },
54485
54485
  });
54486
54486
  return filledOrders;
54487
54487
  }
54488
54488
  catch (error) {
54489
- log$g(`Error fetching filled orders: ${error.message}`, {
54489
+ log$h(`Error fetching filled orders: ${error.message}`, {
54490
54490
  type: "error",
54491
54491
  metadata: { error: error.message },
54492
54492
  });
@@ -54523,7 +54523,7 @@ async function getOrderHistory(client, params = {}) {
54523
54523
  const effectivePageSize = Math.min(pageSize, MAX_ORDERS_PER_REQUEST);
54524
54524
  const sdk = client.getSDK();
54525
54525
  try {
54526
- log$g(`Fetching order history page ${page} (size: ${effectivePageSize})`, {
54526
+ log$h(`Fetching order history page ${page} (size: ${effectivePageSize})`, {
54527
54527
  type: "debug",
54528
54528
  metadata: { page, pageSize: effectivePageSize },
54529
54529
  });
@@ -54596,7 +54596,7 @@ async function getOrderHistory(client, params = {}) {
54596
54596
  };
54597
54597
  }
54598
54598
  catch (error) {
54599
- log$g(`Error fetching order history: ${error.message}`, {
54599
+ log$h(`Error fetching order history: ${error.message}`, {
54600
54600
  type: "error",
54601
54601
  metadata: { error: error.message },
54602
54602
  });
@@ -54636,7 +54636,7 @@ async function getAllOrders(client, params = {}) {
54636
54636
  const orders = await sdk.getOrders(sdkParams);
54637
54637
  return orders;
54638
54638
  }
54639
- log$g("Fetching all orders with pagination", {
54639
+ log$h("Fetching all orders with pagination", {
54640
54640
  type: "debug",
54641
54641
  metadata: { params: queryParams },
54642
54642
  });
@@ -54655,7 +54655,7 @@ async function getAllOrders(client, params = {}) {
54655
54655
  const sdkParams = buildOrderQueryParams(batchParams);
54656
54656
  const batch = (await sdk.getOrders(sdkParams));
54657
54657
  pageCount++;
54658
- log$g(`Fetched page ${pageCount}: ${batch.length} orders`, {
54658
+ log$h(`Fetched page ${pageCount}: ${batch.length} orders`, {
54659
54659
  type: "debug",
54660
54660
  metadata: { pageCount, batchSize: batch.length },
54661
54661
  });
@@ -54680,14 +54680,14 @@ async function getAllOrders(client, params = {}) {
54680
54680
  }
54681
54681
  }
54682
54682
  }
54683
- log$g(`Fetched total of ${allOrders.length} orders across ${pageCount} pages`, {
54683
+ log$h(`Fetched total of ${allOrders.length} orders across ${pageCount} pages`, {
54684
54684
  type: "info",
54685
54685
  metadata: { totalOrders: allOrders.length, pageCount },
54686
54686
  });
54687
54687
  return allOrders;
54688
54688
  }
54689
54689
  catch (error) {
54690
- log$g(`Error fetching all orders: ${error.message}`, {
54690
+ log$h(`Error fetching all orders: ${error.message}`, {
54691
54691
  type: "error",
54692
54692
  metadata: { error: error.message },
54693
54693
  });
@@ -54722,7 +54722,7 @@ async function waitForOrderFill(client, params) {
54722
54722
  const { orderId, timeoutMs = 60000, pollIntervalMs = 1000 } = params;
54723
54723
  const sdk = client.getSDK();
54724
54724
  const startTime = Date.now();
54725
- log$g(`Waiting for order ${orderId} to fill (timeout: ${timeoutMs}ms)`, {
54725
+ log$h(`Waiting for order ${orderId} to fill (timeout: ${timeoutMs}ms)`, {
54726
54726
  type: "debug",
54727
54727
  metadata: { orderId, timeoutMs, pollIntervalMs },
54728
54728
  });
@@ -54732,7 +54732,7 @@ async function waitForOrderFill(client, params) {
54732
54732
  if (elapsed >= timeoutMs) {
54733
54733
  // Fetch final state before returning
54734
54734
  const order = (await sdk.getOrder(orderId));
54735
- log$g(`Order ${orderId} timed out after ${elapsed}ms, status: ${order.status}`, {
54735
+ log$h(`Order ${orderId} timed out after ${elapsed}ms, status: ${order.status}`, {
54736
54736
  type: "warn",
54737
54737
  metadata: { orderId, elapsed, status: order.status },
54738
54738
  });
@@ -54745,7 +54745,7 @@ async function waitForOrderFill(client, params) {
54745
54745
  const order = (await sdk.getOrder(orderId));
54746
54746
  // Check if filled
54747
54747
  if (FILLED_ORDER_STATUSES.includes(order.status)) {
54748
- log$g(`Order ${orderId} filled after ${elapsed}ms`, {
54748
+ log$h(`Order ${orderId} filled after ${elapsed}ms`, {
54749
54749
  type: "info",
54750
54750
  metadata: { orderId, elapsed, status: order.status },
54751
54751
  });
@@ -54757,7 +54757,7 @@ async function waitForOrderFill(client, params) {
54757
54757
  }
54758
54758
  // Check if terminal but not filled
54759
54759
  if (TERMINAL_ORDER_STATUSES.includes(order.status)) {
54760
- log$g(`Order ${orderId} reached terminal state ${order.status} after ${elapsed}ms`, {
54760
+ log$h(`Order ${orderId} reached terminal state ${order.status} after ${elapsed}ms`, {
54761
54761
  type: "info",
54762
54762
  metadata: { orderId, elapsed, status: order.status },
54763
54763
  });
@@ -54772,7 +54772,7 @@ async function waitForOrderFill(client, params) {
54772
54772
  }
54773
54773
  }
54774
54774
  catch (error) {
54775
- log$g(`Error waiting for order fill: ${error.message}`, {
54775
+ log$h(`Error waiting for order fill: ${error.message}`, {
54776
54776
  type: "error",
54777
54777
  metadata: { orderId, error: error.message },
54778
54778
  });
@@ -55130,8 +55130,8 @@ const LOG_SOURCE$7 = "TrailingStops";
55130
55130
  /**
55131
55131
  * Internal logging helper with consistent source
55132
55132
  */
55133
- const log$f = (message, options = { type: "info" }) => {
55134
- log$l(message, { ...options, source: LOG_SOURCE$7 });
55133
+ const log$g = (message, options = { type: "info" }) => {
55134
+ log$m(message, { ...options, source: LOG_SOURCE$7 });
55135
55135
  };
55136
55136
  /**
55137
55137
  * Validation error for trailing stop parameters
@@ -55219,7 +55219,7 @@ async function createTrailingStop(client, params) {
55219
55219
  const trailDescription = params.trailPercent
55220
55220
  ? `${params.trailPercent}%`
55221
55221
  : `$${params.trailPrice?.toFixed(2)}`;
55222
- log$f(`Creating trailing stop: ${params.side} ${params.qty} ${params.symbol} (trail: ${trailDescription})`, {
55222
+ log$g(`Creating trailing stop: ${params.side} ${params.qty} ${params.symbol} (trail: ${trailDescription})`, {
55223
55223
  type: "info",
55224
55224
  });
55225
55225
  try {
@@ -55243,12 +55243,12 @@ async function createTrailingStop(client, params) {
55243
55243
  orderParams.client_order_id = params.clientOrderId;
55244
55244
  }
55245
55245
  const order = await sdk.createOrder(orderParams);
55246
- log$f(`Trailing stop created: orderId=${order.id}, HWM=${order.hwm || "pending"}, status=${order.status}`, { type: "info" });
55246
+ log$g(`Trailing stop created: orderId=${order.id}, HWM=${order.hwm || "pending"}, status=${order.status}`, { type: "info" });
55247
55247
  return order;
55248
55248
  }
55249
55249
  catch (error) {
55250
55250
  const err = error;
55251
- log$f(`Trailing stop creation failed for ${params.symbol}: ${err.message}`, {
55251
+ log$g(`Trailing stop creation failed for ${params.symbol}: ${err.message}`, {
55252
55252
  type: "error",
55253
55253
  });
55254
55254
  throw new Error(`Failed to create trailing stop for ${params.symbol}: ${err.message}`);
@@ -55294,7 +55294,7 @@ async function updateTrailingStop(client, orderId, updates) {
55294
55294
  const updateDescription = updates.trailPercent
55295
55295
  ? `${updates.trailPercent}%`
55296
55296
  : `$${updates.trailPrice?.toFixed(2)}`;
55297
- log$f(`Updating trailing stop ${orderId} to trail: ${updateDescription}`, {
55297
+ log$g(`Updating trailing stop ${orderId} to trail: ${updateDescription}`, {
55298
55298
  type: "info",
55299
55299
  });
55300
55300
  try {
@@ -55307,14 +55307,14 @@ async function updateTrailingStop(client, orderId, updates) {
55307
55307
  replaceParams.trail = updates.trailPrice.toString();
55308
55308
  }
55309
55309
  const order = await sdk.replaceOrder(orderId, replaceParams);
55310
- log$f(`Trailing stop updated: orderId=${order.id}, new replacement created`, {
55310
+ log$g(`Trailing stop updated: orderId=${order.id}, new replacement created`, {
55311
55311
  type: "info",
55312
55312
  });
55313
55313
  return order;
55314
55314
  }
55315
55315
  catch (error) {
55316
55316
  const err = error;
55317
- log$f(`Trailing stop update failed for ${orderId}: ${err.message}`, {
55317
+ log$g(`Trailing stop update failed for ${orderId}: ${err.message}`, {
55318
55318
  type: "error",
55319
55319
  });
55320
55320
  throw new Error(`Failed to update trailing stop ${orderId}: ${err.message}`);
@@ -55344,18 +55344,18 @@ async function getTrailingStopHWM(client, orderId) {
55344
55344
  const order = await sdk.getOrder(orderId);
55345
55345
  // Validate this is actually a trailing stop order
55346
55346
  if (order.type !== "trailing_stop") {
55347
- log$f(`Order ${orderId} is not a trailing stop order (type: ${order.type})`, { type: "warn" });
55347
+ log$g(`Order ${orderId} is not a trailing stop order (type: ${order.type})`, { type: "warn" });
55348
55348
  }
55349
55349
  const result = {
55350
55350
  hwm: order.hwm ? parseFloat(order.hwm) : null,
55351
55351
  currentStop: order.stop_price ? parseFloat(order.stop_price) : null,
55352
55352
  };
55353
- log$f(`Retrieved HWM for ${orderId}: HWM=${result.hwm ?? "N/A"}, currentStop=${result.currentStop ?? "N/A"}`, { type: "debug" });
55353
+ log$g(`Retrieved HWM for ${orderId}: HWM=${result.hwm ?? "N/A"}, currentStop=${result.currentStop ?? "N/A"}`, { type: "debug" });
55354
55354
  return result;
55355
55355
  }
55356
55356
  catch (error) {
55357
55357
  const err = error;
55358
- log$f(`Failed to get trailing stop HWM for ${orderId}: ${err.message}`, {
55358
+ log$g(`Failed to get trailing stop HWM for ${orderId}: ${err.message}`, {
55359
55359
  type: "error",
55360
55360
  });
55361
55361
  throw new Error(`Failed to get trailing stop HWM for ${orderId}: ${err.message}`);
@@ -55375,21 +55375,21 @@ async function getTrailingStopHWM(client, orderId) {
55375
55375
  */
55376
55376
  async function cancelTrailingStop(client, orderId) {
55377
55377
  const sdk = client.getSDK();
55378
- log$f(`Canceling trailing stop order: ${orderId}`, { type: "info" });
55378
+ log$g(`Canceling trailing stop order: ${orderId}`, { type: "info" });
55379
55379
  try {
55380
55380
  await sdk.cancelOrder(orderId);
55381
- log$f(`Trailing stop order canceled: ${orderId}`, { type: "info" });
55381
+ log$g(`Trailing stop order canceled: ${orderId}`, { type: "info" });
55382
55382
  }
55383
55383
  catch (error) {
55384
55384
  const err = error;
55385
55385
  // Check if the order was already filled or canceled
55386
55386
  if (err.message.includes("order is not cancelable")) {
55387
- log$f(`Trailing stop ${orderId} is not cancelable (may already be filled or canceled)`, {
55387
+ log$g(`Trailing stop ${orderId} is not cancelable (may already be filled or canceled)`, {
55388
55388
  type: "warn",
55389
55389
  });
55390
55390
  throw new Error(`Trailing stop ${orderId} is not cancelable: order may already be filled or canceled`);
55391
55391
  }
55392
- log$f(`Failed to cancel trailing stop ${orderId}: ${err.message}`, {
55392
+ log$g(`Failed to cancel trailing stop ${orderId}: ${err.message}`, {
55393
55393
  type: "error",
55394
55394
  });
55395
55395
  throw new Error(`Failed to cancel trailing stop ${orderId}: ${err.message}`);
@@ -55430,28 +55430,28 @@ async function createPortfolioTrailingStops(client, params) {
55430
55430
  const sdk = client.getSDK();
55431
55431
  const results = new Map();
55432
55432
  const excludeSet = new Set(params.excludeSymbols?.map((s) => s.toUpperCase()) || []);
55433
- log$f(`Creating portfolio trailing stops at ${params.trailPercent}%`, {
55433
+ log$g(`Creating portfolio trailing stops at ${params.trailPercent}%`, {
55434
55434
  type: "info",
55435
55435
  });
55436
55436
  try {
55437
55437
  const positions = await sdk.getPositions();
55438
55438
  if (positions.length === 0) {
55439
- log$f("No positions found in portfolio", { type: "info" });
55439
+ log$g("No positions found in portfolio", { type: "info" });
55440
55440
  return results;
55441
55441
  }
55442
- log$f(`Found ${positions.length} positions, checking for eligible trailing stops`, { type: "debug" });
55442
+ log$g(`Found ${positions.length} positions, checking for eligible trailing stops`, { type: "debug" });
55443
55443
  const errors = [];
55444
55444
  for (const position of positions) {
55445
55445
  const symbol = position.symbol.toUpperCase();
55446
55446
  // Skip excluded symbols
55447
55447
  if (excludeSet.has(symbol)) {
55448
- log$f(`Skipping ${symbol} (excluded)`, { type: "debug" });
55448
+ log$g(`Skipping ${symbol} (excluded)`, { type: "debug" });
55449
55449
  continue;
55450
55450
  }
55451
55451
  // Only create trailing stops for long positions
55452
55452
  const qty = parseFloat(position.qty);
55453
55453
  if (qty <= 0) {
55454
- log$f(`Skipping ${symbol} (not a long position, qty: ${qty})`, {
55454
+ log$g(`Skipping ${symbol} (not a long position, qty: ${qty})`, {
55455
55455
  type: "debug",
55456
55456
  });
55457
55457
  continue;
@@ -55469,7 +55469,7 @@ async function createPortfolioTrailingStops(client, params) {
55469
55469
  catch (err) {
55470
55470
  const errorMessage = err.message;
55471
55471
  errors.push({ symbol, error: errorMessage });
55472
- log$f(`Failed to create trailing stop for ${symbol}: ${errorMessage}`, {
55472
+ log$g(`Failed to create trailing stop for ${symbol}: ${errorMessage}`, {
55473
55473
  type: "error",
55474
55474
  });
55475
55475
  }
@@ -55478,9 +55478,9 @@ async function createPortfolioTrailingStops(client, params) {
55478
55478
  const successCount = results.size;
55479
55479
  const failureCount = errors.length;
55480
55480
  const skippedCount = positions.length - successCount - failureCount;
55481
- log$f(`Portfolio trailing stops complete: ${successCount} created, ${failureCount} failed, ${skippedCount} skipped`, { type: "info" });
55481
+ log$g(`Portfolio trailing stops complete: ${successCount} created, ${failureCount} failed, ${skippedCount} skipped`, { type: "info" });
55482
55482
  if (errors.length > 0) {
55483
- log$f(`Failed symbols: ${errors.map((e) => `${e.symbol} (${e.error})`).join(", ")}`, {
55483
+ log$g(`Failed symbols: ${errors.map((e) => `${e.symbol} (${e.error})`).join(", ")}`, {
55484
55484
  type: "warn",
55485
55485
  });
55486
55486
  }
@@ -55488,7 +55488,7 @@ async function createPortfolioTrailingStops(client, params) {
55488
55488
  }
55489
55489
  catch (error) {
55490
55490
  const err = error;
55491
- log$f(`Failed to create portfolio trailing stops: ${err.message}`, {
55491
+ log$g(`Failed to create portfolio trailing stops: ${err.message}`, {
55492
55492
  type: "error",
55493
55493
  });
55494
55494
  throw new Error(`Failed to create portfolio trailing stops: ${err.message}`);
@@ -55523,14 +55523,14 @@ async function getOpenTrailingStops(client, symbol) {
55523
55523
  const orders = (await sdk.getOrders(queryParams));
55524
55524
  // Filter to only trailing stop orders
55525
55525
  const trailingStops = orders.filter((order) => order.type === "trailing_stop");
55526
- log$f(`Found ${trailingStops.length} open trailing stop orders${symbol ? ` for ${symbol}` : ""}`, {
55526
+ log$g(`Found ${trailingStops.length} open trailing stop orders${symbol ? ` for ${symbol}` : ""}`, {
55527
55527
  type: "debug",
55528
55528
  });
55529
55529
  return trailingStops;
55530
55530
  }
55531
55531
  catch (error) {
55532
55532
  const err = error;
55533
- log$f(`Failed to get open trailing stops: ${err.message}`, { type: "error" });
55533
+ log$g(`Failed to get open trailing stops: ${err.message}`, { type: "error" });
55534
55534
  throw new Error(`Failed to get open trailing stops: ${err.message}`);
55535
55535
  }
55536
55536
  }
@@ -55568,7 +55568,7 @@ async function hasActiveTrailingStop(client, symbol) {
55568
55568
  async function cancelTrailingStopsForSymbol(client, symbol) {
55569
55569
  const trailingStops = await getOpenTrailingStops(client, symbol);
55570
55570
  if (trailingStops.length === 0) {
55571
- log$f(`No trailing stops to cancel for ${symbol}`, { type: "debug" });
55571
+ log$g(`No trailing stops to cancel for ${symbol}`, { type: "debug" });
55572
55572
  return 0;
55573
55573
  }
55574
55574
  let canceledCount = 0;
@@ -55583,9 +55583,9 @@ async function cancelTrailingStopsForSymbol(client, symbol) {
55583
55583
  }
55584
55584
  }
55585
55585
  if (errors.length > 0) {
55586
- log$f(`Some trailing stops failed to cancel for ${symbol}: ${errors.join(", ")}`, { type: "warn" });
55586
+ log$g(`Some trailing stops failed to cancel for ${symbol}: ${errors.join(", ")}`, { type: "warn" });
55587
55587
  }
55588
- log$f(`Canceled ${canceledCount}/${trailingStops.length} trailing stops for ${symbol}`, { type: "info" });
55588
+ log$g(`Canceled ${canceledCount}/${trailingStops.length} trailing stops for ${symbol}`, { type: "info" });
55589
55589
  return canceledCount;
55590
55590
  }
55591
55591
  /**
@@ -55628,8 +55628,8 @@ var trailingStops$1 = /*#__PURE__*/Object.freeze({
55628
55628
  *
55629
55629
  * @module oco-orders
55630
55630
  */
55631
- const log$e = (message, options = { type: "info" }) => {
55632
- log$l(message, { ...options, source: "OCOOrders" });
55631
+ const log$f = (message, options = { type: "info" }) => {
55632
+ log$m(message, { ...options, source: "OCOOrders" });
55633
55633
  };
55634
55634
  /**
55635
55635
  * Round a price to the nearest 2 decimal places for Alpaca,
@@ -55738,7 +55738,7 @@ async function createOCOOrder(client, params) {
55738
55738
  // Validate parameters
55739
55739
  validateOCOParams(params);
55740
55740
  const { symbol, qty, side, takeProfit, stopLoss, timeInForce = "gtc", } = params;
55741
- log$e(`Creating OCO order for ${symbol}: ${side} ${qty} shares | ` +
55741
+ log$f(`Creating OCO order for ${symbol}: ${side} ${qty} shares | ` +
55742
55742
  `Take profit at $${takeProfit.limitPrice.toFixed(2)} | ` +
55743
55743
  `Stop loss at $${stopLoss.stopPrice.toFixed(2)}` +
55744
55744
  (stopLoss.limitPrice
@@ -55763,7 +55763,7 @@ async function createOCOOrder(client, params) {
55763
55763
  if (stopLoss.limitPrice !== undefined) {
55764
55764
  orderRequest.stop_loss.limit_price = roundPriceForAlpaca$2(stopLoss.limitPrice).toString();
55765
55765
  }
55766
- log$e(`Submitting OCO order request: ${JSON.stringify(orderRequest)}`, {
55766
+ log$f(`Submitting OCO order request: ${JSON.stringify(orderRequest)}`, {
55767
55767
  symbol,
55768
55768
  type: "debug",
55769
55769
  });
@@ -55772,7 +55772,7 @@ async function createOCOOrder(client, params) {
55772
55772
  // Extract leg orders from the response
55773
55773
  const legs = order.legs || [];
55774
55774
  if (legs.length < 2) {
55775
- log$e(`OCO order created but legs not found in response. Order ID: ${order.id}`, { symbol, type: "warn" });
55775
+ log$f(`OCO order created but legs not found in response. Order ID: ${order.id}`, { symbol, type: "warn" });
55776
55776
  }
55777
55777
  // Identify take profit and stop loss orders from legs
55778
55778
  // Take profit is the limit order, stop loss is the stop/stop_limit order
@@ -55780,7 +55780,7 @@ async function createOCOOrder(client, params) {
55780
55780
  const stopLossOrder = legs.find((leg) => leg.type === "stop" || leg.type === "stop_limit") ||
55781
55781
  legs.find((leg) => leg !== takeProfitOrder) ||
55782
55782
  order;
55783
- log$e(`OCO order created successfully | Parent ID: ${order.id} | ` +
55783
+ log$f(`OCO order created successfully | Parent ID: ${order.id} | ` +
55784
55784
  `Take profit ID: ${takeProfitOrder.id} | Stop loss ID: ${stopLossOrder.id}`, { symbol, type: "info" });
55785
55785
  return {
55786
55786
  takeProfitOrder,
@@ -55791,7 +55791,7 @@ async function createOCOOrder(client, params) {
55791
55791
  }
55792
55792
  catch (error) {
55793
55793
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
55794
- log$e(`Failed to create OCO order for ${symbol}: ${errorMessage}`, {
55794
+ log$f(`Failed to create OCO order for ${symbol}: ${errorMessage}`, {
55795
55795
  symbol,
55796
55796
  type: "error",
55797
55797
  });
@@ -55811,17 +55811,17 @@ async function createOCOOrder(client, params) {
55811
55811
  * await cancelOCOOrder(client, result.parentOrderId);
55812
55812
  */
55813
55813
  async function cancelOCOOrder(client, parentOrderId) {
55814
- log$e(`Canceling OCO order group: ${parentOrderId}`, { type: "info" });
55814
+ log$f(`Canceling OCO order group: ${parentOrderId}`, { type: "info" });
55815
55815
  const sdk = client.getSDK();
55816
55816
  try {
55817
55817
  await sdk.cancelOrder(parentOrderId);
55818
- log$e(`OCO order group canceled successfully: ${parentOrderId}`, {
55818
+ log$f(`OCO order group canceled successfully: ${parentOrderId}`, {
55819
55819
  type: "info",
55820
55820
  });
55821
55821
  }
55822
55822
  catch (error) {
55823
55823
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
55824
- log$e(`Failed to cancel OCO order ${parentOrderId}: ${errorMessage}`, {
55824
+ log$f(`Failed to cancel OCO order ${parentOrderId}: ${errorMessage}`, {
55825
55825
  type: "error",
55826
55826
  });
55827
55827
  throw error;
@@ -55843,17 +55843,17 @@ async function cancelOCOOrder(client, parentOrderId) {
55843
55843
  * });
55844
55844
  */
55845
55845
  async function getOCOOrderStatus(client, parentOrderId) {
55846
- log$e(`Getting OCO order status: ${parentOrderId}`, { type: "debug" });
55846
+ log$f(`Getting OCO order status: ${parentOrderId}`, { type: "debug" });
55847
55847
  const sdk = client.getSDK();
55848
55848
  try {
55849
55849
  const order = (await sdk.getOrder(parentOrderId));
55850
- log$e(`OCO order ${parentOrderId} status: ${order.status} | ` +
55850
+ log$f(`OCO order ${parentOrderId} status: ${order.status} | ` +
55851
55851
  `Legs: ${order.legs?.length || 0}`, { type: "debug" });
55852
55852
  return order;
55853
55853
  }
55854
55854
  catch (error) {
55855
55855
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
55856
- log$e(`Failed to get OCO order status ${parentOrderId}: ${errorMessage}`, {
55856
+ log$f(`Failed to get OCO order status ${parentOrderId}: ${errorMessage}`, {
55857
55857
  type: "error",
55858
55858
  });
55859
55859
  throw error;
@@ -55959,8 +55959,8 @@ var ocoOrders$1 = /*#__PURE__*/Object.freeze({
55959
55959
  *
55960
55960
  * @module oto-orders
55961
55961
  */
55962
- const log$d = (message, options = { type: "info" }) => {
55963
- log$l(message, { ...options, source: "OTOOrders" });
55962
+ const log$e = (message, options = { type: "info" }) => {
55963
+ log$m(message, { ...options, source: "OTOOrders" });
55964
55964
  };
55965
55965
  /**
55966
55966
  * Round a price to the nearest 2 decimal places for Alpaca,
@@ -56030,7 +56030,7 @@ function validateOTOParams(params) {
56030
56030
  // Validate logical order of sides for typical use cases
56031
56031
  // Primary buy should typically trigger sell (exit), and vice versa
56032
56032
  if (params.side === dependent.side) {
56033
- log$d(`Warning: Primary and dependent orders have the same side (${params.side}). ` +
56033
+ log$e(`Warning: Primary and dependent orders have the same side (${params.side}). ` +
56034
56034
  "This is unusual - typically entry and exit are opposite sides.", { symbol: params.symbol, type: "warn" });
56035
56035
  }
56036
56036
  }
@@ -56126,7 +56126,7 @@ async function createOTOOrder(client, params) {
56126
56126
  dependentDescription += ` trail ${dependent.trailPercent}%`;
56127
56127
  if (dependent.trailPrice)
56128
56128
  dependentDescription += ` trail $${dependent.trailPrice.toFixed(2)}`;
56129
- log$d(`Creating OTO order for ${symbol}: Primary [${primaryDescription}] -> Dependent [${dependentDescription}]`, { symbol, type: "info" });
56129
+ log$e(`Creating OTO order for ${symbol}: Primary [${primaryDescription}] -> Dependent [${dependentDescription}]`, { symbol, type: "info" });
56130
56130
  const sdk = client.getSDK();
56131
56131
  try {
56132
56132
  // Build the OTO order request
@@ -56186,7 +56186,7 @@ async function createOTOOrder(client, params) {
56186
56186
  orderRequest.stop_loss.trail_price = roundPriceForAlpaca$1(dependent.trailPrice).toString();
56187
56187
  }
56188
56188
  }
56189
- log$d(`Submitting OTO order request: ${JSON.stringify(orderRequest)}`, {
56189
+ log$e(`Submitting OTO order request: ${JSON.stringify(orderRequest)}`, {
56190
56190
  symbol,
56191
56191
  type: "debug",
56192
56192
  });
@@ -56197,7 +56197,7 @@ async function createOTOOrder(client, params) {
56197
56197
  // The primary order is the parent, dependent is in legs
56198
56198
  const primaryOrder = order;
56199
56199
  const dependentOrder = legs.length > 0 ? legs[0] : null;
56200
- log$d(`OTO order created successfully | Parent ID: ${order.id} | Status: ${order.status}` +
56200
+ log$e(`OTO order created successfully | Parent ID: ${order.id} | Status: ${order.status}` +
56201
56201
  (dependentOrder ? ` | Dependent ID: ${dependentOrder.id}` : ""), { symbol, type: "info" });
56202
56202
  return {
56203
56203
  primaryOrder,
@@ -56208,7 +56208,7 @@ async function createOTOOrder(client, params) {
56208
56208
  }
56209
56209
  catch (error) {
56210
56210
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
56211
- log$d(`Failed to create OTO order for ${symbol}: ${errorMessage}`, {
56211
+ log$e(`Failed to create OTO order for ${symbol}: ${errorMessage}`, {
56212
56212
  symbol,
56213
56213
  type: "error",
56214
56214
  });
@@ -56228,17 +56228,17 @@ async function createOTOOrder(client, params) {
56228
56228
  * await cancelOTOOrder(client, result.parentOrderId);
56229
56229
  */
56230
56230
  async function cancelOTOOrder(client, parentOrderId) {
56231
- log$d(`Canceling OTO order group: ${parentOrderId}`, { type: "info" });
56231
+ log$e(`Canceling OTO order group: ${parentOrderId}`, { type: "info" });
56232
56232
  const sdk = client.getSDK();
56233
56233
  try {
56234
56234
  await sdk.cancelOrder(parentOrderId);
56235
- log$d(`OTO order group canceled successfully: ${parentOrderId}`, {
56235
+ log$e(`OTO order group canceled successfully: ${parentOrderId}`, {
56236
56236
  type: "info",
56237
56237
  });
56238
56238
  }
56239
56239
  catch (error) {
56240
56240
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
56241
- log$d(`Failed to cancel OTO order ${parentOrderId}: ${errorMessage}`, {
56241
+ log$e(`Failed to cancel OTO order ${parentOrderId}: ${errorMessage}`, {
56242
56242
  type: "error",
56243
56243
  });
56244
56244
  throw error;
@@ -56260,17 +56260,17 @@ async function cancelOTOOrder(client, parentOrderId) {
56260
56260
  * }
56261
56261
  */
56262
56262
  async function getOTOOrderStatus(client, parentOrderId) {
56263
- log$d(`Getting OTO order status: ${parentOrderId}`, { type: "debug" });
56263
+ log$e(`Getting OTO order status: ${parentOrderId}`, { type: "debug" });
56264
56264
  const sdk = client.getSDK();
56265
56265
  try {
56266
56266
  const order = (await sdk.getOrder(parentOrderId));
56267
- log$d(`OTO order ${parentOrderId} status: ${order.status} | ` +
56267
+ log$e(`OTO order ${parentOrderId} status: ${order.status} | ` +
56268
56268
  `Legs: ${order.legs?.length || 0}`, { type: "debug" });
56269
56269
  return order;
56270
56270
  }
56271
56271
  catch (error) {
56272
56272
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
56273
- log$d(`Failed to get OTO order status ${parentOrderId}: ${errorMessage}`, {
56273
+ log$e(`Failed to get OTO order status ${parentOrderId}: ${errorMessage}`, {
56274
56274
  type: "error",
56275
56275
  });
56276
56276
  throw error;
@@ -56457,8 +56457,119 @@ var otoOrders$1 = /*#__PURE__*/Object.freeze({
56457
56457
  shortWithStopLoss: shortWithStopLoss
56458
56458
  });
56459
56459
 
56460
+ const log$d = (message, options = { type: "info" }) => {
56461
+ log$m(message, { ...options, source: "AlpacaClock" });
56462
+ };
56463
+ /**
56464
+ * Formats a Date to a YYYY-MM-DD string suitable for Alpaca calendar API requests.
56465
+ *
56466
+ * @param date - The date to format
56467
+ * @returns Date string in YYYY-MM-DD format
56468
+ */
56469
+ function formatCalendarDate(date) {
56470
+ const year = date.getFullYear();
56471
+ const month = String(date.getMonth() + 1).padStart(2, "0");
56472
+ const day = String(date.getDate()).padStart(2, "0");
56473
+ return `${year}-${month}-${day}`;
56474
+ }
56475
+ /**
56476
+ * Fetches the current market clock from Alpaca (GET /v2/clock).
56477
+ *
56478
+ * Returns the current server time, whether the market is open, and the next
56479
+ * open/close timestamps. Useful for determining whether trading is currently
56480
+ * possible before placing orders.
56481
+ *
56482
+ * @param client - An initialized AlpacaClient instance
56483
+ * @returns Promise resolving to the current market clock status
56484
+ *
56485
+ * @example
56486
+ * ```ts
56487
+ * const clock = await getAlpacaClock(client);
56488
+ * if (clock.is_open) {
56489
+ * console.log('Market is open, next close:', clock.next_close);
56490
+ * } else {
56491
+ * console.log('Market closed, next open:', clock.next_open);
56492
+ * }
56493
+ * ```
56494
+ *
56495
+ * @throws {Error} If the Alpaca API request fails
56496
+ */
56497
+ async function getAlpacaClock(client) {
56498
+ log$d("Fetching market clock");
56499
+ try {
56500
+ const sdk = client.getSDK();
56501
+ const clock = await sdk.getClock();
56502
+ log$d(`Market clock fetched: is_open=${clock.is_open}, next_open=${clock.next_open}`);
56503
+ return clock;
56504
+ }
56505
+ catch (error) {
56506
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
56507
+ log$d(`Failed to fetch market clock: ${errorMessage}`, { type: "error" });
56508
+ throw error;
56509
+ }
56510
+ }
56511
+ /**
56512
+ * Fetches the market trading calendar from Alpaca (GET /v2/calendar).
56513
+ *
56514
+ * Returns the scheduled open and close times for each trading day within the
56515
+ * requested date range. The calendar accounts for market holidays and early
56516
+ * closures. Dates default to today when omitted.
56517
+ *
56518
+ * @param client - An initialized AlpacaClient instance
56519
+ * @param options - Optional start/end dates for the calendar range
56520
+ * @returns Promise resolving to an array of trading calendar days
56521
+ *
56522
+ * @example
56523
+ * ```ts
56524
+ * // Fetch the next 5 trading days
56525
+ * const today = new Date();
56526
+ * const nextWeek = new Date(today);
56527
+ * nextWeek.setDate(today.getDate() + 7);
56528
+ *
56529
+ * const calendar = await getAlpacaCalendar(client, {
56530
+ * start: today,
56531
+ * end: nextWeek,
56532
+ * });
56533
+ * console.log('Trading days this week:', calendar.length);
56534
+ * ```
56535
+ *
56536
+ * @throws {Error} If the Alpaca API request fails
56537
+ */
56538
+ async function getAlpacaCalendar(client, options) {
56539
+ const startStr = options?.start
56540
+ ? formatCalendarDate(options.start)
56541
+ : undefined;
56542
+ const endStr = options?.end ? formatCalendarDate(options.end) : undefined;
56543
+ log$d(`Fetching market calendar${startStr ? ` from ${startStr}` : ""}${endStr ? ` to ${endStr}` : ""}`);
56544
+ try {
56545
+ const sdk = client.getSDK();
56546
+ const calendar = await sdk.getCalendar({
56547
+ start: startStr,
56548
+ end: endStr,
56549
+ });
56550
+ log$d(`Market calendar fetched: ${calendar.length} trading days`);
56551
+ return calendar;
56552
+ }
56553
+ catch (error) {
56554
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
56555
+ log$d(`Failed to fetch market calendar: ${errorMessage}`, { type: "error" });
56556
+ throw error;
56557
+ }
56558
+ }
56559
+ var clock = {
56560
+ getAlpacaClock,
56561
+ getAlpacaCalendar,
56562
+ };
56563
+
56564
+ var clock$1 = /*#__PURE__*/Object.freeze({
56565
+ __proto__: null,
56566
+ default: clock,
56567
+ getAlpacaCalendar: getAlpacaCalendar,
56568
+ getAlpacaClock: getAlpacaClock
56569
+ });
56570
+
56460
56571
  const log$c = (message, options = { type: "info" }) => {
56461
- log$l(message, { ...options, source: "AlpacaQuotes" });
56572
+ log$m(message, { ...options, source: "AlpacaQuotes" });
56462
56573
  };
56463
56574
  /**
56464
56575
  * Error thrown when quote operations fail
@@ -56688,7 +56799,7 @@ var quotes$1 = /*#__PURE__*/Object.freeze({
56688
56799
  });
56689
56800
 
56690
56801
  const log$b = (message, options = { type: "info" }) => {
56691
- log$l(message, { ...options, source: "AlpacaBars" });
56802
+ log$m(message, { ...options, source: "AlpacaBars" });
56692
56803
  };
56693
56804
  /**
56694
56805
  * Error thrown when bar operations fail
@@ -57054,7 +57165,7 @@ var bars$1 = /*#__PURE__*/Object.freeze({
57054
57165
  });
57055
57166
 
57056
57167
  const log$a = (message, options = { type: "info" }) => {
57057
- log$l(message, { ...options, source: "AlpacaTrades" });
57168
+ log$m(message, { ...options, source: "AlpacaTrades" });
57058
57169
  };
57059
57170
  /**
57060
57171
  * Error thrown when trade operations fail
@@ -57431,7 +57542,7 @@ var trades$1 = /*#__PURE__*/Object.freeze({
57431
57542
  });
57432
57543
 
57433
57544
  const log$9 = (message, options = { type: "info" }) => {
57434
- log$l(message, { ...options, source: "AlpacaNews" });
57545
+ log$m(message, { ...options, source: "AlpacaNews" });
57435
57546
  };
57436
57547
  /**
57437
57548
  * Error thrown when news operations fail
@@ -57904,7 +58015,7 @@ const LOG_SOURCE$6 = "OptionsContracts";
57904
58015
  * Internal logging helper with consistent source
57905
58016
  */
57906
58017
  const log$8 = (message, options = { type: "info" }) => {
57907
- log$l(message, { ...options, source: LOG_SOURCE$6 });
58018
+ log$m(message, { ...options, source: LOG_SOURCE$6 });
57908
58019
  };
57909
58020
  // ============================================================================
57910
58021
  // API Functions
@@ -58613,7 +58724,7 @@ const LOG_SOURCE$5 = "OptionsOrders";
58613
58724
  * Internal logging helper with consistent source
58614
58725
  */
58615
58726
  const log$7 = (message, options = { type: "info" }) => {
58616
- log$l(message, { ...options, source: LOG_SOURCE$5 });
58727
+ log$m(message, { ...options, source: LOG_SOURCE$5 });
58617
58728
  };
58618
58729
  // ============================================================================
58619
58730
  // Single-Leg Option Orders
@@ -59468,7 +59579,7 @@ const LOG_SOURCE$4 = "AlpacaOrders";
59468
59579
  * Internal logging helper with consistent source
59469
59580
  */
59470
59581
  const log$6 = (message, options = { type: "info" }) => {
59471
- log$l(message, { ...options, source: LOG_SOURCE$4 });
59582
+ log$m(message, { ...options, source: LOG_SOURCE$4 });
59472
59583
  };
59473
59584
  /**
59474
59585
  * Creates a new order using the Alpaca SDK.
@@ -59881,7 +59992,7 @@ const LOG_SOURCE$3 = "OptionsStrategies";
59881
59992
  * Internal logging helper with consistent source
59882
59993
  */
59883
59994
  const log$5 = (message, options = { type: "info" }) => {
59884
- log$l(message, { ...options, source: LOG_SOURCE$3 });
59995
+ log$m(message, { ...options, source: LOG_SOURCE$3 });
59885
59996
  };
59886
59997
  /**
59887
59998
  * Error class for option strategy operations
@@ -60483,7 +60594,7 @@ const LOG_SOURCE$2 = "OptionsData";
60483
60594
  * Internal logging helper with consistent source
60484
60595
  */
60485
60596
  const log$4 = (message, options = { type: "info" }) => {
60486
- log$l(message, { ...options, source: LOG_SOURCE$2 });
60597
+ log$m(message, { ...options, source: LOG_SOURCE$2 });
60487
60598
  };
60488
60599
  /**
60489
60600
  * Error class for options data operations
@@ -60989,7 +61100,7 @@ const LOG_SOURCE$1 = "CryptoOrders";
60989
61100
  * Internal logging helper with consistent source
60990
61101
  */
60991
61102
  const log$3 = (message, options = { type: "info" }) => {
60992
- log$l(message, { ...options, source: LOG_SOURCE$1 });
61103
+ log$m(message, { ...options, source: LOG_SOURCE$1 });
60993
61104
  };
60994
61105
  /**
60995
61106
  * Error thrown when crypto order operations fail
@@ -61481,7 +61592,7 @@ const LOG_SOURCE = "CryptoData";
61481
61592
  * Internal logging helper with consistent source
61482
61593
  */
61483
61594
  const log$2 = (message, options = { type: "info" }) => {
61484
- log$l(message, { ...options, source: LOG_SOURCE });
61595
+ log$m(message, { ...options, source: LOG_SOURCE });
61485
61596
  };
61486
61597
  /**
61487
61598
  * Error thrown when crypto data operations fail
@@ -62300,7 +62411,7 @@ var streams$1 = /*#__PURE__*/Object.freeze({
62300
62411
  });
62301
62412
 
62302
62413
  const log$1 = (message, options = { type: "info" }) => {
62303
- log$l(message, { ...options, source: "SmartOrders" });
62414
+ log$m(message, { ...options, source: "SmartOrders" });
62304
62415
  };
62305
62416
  /**
62306
62417
  * Analyze parameters and determine the best order type
@@ -62738,7 +62849,7 @@ var smartOrders$1 = /*#__PURE__*/Object.freeze({
62738
62849
  const log = (message, options = {
62739
62850
  type: "info",
62740
62851
  }) => {
62741
- log$l(message, { ...options, source: "Positions" });
62852
+ log$m(message, { ...options, source: "Positions" });
62742
62853
  };
62743
62854
  // ============================================================================
62744
62855
  // Helper Functions
@@ -63518,6 +63629,8 @@ const alpaca = {
63518
63629
  positions: positions$1,
63519
63630
  // Trading - Account
63520
63631
  account: account$1,
63632
+ // Trading - Clock & Calendar
63633
+ clock: clock$1,
63521
63634
  // Market Data
63522
63635
  quotes: quotes$1,
63523
63636
  bars: bars$1,
@@ -71413,6 +71526,8 @@ const adaptic = {
71413
71526
  sdkPositions: alpaca.positions,
71414
71527
  /** @description Account information and configuration - SDK-based (requires AlpacaClient) */
71415
71528
  sdkAccount: alpaca.account,
71529
+ /** @description Market clock and trading calendar - SDK-based (requires AlpacaClient) */
71530
+ sdkClock: alpaca.clock,
71416
71531
  // Legacy API (with original signatures for backward compatibility)
71417
71532
  /** @description Standard order operations - Legacy API (uses AlpacaAuth) */
71418
71533
  orders: {
@@ -71673,6 +71788,7 @@ exports.cancelTrailingStop = cancelTrailingStop;
71673
71788
  exports.cancelTrailingStopsForSymbol = cancelTrailingStopsForSymbol;
71674
71789
  exports.checkTradingEligibility = checkTradingEligibility;
71675
71790
  exports.clearClientCache = clearClientCache;
71791
+ exports.clock = clock;
71676
71792
  exports.closeAllOptionPositions = closeAllOptionPositions;
71677
71793
  exports.closeOptionPosition = closeOptionPosition;
71678
71794
  exports.createAlpacaClient = createAlpacaClient;
@@ -71725,6 +71841,8 @@ exports.getAccountDetails = getAccountDetails;
71725
71841
  exports.getAccountSummary = getAccountSummary;
71726
71842
  exports.getAgentPoolStatus = getAgentPoolStatus;
71727
71843
  exports.getAllOrders = getAllOrders;
71844
+ exports.getAlpacaCalendar = getAlpacaCalendar;
71845
+ exports.getAlpacaClock = getAlpacaClock;
71728
71846
  exports.getAverageDailyVolume = getAverageDailyVolume;
71729
71847
  exports.getBars = getBars;
71730
71848
  exports.getBuyingPower = getBuyingPower;