@adaptic/utils 0.0.359

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 (72) hide show
  1. package/README.md +824 -0
  2. package/dist/index.cjs +13641 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.mjs +13614 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/test.js +7336 -0
  7. package/dist/test.js.map +1 -0
  8. package/dist/types/adaptic.d.ts +18 -0
  9. package/dist/types/adaptic.d.ts.map +1 -0
  10. package/dist/types/alpaca-functions.d.ts +233 -0
  11. package/dist/types/alpaca-functions.d.ts.map +1 -0
  12. package/dist/types/alpaca-market-data-api.d.ts +371 -0
  13. package/dist/types/alpaca-market-data-api.d.ts.map +1 -0
  14. package/dist/types/alpaca-trading-api.d.ts +315 -0
  15. package/dist/types/alpaca-trading-api.d.ts.map +1 -0
  16. package/dist/types/alphavantage.d.ts +44 -0
  17. package/dist/types/alphavantage.d.ts.map +1 -0
  18. package/dist/types/crypto.d.ts +46 -0
  19. package/dist/types/crypto.d.ts.map +1 -0
  20. package/dist/types/display-manager.d.ts +24 -0
  21. package/dist/types/display-manager.d.ts.map +1 -0
  22. package/dist/types/format-tools.d.ts +54 -0
  23. package/dist/types/format-tools.d.ts.map +1 -0
  24. package/dist/types/index.d.ts +415 -0
  25. package/dist/types/index.d.ts.map +1 -0
  26. package/dist/types/logging.d.ts +12 -0
  27. package/dist/types/logging.d.ts.map +1 -0
  28. package/dist/types/market-hours.d.ts +24 -0
  29. package/dist/types/market-hours.d.ts.map +1 -0
  30. package/dist/types/market-time.d.ts +184 -0
  31. package/dist/types/market-time.d.ts.map +1 -0
  32. package/dist/types/metrics-calcs.d.ts +6 -0
  33. package/dist/types/metrics-calcs.d.ts.map +1 -0
  34. package/dist/types/misc-utils.d.ts +49 -0
  35. package/dist/types/misc-utils.d.ts.map +1 -0
  36. package/dist/types/performance-metrics.d.ts +88 -0
  37. package/dist/types/performance-metrics.d.ts.map +1 -0
  38. package/dist/types/polygon-indices.d.ts +85 -0
  39. package/dist/types/polygon-indices.d.ts.map +1 -0
  40. package/dist/types/polygon.d.ts +126 -0
  41. package/dist/types/polygon.d.ts.map +1 -0
  42. package/dist/types/price-utils.d.ts +26 -0
  43. package/dist/types/price-utils.d.ts.map +1 -0
  44. package/dist/types/technical-analysis.d.ts +90 -0
  45. package/dist/types/technical-analysis.d.ts.map +1 -0
  46. package/dist/types/test.d.ts +2 -0
  47. package/dist/types/test.d.ts.map +1 -0
  48. package/dist/types/testing/options-ws.d.ts +2 -0
  49. package/dist/types/testing/options-ws.d.ts.map +1 -0
  50. package/dist/types/time-utils.d.ts +17 -0
  51. package/dist/types/time-utils.d.ts.map +1 -0
  52. package/dist/types/types/adaptic-types.d.ts +11 -0
  53. package/dist/types/types/adaptic-types.d.ts.map +1 -0
  54. package/dist/types/types/alpaca-types.d.ts +998 -0
  55. package/dist/types/types/alpaca-types.d.ts.map +1 -0
  56. package/dist/types/types/alphavantage-types.d.ts +66 -0
  57. package/dist/types/types/alphavantage-types.d.ts.map +1 -0
  58. package/dist/types/types/index.d.ts +21 -0
  59. package/dist/types/types/index.d.ts.map +1 -0
  60. package/dist/types/types/logging-types.d.ts +10 -0
  61. package/dist/types/types/logging-types.d.ts.map +1 -0
  62. package/dist/types/types/market-time-types.d.ts +59 -0
  63. package/dist/types/types/market-time-types.d.ts.map +1 -0
  64. package/dist/types/types/metrics-types.d.ts +33 -0
  65. package/dist/types/types/metrics-types.d.ts.map +1 -0
  66. package/dist/types/types/polygon-indices-types.d.ts +190 -0
  67. package/dist/types/types/polygon-indices-types.d.ts.map +1 -0
  68. package/dist/types/types/polygon-types.d.ts +204 -0
  69. package/dist/types/types/polygon-types.d.ts.map +1 -0
  70. package/dist/types/types/ta-types.d.ts +89 -0
  71. package/dist/types/types/ta-types.d.ts.map +1 -0
  72. package/package.json +55 -0
