@discomedia/utils 1.0.6 → 1.0.8

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 (80) hide show
  1. package/README.md +95 -3
  2. package/dist/index-frontend.cjs +16027 -0
  3. package/dist/index-frontend.cjs.map +1 -0
  4. package/dist/index-frontend.mjs +16023 -0
  5. package/dist/index-frontend.mjs.map +1 -0
  6. package/dist/index.cjs +558 -10
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.mjs +558 -10
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/package.json +7 -1
  11. package/dist/test.js +6426 -582
  12. package/dist/test.js.map +1 -1
  13. package/dist/types/alpaca-market-data-api.d.ts +1 -0
  14. package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
  15. package/dist/types/alpaca-trading-api.d.ts.map +1 -1
  16. package/dist/types/index-frontend.d.ts +15 -0
  17. package/dist/types/index-frontend.d.ts.map +1 -0
  18. package/dist/types/index.d.ts +1 -0
  19. package/dist/types/index.d.ts.map +1 -1
  20. package/dist/types/old-test.d.ts +2 -0
  21. package/dist/types/old-test.d.ts.map +1 -0
  22. package/dist/types-frontend/alpaca-market-data-api.d.ts +372 -0
  23. package/dist/types-frontend/alpaca-market-data-api.d.ts.map +1 -0
  24. package/dist/types-frontend/alpaca-trading-api.d.ts +315 -0
  25. package/dist/types-frontend/alpaca-trading-api.d.ts.map +1 -0
  26. package/dist/types-frontend/format-tools.d.ts +46 -0
  27. package/dist/types-frontend/format-tools.d.ts.map +1 -0
  28. package/dist/types-frontend/index-frontend.d.ts +15 -0
  29. package/dist/types-frontend/index-frontend.d.ts.map +1 -0
  30. package/dist/types-frontend/index.d.ts +126 -0
  31. package/dist/types-frontend/index.d.ts.map +1 -0
  32. package/dist/types-frontend/json-tools.d.ts +33 -0
  33. package/dist/types-frontend/json-tools.d.ts.map +1 -0
  34. package/dist/types-frontend/llm-config.d.ts +36 -0
  35. package/dist/types-frontend/llm-config.d.ts.map +1 -0
  36. package/dist/types-frontend/llm-deepseek.d.ts +12 -0
  37. package/dist/types-frontend/llm-deepseek.d.ts.map +1 -0
  38. package/dist/types-frontend/llm-images.d.ts +49 -0
  39. package/dist/types-frontend/llm-images.d.ts.map +1 -0
  40. package/dist/types-frontend/llm-openai.d.ts +64 -0
  41. package/dist/types-frontend/llm-openai.d.ts.map +1 -0
  42. package/dist/types-frontend/llm-utils.d.ts +16 -0
  43. package/dist/types-frontend/llm-utils.d.ts.map +1 -0
  44. package/dist/types-frontend/logging.d.ts +12 -0
  45. package/dist/types-frontend/logging.d.ts.map +1 -0
  46. package/dist/types-frontend/market-hours.d.ts +24 -0
  47. package/dist/types-frontend/market-hours.d.ts.map +1 -0
  48. package/dist/types-frontend/market-time.d.ts +254 -0
  49. package/dist/types-frontend/market-time.d.ts.map +1 -0
  50. package/dist/types-frontend/misc-utils.d.ts +49 -0
  51. package/dist/types-frontend/misc-utils.d.ts.map +1 -0
  52. package/dist/types-frontend/old-test.d.ts +2 -0
  53. package/dist/types-frontend/old-test.d.ts.map +1 -0
  54. package/dist/types-frontend/polygon-indices.d.ts +85 -0
  55. package/dist/types-frontend/polygon-indices.d.ts.map +1 -0
  56. package/dist/types-frontend/polygon.d.ts +126 -0
  57. package/dist/types-frontend/polygon.d.ts.map +1 -0
  58. package/dist/types-frontend/technical-analysis.d.ts +90 -0
  59. package/dist/types-frontend/technical-analysis.d.ts.map +1 -0
  60. package/dist/types-frontend/test.d.ts +2 -0
  61. package/dist/types-frontend/test.d.ts.map +1 -0
  62. package/dist/types-frontend/testing/market-time-refactor-test.d.ts +1 -0
  63. package/dist/types-frontend/testing/market-time-refactor-test.d.ts.map +1 -0
  64. package/dist/types-frontend/types/alpaca-types.d.ts +962 -0
  65. package/dist/types-frontend/types/alpaca-types.d.ts.map +1 -0
  66. package/dist/types-frontend/types/index.d.ts +7 -0
  67. package/dist/types-frontend/types/index.d.ts.map +1 -0
  68. package/dist/types-frontend/types/llm-types.d.ts +82 -0
  69. package/dist/types-frontend/types/llm-types.d.ts.map +1 -0
  70. package/dist/types-frontend/types/logging-types.d.ts +10 -0
  71. package/dist/types-frontend/types/logging-types.d.ts.map +1 -0
  72. package/dist/types-frontend/types/market-time-types.d.ts +59 -0
  73. package/dist/types-frontend/types/market-time-types.d.ts.map +1 -0
  74. package/dist/types-frontend/types/polygon-indices-types.d.ts +190 -0
  75. package/dist/types-frontend/types/polygon-indices-types.d.ts.map +1 -0
  76. package/dist/types-frontend/types/polygon-types.d.ts +204 -0
  77. package/dist/types-frontend/types/polygon-types.d.ts.map +1 -0
  78. package/dist/types-frontend/types/ta-types.d.ts +89 -0
  79. package/dist/types-frontend/types/ta-types.d.ts.map +1 -0
  80. package/package.json +7 -1
