@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 @@
1
+ {"version":3,"file":"smart-orders.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/trading/smart-orders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EAEvB,kBAAkB,EAElB,4BAA4B,EAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAkB,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAkB,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAEnB,MAAM,kBAAkB,CAAC;AAS1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AAEjC;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,IAAI,EAAE,SAAS,CAAC;IAEhB,6EAA6E;IAC7E,KAAK,CAAC,EAAE;QACN,uBAAuB;QACvB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;QACzB,0DAA0D;QAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;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* Native Trailing Stop Orders Module
3
+ *
4
+ * This module provides functions for creating and managing native trailing stop orders
5
+ * using Alpaca's server-side trailing stop functionality. Native trailing stops are
6
+ * handled by Alpaca's servers, eliminating the need for client-side monitoring.
7
+ *
8
+ * Key benefits of native trailing stops:
9
+ * - Server-side execution ensures stops work even if your application is offline
10
+ * - No need for polling or websocket connections to monitor prices
11
+ * - Automatic high water mark (HWM) tracking by Alpaca
12
+ * - Support for both percentage-based and dollar-based trailing
13
+ */
14
+ import { AlpacaClient } from "../client";
15
+ import { AlpacaOrder, OrderSide, TimeInForce } from "../../types/alpaca-types";
16
+ /**
17
+ * Parameters for creating a trailing stop order
18
+ */
19
+ export interface TrailingStopParams {
20
+ /** Stock symbol */
21
+ symbol: string;
22
+ /** Number of shares */
23
+ qty: number;
24
+ /** Order side (usually 'sell' for closing long positions) */
25
+ side: OrderSide;
26
+ /** Trail by percentage (e.g., 1.0 = 1%). Must specify either trailPercent OR trailPrice */
27
+ trailPercent?: number;
28
+ /** Trail by fixed dollar amount. Must specify either trailPercent OR trailPrice */
29
+ trailPrice?: number;
30
+ /** Time in force (default: 'gtc') */
31
+ timeInForce?: TimeInForce;
32
+ /** Extended hours trading */
33
+ extendedHours?: boolean;
34
+ /** Client order ID for tracking */
35
+ clientOrderId?: string;
36
+ }
37
+ /**
38
+ * Result of trailing stop HWM query
39
+ */
40
+ export interface TrailingStopHWMResult {
41
+ /** High water mark - the highest price seen since order placement (for sell stops) */
42
+ hwm: number | null;
43
+ /** Current calculated stop price based on HWM and trail amount */
44
+ currentStop: number | null;
45
+ }
46
+ /**
47
+ * Parameters for creating trailing stops across a portfolio
48
+ */
49
+ export interface PortfolioTrailingStopParams {
50
+ /** Trail by percentage (e.g., 2.0 = 2%) */
51
+ trailPercent: number;
52
+ /** Time in force (default: 'gtc') */
53
+ timeInForce?: TimeInForce;
54
+ /** Symbols to exclude from trailing stop creation */
55
+ excludeSymbols?: string[];
56
+ }
57
+ /**
58
+ * Validation error for trailing stop parameters
59
+ */
60
+ export declare class TrailingStopValidationError extends Error {
61
+ constructor(message: string);
62
+ }
63
+ /**
64
+ * Create a native trailing stop order
65
+ *
66
+ * The trailing stop automatically adjusts based on price movement:
67
+ * - For SELL: Stop rises as price rises, locks in when price falls
68
+ * - For BUY: Stop falls as price falls, triggers when price rises
69
+ *
70
+ * Must specify either trailPercent OR trailPrice (not both)
71
+ *
72
+ * @param client - AlpacaClient instance
73
+ * @param params - Trailing stop parameters
74
+ * @returns The created order
75
+ * @throws {TrailingStopValidationError} If parameters are invalid
76
+ * @throws {Error} If order creation fails
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * // Trail by 2% on a sell (closing long position)
81
+ * await createTrailingStop(client, {
82
+ * symbol: 'AAPL',
83
+ * qty: 100,
84
+ * side: 'sell',
85
+ * trailPercent: 2.0,
86
+ * });
87
+ *
88
+ * // Trail by $5 on a sell
89
+ * await createTrailingStop(client, {
90
+ * symbol: 'AAPL',
91
+ * qty: 100,
92
+ * side: 'sell',
93
+ * trailPrice: 5.00,
94
+ * });
95
+ * ```
96
+ */
97
+ export declare function createTrailingStop(client: AlpacaClient, params: TrailingStopParams): Promise<AlpacaOrder>;
98
+ /**
99
+ * Update an existing trailing stop order
100
+ *
101
+ * You can update the trail_percent or trail_price of an existing order.
102
+ * Note: Alpaca uses 'trail' parameter for replacements (works for both percent and price).
103
+ *
104
+ * @param client - AlpacaClient instance
105
+ * @param orderId - The ID of the order to update
106
+ * @param updates - New trail parameters (specify one of trailPercent or trailPrice)
107
+ * @returns The updated order
108
+ * @throws {Error} If no update parameters provided or update fails
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * // Tighten trailing stop to 1.5%
113
+ * await updateTrailingStop(client, 'order-id-123', { trailPercent: 1.5 });
114
+ *
115
+ * // Change to $3 trail
116
+ * await updateTrailingStop(client, 'order-id-123', { trailPrice: 3.00 });
117
+ * ```
118
+ */
119
+ export declare function updateTrailingStop(client: AlpacaClient, orderId: string, updates: {
120
+ trailPercent?: number;
121
+ trailPrice?: number;
122
+ }): Promise<AlpacaOrder>;
123
+ /**
124
+ * Get the current high water mark (HWM) for a trailing stop
125
+ *
126
+ * The HWM is the highest price seen since order placement (for sell stops)
127
+ * or the lowest price (for buy stops). The current stop price is calculated
128
+ * based on the HWM and the trail amount.
129
+ *
130
+ * @param client - AlpacaClient instance
131
+ * @param orderId - The ID of the trailing stop order
132
+ * @returns Object containing HWM and current stop price (null if not yet established)
133
+ * @throws {Error} If order retrieval fails
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const { hwm, currentStop } = await getTrailingStopHWM(client, 'order-id-123');
138
+ * console.log(`High water mark: $${hwm}, Current stop: $${currentStop}`);
139
+ * ```
140
+ */
141
+ export declare function getTrailingStopHWM(client: AlpacaClient, orderId: string): Promise<TrailingStopHWMResult>;
142
+ /**
143
+ * Cancel a trailing stop order
144
+ *
145
+ * @param client - AlpacaClient instance
146
+ * @param orderId - The ID of the trailing stop order to cancel
147
+ * @throws {Error} If cancellation fails
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * await cancelTrailingStop(client, 'order-id-123');
152
+ * ```
153
+ */
154
+ export declare function cancelTrailingStop(client: AlpacaClient, orderId: string): Promise<void>;
155
+ /**
156
+ * Create trailing stops for all positions in a portfolio
157
+ *
158
+ * This function creates trailing stop orders for all long positions in the portfolio,
159
+ * which is useful for applying blanket downside protection. Short positions are skipped.
160
+ *
161
+ * @param client - AlpacaClient instance
162
+ * @param params - Configuration for portfolio-wide trailing stops
163
+ * @returns Map of symbol to created order (symbols that failed are not included)
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * // Apply 3% trailing stops to all positions except TSLA and NVDA
168
+ * const orders = await createPortfolioTrailingStops(client, {
169
+ * trailPercent: 3.0,
170
+ * excludeSymbols: ['TSLA', 'NVDA'],
171
+ * });
172
+ *
173
+ * console.log(`Created ${orders.size} trailing stops`);
174
+ * for (const [symbol, order] of orders) {
175
+ * console.log(`${symbol}: ${order.id}`);
176
+ * }
177
+ * ```
178
+ */
179
+ export declare function createPortfolioTrailingStops(client: AlpacaClient, params: PortfolioTrailingStopParams): Promise<Map<string, AlpacaOrder>>;
180
+ /**
181
+ * Get all open trailing stop orders
182
+ *
183
+ * @param client - AlpacaClient instance
184
+ * @param symbol - Optional symbol to filter by
185
+ * @returns Array of open trailing stop orders
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * // Get all trailing stops
190
+ * const allStops = await getOpenTrailingStops(client);
191
+ *
192
+ * // Get trailing stops for specific symbol
193
+ * const appleStops = await getOpenTrailingStops(client, 'AAPL');
194
+ * ```
195
+ */
196
+ export declare function getOpenTrailingStops(client: AlpacaClient, symbol?: string): Promise<AlpacaOrder[]>;
197
+ /**
198
+ * Check if a symbol has an active trailing stop order
199
+ *
200
+ * @param client - AlpacaClient instance
201
+ * @param symbol - Stock symbol to check
202
+ * @returns True if an active trailing stop exists for the symbol
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * if (await hasActiveTrailingStop(client, 'AAPL')) {
207
+ * console.log('AAPL already has a trailing stop');
208
+ * }
209
+ * ```
210
+ */
211
+ export declare function hasActiveTrailingStop(client: AlpacaClient, symbol: string): Promise<boolean>;
212
+ /**
213
+ * Cancel all trailing stop orders for a specific symbol
214
+ *
215
+ * @param client - AlpacaClient instance
216
+ * @param symbol - Stock symbol
217
+ * @returns Number of orders canceled
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const canceled = await cancelTrailingStopsForSymbol(client, 'AAPL');
222
+ * console.log(`Canceled ${canceled} trailing stop orders for AAPL`);
223
+ * ```
224
+ */
225
+ export declare function cancelTrailingStopsForSymbol(client: AlpacaClient, symbol: string): Promise<number>;
226
+ /**
227
+ * Default export object with all trailing stop functions
228
+ */
229
+ declare const _default: {
230
+ createTrailingStop: typeof createTrailingStop;
231
+ updateTrailingStop: typeof updateTrailingStop;
232
+ getTrailingStopHWM: typeof getTrailingStopHWM;
233
+ cancelTrailingStop: typeof cancelTrailingStop;
234
+ createPortfolioTrailingStops: typeof createPortfolioTrailingStops;
235
+ getOpenTrailingStops: typeof getOpenTrailingStops;
236
+ hasActiveTrailingStop: typeof hasActiveTrailingStop;
237
+ cancelTrailingStopsForSymbol: typeof cancelTrailingStopsForSymbol;
238
+ };
239
+ export default _default;
240
+ //# sourceMappingURL=trailing-stops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trailing-stops.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/trading/trailing-stops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EACL,WAAW,EACX,SAAS,EACT,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AAWlC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,IAAI,EAAE,SAAS,CAAC;IAChB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,6BAA6B;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,sFAAsF;IACtF,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,kEAAkE;IAClE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,EA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;;;;;;GAYG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAiCjB;AAED;;GAEG;;;;;;;;;;;AACH,wBASE"}
@@ -0,0 +1,386 @@
1
+ import { Bar, AlpacaQuote, TimeFrame, AlpacaAsset, OptionBar, OptionGreeks, OptionsChainParams, OptionsChainResponse, LatestOptionsTradesParams, LatestOptionsTradesResponse, LatestOptionsQuotesParams, LatestOptionsQuotesResponse, LatestQuotesResponse, LatestTradesResponse, HistoricalOptionsBarsParams, HistoricalOptionsBarsResponse, HistoricalOptionsTradesParams, HistoricalOptionsTradesResponse, OptionsSnapshotsParams, OptionsSnapshotsResponse, OptionsConditionCodesResponse, OptionsExchangeCodesResponse, OptionTickType, SimpleNews, DataFeed, StockStreamEventName, OptionStreamEventName, CryptoStreamEventName, StockStreamEventMap, OptionStreamEventMap, CryptoStreamEventMap } from "./types/alpaca-types";
2
+ import { EventEmitter } from "events";
3
+ /**
4
+ * Parameters for retrieving historical market data bars
5
+ * @see https://data.alpaca.markets/v2/stocks/bars
6
+ */
7
+ export interface HistoricalBarsParams {
8
+ /** Comma-separated list of stock symbols to query, e.g. 'AAPL,MSFT,TSLA' */
9
+ symbols: string[];
10
+ /**
11
+ * Bar duration/timeframe
12
+ * Format: [1-59]Min/T, [1-23]Hour/H, 1Day/D, 1Week/W, [1,2,3,4,6,12]Month/M
13
+ * Examples: "1Min", "5Min", "1Hour", "1Day", "1Week", "1Month"
14
+ */
15
+ timeframe: TimeFrame;
16
+ /**
17
+ * Start datetime in RFC-3339 format (YYYY-MM-DD)
18
+ * Example: "2024-02-11T09:00:00Z"
19
+ */
20
+ start?: string;
21
+ /**
22
+ * End datetime in RFC-3339 format (YYYY-MM-DD)
23
+ * Example: "2024-02-11T16:00:00Z"
24
+ */
25
+ end?: string;
26
+ /**
27
+ * Number of bars to return (1-10000)
28
+ * Default: 1000
29
+ */
30
+ limit?: number;
31
+ /**
32
+
33
+ /**
34
+ * Pagination token for retrieving next page of results
35
+ * Returned in the next_page_token field of the response
36
+ */
37
+ page_token?: string;
38
+ /**
39
+ * Sort order of returned bars
40
+ * - asc: Oldest to newest (default)
41
+ * - desc: Newest to oldest
42
+ */
43
+ sort?: "asc" | "desc";
44
+ }
45
+ /**
46
+ * Response from historical bars endpoint
47
+ * Contains OHLCV (Open, High, Low, Close, Volume) data for requested symbols
48
+ */
49
+ export interface HistoricalBarsResponse {
50
+ /**
51
+ * Map of symbol to array of bar data
52
+ * Each bar contains OHLCV data for the specified timeframe
53
+ */
54
+ bars: {
55
+ [symbol: string]: Bar[];
56
+ };
57
+ /**
58
+ * Token for retrieving the next page of results
59
+ * null if there are no more results
60
+ */
61
+ next_page_token: string | null;
62
+ /** Currency of the price data in ISO 4217 format */
63
+ currency: string;
64
+ }
65
+ /**
66
+ * Response from latest bars endpoint
67
+ * Contains the most recent minute bar for each requested symbol
68
+ */
69
+ export interface LatestBarsResponse {
70
+ /**
71
+ * Map of symbol to latest bar data
72
+ * Each bar contains OHLCV data for the most recent minute
73
+ */
74
+ bars: {
75
+ [symbol: string]: Bar;
76
+ };
77
+ /** Currency of the price data in ISO 4217 format */
78
+ currency: string;
79
+ }
80
+ /**
81
+ * Response from last trade endpoint for a single symbol
82
+ * Contains detailed information about the most recent trade
83
+ */
84
+ export interface LastTradeResponse {
85
+ /** Status of the request */
86
+ status: string;
87
+ /** The stock symbol that was queried */
88
+ symbol: string;
89
+ /**
90
+ * Details of the last trade
91
+ * @property price - Trade price
92
+ * @property size - Trade size (quantity)
93
+ * @property exchange - Exchange where trade occurred (see Common Exchange Codes in docs)
94
+ * @property cond1-4 - Trade conditions
95
+ * @property timestamp - UNIX epoch timestamp in milliseconds
96
+ */
97
+ last: {
98
+ price: number;
99
+ size: number;
100
+ exchange: number;
101
+ cond1: number;
102
+ cond2: number;
103
+ cond3: number;
104
+ cond4: number;
105
+ timestamp: number;
106
+ };
107
+ }
108
+ /**
109
+ * Singleton class for interacting with Alpaca Market Data API
110
+ * Provides methods for fetching historical bars, latest bars, last trades, latest trades, latest quotes, and latest quote for a single symbol
111
+ */
112
+ export declare class AlpacaMarketDataAPI extends EventEmitter {
113
+ private static instance;
114
+ private headers;
115
+ private dataURL;
116
+ private apiURL;
117
+ private v1beta1url;
118
+ /** Whether API credentials are valid and available. False during build time when env vars are missing. */
119
+ private credentialsValid;
120
+ private stockStreamUrl;
121
+ private optionStreamUrl;
122
+ private cryptoStreamUrl;
123
+ private stockWs;
124
+ private optionWs;
125
+ private cryptoWs;
126
+ private stockSubscriptions;
127
+ private optionSubscriptions;
128
+ private cryptoSubscriptions;
129
+ setMode(mode?: "sandbox" | "test" | "production"): void;
130
+ getMode(): "sandbox" | "test" | "production";
131
+ private constructor();
132
+ static getInstance(): AlpacaMarketDataAPI;
133
+ on<K extends StockStreamEventName>(event: K, listener: (data: StockStreamEventMap[K]) => void): this;
134
+ on<K extends OptionStreamEventName>(event: K, listener: (data: OptionStreamEventMap[K]) => void): this;
135
+ on<K extends CryptoStreamEventName>(event: K, listener: (data: CryptoStreamEventMap[K]) => void): this;
136
+ emit<K extends StockStreamEventName>(event: K, data: StockStreamEventMap[K]): boolean;
137
+ emit<K extends OptionStreamEventName>(event: K, data: OptionStreamEventMap[K]): boolean;
138
+ emit<K extends CryptoStreamEventName>(event: K, data: CryptoStreamEventMap[K]): boolean;
139
+ private connect;
140
+ private sendSubscription;
141
+ connectStockStream(): void;
142
+ connectOptionStream(): void;
143
+ connectCryptoStream(): void;
144
+ disconnectStockStream(): void;
145
+ disconnectOptionStream(): void;
146
+ disconnectCryptoStream(): void;
147
+ /**
148
+ * Check if a specific stream is connected
149
+ * @param streamType - The type of stream to check
150
+ * @returns True if the stream is connected
151
+ */
152
+ isStreamConnected(streamType: "stock" | "option" | "crypto"): boolean;
153
+ subscribe(streamType: "stock" | "option" | "crypto", subscriptions: {
154
+ trades?: string[];
155
+ quotes?: string[];
156
+ bars?: string[];
157
+ }): void;
158
+ unsubscribe(streamType: "stock" | "option" | "crypto", subscriptions: {
159
+ trades?: string[];
160
+ quotes?: string[];
161
+ bars?: string[];
162
+ }): void;
163
+ private makeRequest;
164
+ /**
165
+ * Get historical OHLCV bars for specified symbols, including pre-market and post-market data
166
+ * Automatically handles pagination to fetch all available data
167
+ * @param params Parameters for historical bars request
168
+ * @returns Historical bars data with all pages combined
169
+ */
170
+ getHistoricalBars(params: HistoricalBarsParams): Promise<HistoricalBarsResponse>;
171
+ /**
172
+ * Get the most recent minute bar for requested symbols
173
+ * @param symbols Array of stock symbols to query
174
+ * @param currency Optional currency in ISO 4217 format
175
+ * @returns Latest bar data for each symbol
176
+
177
+ */
178
+ getLatestBars(symbols: string[], currency?: string): Promise<LatestBarsResponse>;
179
+ /**
180
+ * Get the last trade for a single symbol
181
+ * @param symbol The stock symbol to query
182
+ * @returns Last trade details including price, size, exchange, and conditions
183
+ */
184
+ getLastTrade(symbol: string): Promise<LastTradeResponse>;
185
+ /**
186
+ * Get the most recent trades for requested symbols
187
+ * @param symbols Array of stock symbols to query
188
+ * @param feed Optional data source (sip/iex/delayed_sip)
189
+ * @param currency Optional currency in ISO 4217 format
190
+ * @returns Latest trade data for each symbol
191
+
192
+ */
193
+ getLatestTrades(symbols: string[], feed?: DataFeed, currency?: string): Promise<LatestTradesResponse>;
194
+ /**
195
+ * Get the most recent quotes for requested symbols
196
+ * @param symbols Array of stock symbols to query
197
+ * @param feed Optional data source (sip/iex/delayed_sip)
198
+ * @param currency Optional currency in ISO 4217 format
199
+ * @returns Latest quote data for each symbol
200
+ */
201
+ getLatestQuotes(symbols: string[], feed?: DataFeed, currency?: string): Promise<LatestQuotesResponse>;
202
+ /**
203
+ * Get the latest quote for a single symbol
204
+ * @param symbol The stock symbol to query
205
+ * @param feed Optional data source (sip/iex/delayed_sip)
206
+ * @param currency Optional currency in ISO 4217 format
207
+ * @returns Latest quote data with symbol and currency information
208
+ */
209
+ getLatestQuote(symbol: string, feed?: DataFeed, currency?: string): Promise<{
210
+ quote: AlpacaQuote;
211
+ symbol: string;
212
+ currency: string;
213
+ }>;
214
+ /**
215
+ * Get the previous day's closing price for a symbol
216
+ * @param symbol The stock symbol to query
217
+ * @param referenceDate Optional reference date to get the previous close for
218
+ * @returns Previous day's closing price data
219
+ */
220
+ getPreviousClose(symbol: string, referenceDate?: Date): Promise<Bar | null>;
221
+ /**
222
+ * Get hourly price data for a symbol
223
+ * @param symbol The stock symbol to query
224
+ * @param start Start time in milliseconds
225
+ * @param end End time in milliseconds
226
+ * @returns Array of hourly price bars
227
+ */
228
+ getHourlyPrices(symbol: string, start: number, end: number): Promise<Bar[]>;
229
+ /**
230
+ * Get half-hourly price data for a symbol
231
+ * @param symbol The stock symbol to query
232
+ * @param start Start time in milliseconds
233
+ * @param end End time in milliseconds
234
+ * @returns Array of half-hourly price bars
235
+ */
236
+ getHalfHourlyPrices(symbol: string, start: number, end: number): Promise<Bar[]>;
237
+ /**
238
+ * Get daily price data for a symbol
239
+ * @param symbol The stock symbol to query
240
+ * @param start Start time in milliseconds
241
+ * @param end End time in milliseconds
242
+ * @returns Array of daily price bars
243
+ */
244
+ getDailyPrices(symbol: string, start: number, end: number): Promise<Bar[]>;
245
+ /**
246
+ * Get intraday price data for a symbol
247
+ * @param symbol The stock symbol to query
248
+ * @param minutePeriod Minutes per bar (1, 5, 15, etc.)
249
+ * @param start Start time in milliseconds
250
+ * @param end End time in milliseconds
251
+ * @returns Array of intraday price bars
252
+ */
253
+ getIntradayPrices(symbol: string, minutePeriod: number, start: number, end: number): Promise<Bar[]>;
254
+ /**
255
+ * Analyzes an array of price bars and returns a summary string
256
+ * @param bars Array of price bars to analyze
257
+ * @returns A string summarizing the price data
258
+ */
259
+ static analyzeBars(bars: Bar[]): string;
260
+ /**
261
+ * Get all assets available for trade and data consumption from Alpaca
262
+ * @param params Optional query params: status (e.g. 'active'), asset_class (e.g. 'us_equity', 'crypto')
263
+ * @returns Array of AlpacaAsset objects
264
+ * @see https://docs.alpaca.markets/reference/get-v2-assets-1
265
+ */
266
+ getAssets(params?: {
267
+ status?: string;
268
+ asset_class?: string;
269
+ }): Promise<AlpacaAsset[]>;
270
+ /**
271
+ * Get a single asset by symbol or asset_id
272
+ * @param symbolOrAssetId Symbol or asset_id
273
+ * @returns AlpacaAsset object
274
+ * @see https://docs.alpaca.markets/reference/get-v2-assets-symbol_or_asset_id
275
+ */
276
+ getAsset(symbolOrAssetId: string): Promise<AlpacaAsset>;
277
+ /**
278
+ * Get options chain for an underlying symbol
279
+ * Provides the latest trade, latest quote, and greeks for each contract symbol of the underlying symbol
280
+ * @param params Options chain request parameters
281
+ * @returns Options chain data with snapshots for each contract
282
+ * @see https://docs.alpaca.markets/reference/optionchain
283
+ */
284
+ getOptionsChain(params: OptionsChainParams): Promise<OptionsChainResponse>;
285
+ /**
286
+ * Get the most recent trades for requested option contract symbols
287
+ * @param params Latest options trades request parameters
288
+ * @returns Latest trade data for each option contract symbol
289
+
290
+ * @see https://docs.alpaca.markets/reference/optionlatesttrades
291
+ */
292
+ getLatestOptionsTrades(params: LatestOptionsTradesParams): Promise<LatestOptionsTradesResponse>;
293
+ /**
294
+ * Get the most recent quotes for requested option contract symbols
295
+ * @param params Latest options quotes request parameters
296
+ * @returns Latest quote data for each option contract symbol
297
+
298
+ * @see https://docs.alpaca.markets/reference/optionlatestquotes
299
+ */
300
+ getLatestOptionsQuotes(params: LatestOptionsQuotesParams): Promise<LatestOptionsQuotesResponse>;
301
+ /**
302
+ * Get historical OHLCV bars for option contract symbols
303
+ * Automatically handles pagination to fetch all available data
304
+ * @param params Historical options bars request parameters
305
+ * @returns Historical bar data for each option contract symbol with all pages combined
306
+
307
+ * @see https://docs.alpaca.markets/reference/optionbars
308
+ */
309
+ getHistoricalOptionsBars(params: HistoricalOptionsBarsParams): Promise<HistoricalOptionsBarsResponse>;
310
+ /**
311
+ * Get historical trades for option contract symbols
312
+ * Automatically handles pagination to fetch all available data
313
+ * @param params Historical options trades request parameters
314
+ * @returns Historical trade data for each option contract symbol with all pages combined
315
+
316
+ * @see https://docs.alpaca.markets/reference/optiontrades
317
+ */
318
+ getHistoricalOptionsTrades(params: HistoricalOptionsTradesParams): Promise<HistoricalOptionsTradesResponse>;
319
+ /**
320
+ * Get snapshots for option contract symbols
321
+ * Provides latest trade, latest quote, and greeks for each contract symbol
322
+ * @param params Options snapshots request parameters
323
+ * @returns Snapshot data for each option contract symbol
324
+
325
+ * @see https://docs.alpaca.markets/reference/optionsnapshots
326
+ */
327
+ getOptionsSnapshot(params: OptionsSnapshotsParams): Promise<OptionsSnapshotsResponse>;
328
+ /**
329
+ * Get condition codes for options trades or quotes
330
+ * Returns the mapping between condition codes and their descriptions
331
+ * @param tickType The type of tick data ('trade' or 'quote')
332
+ * @returns Mapping of condition codes to descriptions
333
+
334
+ * @see https://docs.alpaca.markets/reference/optionmetaconditions
335
+ */
336
+ getOptionsConditionCodes(tickType: OptionTickType): Promise<OptionsConditionCodesResponse>;
337
+ /**
338
+ * Get exchange codes for options
339
+ * Returns the mapping between option exchange codes and exchange names
340
+ * @returns Mapping of exchange codes to exchange names
341
+
342
+ * @see https://docs.alpaca.markets/reference/optionmetaexchanges
343
+ */
344
+ getOptionsExchangeCodes(): Promise<OptionsExchangeCodesResponse>;
345
+ /**
346
+ * Analyzes an array of option bars and returns a summary string
347
+ * @param bars Array of option bars to analyze
348
+ * @returns A string summarizing the option price data
349
+ */
350
+ static analyzeOptionBars(bars: OptionBar[]): string;
351
+ /**
352
+ * Formats option greeks for display
353
+ * @param greeks Option greeks object
354
+ * @returns Formatted string with greek values
355
+ */
356
+ static formatOptionGreeks(greeks: OptionGreeks | null | undefined): string;
357
+ /**
358
+ * Interprets condition codes using the provided condition codes mapping
359
+ * @param conditionCodes Array of condition codes from trade or quote
360
+ * @param conditionCodesMap Mapping of condition codes to descriptions
361
+ * @returns Formatted string with condition descriptions
362
+ */
363
+ static interpretConditionCodes(conditionCodes: string[], conditionCodesMap: OptionsConditionCodesResponse): string;
364
+ /**
365
+ * Gets the exchange name from exchange code using the provided exchange codes mapping
366
+ * @param exchangeCode Exchange code from trade or quote
367
+ * @param exchangeCodesMap Mapping of exchange codes to names
368
+ * @returns Exchange name or formatted unknown exchange
369
+ */
370
+ static getExchangeName(exchangeCode: string, exchangeCodesMap: OptionsExchangeCodesResponse): string;
371
+ /**
372
+ * Fetches news articles from Alpaca API for a symbol, paginating through all results.
373
+ * @param symbol The symbol to fetch news for (e.g., 'AAPL')
374
+ * @param params Optional parameters: start, end, limit, sort, include_content
375
+ * @returns Array of SimpleNews articles
376
+ */
377
+ fetchNews(symbol: string, params?: {
378
+ start?: Date | string;
379
+ end?: Date | string;
380
+ limit?: number;
381
+ sort?: "asc" | "desc";
382
+ include_content?: boolean;
383
+ }): Promise<SimpleNews[]>;
384
+ }
385
+ export declare const marketDataAPI: AlpacaMarketDataAPI;
386
+ //# sourceMappingURL=alpaca-market-data-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alpaca-market-data-api.d.ts","sourceRoot":"","sources":["../../src/alpaca-market-data-api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EACH,WAAW,EACX,SAAS,EAET,WAAW,EACX,SAAS,EAET,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,6BAA6B,EAC7B,6BAA6B,EAC7B,+BAA+B,EAC/B,sBAAsB,EACtB,wBAAwB,EACxB,6BAA6B,EAC7B,4BAA4B,EAC5B,cAAc,EACd,UAAU,EAEV,QAAQ,EAIR,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAU9B,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AActC;;;GAGG;AACH,MAAM,WAAW,oBAA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