@@ -0,0 +1,315 @@
1
+ import { AlpacaAccountDetails, AlpacaCredentials, AlpacaPosition, AssetClass, GetOptionContractsParams, GetOrdersParams, OptionAccountActivity, OptionContract, OptionContractsResponse, AlpacaOrder, OrderLeg, TradeUpdate } from './types/alpaca-types';
2
+ /**
3
+ Websocket example
4
+ const alpacaAPI = createAlpacaTradingAPI(credentials); // type AlpacaCredentials
5
+ alpacaAPI.onTradeUpdate((update: TradeUpdate) => {
6
+ this.log(`Received trade update: event ${update.event} for an order to ${update.order.side} ${update.order.qty} of ${update.order.symbol}`);
7
+ });
8
+ alpacaAPI.connectWebsocket(); // necessary to connect to the WebSocket
9
+ */
10
+ export declare class AlpacaTradingAPI {
11
+ static new(credentials: AlpacaCredentials): AlpacaTradingAPI;
12
+ static getInstance(credentials: AlpacaCredentials): AlpacaTradingAPI;
13
+ private ws;
14
+ private headers;
15
+ private tradeUpdateCallback;
16
+ private credentials;
17
+ private apiBaseUrl;
18
+ private wsUrl;
19
+ private authenticated;
20
+ private connecting;
21
+ private reconnectDelay;
22
+ private reconnectTimeout;
23
+ private messageHandlers;
24
+ private debugLogging;
25
+ /**
26
+ * Constructor for AlpacaTradingAPI
27
+ * @param credentials - Alpaca credentials,
28
+ * accountName: string; // The account identifier used inthis.logs and tracking
29
+ * apiKey: string; // Alpaca API key
30
+ * apiSecret: string; // Alpaca API secret
31
+ * type: AlpacaAccountType;
32
+ * orderType: AlpacaOrderType;
33
+ * @param options - Optional options
34
+ * debugLogging: boolean; // Whether to log messages of type 'debug'
35
+ */
36
+ constructor(credentials: AlpacaCredentials, options?: {
37
+ debugLogging?: boolean;
38
+ });
39
+ private log;
40
+ /**
41
+ * Round a price to the nearest 2 decimal places for Alpaca, or 4 decimal places for prices less than $1
42
+ * @param price - The price to round
43
+ * @returns The rounded price
44
+ */
45
+ private roundPriceForAlpaca;
46
+ private handleAuthMessage;
47
+ private handleListenMessage;
48
+ private handleTradeUpdate;
49
+ private handleMessage;
50
+ connectWebsocket(): void;
51
+ private authenticate;
52
+ private subscribeToTradeUpdates;
53
+ private makeRequest;
54
+ getPositions(assetClass?: AssetClass): Promise<AlpacaPosition[]>;
55
+ /**
56
+ * Get all orders
57
+ * @param params (GetOrdersParams) - optional parameters to filter the orders
58
+ * - status: 'open' | 'closed' | 'all'
59
+ * - limit: number
60
+ * - after: string
61
+ * - until: string
62
+ * - direction: 'asc' | 'desc'
63
+ * - nested: boolean
64
+ * - symbols: string[], an array of all the symbols
65
+ * - side: 'buy' | 'sell'
66
+ * @returns all orders
67
+ */
68
+ getOrders(params?: GetOrdersParams): Promise<AlpacaOrder[]>;
69
+ getAccountDetails(): Promise<AlpacaAccountDetails>;
70
+ /**
71
+ * Create a trailing stop order
72
+ * @param symbol (string) - the symbol of the order
73
+ * @param qty (number) - the quantity of the order
74
+ * @param side (string) - the side of the order
75
+ * @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
76
+ * @param position_intent (string) - the position intent of the order
77
+ */
78
+ createTrailingStop(symbol: string, qty: number, side: 'buy' | 'sell', trailPercent100: number, position_intent: 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close'): Promise<void>;
79
+ /**
80
+ * Create a market order
81
+ * @param symbol (string) - the symbol of the order
82
+ * @param qty (number) - the quantity of the order
83
+ * @param side (string) - the side of the order
84
+ * @param position_intent (string) - the position intent of the order. Important for knowing if a position needs a trailing stop.
85
+ */
86
+ createMarketOrder(symbol: string, qty: number, side: 'buy' | 'sell', position_intent: 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close', client_order_id?: string): Promise<AlpacaOrder>;
87
+ /**
88
+ * Get the current trail percent for a symbol, assuming that it has an open position and a trailing stop order to close it. Because this relies on an orders request for one symbol, you can't do it too often.
89
+ * @param symbol (string) - the symbol of the order
90
+ * @returns the current trail percent
91
+ */
92
+ getCurrentTrailPercent(symbol: string): Promise<number | null>;
93
+ /**
94
+ * Update the trail percent for a trailing stop order
95
+ * @param symbol (string) - the symbol of the order
96
+ * @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
97
+ */
98
+ updateTrailingStop(symbol: string, trailPercent100: number): Promise<void>;
99
+ /**
100
+ * Cancel all open orders
101
+ */
102
+ cancelAllOrders(): Promise<void>;
103
+ /**
104
+ * Cancel a specific order by its ID
105
+ * @param orderId The id of the order to cancel
106
+ * @throws Error if the order is not cancelable (status 422) or if the order doesn't exist
107
+ * @returns Promise that resolves when the order is successfully canceled
108
+ */
109
+ cancelOrder(orderId: string): Promise<void>;
110
+ /**
111
+ * Create a limit order
112
+ * @param symbol (string) - the symbol of the order
113
+ * @param qty (number) - the quantity of the order
114
+ * @param side (string) - the side of the order
115
+ * @param limitPrice (number) - the limit price of the order
116
+ * @param position_intent (string) - the position intent of the order
117
+ * @param extended_hours (boolean) - whether the order is in extended hours
118
+ * @param client_order_id (string) - the client order id of the order
119
+ */
120
+ createLimitOrder(symbol: string, qty: number, side: 'buy' | 'sell', limitPrice: number, position_intent: 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close', extended_hours?: boolean, client_order_id?: string): Promise<AlpacaOrder>;
121
+ /**
122
+ * Close all equities positions
123
+ * @param options (object) - the options for closing the positions
124
+ * - cancel_orders (boolean) - whether to cancel related orders
125
+ * - useLimitOrders (boolean) - whether to use limit orders to close the positions
126
+ */
127
+ closeAllPositions(options?: {
128
+ cancel_orders: boolean;
129
+ useLimitOrders: boolean;
130
+ }): Promise<void>;
131
+ /**
132
+ * Close all equities positions using limit orders during extended hours trading
133
+ * @param cancelOrders Whether to cancel related orders (default: true)
134
+ * @returns Promise that resolves when all positions are closed
135
+ */
136
+ closeAllPositionsAfterHours(): Promise<void>;
137
+ onTradeUpdate(callback: (update: TradeUpdate) => void): void;
138
+ /**
139
+ * Get portfolio history for the account
140
+ * @param params Parameters for the portfolio history request
141
+ * @returns Portfolio history data
142
+ */
143
+ getPortfolioHistory(params: {
144
+ timeframe?: '1Min' | '5Min' | '15Min' | '1H' | '1D';
145
+ period?: string;
146
+ extended_hours?: boolean;
147
+ date_end?: string;
148
+ }): Promise<{
149
+ timestamp: number[];
150
+ equity: number[];
151
+ profit_loss: number[];
152
+ profit_loss_pct: number[];
153
+ base_value: number;
154
+ timeframe: string;
155
+ }>;
156
+ /**
157
+ * Get option contracts based on specified parameters
158
+ * @param params Parameters to filter option contracts
159
+ * @returns Option contracts matching the criteria
160
+ */
161
+ getOptionContracts(params: GetOptionContractsParams): Promise<OptionContractsResponse>;
162
+ /**
163
+ * Get a specific option contract by symbol or ID
164
+ * @param symbolOrId The symbol or ID of the option contract
165
+ * @returns The option contract details
166
+ */
167
+ getOptionContract(symbolOrId: string): Promise<OptionContract>;
168
+ /**
169
+ * Create a simple option order (market or limit)
170
+ * @param symbol Option contract symbol
171
+ * @param qty Quantity of contracts (must be a whole number)
172
+ * @param side Buy or sell
173
+ * @param position_intent Position intent (buy_to_open, buy_to_close, sell_to_open, sell_to_close)
174
+ * @param type Order type (market or limit)
175
+ * @param limitPrice Limit price (required for limit orders)
176
+ * @returns The created order
177
+ */
178
+ createOptionOrder(symbol: string, qty: number, side: 'buy' | 'sell', position_intent: 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close', type: 'market' | 'limit', limitPrice?: number): Promise<AlpacaOrder>;
179
+ /**
180
+ * Create a multi-leg option order
181
+ * @param legs Array of order legs
182
+ * @param qty Quantity of the multi-leg order (must be a whole number)
183
+ * @param type Order type (market or limit)
184
+ * @param limitPrice Limit price (required for limit orders)
185
+ * @returns The created multi-leg order
186
+ */
187
+ createMultiLegOptionOrder(legs: OrderLeg[], qty: number, type: 'market' | 'limit', limitPrice?: number): Promise<AlpacaOrder>;
188
+ /**
189
+ * Exercise an option contract
190
+ * @param symbolOrContractId The symbol or ID of the option contract to exercise
191
+ * @returns Response from the exercise request
192
+ */
193
+ exerciseOption(symbolOrContractId: string): Promise<any>;
194
+ /**
195
+ * Get option positions
196
+ * @returns Array of option positions
197
+ */
198
+ getOptionPositions(): Promise<AlpacaPosition[]>;
199
+ getOptionsOpenSpreadTrades(): Promise<void>;
200
+ /**
201
+ * Get option account activities (exercises, assignments, expirations)
202
+ * @param activityType Type of option activity to filter by
203
+ * @param date Date to filter activities (YYYY-MM-DD format)
204
+ * @returns Array of option account activities
205
+ */
206
+ getOptionActivities(activityType?: 'OPEXC' | 'OPASN' | 'OPEXP', date?: string): Promise<OptionAccountActivity[]>;
207
+ /**
208
+ * Create a long call spread (buy lower strike call, sell higher strike call)
209
+ * @param lowerStrikeCallSymbol Symbol of the lower strike call option
210
+ * @param higherStrikeCallSymbol Symbol of the higher strike call option
211
+ * @param qty Quantity of spreads to create (must be a whole number)
212
+ * @param limitPrice Limit price for the spread
213
+ * @returns The created multi-leg order
214
+ */
215
+ createLongCallSpread(lowerStrikeCallSymbol: string, higherStrikeCallSymbol: string, qty: number, limitPrice: number): Promise<AlpacaOrder>;
216
+ /**
217
+ * Create a long put spread (buy higher strike put, sell lower strike put)
218
+ * @param higherStrikePutSymbol Symbol of the higher strike put option
219
+ * @param lowerStrikePutSymbol Symbol of the lower strike put option
220
+ * @param qty Quantity of spreads to create (must be a whole number)
221
+ * @param limitPrice Limit price for the spread
222
+ * @returns The created multi-leg order
223
+ */
224
+ createLongPutSpread(higherStrikePutSymbol: string, lowerStrikePutSymbol: string, qty: number, limitPrice: number): Promise<AlpacaOrder>;
225
+ /**
226
+ * Create an iron condor (sell call spread and put spread)
227
+ * @param longPutSymbol Symbol of the lower strike put (long)
228
+ * @param shortPutSymbol Symbol of the higher strike put (short)
229
+ * @param shortCallSymbol Symbol of the lower strike call (short)
230
+ * @param longCallSymbol Symbol of the higher strike call (long)
231
+ * @param qty Quantity of iron condors to create (must be a whole number)
232
+ * @param limitPrice Limit price for the iron condor (credit)
233
+ * @returns The created multi-leg order
234
+ */
235
+ createIronCondor(longPutSymbol: string, shortPutSymbol: string, shortCallSymbol: string, longCallSymbol: string, qty: number, limitPrice: number): Promise<AlpacaOrder>;
236
+ /**
237
+ * Create a covered call (sell call option against owned stock)
238
+ * @param stockSymbol Symbol of the underlying stock
239
+ * @param callOptionSymbol Symbol of the call option to sell
240
+ * @param qty Quantity of covered calls to create (must be a whole number)
241
+ * @param limitPrice Limit price for the call option
242
+ * @returns The created order
243
+ */
244
+ createCoveredCall(stockSymbol: string, callOptionSymbol: string, qty: number, limitPrice: number): Promise<AlpacaOrder>;
245
+ /**
246
+ * Roll an option position to a new expiration or strike
247
+ * @param currentOptionSymbol Symbol of the current option position
248
+ * @param newOptionSymbol Symbol of the new option to roll to
249
+ * @param qty Quantity of options to roll (must be a whole number)
250
+ * @param currentPositionSide Side of the current position ('buy' or 'sell')
251
+ * @param limitPrice Net limit price for the roll
252
+ * @returns The created multi-leg order
253
+ */
254
+ rollOptionPosition(currentOptionSymbol: string, newOptionSymbol: string, qty: number, currentPositionSide: 'buy' | 'sell', limitPrice: number): Promise<AlpacaOrder>;
255
+ /**
256
+ * Get option chain for a specific underlying symbol and expiration date
257
+ * @param underlyingSymbol The underlying stock symbol
258
+ * @param expirationDate The expiration date (YYYY-MM-DD format)
259
+ * @returns Option contracts for the specified symbol and expiration date
260
+ */
261
+ getOptionChain(underlyingSymbol: string, expirationDate: string): Promise<OptionContract[]>;
262
+ /**
263
+ * Get all available expiration dates for a specific underlying symbol
264
+ * @param underlyingSymbol The underlying stock symbol
265
+ * @returns Array of available expiration dates
266
+ */
267
+ getOptionExpirationDates(underlyingSymbol: string): Promise<string[]>;
268
+ /**
269
+ * Get the current options trading level for the account
270
+ * @returns The options trading level (0-3)
271
+ */
272
+ getOptionsTradingLevel(): Promise<number>;
273
+ /**
274
+ * Check if the account has options trading enabled
275
+ * @returns Boolean indicating if options trading is enabled
276
+ */
277
+ isOptionsEnabled(): Promise<boolean>;
278
+ /**
279
+ * Close all option positions
280
+ * @param cancelOrders Whether to cancel related orders (default: true)
281
+ * @returns Response from the close positions request
282
+ */
283
+ closeAllOptionPositions(cancelOrders?: boolean): Promise<void>;
284
+ /**
285
+ * Close a specific option position
286
+ * @param symbol The option contract symbol
287
+ * @param qty Optional quantity to close (defaults to entire position)
288
+ * @returns The created order
289
+ */
290
+ closeOptionPosition(symbol: string, qty?: number): Promise<AlpacaOrder>;
291
+ /**
292
+ * Create a complete equities trade with optional stop loss and take profit
293
+ * @param params Trade parameters including symbol, qty, side, and optional referencePrice
294
+ * @param options Trade options including order type, extended hours, stop loss, and take profit settings
295
+ * @returns The created order
296
+ */
297
+ createEquitiesTrade(params: {
298
+ symbol: string;
299
+ qty: number;
300
+ side: 'buy' | 'sell';
301
+ referencePrice?: number;
302
+ }, options?: {
303
+ type?: 'market' | 'limit';
304
+ limitPrice?: number;
305
+ extendedHours?: boolean;
306
+ useStopLoss?: boolean;
307
+ stopPrice?: number;
308
+ stopPercent100?: number;
309
+ useTakeProfit?: boolean;
310
+ takeProfitPrice?: number;
311
+ takeProfitPercent100?: number;
312
+ clientOrderId?: string;
313
+ }): Promise<AlpacaOrder>;
314
+ }
315
+ //# sourceMappingURL=alpaca-trading-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alpaca-trading-api.d.ts","sourceRoot":"","sources":["../../src/alpaca-trading-api.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,uBAAuB,EACvB,WAAW,EACX,QAAQ,EACR,WAAW,EAGZ,MAAM,sBAAsB,CAAC;AAK9B;;;;;;;EAOE;AAEF,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,iBAAiB,GAAG,gBAAgB;IAI5D,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,iBAAiB,GAAG,gBAAgB;IAIpE,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,mBAAmB,CAAgD;IAC3E,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,UAAU,CAAS;IAC3B,O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IACG,uBAAuB,CAAC,YAAY,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC1E;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAyB7E;;;;;OAKG;IACG,mBAAmB,CACvB,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,EACD,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;QAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GACA,OAAO,CAAC,WAAW,CAAC;CAqKxB"}
@@ -0,0 +1,44 @@
1
+ /**********************************************************************************
2
+ * AlphaVantage calls
3
+ **********************************************************************************/
4
+ import { AlphaVantageQuoteResponse, AVNewsArticle } from './types';
5
+ /**
6
+ * Fetches the current quote for a given ticker symbol.
7
+ * @param {string} ticker - The ticker symbol to fetch the quote for.
8
+ * @param {Object} [options] - Optional parameters.
9
+ * @param {string} [options.apiKey] - The API key to use for the request.
10
+ * @returns {Promise<AlphaVantageQuoteResponse>} The current quote response.
11
+ */
12
+ export declare const fetchQuote: (ticker: string, options?: {
13
+ apiKey?: string;
14
+ }) => Promise<AlphaVantageQuoteResponse>;
15
+ /**
16
+ * Converts a Date object to a string in the format YYYYMMDDTHHMM.
17
+ * @param {Date} date - The date to convert.
18
+ * @returns {string} The formatted date string.
19
+ */
20
+ export declare function convertDateToYYYYMMDDTHHMM(date: Date): string;
21
+ /**
22
+ * Converts a string in the format YYYYMMDDTHHMMSS to a Date object.
23
+ * @param {string} dateString - The date string to convert.
24
+ * @returns {Date} The corresponding Date object.
25
+ */
26
+ export declare function convertYYYYMMDDTHHMMSSToDate(dateString: string): Date;
27
+ /**
28
+ * Fetches news articles from AlphaVantage for a given ticker symbol. Performs filtering as the API endpoint doesn't respect the parameters.
29
+ * @param {string} ticker - The ticker symbol to fetch news for.
30
+ * @param {Object} [options] - Optional parameters.
31
+ * @param {Date} [options.start] - The start date for fetching news.
32
+ * @param {Date} [options.end] - The end date for fetching news.
33
+ * @param {number} [options.limit] - The maximum number of news articles to fetch.
34
+ * @param {string} [options.apiKey] - The API key to use for the request.
35
+ * @returns {Promise<AVNewsArticle[]>} The fetched news articles.
36
+ */
37
+ export declare const fetchTickerNews: (ticker: string, options?: {
38
+ start?: Date;
39
+ end?: Date;
40
+ limit?: number;
41
+ apiKey?: string;
42
+ sort?: "LATEST" | "EARLIEST" | "RELEVANCE";
43
+ }) => Promise<AVNewsArticle[]>;
44
+ //# sourceMappingURL=alphavantage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alphavantage.d.ts","sourceRoot":"","sources":["../../src/alphavantage.ts"],"names":[],"mappings":"AAAA;;oFAEoF;AAEpF,OAAO,EAAE,yBAAyB,EAAkB,aAAa,EAAE,MAAM,SAAS,CAAC;AAmBnF;;;;;;GAMG;AAEH,eAAO,MAAM,UAAU,GAAU,QAAQ,MAAM,EAAE,UAAU;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAAG,OAAO,CAAC,yBAAyB,CAajH,CAAC;AAEF;;;;GAIG;AAEH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAU7D;AAED;;;;GAIG;AAEH,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CASrE;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,EACd,UAAS;IAAE,KAAK,CAAC,EAAE,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAA;CAK/G,KACA,OAAO,CAAC,aAAa,EAAE,CAgDzB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { CryptoBarsParams, CryptoBar, AlpacaNewsArticle } 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
+ export {};
46
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAsB,SAAS,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAKlH;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;CAAE,CAAC,CAgEpG;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE;IACN,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAqE9B"}
@@ -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;IAqCvD;;OAEG;IACH,OAAO,CAAC,cAAc;IA2BtB;;OAEG;IACH,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,WAAW;IAIZ,WAAW,IAAI,IAAI;IAKnB,aAAa,IAAI,IAAI;CAG7B"}
@@ -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,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,GAAE,MAAU,GAAG,MAAM,CAQjF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAYhD"}