@adaptic/utils 0.0.970 → 0.0.972

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.mjs CHANGED
@@ -50900,6 +50900,13 @@ var orderUtils$1 = /*#__PURE__*/Object.freeze({
50900
50900
  });
50901
50901
 
50902
50902
  const LOG_SOURCE$7 = "TrailingStops";
50903
+ /**
50904
+ * Alpaca's hard upper limit for `trail_percent` on trailing-stop orders.
50905
+ * Submissions exceeding this value are rejected with HTTP 422 / code 42210000
50906
+ * ("trail_percent must be <= 25"). See:
50907
+ * https://docs.alpaca.markets/reference/postorder
50908
+ */
50909
+ const ALPACA_MAX_TRAIL_PERCENT = 25;
50903
50910
  /**
50904
50911
  * Internal logging helper with consistent source
50905
50912
  */
@@ -50927,13 +50934,13 @@ function validateTrailingStopParams(params) {
50927
50934
  if (params.trailPercent !== undefined && params.trailPrice !== undefined) {
50928
50935
  throw new TrailingStopValidationError("Cannot specify both trailPercent and trailPrice");
50929
50936
  }
50930
- // Validate trailPercent range
50937
+ // Validate trailPercent range — Alpaca rejects values > 25 with HTTP 422.
50931
50938
  if (params.trailPercent !== undefined) {
50932
50939
  if (params.trailPercent <= 0) {
50933
50940
  throw new TrailingStopValidationError("trailPercent must be greater than 0");
50934
50941
  }
50935
- if (params.trailPercent > 100) {
50936
- throw new TrailingStopValidationError("trailPercent cannot exceed 100");
50942
+ if (params.trailPercent > ALPACA_MAX_TRAIL_PERCENT) {
50943
+ throw new TrailingStopValidationError(`trailPercent cannot exceed ${ALPACA_MAX_TRAIL_PERCENT} (Alpaca API limit)`);
50937
50944
  }
50938
50945
  }
50939
50946
  // Validate trailPrice
@@ -51376,6 +51383,7 @@ var trailingStops = {
51376
51383
 
51377
51384
  var trailingStops$1 = /*#__PURE__*/Object.freeze({
51378
51385
  __proto__: null,
51386
+ ALPACA_MAX_TRAIL_PERCENT: ALPACA_MAX_TRAIL_PERCENT,
51379
51387
  TrailingStopValidationError: TrailingStopValidationError,
51380
51388
  cancelTrailingStop: cancelTrailingStop,
51381
51389
  cancelTrailingStopsForSymbol: cancelTrailingStopsForSymbol,
@@ -58573,6 +58581,7 @@ var smartOrders = {
58573
58581
 
58574
58582
  var smartOrders$1 = /*#__PURE__*/Object.freeze({
58575
58583
  __proto__: null,
58584
+ ALPACA_MAX_TRAIL_PERCENT: ALPACA_MAX_TRAIL_PERCENT,
58576
58585
  TrailingStopValidationError: TrailingStopValidationError,
58577
58586
  buyWithStopLoss: buyWithStopLoss,
58578
58587
  buyWithTrailingStop: buyWithTrailingStop,