@adaptic/utils 0.0.1024 → 0.0.1026
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 +23 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +23 -6
- package/dist/index.mjs.map +1 -1
- package/dist/test.js +23 -6
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-market-data-api.d.ts +29 -3
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3655,6 +3655,23 @@ const DEFAULT_ADJUSTMENT = "all";
|
|
|
3655
3655
|
// `feed` argument on getOptions*/getLatestBars/etc.) still win.
|
|
3656
3656
|
const DEFAULT_FEED$1 = (process.env.ALPACA_MARKET_DATA_FEED || "iex");
|
|
3657
3657
|
const DEFAULT_CURRENCY$1 = "USD";
|
|
3658
|
+
/** Close code that the close handler treats as "do not reconnect". */
|
|
3659
|
+
const INTENTIONAL_CLOSE_CODE = 1000;
|
|
3660
|
+
/** Reason text carried on an intentional close, for server-side logs. */
|
|
3661
|
+
const INTENTIONAL_CLOSE_REASON = "intentional disconnect";
|
|
3662
|
+
/**
|
|
3663
|
+
* Close a stream, optionally in the way the close handler treats as final.
|
|
3664
|
+
*
|
|
3665
|
+
* @param ws - The socket to close.
|
|
3666
|
+
* @param options - Whether this close is intentional.
|
|
3667
|
+
*/
|
|
3668
|
+
function closeStream(ws, options) {
|
|
3669
|
+
if (options.intentional === true) {
|
|
3670
|
+
ws.close(INTENTIONAL_CLOSE_CODE, INTENTIONAL_CLOSE_REASON);
|
|
3671
|
+
return;
|
|
3672
|
+
}
|
|
3673
|
+
ws.close();
|
|
3674
|
+
}
|
|
3658
3675
|
/**
|
|
3659
3676
|
* Singleton class for interacting with Alpaca Market Data API
|
|
3660
3677
|
* Provides methods for fetching historical bars, latest bars, last trades, latest trades, latest quotes, and latest quote for a single symbol
|
|
@@ -4040,19 +4057,19 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
4040
4057
|
this.connect("crypto");
|
|
4041
4058
|
}
|
|
4042
4059
|
}
|
|
4043
|
-
disconnectStockStream() {
|
|
4060
|
+
disconnectStockStream(options = {}) {
|
|
4044
4061
|
if (this.stockWs) {
|
|
4045
|
-
this.stockWs
|
|
4062
|
+
closeStream(this.stockWs, options);
|
|
4046
4063
|
}
|
|
4047
4064
|
}
|
|
4048
|
-
disconnectOptionStream() {
|
|
4065
|
+
disconnectOptionStream(options = {}) {
|
|
4049
4066
|
if (this.optionWs) {
|
|
4050
|
-
this.optionWs
|
|
4067
|
+
closeStream(this.optionWs, options);
|
|
4051
4068
|
}
|
|
4052
4069
|
}
|
|
4053
|
-
disconnectCryptoStream() {
|
|
4070
|
+
disconnectCryptoStream(options = {}) {
|
|
4054
4071
|
if (this.cryptoWs) {
|
|
4055
|
-
this.cryptoWs
|
|
4072
|
+
closeStream(this.cryptoWs, options);
|
|
4056
4073
|
}
|
|
4057
4074
|
}
|
|
4058
4075
|
/**
|