@adaptic/utils 0.0.99

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.
Files changed (238) hide show
  1. package/README.md +916 -0
  2. package/dist/index.cjs +71971 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.mjs +71677 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/test.js +7799 -0
  7. package/dist/test.js.map +1 -0
  8. package/dist/types/__tests__/alpaca-functions.test.d.ts +2 -0
  9. package/dist/types/__tests__/alpaca-functions.test.d.ts.map +1 -0
  10. package/dist/types/__tests__/api-endpoints.test.d.ts +2 -0
  11. package/dist/types/__tests__/api-endpoints.test.d.ts.map +1 -0
  12. package/dist/types/__tests__/asset-allocation.test.d.ts +2 -0
  13. package/dist/types/__tests__/asset-allocation.test.d.ts.map +1 -0
  14. package/dist/types/__tests__/auth-validator.test.d.ts +2 -0
  15. package/dist/types/__tests__/auth-validator.test.d.ts.map +1 -0
  16. package/dist/types/__tests__/cache.test.d.ts +2 -0
  17. package/dist/types/__tests__/cache.test.d.ts.map +1 -0
  18. package/dist/types/__tests__/errors.test.d.ts +2 -0
  19. package/dist/types/__tests__/errors.test.d.ts.map +1 -0
  20. package/dist/types/__tests__/financial-regression.test.d.ts +2 -0
  21. package/dist/types/__tests__/financial-regression.test.d.ts.map +1 -0
  22. package/dist/types/__tests__/format-tools.test.d.ts +2 -0
  23. package/dist/types/__tests__/format-tools.test.d.ts.map +1 -0
  24. package/dist/types/__tests__/http-keep-alive.test.d.ts +2 -0
  25. package/dist/types/__tests__/http-keep-alive.test.d.ts.map +1 -0
  26. package/dist/types/__tests__/http-timeout.test.d.ts +2 -0
  27. package/dist/types/__tests__/http-timeout.test.d.ts.map +1 -0
  28. package/dist/types/__tests__/logger.test.d.ts +2 -0
  29. package/dist/types/__tests__/logger.test.d.ts.map +1 -0
  30. package/dist/types/__tests__/market-time.test.d.ts +2 -0
  31. package/dist/types/__tests__/market-time.test.d.ts.map +1 -0
  32. package/dist/types/__tests__/misc-utils.test.d.ts +2 -0
  33. package/dist/types/__tests__/misc-utils.test.d.ts.map +1 -0
  34. package/dist/types/__tests__/paginator.test.d.ts +2 -0
  35. package/dist/types/__tests__/paginator.test.d.ts.map +1 -0
  36. package/dist/types/__tests__/performance-metrics.test.d.ts +2 -0
  37. package/dist/types/__tests__/performance-metrics.test.d.ts.map +1 -0
  38. package/dist/types/__tests__/polygon.test.d.ts +2 -0
  39. package/dist/types/__tests__/polygon.test.d.ts.map +1 -0
  40. package/dist/types/__tests__/price-utils.test.d.ts +2 -0
  41. package/dist/types/__tests__/price-utils.test.d.ts.map +1 -0
  42. package/dist/types/__tests__/property-based-financial.test.d.ts +2 -0
  43. package/dist/types/__tests__/property-based-financial.test.d.ts.map +1 -0
  44. package/dist/types/__tests__/rate-limiter.test.d.ts +2 -0
  45. package/dist/types/__tests__/rate-limiter.test.d.ts.map +1 -0
  46. package/dist/types/__tests__/schema-validation.test.d.ts +2 -0
  47. package/dist/types/__tests__/schema-validation.test.d.ts.map +1 -0
  48. package/dist/types/__tests__/technical-analysis.test.d.ts +2 -0
  49. package/dist/types/__tests__/technical-analysis.test.d.ts.map +1 -0
  50. package/dist/types/__tests__/time-utils.test.d.ts +2 -0
  51. package/dist/types/__tests__/time-utils.test.d.ts.map +1 -0
  52. package/dist/types/adaptic.d.ts +52 -0
  53. package/dist/types/adaptic.d.ts.map +1 -0
  54. package/dist/types/alpaca/client.d.ts +95 -0
  55. package/dist/types/alpaca/client.d.ts.map +1 -0
  56. package/dist/types/alpaca/crypto/data.d.ts +281 -0
  57. package/dist/types/alpaca/crypto/data.d.ts.map +1 -0
  58. package/dist/types/alpaca/crypto/index.d.ts +75 -0
  59. package/dist/types/alpaca/crypto/index.d.ts.map +1 -0
  60. package/dist/types/alpaca/crypto/orders.d.ts +221 -0
  61. package/dist/types/alpaca/crypto/orders.d.ts.map +1 -0
  62. package/dist/types/alpaca/index.d.ts +205 -0
  63. package/dist/types/alpaca/index.d.ts.map +1 -0
  64. package/dist/types/alpaca/legacy/account.d.ts +34 -0
  65. package/dist/types/alpaca/legacy/account.d.ts.map +1 -0
  66. package/dist/types/alpaca/legacy/assets.d.ts +13 -0
  67. package/dist/types/alpaca/legacy/assets.d.ts.map +1 -0
  68. package/dist/types/alpaca/legacy/auth.d.ts +18 -0
  69. package/dist/types/alpaca/legacy/auth.d.ts.map +1 -0
  70. package/dist/types/alpaca/legacy/index.d.ts +15 -0
  71. package/dist/types/alpaca/legacy/index.d.ts.map +1 -0
  72. package/dist/types/alpaca/legacy/market-data.d.ts +32 -0
  73. package/dist/types/alpaca/legacy/market-data.d.ts.map +1 -0
  74. package/dist/types/alpaca/legacy/orders.d.ts +84 -0
  75. package/dist/types/alpaca/legacy/orders.d.ts.map +1 -0
  76. package/dist/types/alpaca/legacy/positions.d.ts +66 -0
  77. package/dist/types/alpaca/legacy/positions.d.ts.map +1 -0
  78. package/dist/types/alpaca/legacy/utils.d.ts +18 -0
  79. package/dist/types/alpaca/legacy/utils.d.ts.map +1 -0
  80. package/dist/types/alpaca/market-data/bars.d.ts +142 -0
  81. package/dist/types/alpaca/market-data/bars.d.ts.map +1 -0
  82. package/dist/types/alpaca/market-data/index.d.ts +13 -0
  83. package/dist/types/alpaca/market-data/index.d.ts.map +1 -0
  84. package/dist/types/alpaca/market-data/news.d.ts +87 -0
  85. package/dist/types/alpaca/market-data/news.d.ts.map +1 -0
  86. package/dist/types/alpaca/market-data/quotes.d.ts +85 -0
  87. package/dist/types/alpaca/market-data/quotes.d.ts.map +1 -0
  88. package/dist/types/alpaca/market-data/trades.d.ts +98 -0
  89. package/dist/types/alpaca/market-data/trades.d.ts.map +1 -0
  90. package/dist/types/alpaca/options/contracts.d.ts +279 -0
  91. package/dist/types/alpaca/options/contracts.d.ts.map +1 -0
  92. package/dist/types/alpaca/options/data.d.ts +126 -0
  93. package/dist/types/alpaca/options/data.d.ts.map +1 -0
  94. package/dist/types/alpaca/options/index.d.ts +17 -0
  95. package/dist/types/alpaca/options/index.d.ts.map +1 -0
  96. package/dist/types/alpaca/options/orders.d.ts +366 -0
  97. package/dist/types/alpaca/options/orders.d.ts.map +1 -0
  98. package/dist/types/alpaca/options/strategies.d.ts +224 -0
  99. package/dist/types/alpaca/options/strategies.d.ts.map +1 -0
  100. package/dist/types/alpaca/streams/base-stream.d.ts +143 -0
  101. package/dist/types/alpaca/streams/base-stream.d.ts.map +1 -0
  102. package/dist/types/alpaca/streams/crypto-stream.d.ts +173 -0
  103. package/dist/types/alpaca/streams/crypto-stream.d.ts.map +1 -0
  104. package/dist/types/alpaca/streams/index.d.ts +54 -0
  105. package/dist/types/alpaca/streams/index.d.ts.map +1 -0
  106. package/dist/types/alpaca/streams/option-stream.d.ts +167 -0
  107. package/dist/types/alpaca/streams/option-stream.d.ts.map +1 -0
  108. package/dist/types/alpaca/streams/stock-stream.d.ts +176 -0
  109. package/dist/types/alpaca/streams/stock-stream.d.ts.map +1 -0
  110. package/dist/types/alpaca/streams/stream-manager.d.ts +277 -0
  111. package/dist/types/alpaca/streams/stream-manager.d.ts.map +1 -0
  112. package/dist/types/alpaca/streams/trading-stream.d.ts +186 -0
  113. package/dist/types/alpaca/streams/trading-stream.d.ts.map +1 -0
  114. package/dist/types/alpaca/streams.d.ts +88 -0
  115. package/dist/types/alpaca/streams.d.ts.map +1 -0
  116. package/dist/types/alpaca/test-imports.d.ts +7 -0
  117. package/dist/types/alpaca/test-imports.d.ts.map +1 -0
  118. package/dist/types/alpaca/trading/account.d.ts +198 -0
  119. package/dist/types/alpaca/trading/account.d.ts.map +1 -0
  120. package/dist/types/alpaca/trading/bracket-orders.d.ts +162 -0
  121. package/dist/types/alpaca/trading/bracket-orders.d.ts.map +1 -0
  122. package/dist/types/alpaca/trading/clock.d.ts +99 -0
  123. package/dist/types/alpaca/trading/clock.d.ts.map +1 -0
  124. package/dist/types/alpaca/trading/index.d.ts +15 -0
  125. package/dist/types/alpaca/trading/index.d.ts.map +1 -0
  126. package/dist/types/alpaca/trading/oco-orders.d.ts +203 -0
  127. package/dist/types/alpaca/trading/oco-orders.d.ts.map +1 -0
  128. package/dist/types/alpaca/trading/order-utils.d.ts +404 -0
  129. package/dist/types/alpaca/trading/order-utils.d.ts.map +1 -0
  130. package/dist/types/alpaca/trading/orders.d.ts +199 -0
  131. package/dist/types/alpaca/trading/orders.d.ts.map +1 -0
  132. package/dist/types/alpaca/trading/oto-orders.d.ts +282 -0
  133. package/dist/types/alpaca/trading/oto-orders.d.ts.map +1 -0
  134. package/dist/types/alpaca/trading/positions.d.ts +389 -0
  135. package/dist/types/alpaca/trading/positions.d.ts.map +1 -0
  136. package/dist/types/alpaca/trading/smart-orders.d.ts +301 -0
  137. package/dist/types/alpaca/trading/smart-orders.d.ts.map +1 -0
  138. package/dist/types/alpaca/trading/trailing-stops.d.ts +240 -0
  139. package/dist/types/alpaca/trading/trailing-stops.d.ts.map +1 -0
  140. package/dist/types/alpaca-market-data-api.d.ts +386 -0
  141. package/dist/types/alpaca-market-data-api.d.ts.map +1 -0
  142. package/dist/types/alpaca-trading-api.d.ts +315 -0
  143. package/dist/types/alpaca-trading-api.d.ts.map +1 -0
  144. package/dist/types/alphavantage.d.ts +44 -0
  145. package/dist/types/alphavantage.d.ts.map +1 -0
  146. package/dist/types/asset-allocation-algorithm.d.ts +143 -0
  147. package/dist/types/asset-allocation-algorithm.d.ts.map +1 -0
  148. package/dist/types/cache/stampede-protected-cache.d.ts +565 -0
  149. package/dist/types/cache/stampede-protected-cache.d.ts.map +1 -0
  150. package/dist/types/config/api-endpoints.d.ts +94 -0
  151. package/dist/types/config/api-endpoints.d.ts.map +1 -0
  152. package/dist/types/crypto.d.ts +76 -0
  153. package/dist/types/crypto.d.ts.map +1 -0
  154. package/dist/types/display-manager.d.ts +24 -0
  155. package/dist/types/display-manager.d.ts.map +1 -0
  156. package/dist/types/errors/index.d.ts +130 -0
  157. package/dist/types/errors/index.d.ts.map +1 -0
  158. package/dist/types/examples/asset-allocation-example.d.ts +36 -0
  159. package/dist/types/examples/asset-allocation-example.d.ts.map +1 -0
  160. package/dist/types/examples/rate-limiter-example.d.ts +7 -0
  161. package/dist/types/examples/rate-limiter-example.d.ts.map +1 -0
  162. package/dist/types/format-tools.d.ts +54 -0
  163. package/dist/types/format-tools.d.ts.map +1 -0
  164. package/dist/types/http-timeout.d.ts +37 -0
  165. package/dist/types/http-timeout.d.ts.map +1 -0
  166. package/dist/types/index.d.ts +766 -0
  167. package/dist/types/index.d.ts.map +1 -0
  168. package/dist/types/logger.d.ts +56 -0
  169. package/dist/types/logger.d.ts.map +1 -0
  170. package/dist/types/logging.d.ts +12 -0
  171. package/dist/types/logging.d.ts.map +1 -0
  172. package/dist/types/market-hours.d.ts +24 -0
  173. package/dist/types/market-hours.d.ts.map +1 -0
  174. package/dist/types/market-time.d.ts +246 -0
  175. package/dist/types/market-time.d.ts.map +1 -0
  176. package/dist/types/metrics-calcs.d.ts +6 -0
  177. package/dist/types/metrics-calcs.d.ts.map +1 -0
  178. package/dist/types/misc-utils.d.ts +52 -0
  179. package/dist/types/misc-utils.d.ts.map +1 -0
  180. package/dist/types/performance-metrics.d.ts +88 -0
  181. package/dist/types/performance-metrics.d.ts.map +1 -0
  182. package/dist/types/polygon-indices.d.ts +85 -0
  183. package/dist/types/polygon-indices.d.ts.map +1 -0
  184. package/dist/types/polygon.d.ts +126 -0
  185. package/dist/types/polygon.d.ts.map +1 -0
  186. package/dist/types/price-utils.d.ts +26 -0
  187. package/dist/types/price-utils.d.ts.map +1 -0
  188. package/dist/types/rate-limiter.d.ts +171 -0
  189. package/dist/types/rate-limiter.d.ts.map +1 -0
  190. package/dist/types/schemas/alpaca-schemas.d.ts +779 -0
  191. package/dist/types/schemas/alpaca-schemas.d.ts.map +1 -0
  192. package/dist/types/schemas/alphavantage-schemas.d.ts +255 -0
  193. package/dist/types/schemas/alphavantage-schemas.d.ts.map +1 -0
  194. package/dist/types/schemas/index.d.ts +21 -0
  195. package/dist/types/schemas/index.d.ts.map +1 -0
  196. package/dist/types/schemas/polygon-schemas.d.ts +551 -0
  197. package/dist/types/schemas/polygon-schemas.d.ts.map +1 -0
  198. package/dist/types/schemas/validate-response.d.ts +88 -0
  199. package/dist/types/schemas/validate-response.d.ts.map +1 -0
  200. package/dist/types/technical-analysis.d.ts +90 -0
  201. package/dist/types/technical-analysis.d.ts.map +1 -0
  202. package/dist/types/test.d.ts +2 -0
  203. package/dist/types/test.d.ts.map +1 -0
  204. package/dist/types/testing/options-ws.d.ts +2 -0
  205. package/dist/types/testing/options-ws.d.ts.map +1 -0
  206. package/dist/types/time-utils.d.ts +17 -0
  207. package/dist/types/time-utils.d.ts.map +1 -0
  208. package/dist/types/types/adaptic-types.d.ts +11 -0
  209. package/dist/types/types/adaptic-types.d.ts.map +1 -0
  210. package/dist/types/types/alpaca-types.d.ts +1165 -0
  211. package/dist/types/types/alpaca-types.d.ts.map +1 -0
  212. package/dist/types/types/alphavantage-types.d.ts +66 -0
  213. package/dist/types/types/alphavantage-types.d.ts.map +1 -0
  214. package/dist/types/types/asset-allocation-types.d.ts +328 -0
  215. package/dist/types/types/asset-allocation-types.d.ts.map +1 -0
  216. package/dist/types/types/index.d.ts +21 -0
  217. package/dist/types/types/index.d.ts.map +1 -0
  218. package/dist/types/types/logging-types.d.ts +10 -0
  219. package/dist/types/types/logging-types.d.ts.map +1 -0
  220. package/dist/types/types/market-time-types.d.ts +59 -0
  221. package/dist/types/types/market-time-types.d.ts.map +1 -0
  222. package/dist/types/types/metrics-types.d.ts +33 -0
  223. package/dist/types/types/metrics-types.d.ts.map +1 -0
  224. package/dist/types/types/polygon-indices-types.d.ts +190 -0
  225. package/dist/types/types/polygon-indices-types.d.ts.map +1 -0
  226. package/dist/types/types/polygon-types.d.ts +204 -0
  227. package/dist/types/types/polygon-types.d.ts.map +1 -0
  228. package/dist/types/types/ta-types.d.ts +89 -0
  229. package/dist/types/types/ta-types.d.ts.map +1 -0
  230. package/dist/types/utils/auth-validator.d.ts +32 -0
  231. package/dist/types/utils/auth-validator.d.ts.map +1 -0
  232. package/dist/types/utils/http-keep-alive.d.ts +110 -0
  233. package/dist/types/utils/http-keep-alive.d.ts.map +1 -0
  234. package/dist/types/utils/paginator.d.ts +154 -0
  235. package/dist/types/utils/paginator.d.ts.map +1 -0
  236. package/dist/types/utils/retry.d.ts +78 -0
  237. package/dist/types/utils/retry.d.ts.map +1 -0
  238. package/package.json +78 -0
