@luisjpf/alpaca-sdk 0.2.10 → 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.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4;// ../core/dist/index.js
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4;// 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 = _nullishCoalesce(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
  var _openapifetch = require('openapi-fetch'); var _openapifetch2 = _interopRequireDefault(_openapifetch);
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
 
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
 
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
  var _ws = require('ws'); var _ws2 = _interopRequireDefault(_ws);
1443
1449
  var _msgpack = require('@msgpack/msgpack');
1444
-
1445
-
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 = class {
1730
1734
  }
1731
1735
  }
1732
1736
  }, _class);
1737
+
1738
+ // src/streaming/stock-stream.ts
1733
1739
  var STOCK_STREAM_BASE_URL = "wss://stream.data.alpaca.markets/v2";
1734
1740
  var StockStreamImpl = (_class2 = class extends BaseStream {
1735
1741
 
@@ -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 = (_class3 = class extends BaseStream {
1920
1928
 
@@ -2100,6 +2108,10 @@ function createCryptoStream(config) {
2100
2108
  }
2101
2109
  };
2102
2110
  }
2111
+
2112
+ // src/streaming/trade-updates-stream.ts
2113
+
2114
+
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;