@adaptic/utils 0.0.971 → 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.cjs +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +12 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types/alpaca/index.d.ts +1 -0
- package/dist/types/alpaca/index.d.ts.map +1 -1
- package/dist/types/alpaca/trading/trailing-stops.d.ts +7 -0
- package/dist/types/alpaca/trading/trailing-stops.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -50902,6 +50902,13 @@ var orderUtils$1 = /*#__PURE__*/Object.freeze({
|
|
|
50902
50902
|
});
|
|
50903
50903
|
|
|
50904
50904
|
const LOG_SOURCE$7 = "TrailingStops";
|
|
50905
|
+
/**
|
|
50906
|
+
* Alpaca's hard upper limit for `trail_percent` on trailing-stop orders.
|
|
50907
|
+
* Submissions exceeding this value are rejected with HTTP 422 / code 42210000
|
|
50908
|
+
* ("trail_percent must be <= 25"). See:
|
|
50909
|
+
* https://docs.alpaca.markets/reference/postorder
|
|
50910
|
+
*/
|
|
50911
|
+
const ALPACA_MAX_TRAIL_PERCENT = 25;
|
|
50905
50912
|
/**
|
|
50906
50913
|
* Internal logging helper with consistent source
|
|
50907
50914
|
*/
|
|
@@ -50929,13 +50936,13 @@ function validateTrailingStopParams(params) {
|
|
|
50929
50936
|
if (params.trailPercent !== undefined && params.trailPrice !== undefined) {
|
|
50930
50937
|
throw new TrailingStopValidationError("Cannot specify both trailPercent and trailPrice");
|
|
50931
50938
|
}
|
|
50932
|
-
// Validate trailPercent range
|
|
50939
|
+
// Validate trailPercent range — Alpaca rejects values > 25 with HTTP 422.
|
|
50933
50940
|
if (params.trailPercent !== undefined) {
|
|
50934
50941
|
if (params.trailPercent <= 0) {
|
|
50935
50942
|
throw new TrailingStopValidationError("trailPercent must be greater than 0");
|
|
50936
50943
|
}
|
|
50937
|
-
if (params.trailPercent >
|
|
50938
|
-
throw new TrailingStopValidationError(
|
|
50944
|
+
if (params.trailPercent > ALPACA_MAX_TRAIL_PERCENT) {
|
|
50945
|
+
throw new TrailingStopValidationError(`trailPercent cannot exceed ${ALPACA_MAX_TRAIL_PERCENT} (Alpaca API limit)`);
|
|
50939
50946
|
}
|
|
50940
50947
|
}
|
|
50941
50948
|
// Validate trailPrice
|
|
@@ -51378,6 +51385,7 @@ var trailingStops = {
|
|
|
51378
51385
|
|
|
51379
51386
|
var trailingStops$1 = /*#__PURE__*/Object.freeze({
|
|
51380
51387
|
__proto__: null,
|
|
51388
|
+
ALPACA_MAX_TRAIL_PERCENT: ALPACA_MAX_TRAIL_PERCENT,
|
|
51381
51389
|
TrailingStopValidationError: TrailingStopValidationError,
|
|
51382
51390
|
cancelTrailingStop: cancelTrailingStop,
|
|
51383
51391
|
cancelTrailingStopsForSymbol: cancelTrailingStopsForSymbol,
|
|
@@ -58575,6 +58583,7 @@ var smartOrders = {
|
|
|
58575
58583
|
|
|
58576
58584
|
var smartOrders$1 = /*#__PURE__*/Object.freeze({
|
|
58577
58585
|
__proto__: null,
|
|
58586
|
+
ALPACA_MAX_TRAIL_PERCENT: ALPACA_MAX_TRAIL_PERCENT,
|
|
58578
58587
|
TrailingStopValidationError: TrailingStopValidationError,
|
|
58579
58588
|
buyWithStopLoss: buyWithStopLoss,
|
|
58580
58589
|
buyWithTrailingStop: buyWithTrailingStop,
|