@@ -0,0 +1,76 @@
1
+ import type { CryptoBarsParams, CryptoBar, AlpacaNewsArticle, LatestTradesResponse, LatestQuotesResponse } from "./types/alpaca-types.js";
2
+ /**
3
+ * Fetches cryptocurrency bars for the specified parameters.
4
+ * This function retrieves historical price data for multiple cryptocurrencies.
5
+ *
6
+ * @param params - The parameters for fetching crypto bars.
7
+ * @param params.symbols - An array of cryptocurrency symbols to fetch data for.
8
+ * @param params.timeframe - The timeframe for the bars (e.g., '1Min', '5Min', '1H', '1D').
9
+ * @param params.start - The start date for fetching bars (optional).
10
+ * @param params.end - The end date for fetching bars (optional).
11
+ * @param params.limit - The maximum number of bars to return (optional).
12
+ * @param params.page_token - The token for pagination (optional).
13
+ * @param params.sort - The sorting order for the results (optional).
14
+ * @returns A promise that resolves to an object containing arrays of CryptoBar objects for each symbol.
15
+ */
16
+ export declare function fetchBars(params: CryptoBarsParams): Promise<{
17
+ [symbol: string]: CryptoBar[];
18
+ }>;
19
+ type AlpacaAuth = {
20
+ APIKey: string;
21
+ APISecret: string;
22
+ type?: "PAPER" | "LIVE";
23
+ };
24
+ /**
25
+ * Fetches news articles related to a specific cryptocurrency symbol.
26
+ * This function retrieves news articles from the Alpaca API.
27
+ *
28
+ * @param params - The parameters for fetching news articles.
29
+ * @param params.symbol - The cryptocurrency symbol to fetch news for.
30
+ * @param params.start - The start date for fetching news (optional).
31
+ * @param params.sort - The sorting order for the results (optional).
32
+ * @param params.includeContent - Whether to include the full content of the articles (optional).
33
+ * @param params.limit - The maximum number of articles to return (optional).
34
+ * @param auth - The Alpaca authentication object containing API key and secret.
35
+ * @returns A promise that resolves to an array of AlpacaNewsArticle objects.
36
+ * @throws Will throw an error if required parameters are missing or if fetching fails.
37
+ */
38
+ export declare function fetchNews(params: {
39
+ symbol: string;
40
+ start?: Date;
41
+ sort?: string;
42
+ includeContent?: boolean;
43
+ limit?: number;
44
+ }, auth: AlpacaAuth): Promise<AlpacaNewsArticle[]>;
45
+ /**
46
+ * Fetches the latest trades for the specified cryptocurrency symbols.
47
+ * This function retrieves the most recent trade price and volume for each symbol.
48
+ *
49
+ * @param params - The parameters for fetching latest trades.
50
+ * @param params.symbols - An array of cryptocurrency symbols to fetch data for (e.g., ['BTC-USD', 'ETH-USD']).
51
+ * @param params.loc - The location identifier (default: 'us'). Options: 'us' (Alpaca US), 'us-1' (Kraken US), 'eu-1' (Kraken EU).
52
+ * @param auth - The Alpaca authentication object containing API key and secret.
53
+ * @returns A promise that resolves to an object containing the latest trade for each symbol.
54
+ * @throws Will throw an error if required parameters are missing or if fetching fails.
55
+ */
56
+ export declare function fetchLatestTrades(params: {
57
+ symbols: string[];
58
+ loc?: string;
59
+ }, auth: AlpacaAuth): Promise<LatestTradesResponse>;
60
+ /**
61
+ * Fetches the latest quotes (bid/ask prices) for the specified cryptocurrency symbols.
62
+ * This function retrieves the most recent bid and ask prices for each symbol.
63
+ *
64
+ * @param params - The parameters for fetching latest quotes.
65
+ * @param params.symbols - An array of cryptocurrency symbols to fetch data for (e.g., ['BTC-USD', 'ETH-USD']).
66
+ * @param params.loc - The location identifier (default: 'us'). Options: 'us' (Alpaca US), 'us-1' (Kraken US), 'eu-1' (Kraken EU).
67
+ * @param auth - The Alpaca authentication object containing API key and secret.
68
+ * @returns A promise that resolves to an object containing the latest quote for each symbol.
69
+ * @throws Will throw an error if required parameters are missing or if fetching fails.
70
+ */
71
+ export declare function fetchLatestQuotes(params: {
72
+ symbols: string[];
73
+ loc?: string;
74
+ }, auth: AlpacaAuth): Promise<LatestQuotesResponse>;
75
+ export {};
76
+ //# sourceMapping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/B"}
@@ -0,0 +1,24 @@
1
+ import { LogOptions } from "./types/logging-types";
2
+ export declare class DisplayManager {
3
+ private static instance;
4
+ private promptText;
5
+ private constructor();
6
+ static getInstance(): DisplayManager;
7
+ setPrompt(prompt: string): void;
8
+ /**
9
+ * Logs a message while preserving the prompt at the bottom
10
+ */
11
+ log(message: string, options?: LogOptions): void;
12
+ /**
13
+ * Writes a log entry to a symbol-specific log file
14
+ */
15
+ private writeSymbolLog;
16
+ /**
17
+ * Writes a log entry to a generic log file when no symbol is provided
18
+ */
19
+ private writeGenericLog;
20
+ private writePrompt;
21
+ clearPrompt(): void;
22
+ restorePrompt(): void;
23
+ }
24
+ //# sourceMappingURL=display-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-manager.d.ts","sourceRoot":"","sources":["../../src/display-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IACxC,OAAO,CAAC,UAAU,CAAc;IAEhC,OAAO;WAEO,WAAW,IAAI,cAAc;IAOpC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAItC;;OAEG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAuCvD;;OAEG;IACH,OAAO,CAAC,cAAc;IAgCtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAiCvB,OAAO,CAAC,WAAW;IAIZ,WAAW,IAAI,IAAI;IAKnB,aAAa,IAAI,IAAI;CAG7B"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Structured error type hierarchy for all API integrations
3
+ *
4
+ * This module provides a comprehensive error handling system for external API integrations,
5
+ * including Alpaca, Polygon, and AlphaVantage services.
6
+ */
7
+ /**
8
+ * Base error class for all @adaptic/utils errors
9
+ * Extends Error with additional context about service, error code, and retry capability
10
+ */
11
+ export declare class AdapticUtilsError extends Error {
12
+ readonly code: string;
13
+ readonly service: string;
14
+ readonly isRetryable: boolean;
15
+ readonly cause?: unknown | undefined;
16
+ readonly name: string;
17
+ constructor(message: string, code: string, service: string, isRetryable?: boolean, cause?: unknown | undefined);
18
+ }
19
+ /**
20
+ * Alpaca API specific errors
21
+ * Handles all errors from Alpaca trading and market data APIs
22
+ */
23
+ export declare class AlpacaApiError extends AdapticUtilsError {
24
+ readonly statusCode?: number | undefined;
25
+ constructor(message: string, code: string, statusCode?: number | undefined, cause?: unknown);
26
+ }
27
+ /**
28
+ * Polygon.io API specific errors
29
+ * Handles all errors from Polygon market data API
30
+ */
31
+ export declare class PolygonApiError extends AdapticUtilsError {
32
+ readonly statusCode?: number | undefined;
33
+ constructor(message: string, code: string, statusCode?: number | undefined, cause?: unknown);
34
+ }
35
+ /**
36
+ * AlphaVantage API specific errors
37
+ * Handles all errors from AlphaVantage financial data API
38
+ */
39
+ export declare class AlphaVantageError extends AdapticUtilsError {
40
+ readonly statusCode?: number | undefined;
41
+ constructor(message: string, code: string, statusCode?: number | undefined, cause?: unknown);
42
+ }
43
+ /**
44
+ * Network timeout errors
45
+ * Used when API requests exceed configured timeout limits
46
+ * Always retryable as timeouts are often transient
47
+ */
48
+ export declare class TimeoutError extends AdapticUtilsError {
49
+ readonly service: string;
50
+ readonly timeoutMs: number;
51
+ constructor(message: string, service: string, timeoutMs: number, cause?: unknown);
52
+ }
53
+ /**
54
+ * Input validation errors
55
+ * Used when function inputs fail validation checks
56
+ * Never retryable as the inputs need to be corrected
57
+ */
58
+ export declare class ValidationError extends AdapticUtilsError {
59
+ readonly service: string;
60
+ readonly invalidField?: string | undefined;
61
+ constructor(message: string, service: string, invalidField?: string | undefined, cause?: unknown);
62
+ }
63
+ /**
64
+ * Authentication and authorization errors
65
+ * Used when API credentials are invalid, expired, or lack permissions
66
+ * Never retryable as credentials need to be updated
67
+ */
68
+ export declare class AuthenticationError extends AdapticUtilsError {
69
+ readonly service: string;
70
+ readonly statusCode?: number | undefined;
71
+ constructor(message: string, service: string, statusCode?: number | undefined, cause?: unknown);
72
+ }
73
+ /**
74
+ * HTTP client errors (4xx)
75
+ * Used for client-side errors that are not authentication or validation related
76
+ * Generally not retryable unless specific status codes indicate otherwise
77
+ */
78
+ export declare class HttpClientError extends AdapticUtilsError {
79
+ readonly service: string;
80
+ readonly statusCode: number;
81
+ constructor(message: string, service: string, statusCode: number, cause?: unknown);
82
+ }
83
+ /**
84
+ * HTTP server errors (5xx)
85
+ * Used for server-side errors from external APIs
86
+ * Always retryable as server issues are often transient
87
+ */
88
+ export declare class HttpServerError extends AdapticUtilsError {
89
+ readonly service: string;
90
+ readonly statusCode: number;
91
+ constructor(message: string, service: string, statusCode: number, cause?: unknown);
92
+ }
93
+ /**
94
+ * Rate limit errors (429)
95
+ * Used when API rate limits are exceeded
96
+ * Always retryable, often with retry-after header information
97
+ */
98
+ export declare class RateLimitError extends AdapticUtilsError {
99
+ readonly service: string;
100
+ readonly retryAfterMs?: number | undefined;
101
+ constructor(message: string, service: string, retryAfterMs?: number | undefined, cause?: unknown);
102
+ }
103
+ /**
104
+ * WebSocket connection errors
105
+ * Used for WebSocket-specific connection and communication failures
106
+ * Retryability depends on the specific error condition
107
+ */
108
+ export declare class WebSocketError extends AdapticUtilsError {
109
+ readonly service: string;
110
+ constructor(message: string, service: string, isRetryable?: boolean, cause?: unknown);
111
+ }
112
+ /**
113
+ * Network errors (connection failures, DNS issues, etc.)
114
+ * Used for low-level network failures
115
+ * Always retryable as network issues are often transient
116
+ */
117
+ export declare class NetworkError extends AdapticUtilsError {
118
+ readonly service: string;
119
+ constructor(message: string, service: string, cause?: unknown);
120
+ }
121
+ /**
122
+ * Data parsing and format errors
123
+ * Used when API responses cannot be parsed or are in unexpected format
124
+ * Not retryable as the data format issue needs investigation
125
+ */
126
+ export declare class DataFormatError extends AdapticUtilsError {
127
+ readonly service: string;
128
+ constructor(message: string, service: string, cause?: unknown);
129
+ }
130
+ //# sourceM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,MAAM,EAC/B,WAAW,GAAE,OAAc,EAC3B,KAAK,CAAC,EAAE,OAAO;CAIlB;AAED;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,iBAAiB;aAG/B,OAAO,EAAE,MAAM;gBAD/B,OAAO,EAAE,MAAM,EACC,OAAO,EAAE,MAAM,EAC/B,KAAK,CAAC,EAAE,OAAO;CAUlB;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,iBAAiB;aAGlC,OAAO,EAAE,MAAM;gBAD/B,OAAO,EAAE,MAAM,EACC,OAAO,EAAE,MAAM,EAC/B,KAAK,CAAC,EAAE,OAAO;CAUlB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Asset Allocation Algorithm - Example Usage
3
+ *
4
+ * Demonstrates practical usage of the asset allocation engine
5
+ * with real-world scenarios and best practices.
6
+ */
7
+ import { type AllocationRecommendation } from "../index";
8
+ /**
9
+ * Example 1: Basic Conservative Portfolio for Retirement
10
+ */
11
+ export declare function conservativeRetirementPortfolio(): Promise<AllocationRecommendation>;
12
+ /**
13
+ * Example 2: Aggressive Growth Portfolio for Young Investor
14
+ */
15
+ export declare function aggressiveGrowthPortfolio(): Promise<AllocationRecommendation>;
16
+ /**
17
+ * Example 3: Rebalancing an Existing Portfolio
18
+ */
19
+ export declare function rebalancePortfolio(): Promise<AllocationRecommendation>;
20
+ /**
21
+ * Example 4: Crisis Mode Allocation
22
+ */
23
+ export declare function crisisModePortfolio(): Promise<AllocationRecommendation>;
24
+ /**
25
+ * Example 5: Risk Parity Portfolio
26
+ */
27
+ export declare function riskParityPortfolio(): Promise<AllocationRecommendation>;
28
+ /**
29
+ * Example 6: Small Account Allocation
30
+ */
31
+ export declare function smallAccountPortfolio(): Promise<AllocationRecommendation>;
32
+ /**
33
+ * Run all examples
34
+ */
35
+ export declare function runAllExamples(): Promise<void>;
36
+ //# sourceMappingURL=asset-allocation-example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-allocation-example.d.ts","sourceRoot":"","sources":["../../../src/examples/asset-allocation-example.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAWL,KAAK,wBAAwB,EAC9B,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,wBAAsB,+BAA+B,sCAyKpD;AAED;;GAEG;AACH,wBAAsB,yBAAyB,sCA6C9C;AAED;;GAEG;AACH,wBAAsB,kBAAkB,sCAiFvC;AAED;;GAEG;AACH,wBAAsB,mBAAmB,sCAyDxC;AAED;;GAEG;AACH,wBAAsB,mBAAmB,sCAmDxC;AAED;;GAEG;AACH,wBAAsB,qBAAqB,sCAyC1C;AAkLD;;GAEG;AACH,wBAAsB,cAAc,kBAOnC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Rate Limiter Usage Examples
3
+ *
4
+ * Demonstrates how to use the TokenBucketRateLimiter for various API integrations
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=rate-limiter-example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limiter-example.d.ts","sourceRoot":"","sources":["../../../src/examples/rate-limiter-example.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Capitalizes the first letter of a string
3
+ * @param {string} str - The string to capitalize
4
+ * @returns {string} The capitalized string, or original value if not a string
5
+ * @example
6
+ * capitalize('hello') // 'Hello'
7
+ * capitalize(123) // 123
8
+ */
9
+ export declare function capitalize(str: string): string;
10
+ /**
11
+ * Transforms enum formatting to human readable format (e.g. 'STOCK_TICKER' to 'Stock Ticker')
12
+ * @param {string} value - The enum string to format
13
+ * @returns {string} The formatted string, or empty string if no value provided
14
+ * @example
15
+ * formatEnum('STOCK_TICKER') // 'Stock Ticker'
16
+ */
17
+ export declare function formatEnum(value: string): string;
18
+ /**
19
+ * Formats a number as US currency
20
+ * @param {number} value - The number to format
21
+ * @returns {string} The formatted currency string (e.g. '$1,234.56')
22
+ * @example
23
+ * formatCurrency(1234.56) // '$1,234.56'
24
+ * formatCurrency(NaN) // '$0.00'
25
+ */
26
+ export declare function formatCurrency(value: number): string;
27
+ /**
28
+ * Formats a number with commas
29
+ * @param {number} value - The number to format
30
+ * @returns {string} The formatted number string (e.g. '1,234.56')
31
+ * @example
32
+ * formatNumber(1234.56) // '1,234.56'
33
+ * formatNumber(NaN) // '0'
34
+ */
35
+ export declare function formatNumber(value: number): string;
36
+ /**
37
+ * Formats a number as a percentage
38
+ * @param {number} value - The number to format (e.g. 0.75 for 75%)
39
+ * @param {number} [decimalPlaces=2] - Number of decimal places to show
40
+ * @returns {string} The formatted percentage string (e.g. '75.00%')
41
+ * @example
42
+ * formatPercentage(0.75) // '75.00%'
43
+ * formatPercentage(0.753, 1) // '75.3%'
44
+ */
45
+ export declare function formatPercentage(value: number, decimalPlaces?: number): string;
46
+ /**
47
+ * Formats a Date object to Australian datetime format for Google Sheets
48
+ * @param {Date} date - The date to format
49
+ * @returns {string} The formatted datetime string in 'DD/MM/YYYY HH:MM:SS' format
50
+ * @example
51
+ * dateTimeForGS(new Date('2025-01-01T12:34:56')) // '01/01/2025 12:34:56'
52
+ */
53
+ export declare function dateTimeForGS(date: Date): string;
54
+ //# sourceMappingURL=format-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-tools.d.ts","sourceRoot":"","sources":["../../src/format-tools.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG9C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASpD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,aAAa,GAAE,MAAU,GACxB,MAAM,CAQR;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAYhD"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * HTTP request timeout utilities
3
+ * Provides configurable timeout handling for external API calls
4
+ */
5
+ /**
6
+ * Default timeout values for different external APIs (in milliseconds)
7
+ * Can be overridden via environment variables
8
+ */
9
+ export declare const DEFAULT_TIMEOUTS: {
10
+ readonly ALPACA_API: number;
11
+ readonly POLYGON_API: number;
12
+ readonly ALPHA_VANTAGE: number;
13
+ readonly GENERAL: number;
14
+ };
15
+ /**
16
+ * Wraps a promise with a timeout
17
+ * @param promise - The promise to wrap with timeout
18
+ * @param ms - Timeout duration in milliseconds
19
+ * @param label - Label for error messages to identify the request
20
+ * @returns Promise that rejects if timeout is exceeded
21
+ * @throws Error if the promise takes longer than the specified timeout
22
+ */
23
+ export declare function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T>;
24
+ /**
25
+ * Creates an AbortSignal that times out after the specified duration
26
+ * Compatible with fetch API
27
+ * @param ms - Timeout duration in milliseconds
28
+ * @returns AbortSignal that will abort after the specified duration
29
+ */
30
+ export declare function createTimeoutSignal(ms: number): AbortSignal;
31
+ /**
32
+ * Get the appropriate timeout value for a given API
33
+ * @param api - The API type to get timeout for
34
+ * @returns Timeout value in milliseconds
35
+ */
36
+ export declare function getTimeout(api: keyof typeof DEFAULT_TIMEOUTS): number;
37
+ //# sourceMappingURL=http-timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-timeout.d.ts","sourceRoot":"","sources":["../../src/http-timeout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;CAKnB,CAAC;AAEX;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,OAAO,gBAAgB,GAAG,MAAM,CAErE"}