@luisjpf/alpaca-sdk 0.2.9 → 0.3.2

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.js CHANGED
@@ -1,4 +1,4 @@
1
- // ../core/dist/index.js
1
+ // src/core/errors.ts
2
2
  var ErrorType = {
3
3
  Authentication: "authentication",
4
4
  Forbidden: "forbidden",
@@ -201,6 +201,8 @@ var isValidationError = (e) => e.type === ErrorType.Validation;
201
201
  var isInsufficientFundsError = (e) => e.type === ErrorType.InsufficientFunds;
202
202
  var isMarketClosedError = (e) => e.type === ErrorType.MarketClosed;
203
203
  var isServerError = (e) => e.type === ErrorType.Server;
204
+
205
+ // src/core/auth.ts
204
206
  function validateCredential(value, name) {
205
207
  if (!value || typeof value !== "string" || value.trim().length === 0) {
206
208
  throw new Error(`${name} cannot be empty`);
@@ -245,6 +247,8 @@ function createWebSocketOAuth(token) {
245
247
  secret: token
246
248
  };
247
249
  }
250
+
251
+ // src/core/client.ts
248
252
  var ALPACA_URLS = {
249
253
  trading: {
250
254
  paper: "https://paper-api.alpaca.markets",
@@ -397,6 +401,8 @@ function createApiFetch(config, authType = "apiKey") {
397
401
  );
398
402
  };
399
403
  }
404
+
405
+ // src/core/response.ts
400
406
  function createAlpacaErrorFromResponse(error, response) {
401
407
  const requestId = response.headers.get("x-request-id") ?? void 0;
402
408
  const retryAfterHeader = response.headers.get("retry-after");
@@ -434,7 +440,7 @@ function unwrapOptional(result) {
434
440
  return result.data;
435
441
  }
436
442
 
437
- // ../trading/dist/index.js
443
+ // src/trading/client.ts
438
444
  import createClient from "openapi-fetch";
439
445
  function createTradingClient(config) {
440
446
  const resolvedConfig = resolveConfig(config, "trading");
@@ -713,7 +719,7 @@ function createTradingClient(config) {
713
719
  };
714
720
  }
715
721
 
716
- // ../market-data/dist/index.js
722
+ // src/market-data/client.ts
717
723
  import createClient2 from "openapi-fetch";
718
724
  function createMarketDataClient(config) {
719
725
  const resolvedConfig = resolveConfig(config, "marketData");
@@ -1119,7 +1125,7 @@ function createMarketDataClient(config) {
1119
1125
  };
1120
1126
  }
1121
1127
 
1122
- // ../broker/dist/index.js
1128
+ // src/broker/client.ts
1123
1129
  import createClient3 from "openapi-fetch";
1124
1130
  function createBrokerClient(config) {
1125
1131
  const resolvedConfig = resolveConfig(config, "broker");
@@ -1438,11 +1444,9 @@ function createBrokerClient(config) {
1438
1444
  };
1439
1445
  }
1440
1446
 
1441
- // ../streaming/dist/index.js
1447
+ // src/streaming/base-stream.ts
1442
1448
  import WebSocket from "ws";
1443
1449
  import { encode, decode } from "@msgpack/msgpack";
1444
- import WebSocket2 from "ws";
1445
- import { encode as encode2, decode as decode2 } from "@msgpack/msgpack";
1446
1450
  var RECONNECT_INITIAL_DELAY = 1e3;
1447
1451
  var RECONNECT_MAX_DELAY = 3e4;
1448
1452
  var RECONNECT_BACKOFF_MULTIPLIER = 2;
@@ -1730,6 +1734,8 @@ var BaseStream = class {
1730
1734
  }
1731
1735
  }
1732
1736
  };
1737
+
1738
+ // src/streaming/stock-stream.ts
1733
1739
  var STOCK_STREAM_BASE_URL = "wss://stream.data.alpaca.markets/v2";
1734
1740
  var StockStreamImpl = class extends BaseStream {
1735
1741
  feed;
@@ -1915,6 +1921,8 @@ function createStockStream(config) {
1915
1921
  }
1916
1922
  };
1917
1923
  }
1924
+
1925
+ // src/streaming/crypto-stream.ts
1918
1926
  var CRYPTO_STREAM_BASE_URL = "wss://stream.data.alpaca.markets/v1beta3/crypto";
1919
1927
  var CryptoStreamImpl = class extends BaseStream {
1920
1928
  location;
@@ -2100,6 +2108,10 @@ function createCryptoStream(config) {
2100
2108
  }
2101
2109
  };
2102
2110
  }
2111
+
2112
+ // src/streaming/trade-updates-stream.ts
2113
+ import WebSocket2 from "ws";
2114
+ import { encode as encode2, decode as decode2 } from "@msgpack/msgpack";
2103
2115
  var PAPER_TRADING_URL = "wss://paper-api.alpaca.markets/stream";
2104
2116
  var LIVE_TRADING_URL = "wss://api.alpaca.markets/stream";
2105
2117
  var RECONNECT_INITIAL_DELAY2 = 1e3;