@@ -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":"AAEA,OAAO,EACL,o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AC,EAAE,MAAM,CAAC;QAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GACA,OAAO,CAAC,WAAW,CAAC;CAqKxB"}
@@ -0,0 +1,46 @@
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 capFirstLetter(str: string): string;
10
+ /**
11
+ * Formats a number as US currency
12
+ * @param {number} value - The number to format
13
+ * @returns {string} The formatted currency string (e.g. '$1,234.56')
14
+ * @example
15
+ * formatCurrency(1234.56) // '$1,234.56'
16
+ * formatCurrency(NaN) // '$0.00'
17
+ */
18
+ export declare function formatCurrency(value: number): string;
19
+ /**
20
+ * Formats a number with commas
21
+ * @param {number} value - The number to format
22
+ * @returns {string} The formatted number string (e.g. '1,234.56')
23
+ * @example
24
+ * formatNumber(1234.56) // '1,234.56'
25
+ * formatNumber(NaN) // '0'
26
+ */
27
+ export declare function formatNumber(value: number): string;
28
+ /**
29
+ * Formats a number as a percentage
30
+ * @param {number} value - The number to format (e.g. 0.75 for 75%)
31
+ * @param {number} [decimalPlaces=2] - Number of decimal places to show
32
+ * @returns {string} The formatted percentage string (e.g. '75.00%')
33
+ * @example
34
+ * formatPercentage(0.75) // '75.00%'
35
+ * formatPercentage(0.753, 1) // '75.3%'
36
+ */
37
+ export declare function formatPercentage(value: number, decimalPlaces?: number): string;
38
+ /**
39
+ * Formats a Date object to Australian datetime format for Google Sheets
40
+ * @param {Date} date - The date to format
41
+ * @returns {string} The formatted datetime string in 'DD/MM/YYYY HH:MM:SS' format
42
+ * @example
43
+ * dateTimeForGS(new Date('2025-01-01T12:34:56')) // '01/01/2025 12:34:56'
44
+ */
45
+ export declare function dateTimeForGS(date: Date): string;
46
+ //# 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,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGlD;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"}
@@ -0,0 +1,15 @@
1
+ import * as Types from './types';
2
+ import * as llm from './llm-openai';
3
+ import * as llmImages from './llm-images';
4
+ export * from './types';
5
+ export { AlpacaTradingAPI } from './alpaca-trading-api';
6
+ export { AlpacaMarketDataAPI } from './alpaca-market-data-api';
7
+ export declare const disco: {
8
+ types: typeof Types;
9
+ llm: {
10
+ call: typeof llm.makeLLMCall;
11
+ seek: <T = any>(content: string | import("openai/resources/index").ChatCompletionContentPart[], responseFormat?: Types.OpenAIResponseFormat, options?: Types.LLMOptions) => Promise<Types.LLMResponse<T>>;
12
+ images: typeof llmImages.makeImagesCall;
13
+ };
14
+ };
15
+ //# sourceMappingURL=index-frontend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-frontend.d.ts","sourceRoot":"","sources":["../../src/index-frontend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAI1C,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,KAAK;;;;;;;CAOjB,CAAC"}
@@ -0,0 +1,126 @@
1
+ import * as mt from './market-time';
2
+ import * as ft from './format-tools';
3
+ import * as Types from './types';
4
+ import * as misc from './misc-utils';
5
+ import * as polygon from './polygon';
6
+ import * as llm from './llm-openai';
7
+ import * as llmImages from './llm-images';
8
+ import * as ta from './technical-analysis';
9
+ export * from './types';
10
+ export { AlpacaTradingAPI } from './alpaca-trading-api';
11
+ export { AlpacaMarketDataAPI } from './alpaca-market-data-api';
12
+ export declare const disco: {
13
+ types: typeof Types;
14
+ alpaca: {
15
+ TradingAPI: typeof Types.AlpacaTradingAPI;
16
+ MarketDataAPI: typeof Types.AlpacaMarketDataAPI;
17
+ };
18
+ format: {
19
+ capFirstLetter: typeof ft.capFirstLetter;
20
+ currency: typeof ft.formatCurrency;
21
+ number: typeof ft.formatNumber;
22
+ pct: typeof ft.formatPercentage;
23
+ dateTimeForGS: typeof ft.dateTimeForGS;
24
+ };
25
+ indices: {
26
+ fetchAggregates: (params: Types.PolygonIndicesAggregatesParams, options?: {
27
+ apiKey?: string;
28
+ }) => Promise<Types.PolygonIndicesAggregatesResponse>;
29
+ fetchPreviousClose: (indicesTicker: string, options?: {
30
+ apiKey?: string;
31
+ }) => Promise<Types.PolygonIndicesPrevCloseResponse>;
32
+ fetchDailyOpenClose: (indicesTicker: string, date: string, options?: {
33
+ apiKey?: string;
34
+ }) => Promise<Types.PolygonIndicesDailyOpenCloseResponse>;
35
+ fetchSnapshot: (params?: Types.PolygonIndicesSnapshotParams, options?: {
36
+ apiKey?: string;
37
+ }) => Promise<Types.PolygonIndicesSnapshotResponse>;
38
+ fetchUniversalSnapshot: (tickers: string[], options?: {
39
+ apiKey?: string;
40
+ type?: string;
41
+ order?: string;
42
+ limit?: number;
43
+ sort?: string;
44
+ }) => Promise<any>;
45
+ formatBarData: (data: Types.PolygonIndicesAggregatesResponse) => Array<{
46
+ date: string;
47
+ open: number;
48
+ high: number;
49
+ low: number;
50
+ close: number;
51
+ timestamp: number;
52
+ }>;
53
+ };
54
+ llm: {
55
+ call: typeof llm.makeLLMCall;
56
+ seek: <T = any>(content: string | import("openai/resources/index").ChatCompletionContentPart[], responseFormat?: Types.OpenAIResponseFormat, options?: Types.LLMOptions) => Promise<Types.LLMResponse<T>>;
57
+ images: typeof llmImages.makeImagesCall;
58
+ };
59
+ polygon: {
60
+ fetchTickerInfo: (symbol: string, options?: {
61
+ apiKey?: string;
62
+ }) => Promise<Types.PolygonTickerInfo | null>;
63
+ fetchGroupedDaily: (date: string, options?: {
64
+ apiKey?: string;
65
+ adjusted?: boolean;
66
+ includeOTC?: boolean;
67
+ }) => Promise<Types.PolygonGroupedDailyResponse>;
68
+ fetchLastTrade: (symbol: string, options?: {
69
+ apiKey?: string;
70
+ }) => Promise<Types.PolygonQuote>;
71
+ fetchTrades: (symbol: string, options?: {
72
+ apiKey?: string;
73
+ timestamp?: string | number;
74
+ timestampgt?: string | number;
75
+ timestampgte?: string | number;
76
+ timestamplt?: string | number;
77
+ timestamplte?: string | number;
78
+ order?: "asc" | "desc";
79
+ limit?: number;
80
+ sort?: string;
81
+ }) => Promise<Types.PolygonTradesResponse>;
82
+ fetchPrices: (params: {
83
+ ticker: string;
84
+ start: number;
85
+ end?: number;
86
+ multiplier: number;
87
+ timespan: string;
88
+ limit?: number;
89
+ }, options?: {
90
+ apiKey?: string;
91
+ }) => Promise<Types.PolygonPriceData[]>;
92
+ analysePolygonPriceData: typeof polygon.analysePolygonPriceData;
93
+ formatPriceData: typeof polygon.formatPriceData;
94
+ fetchDailyOpenClose: (symbol: string, date?: Date, options?: {
95
+ apiKey?: string;
96
+ adjusted?: boolean;
97
+ }) => Promise<Types.PolygonDailyOpenClose>;
98
+ getPreviousClose: typeof polygon.getPreviousClose;
99
+ };
100
+ ta: {
101
+ calculateEMA: typeof ta.calculateEMA;
102
+ calculateMACD: typeof ta.calculateMACD;
103
+ calculateRSI: typeof ta.calculateRSI;
104
+ calculateStochasticOscillator: typeof ta.calculateStochasticOscillator;
105
+ calculateBollingerBands: typeof ta.calculateBollingerBands;
106
+ calculateSupportAndResistance: typeof ta.calculateSupportAndResistance;
107
+ calculateFibonacciLevels: typeof ta.calculateFibonacciLevels;
108
+ };
109
+ time: {
110
+ getStartAndEndDates: typeof mt.getStartAndEndDates;
111
+ getMarketOpenClose: typeof mt.getMarketOpenClose;
112
+ getLastFullTradingDate: typeof mt.getLastFullTradingDate;
113
+ getNextMarketDay: typeof mt.getNextMarketDay;
114
+ getMarketStatus: typeof mt.getMarketStatus;
115
+ getNYTimeZone: typeof mt.getNYTimeZone;
116
+ getTradingDate: typeof mt.getTradingDate;
117
+ getTradingStartAndEndDates: typeof mt.getTradingStartAndEndDates;
118
+ MARKET_TIMES: Types.MarketTimesConfig;
119
+ };
120
+ utils: {
121
+ logIfDebug: (message: string, data?: unknown, type?: "info" | "warn" | "error" | "debug" | "trace") => void;
122
+ fetchWithRetry: typeof misc.fetchWithRetry;
123
+ validatePolygonApiKey: typeof misc.validatePolygonApiKey;
124
+ };
125
+ };
126
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAK3C,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;kBA6BX,CAAC;;;kBAkCkQ,CAAC;;;kBAA4zC,CAAC;;;kBAAkwC,CAAC;;;kBAAisD,CAAC;gBAAkB,CAAC;iBAAmB,CAAC;iBAAmB,CAAC;gBAAkB,CAAC;;;;;;;;;;;;;;;;;;kBA/CjlJ,CAAC;;;kBA+C2xS,CAAC;oBAAsB,CAAC;sBAAyB,CAAC;;;kBAAhxP,CAAC;;;kBAA6jc,CAAC;qBAAuB,CAAC;uBAAkC,CAAC;wBAAmC,CAAC;uBAAkC,CAAC;wBAAmC,CAAC;iBAA4B,CAAC;iBAA2B,CAAC;gBAAkB,CAAC;;;;;eAAjgX,CAAC;;;iBAAiE,CAAC;;kBAAmC,CAAC;;;;;kBAA65Q,CAAC;oBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CADn5Z,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Fix a broken JSON string by attempting to extract and parse valid JSON content. This function is very lenient and will attempt to fix many types of JSON errors, including unbalanced brackets, missing or extra commas, improperly escaped $ signs, unquoted strings, trailing commas, missing closing brackets or braces, etc.
3
+ * @param {string} jsonStr - The broken JSON string to fix
4
+ * @returns {JsonValue} - The parsed JSON value
5
+ */
6
+ export declare function fixBrokenJson(jsonStr: string): JsonValue;
7
+ /**
8
+ * Returns true if the given JSON string is valid, false otherwise.
9
+ *
10
+ * This function simply attempts to parse the given string as JSON and returns true if successful, or false if an error is thrown.
11
+ *
12
+ * @param {string} jsonString The JSON string to validate.
13
+ * @returns {boolean} True if the JSON string is valid, false otherwise.
14
+ */
15
+ export declare function isValidJson(jsonString: string): boolean;
16
+ interface JsonObject {
17
+ [key: string]: JsonValue;
18
+ }
19
+ type JsonArray = JsonValue[];
20
+ type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
21
+ /**
22
+ * Fixes broken JSON by sending it to the OpenAI GPT-4.1-mini model as a chat completion.
23
+ * The GPT-4.1-mini model is a large language model that can understand and generate code,
24
+ * including JSON. The returned JSON is the fixed version of the input JSON.
25
+ * If the model fails to return valid JSON, an error is thrown.
26
+ * @param jsonStr - the broken JSON to fix
27
+ * @param apiKey - the OpenAI API key to use, or undefined to use the value of the OPENAI_API_KEY environment variable
28
+ * @returns the fixed JSON
29
+ * @throws an error if the model fails to return valid JSON
30
+ */
31
+ export declare function fixJsonWithAI(jsonStr: string, apiKey?: string): Promise<JsonValue>;
32
+ export {};
33
+ //# sourceMappingURL=json-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-tools.d.ts","sourceRoot":"","sources":["../../src/json-tools.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAmMxD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAOvD;AAGD,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AACD,KAAK,SAAS,GAAG,SAAS,EAAE,CAAC;AAC7B,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,CAAC;AAqB3E;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA+BxF"}
@@ -0,0 +1,36 @@
1
+ export declare const DEFAULT_MODEL = "gpt-4.1-mini";
2
+ export declare const DEFAULT_DEVELOPER_PROMPT = "\n You are a highly experienced coding, business analyst, and financial analyst associate.\n Help with coding, business process design and analysis, data generation and refinement, content creation, financial analysis, and more.\n When presented with a coding problem, logic problem, or other problem benefiting from systematic thinking, think through it step by step before giving your final answer.\n Present complete, high-confidence, final answers only. Do not rephrase to be more brief or omit parts of answers.\n Respond only with final content (e.g. code, a json or yaml object, a formatted string, or a markdown document) and nothing else. Do not reply with a preamble, introduction, or conclusion.\n";
3
+ interface AIModelCosts {
4
+ [modelName: string]: {
5
+ inputCost: number;
6
+ outputCost: number;
7
+ cacheHitCost?: number;
8
+ };
9
+ }
10
+ /** Token costs in USD per 1M tokens. Last updated Feb 2025. */
11
+ export declare const openAiModelCosts: AIModelCosts;
12
+ export declare const deepseekModelCosts: AIModelCosts;
13
+ /** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
14
+ export declare const openAiImageCosts: Record<string, number>;
15
+ /**
16
+ * Calculates the cost of generating images using OpenAI's Images API.
17
+ *
18
+ * @param model The image generation model name.
19
+ * @param imageCount The number of images generated.
20
+ * @returns The cost of generating the images in USD.
21
+ */
22
+ export declare function calculateImageCost(model: string, imageCount: number): number;
23
+ /**
24
+ * Calculates the cost of calling a language model in USD based on the provider and model, tokens, and given costs per 1M tokens.
25
+ *
26
+ * @param provider The provider of the language model. Supported providers are 'openai' and 'deepseek'.
27
+ * @param model The name of the language model. Supported models are listed in the `openAiModelCosts` and `deepseekModelCosts` objects.
28
+ * @param inputTokens The number of input tokens passed to the language model.
29
+ * @param outputTokens The number of output tokens generated by the language model.
30
+ * @param reasoningTokens The number of output tokens generated by the language model for reasoning. This is only used for Deepseek models.
31
+ * @param cacheHitTokens The number of input tokens that were cache hits for Deepseek models.
32
+ * @returns The cost of calling the language model in USD.
33
+ */
34
+ export declare function calculateCost(provider: string, model: string, inputTokens: number, outputTokens: number, reasoningTokens?: number, cacheHitTokens?: number): number;
35
+ export {};
36
+ //# sourceMappingURL=llm-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-config.d.ts","sourceRoot":"","sources":["../../src/llm-config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,iBAAiB,CAAC;AAE5C,eAAO,MAAM,wBAAwB,wtBAMpC,CAAC;AAEF,UAAU,YAAY;IACpB,CAAC,SAAS,EAAE,MAAM,GAAG;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,EAAE,YAyC9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAWhC,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAEnD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAS5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,CA0BR"}
@@ -0,0 +1,12 @@
1
+ import { ChatCompletionContentPart } from 'openai/resources/chat';
2
+ import { LLMResponse, LLMOptions, OpenAIResponseFormat } from './types';
3
+ /**
4
+ * Makes a call to the Deepseek AI API.
5
+ *
6
+ * @param content The content to pass to the LLM. Can be a string or an array of content parts.
7
+ * @param responseFormat The format of the response. Defaults to 'json'.
8
+ * @param options Configuration options including model ('deepseek-chat' or 'deepseek-reasoner'), tools, and apiKey.
9
+ * @return A promise that resolves to the response from the Deepseek API.
10
+ */
11
+ export declare const makeDeepseekCall: <T = any>(content: string | ChatCompletionContentPart[], responseFormat?: OpenAIResponseFormat, options?: LLMOptions) => Promise<LLMResponse<T>>;
12
+ //# sourceMappingURL=llm-deepseek.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-deepseek.d.ts","sourceRoot":"","sources":["../../src/llm-deepseek.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EAG1B,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAe,oBAAoB,EAA2B,MAAM,SAAS,CAAC;AAyL9G;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAU,CAAC,GAAG,GAAG,EAC5C,SAAS,MAAM,GAAG,yBAAyB,EAAE,EAC7C,iBAAgB,oBAA6B,EAC7C,UAAS,UAAe,KACvB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAkIxB,CAAC"}