@discomedia/utils 1.0.76 → 1.0.78

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 (86) hide show
  1. package/dist/index-frontend.cjs +2024 -15229
  2. package/dist/index-frontend.cjs.map +7 -1
  3. package/dist/index-frontend.mjs +1985 -15219
  4. package/dist/index-frontend.mjs.map +7 -1
  5. package/dist/index.cjs +5368 -24346
  6. package/dist/index.cjs.map +7 -1
  7. package/dist/index.mjs +5326 -24333
  8. package/dist/index.mjs.map +7 -1
  9. package/dist/package.json +10 -11
  10. package/dist/test.mjs +1977 -0
  11. package/dist/test.mjs.map +7 -0
  12. package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
  13. package/dist/types/alpaca-trading-api.d.ts.map +1 -1
  14. package/dist/types/index-frontend.d.ts +2 -1
  15. package/dist/types/index-frontend.d.ts.map +1 -1
  16. package/dist/types/index.d.ts +7 -4
  17. package/dist/types/index.d.ts.map +1 -1
  18. package/dist/types/llm-config.d.ts +4 -2
  19. package/dist/types/llm-config.d.ts.map +1 -1
  20. package/dist/types/llm-deepseek.d.ts.map +1 -1
  21. package/dist/types/llm-images.d.ts.map +1 -1
  22. package/dist/types/llm-openai.d.ts +7 -4
  23. package/dist/types/llm-openai.d.ts.map +1 -1
  24. package/dist/types/llm-openrouter.d.ts.map +1 -1
  25. package/dist/types/market-time.d.ts +1 -1
  26. package/dist/types/market-time.d.ts.map +1 -1
  27. package/dist/types/misc-utils.d.ts +1 -1
  28. package/dist/types/misc-utils.d.ts.map +1 -1
  29. package/dist/types/performance-timer.d.ts.map +1 -1
  30. package/dist/types/types/llm-types.d.ts +8 -5
  31. package/dist/types/types/llm-types.d.ts.map +1 -1
  32. package/package.json +10 -11
  33. package/dist/test.js +0 -17459
  34. package/dist/test.js.map +0 -1
  35. package/dist/types-frontend/alpaca-market-data-api.d.ts +0 -451
  36. package/dist/types-frontend/alpaca-market-data-api.d.ts.map +0 -1
  37. package/dist/types-frontend/alpaca-trading-api.d.ts +0 -407
  38. package/dist/types-frontend/alpaca-trading-api.d.ts.map +0 -1
  39. package/dist/types-frontend/format-tools.d.ts +0 -46
  40. package/dist/types-frontend/format-tools.d.ts.map +0 -1
  41. package/dist/types-frontend/index-frontend.d.ts +0 -18
  42. package/dist/types-frontend/index-frontend.d.ts.map +0 -1
  43. package/dist/types-frontend/index.d.ts +0 -59
  44. package/dist/types-frontend/index.d.ts.map +0 -1
  45. package/dist/types-frontend/json-tools.d.ts +0 -31
  46. package/dist/types-frontend/json-tools.d.ts.map +0 -1
  47. package/dist/types-frontend/llm-config.d.ts +0 -51
  48. package/dist/types-frontend/llm-config.d.ts.map +0 -1
  49. package/dist/types-frontend/llm-deepseek.d.ts +0 -12
  50. package/dist/types-frontend/llm-deepseek.d.ts.map +0 -1
  51. package/dist/types-frontend/llm-images.d.ts +0 -52
  52. package/dist/types-frontend/llm-images.d.ts.map +0 -1
  53. package/dist/types-frontend/llm-openai.d.ts +0 -79
  54. package/dist/types-frontend/llm-openai.d.ts.map +0 -1
  55. package/dist/types-frontend/llm-openrouter.d.ts +0 -28
  56. package/dist/types-frontend/llm-openrouter.d.ts.map +0 -1
  57. package/dist/types-frontend/llm-utils.d.ts +0 -16
  58. package/dist/types-frontend/llm-utils.d.ts.map +0 -1
  59. package/dist/types-frontend/logging.d.ts +0 -12
  60. package/dist/types-frontend/logging.d.ts.map +0 -1
  61. package/dist/types-frontend/market-hours.d.ts +0 -24
  62. package/dist/types-frontend/market-hours.d.ts.map +0 -1
  63. package/dist/types-frontend/market-time.d.ts +0 -270
  64. package/dist/types-frontend/market-time.d.ts.map +0 -1
  65. package/dist/types-frontend/misc-utils.d.ts +0 -43
  66. package/dist/types-frontend/misc-utils.d.ts.map +0 -1
  67. package/dist/types-frontend/performance-timer.d.ts +0 -73
  68. package/dist/types-frontend/performance-timer.d.ts.map +0 -1
  69. package/dist/types-frontend/test.d.ts +0 -2
  70. package/dist/types-frontend/test.d.ts.map +0 -1
  71. package/dist/types-frontend/testing/market-time-refactor-test.d.ts +0 -1
  72. package/dist/types-frontend/testing/market-time-refactor-test.d.ts.map +0 -1
  73. package/dist/types-frontend/types/alpaca-crypto-pairs.d.ts +0 -11
  74. package/dist/types-frontend/types/alpaca-crypto-pairs.d.ts.map +0 -1
  75. package/dist/types-frontend/types/alpaca-types.d.ts +0 -1181
  76. package/dist/types-frontend/types/alpaca-types.d.ts.map +0 -1
  77. package/dist/types-frontend/types/index.d.ts +0 -6
  78. package/dist/types-frontend/types/index.d.ts.map +0 -1
  79. package/dist/types-frontend/types/llm-types.d.ts +0 -174
  80. package/dist/types-frontend/types/llm-types.d.ts.map +0 -1
  81. package/dist/types-frontend/types/logging-types.d.ts +0 -10
  82. package/dist/types-frontend/types/logging-types.d.ts.map +0 -1
  83. package/dist/types-frontend/types/market-time-types.d.ts +0 -64
  84. package/dist/types-frontend/types/market-time-types.d.ts.map +0 -1
  85. package/dist/types-frontend/types/ta-types.d.ts +0 -89
  86. package/dist/types-frontend/types/ta-types.d.ts.map +0 -1
@@ -1,407 +0,0 @@
1
- import { AlpacaAccountDetails, AlpacaCredentials, AlpacaPosition, AssetClass, GetOptionContractsParams, GetOrdersParams, OptionAccountActivity, OptionContract, OptionContractsResponse, AlpacaOrder, OrderLeg, TradeUpdate, PortfolioHistoryResponse, EquitiesTradeOptions } 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
- Portfolio History examples
11
- // Get standard portfolio history
12
- const portfolioHistory = await alpacaAPI.getPortfolioHistory({
13
- timeframe: '1D',
14
- period: '1M'
15
- });
16
-
17
- // Get daily portfolio history with current day included (if available from hourly data)
18
- const dailyHistory = await alpacaAPI.getPortfolioDailyHistory({
19
- period: '1M'
20
- });
21
- */
22
- export declare class AlpacaTradingAPI {
23
- static new(credentials: AlpacaCredentials): AlpacaTradingAPI;
24
- static getInstance(credentials: AlpacaCredentials): AlpacaTradingAPI;
25
- private ws;
26
- private headers;
27
- private tradeUpdateCallback;
28
- private credentials;
29
- private apiBaseUrl;
30
- private wsUrl;
31
- private authenticated;
32
- private connecting;
33
- private reconnectDelay;
34
- private reconnectTimeout;
35
- private messageHandlers;
36
- private debugLogging;
37
- private manualDisconnect;
38
- /**
39
- * Constructor for AlpacaTradingAPI
40
- * @param credentials - Alpaca credentials,
41
- * accountName: string; // The account identifier used inthis.logs and tracking
42
- * apiKey: string; // Alpaca API key
43
- * apiSecret: string; // Alpaca API secret
44
- * type: AlpacaAccountType;
45
- * orderType: AlpacaOrderType;
46
- * @param options - Optional options
47
- * debugLogging: boolean; // Whether to log messages of type 'debug'
48
- */
49
- constructor(credentials: AlpacaCredentials, options?: {
50
- debugLogging?: boolean;
51
- });
52
- private log;
53
- /**
54
- * Round a price to the nearest 2 decimal places for Alpaca, or 4 decimal places for prices less than $1
55
- * @param price - The price to round
56
- * @returns The rounded price
57
- */
58
- private roundPriceForAlpaca;
59
- private isJsonObject;
60
- private parseAlpacaAPIErrorResponse;
61
- private formatJsonValueForLog;
62
- private formatAlpacaAPIErrorDetails;
63
- private formatRequestAction;
64
- private buildAlpacaAPIErrorMessage;
65
- private buildRequestExecutionErrorMessage;
66
- private handleAuthMessage;
67
- private handleListenMessage;
68
- private handleTradeUpdate;
69
- private handleMessage;
70
- connectWebsocket(): void;
71
- /**
72
- * Cleanly disconnect from the WebSocket and stop auto-reconnects
73
- */
74
- disconnect(): void;
75
- private authenticate;
76
- private subscribeToTradeUpdates;
77
- private makeRequest;
78
- getPositions(assetClass?: AssetClass): Promise<AlpacaPosition[]>;
79
- /**
80
- * Get all orders
81
- * @param params (GetOrdersParams) - optional parameters to filter the orders
82
- * - status: 'open' | 'closed' | 'all'
83
- * - limit: number
84
- * - after: string
85
- * - until: string
86
- * - direction: 'asc' | 'desc'
87
- * - nested: boolean
88
- * - symbols: string[], an array of all the symbols
89
- * - side: 'buy' | 'sell'
90
- * @returns all orders
91
- */
92
- getOrders(params?: GetOrdersParams): Promise<AlpacaOrder[]>;
93
- getAccountDetails(): Promise<AlpacaAccountDetails>;
94
- /**
95
- * Create a trailing stop order
96
- * @param symbol (string) - the symbol of the order
97
- * @param qty (number) - the quantity of the order
98
- * @param side (string) - the side of the order
99
- * @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
100
- * @param position_intent (string) - the position intent of the order
101
- * @param client_order_id (string) - optional client order id
102
- * @returns The created trailing stop order
103
- */
104
- createTrailingStop(symbol: string, qty: number, side: 'buy' | 'sell', trailPercent100: number, position_intent: 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close', client_order_id?: string): Promise<AlpacaOrder>;
105
- /**
106
- * Create a stop order (stop or stop-limit)
107
- * @param symbol (string) - the symbol of the order
108
- * @param qty (number) - the quantity of the order
109
- * @param side (string) - the side of the order
110
- * @param stopPrice (number) - the stop price that triggers the order
111
- * @param position_intent (string) - the position intent of the order
112
- * @param limitPrice (number) - optional limit price (if provided, creates a stop-limit order)
113
- * @param client_order_id (string) - optional client order id
114
- * @returns The created stop order
115
- */
116
- createStopOrder(symbol: string, qty: number, side: 'buy' | 'sell', stopPrice: number, position_intent: 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close', limitPrice?: number, client_order_id?: string): Promise<AlpacaOrder>;
117
- /**
118
- * Create a market order
119
- * @param symbol (string) - the symbol of the order
120
- * @param qty (number) - the quantity of the order
121
- * @param side (string) - the side of the order
122
- * @param position_intent (string) - the position intent of the order. Important for knowing if a position needs a trailing stop.
123
- * @param client_order_id (string) - optional client order id
124
- */
125
- 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>;
126
- /**
127
- * Create a Market on Open (MOO) order - executes in the opening auction
128
- *
129
- * IMPORTANT TIMING CONSTRAINTS:
130
- * - Valid submission window: After 7:00pm ET and before 9:28am ET
131
- * - Orders submitted between 9:28am and 7:00pm ET will be REJECTED
132
- * - Orders submitted after 7:00pm ET are queued for the next trading day's opening auction
133
- * - Example: An order at 8:00pm Monday will execute at Tuesday's market open (9:30am)
134
- *
135
- * @param symbol - The symbol of the order
136
- * @param qty - The quantity of shares
137
- * @param side - Buy or sell
138
- * @param position_intent - The position intent (buy_to_open, sell_to_close, etc.)
139
- * @param client_order_id - Optional client order id
140
- * @returns The created order
141
- */
142
- createMOOOrder(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>;
143
- /**
144
- * Create a Market on Close (MOC) order - executes in the closing auction
145
- *
146
- * IMPORTANT TIMING CONSTRAINTS:
147
- * - Valid submission window: After 7:00pm ET (previous day) and before 3:50pm ET (same day)
148
- * - Orders submitted between 3:50pm and 7:00pm ET will be REJECTED
149
- * - Orders submitted after 7:00pm ET are queued for the next trading day's closing auction
150
- * - Example: An order at 8:00pm Monday will execute at Tuesday's market close (4:00pm)
151
- *
152
- * @param symbol - The symbol of the order
153
- * @param qty - The quantity of shares
154
- * @param side - Buy or sell
155
- * @param position_intent - The position intent (buy_to_open, sell_to_close, etc.)
156
- * @param client_order_id - Optional client order id
157
- * @returns The created order
158
- */
159
- createMOCOrder(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>;
160
- /**
161
- * Create an OCO (One-Cancels-Other) order with take profit and stop loss
162
- * @param symbol (string) - the symbol of the order
163
- * @param qty (number) - the quantity of the order
164
- * @param side (string) - the side of the order (buy or sell)
165
- * @param position_intent (string) - the position intent of the order
166
- * @param limitPrice (number) - the limit price for the entry order (OCO orders must be limit orders)
167
- * @param takeProfitPrice (number) - the take profit price
168
- * @param stopLossPrice (number) - the stop loss price
169
- * @param stopLossLimitPrice (number) - optional limit price for stop loss (creates stop-limit instead of stop)
170
- * @param client_order_id (string) - optional client order id
171
- * @returns The created OCO order
172
- */
173
- createOCOOrder(symbol: string, qty: number, side: 'buy' | 'sell', position_intent: 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close', limitPrice: number, takeProfitPrice: number, stopLossPrice: number, stopLossLimitPrice?: number, client_order_id?: string): Promise<AlpacaOrder>;
174
- /**
175
- * 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.
176
- * @param symbol (string) - the symbol of the order
177
- * @returns the current trail percent
178
- */
179
- getCurrentTrailPercent(symbol: string): Promise<number | null>;
180
- /**
181
- * Update the trail percent for a trailing stop order
182
- * @param symbol (string) - the symbol of the order
183
- * @param trailPercent100 (number) - the trail percent of the order (scale 100, i.e. 0.5 = 0.5%)
184
- */
185
- updateTrailingStop(symbol: string, trailPercent100: number): Promise<void>;
186
- /**
187
- * Cancel all open orders
188
- */
189
- cancelAllOrders(): Promise<void>;
190
- /**
191
- * Cancel a specific order by its ID
192
- * @param orderId The id of the order to cancel
193
- * @throws Error if the order is not cancelable (status 422) or if the order doesn't exist
194
- * @returns Promise that resolves when the order is successfully canceled
195
- */
196
- cancelOrder(orderId: string): Promise<void>;
197
- /**
198
- * Create a limit order
199
- * @param symbol (string) - the symbol of the order
200
- * @param qty (number) - the quantity of the order
201
- * @param side (string) - the side of the order
202
- * @param limitPrice (number) - the limit price of the order
203
- * @param position_intent (string) - the position intent of the order
204
- * @param extended_hours (boolean) - whether the order is in extended hours
205
- * @param client_order_id (string) - the client order id of the order
206
- */
207
- 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>;
208
- /**
209
- * Close all equities positions
210
- * @param options (object) - the options for closing the positions
211
- * - cancel_orders (boolean) - whether to cancel related orders
212
- * - useLimitOrders (boolean) - whether to use limit orders to close the positions
213
- */
214
- closeAllPositions(options?: {
215
- cancel_orders: boolean;
216
- useLimitOrders: boolean;
217
- }): Promise<void>;
218
- /**
219
- * Close all equities positions using limit orders during extended hours trading
220
- * @param cancelOrders Whether to cancel related orders (default: true)
221
- * @returns Promise that resolves when all positions are closed
222
- */
223
- closeAllPositionsAfterHours(): Promise<void>;
224
- onTradeUpdate(callback: (update: TradeUpdate) => void): void;
225
- /**
226
- * Get portfolio history for the account
227
- * @param params Parameters for the portfolio history request
228
- * @returns Portfolio history data
229
- */
230
- getPortfolioHistory(params: {
231
- timeframe?: '1Min' | '5Min' | '15Min' | '1H' | '1D';
232
- period?: string;
233
- start?: string;
234
- end?: string;
235
- extended_hours?: boolean;
236
- date_end?: string;
237
- }): Promise<PortfolioHistoryResponse>;
238
- /**
239
- * Get portfolio daily history for the account, ensuring the most recent day is included
240
- * by combining daily and hourly history if needed.
241
- *
242
- * This function performs two API calls:
243
- * 1. Retrieves daily portfolio history
244
- * 2. Retrieves hourly portfolio history to check for more recent data
245
- *
246
- * If hourly history has timestamps more recent than the last timestamp in daily history,
247
- * it appends one additional day to the daily history using the most recent hourly values.
248
- *
249
- * @param params Parameters for the portfolio history request (same as getPortfolioHistory except timeframe is forced to '1D')
250
- * @returns Portfolio history data with daily timeframe, including the most recent day if available from hourly data
251
- */
252
- getPortfolioDailyHistory(params: {
253
- period?: string;
254
- start?: string;
255
- end?: string;
256
- extended_hours?: boolean;
257
- date_end?: string;
258
- }): Promise<PortfolioHistoryResponse>;
259
- /**
260
- * Get option contracts based on specified parameters
261
- * @param params Parameters to filter option contracts
262
- * @returns Option contracts matching the criteria
263
- */
264
- getOptionContracts(params: GetOptionContractsParams): Promise<OptionContractsResponse>;
265
- /**
266
- * Get a specific option contract by symbol or ID
267
- * @param symbolOrId The symbol or ID of the option contract
268
- * @returns The option contract details
269
- */
270
- getOptionContract(symbolOrId: string): Promise<OptionContract>;
271
- /**
272
- * Create a simple option order (market or limit)
273
- * @param symbol Option contract symbol
274
- * @param qty Quantity of contracts (must be a whole number)
275
- * @param side Buy or sell
276
- * @param position_intent Position intent (buy_to_open, buy_to_close, sell_to_open, sell_to_close)
277
- * @param type Order type (market or limit)
278
- * @param limitPrice Limit price (required for limit orders)
279
- * @returns The created order
280
- */
281
- 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>;
282
- /**
283
- * Create a multi-leg option order
284
- * @param legs Array of order legs
285
- * @param qty Quantity of the multi-leg order (must be a whole number)
286
- * @param type Order type (market or limit)
287
- * @param limitPrice Limit price (required for limit orders)
288
- * @returns The created multi-leg order
289
- */
290
- createMultiLegOptionOrder(legs: OrderLeg[], qty: number, type: 'market' | 'limit', limitPrice?: number): Promise<AlpacaOrder>;
291
- /**
292
- * Exercise an option contract
293
- * @param symbolOrContractId The symbol or ID of the option contract to exercise
294
- * @returns Response from the exercise request
295
- */
296
- exerciseOption(symbolOrContractId: string): Promise<null>;
297
- /**
298
- * Get option positions
299
- * @returns Array of option positions
300
- */
301
- getOptionPositions(): Promise<AlpacaPosition[]>;
302
- getOptionsOpenSpreadTrades(): Promise<void>;
303
- /**
304
- * Get option account activities (exercises, assignments, expirations)
305
- * @param activityType Type of option activity to filter by
306
- * @param date Date to filter activities (YYYY-MM-DD format)
307
- * @returns Array of option account activities
308
- */
309
- getOptionActivities(activityType?: 'OPEXC' | 'OPASN' | 'OPEXP', date?: string): Promise<OptionAccountActivity[]>;
310
- /**
311
- * Create a long call spread (buy lower strike call, sell higher strike call)
312
- * @param lowerStrikeCallSymbol Symbol of the lower strike call option
313
- * @param higherStrikeCallSymbol Symbol of the higher strike call option
314
- * @param qty Quantity of spreads to create (must be a whole number)
315
- * @param limitPrice Limit price for the spread
316
- * @returns The created multi-leg order
317
- */
318
- createLongCallSpread(lowerStrikeCallSymbol: string, higherStrikeCallSymbol: string, qty: number, limitPrice: number): Promise<AlpacaOrder>;
319
- /**
320
- * Create a long put spread (buy higher strike put, sell lower strike put)
321
- * @param higherStrikePutSymbol Symbol of the higher strike put option
322
- * @param lowerStrikePutSymbol Symbol of the lower strike put option
323
- * @param qty Quantity of spreads to create (must be a whole number)
324
- * @param limitPrice Limit price for the spread
325
- * @returns The created multi-leg order
326
- */
327
- createLongPutSpread(higherStrikePutSymbol: string, lowerStrikePutSymbol: string, qty: number, limitPrice: number): Promise<AlpacaOrder>;
328
- /**
329
- * Create an iron condor (sell call spread and put spread)
330
- * @param longPutSymbol Symbol of the lower strike put (long)
331
- * @param shortPutSymbol Symbol of the higher strike put (short)
332
- * @param shortCallSymbol Symbol of the lower strike call (short)
333
- * @param longCallSymbol Symbol of the higher strike call (long)
334
- * @param qty Quantity of iron condors to create (must be a whole number)
335
- * @param limitPrice Limit price for the iron condor (credit)
336
- * @returns The created multi-leg order
337
- */
338
- createIronCondor(longPutSymbol: string, shortPutSymbol: string, shortCallSymbol: string, longCallSymbol: string, qty: number, limitPrice: number): Promise<AlpacaOrder>;
339
- /**
340
- * Create a covered call (sell call option against owned stock)
341
- * @param stockSymbol Symbol of the underlying stock
342
- * @param callOptionSymbol Symbol of the call option to sell
343
- * @param qty Quantity of covered calls to create (must be a whole number)
344
- * @param limitPrice Limit price for the call option
345
- * @returns The created order
346
- */
347
- createCoveredCall(stockSymbol: string, callOptionSymbol: string, qty: number, limitPrice: number): Promise<AlpacaOrder>;
348
- /**
349
- * Roll an option position to a new expiration or strike
350
- * @param currentOptionSymbol Symbol of the current option position
351
- * @param newOptionSymbol Symbol of the new option to roll to
352
- * @param qty Quantity of options to roll (must be a whole number)
353
- * @param currentPositionSide Side of the current position ('buy' or 'sell')
354
- * @param limitPrice Net limit price for the roll
355
- * @returns The created multi-leg order
356
- */
357
- rollOptionPosition(currentOptionSymbol: string, newOptionSymbol: string, qty: number, currentPositionSide: 'buy' | 'sell', limitPrice: number): Promise<AlpacaOrder>;
358
- /**
359
- * Get option chain for a specific underlying symbol and expiration date
360
- * @param underlyingSymbol The underlying stock symbol
361
- * @param expirationDate The expiration date (YYYY-MM-DD format)
362
- * @returns Option contracts for the specified symbol and expiration date
363
- */
364
- getOptionChain(underlyingSymbol: string, expirationDate: string): Promise<OptionContract[]>;
365
- /**
366
- * Get all available expiration dates for a specific underlying symbol
367
- * @param underlyingSymbol The underlying stock symbol
368
- * @returns Array of available expiration dates
369
- */
370
- getOptionExpirationDates(underlyingSymbol: string): Promise<string[]>;
371
- /**
372
- * Get the current options trading level for the account
373
- * @returns The options trading level (0-3)
374
- */
375
- getOptionsTradingLevel(): Promise<number>;
376
- /**
377
- * Check if the account has options trading enabled
378
- * @returns Boolean indicating if options trading is enabled
379
- */
380
- isOptionsEnabled(): Promise<boolean>;
381
- /**
382
- * Close all option positions
383
- * @param cancelOrders Whether to cancel related orders (default: true)
384
- * @returns Response from the close positions request
385
- */
386
- closeAllOptionPositions(cancelOrders?: boolean): Promise<void>;
387
- /**
388
- * Close a specific option position
389
- * @param symbol The option contract symbol
390
- * @param qty Optional quantity to close (defaults to entire position)
391
- * @returns The created order
392
- */
393
- closeOptionPosition(symbol: string, qty?: number): Promise<AlpacaOrder>;
394
- /**
395
- * Create a complete equities trade with optional stop loss and take profit
396
- * @param params Trade parameters including symbol, qty, side, and optional referencePrice
397
- * @param options Trade options including order type, extended hours, stop loss, and take profit settings
398
- * @returns The created order
399
- */
400
- createEquitiesTrade(params: {
401
- symbol: string;
402
- qty: number;
403
- side: 'buy' | 'sell';
404
- referencePrice?: number;
405
- }, options?: EquitiesTradeOptions): Promise<AlpacaOrder>;
406
- }
407
- //# sourceMappingURL=alpaca-trading-api.d.ts.map
@@ -1 +0,0 @@
1
- {"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;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,oBAAoB,GAC7B,OAAO,CAAC,WAAW,CAAC;CAgKxB"}
@@ -1,46 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,18 +0,0 @@
1
- import * as Types from './types';
2
- import * as llm from './llm-openai';
3
- import * as llmImages from './llm-images';
4
- import * as time from './market-time';
5
- export * from './types';
6
- export { supportsTemperature, uploadVisionFile } from './llm-openai';
7
- export { OPENAI_MODELS, OPENROUTER_MODELS } from './types/llm-types';
8
- export declare const disco: {
9
- types: typeof Types;
10
- llm: {
11
- call: typeof llm.makeLLMCall;
12
- uploadVisionFile: typeof llm.uploadVisionFile;
13
- seek: <T = string>(content: string | import("openai/resources/index.mjs").ChatCompletionContentPart[], responseFormat?: Types.OpenAIResponseFormat, options?: Types.LLMOptions) => Promise<Types.LLMResponse<T>>;
14
- images: typeof llmImages.makeImagesCall;
15
- };
16
- time: typeof time;
17
- };
18
- //# sourceMappingURL=index-frontend.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-frontend.d.ts","sourceRoot":"","sources":["../../src/index-frontend.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAGtC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAErE,eAAO,MAAM,KAAK;;;;;;;;;CASjB,CAAC"}
@@ -1,59 +0,0 @@
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 llm from './llm-openai';
6
- import * as llmImages from './llm-images';
7
- import * as openrouter from './llm-openrouter';
8
- import { PerformanceTimer } from './performance-timer';
9
- export * from './types';
10
- export { AlpacaTradingAPI } from './alpaca-trading-api';
11
- export { AlpacaMarketDataAPI } from './alpaca-market-data-api';
12
- export { supportsTemperature, uploadVisionFile } from './llm-openai';
13
- export { OPENAI_IMAGE_MODELS, OPENAI_MODELS, OPENROUTER_MODELS } from './types/llm-types';
14
- export declare const disco: {
15
- types: typeof Types;
16
- alpaca: {
17
- TradingAPI: typeof Types.AlpacaTradingAPI;
18
- MarketDataAPI: typeof Types.AlpacaMarketDataAPI;
19
- };
20
- format: {
21
- capFirstLetter: typeof ft.capFirstLetter;
22
- currency: typeof ft.formatCurrency;
23
- number: typeof ft.formatNumber;
24
- pct: typeof ft.formatPercentage;
25
- dateTimeForGS: typeof ft.dateTimeForGS;
26
- };
27
- llm: {
28
- call: typeof llm.makeLLMCall;
29
- uploadVisionFile: typeof llm.uploadVisionFile;
30
- seek: <T = string>(content: string | import("openai/resources/index.mjs").ChatCompletionContentPart[], responseFormat?: Types.OpenAIResponseFormat, options?: Types.LLMOptions) => Promise<Types.LLMResponse<T>>;
31
- images: typeof llmImages.makeImagesCall;
32
- open: typeof openrouter.makeOpenRouterCall;
33
- };
34
- time: {
35
- convertDateToMarketTimeZone: typeof mt.convertDateToMarketTimeZone;
36
- getStartAndEndDates: typeof mt.getStartAndEndDates;
37
- getMarketOpenClose: typeof mt.getMarketOpenClose;
38
- getOpenCloseForTradingDay: typeof mt.getOpenCloseForTradingDay;
39
- getLastFullTradingDate: typeof mt.getLastFullTradingDate;
40
- getNextMarketDay: typeof mt.getNextMarketDay;
41
- getPreviousMarketDay: typeof mt.getPreviousMarketDay;
42
- getMarketTimePeriod: typeof mt.getMarketTimePeriod;
43
- getMarketStatus: typeof mt.getMarketStatus;
44
- getNYTimeZone: typeof mt.getNYTimeZone;
45
- getTradingDate: typeof mt.getTradingDate;
46
- getTradingStartAndEndDates: typeof mt.getTradingStartAndEndDates;
47
- getTradingDaysBack: typeof mt.getTradingDaysBack;
48
- isMarketDay: typeof mt.isMarketDay;
49
- isWithinMarketHours: typeof mt.isWithinMarketHours;
50
- countTradingDays: typeof mt.countTradingDays;
51
- MARKET_TIMES: Types.MarketTimesConfig;
52
- };
53
- utils: {
54
- logIfDebug: (message: string, data?: unknown, type?: "info" | "warn" | "error" | "debug" | "trace") => void;
55
- fetchWithRetry: typeof misc.fetchWithRetry;
56
- Timer: typeof PerformanceTimer;
57
- };
58
- };
59
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAOvD,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE1F,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CjB,CAAC"}
@@ -1,31 +0,0 @@
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 OpenAI to fix it.
23
- * If the model fails to return valid JSON, an error is thrown.
24
- * @param jsonStr - the broken JSON to fix
25
- * @param apiKey - the OpenAI API key to use, or undefined to use the value of the OPENAI_API_KEY environment variable
26
- * @returns the fixed JSON
27
- * @throws an error if the model fails to return valid JSON
28
- */
29
- export declare function fixJsonWithAI(jsonStr: string, apiKey?: string): Promise<JsonValue>;
30
- export {};
31
- //# sourceMappingURL=json-tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-tools.d.ts","sourceRoot":"","sources":["../../src/json-tools.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAoMxD;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;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA+BxF"}
@@ -1,51 +0,0 @@
1
- import type { ImageGenerateParams } from 'openai/resources/images';
2
- import type { OpenAIImageModel, OpenAIModel } from './types/llm-types';
3
- export declare const DEFAULT_MODEL: OpenAIModel;
4
- 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";
5
- interface AIModelCosts {
6
- [modelName: string]: {
7
- inputCost: number;
8
- outputCost: number;
9
- cacheHitCost?: number;
10
- };
11
- }
12
- /** Token costs in USD per 1M tokens. Last updated May 2026 from the OpenAI API pricing page. */
13
- export declare const openAiModelCosts: AIModelCosts;
14
- export declare const deepseekModelCosts: AIModelCosts;
15
- export type PricedOpenAIImageModel = 'gpt-image-2' | 'gpt-image-2-2026-04-21' | 'gpt-image-1.5' | 'gpt-image-1' | 'gpt-image-1-mini';
16
- export type OpenAIImagePricingQuality = 'low' | 'medium' | 'high';
17
- export type OpenAIImagePricingSize = '1024x1024' | '1024x1536' | '1536x1024';
18
- export declare const DEFAULT_IMAGE_PRICING_QUALITY: OpenAIImagePricingQuality;
19
- export declare const DEFAULT_IMAGE_PRICING_SIZE: OpenAIImagePricingSize;
20
- /**
21
- * Estimated image output costs in USD per image for common GPT Image sizes.
22
- * Last updated May 2026 from the OpenAI image generation guide. Text and image
23
- * input token costs for prompts and edit inputs are not included.
24
- */
25
- export declare const openAiImageCostByQualityAndSize: Record<PricedOpenAIImageModel, Record<OpenAIImagePricingQuality, Record<OpenAIImagePricingSize, number>>>;
26
- /** Default image output costs in USD per image for legacy callers. */
27
- export declare const openAiImageCosts: Record<PricedOpenAIImageModel, number>;
28
- /**
29
- * Calculates the cost of generating images using OpenAI's Images API.
30
- *
31
- * @param model The image generation model name.
32
- * @param imageCount The number of images generated.
33
- * @param quality The requested image quality.
34
- * @param size The requested image size.
35
- * @returns The cost of generating the images in USD.
36
- */
37
- export declare function calculateImageCost(model: OpenAIImageModel | string, imageCount: number, quality?: ImageGenerateParams['quality'], size?: ImageGenerateParams['size']): number;
38
- /**
39
- * Calculates the cost of calling a language model in USD based on the provider and model, tokens, and given costs per 1M tokens.
40
- *
41
- * @param provider The provider of the language model. Supported providers are 'openai' and 'deepseek'.
42
- * @param model The name of the language model. Supported models are listed in the `openAiModelCosts` and `deepseekModelCosts` objects.
43
- * @param inputTokens The number of input tokens passed to the language model.
44
- * @param outputTokens The number of output tokens generated by the language model.
45
- * @param reasoningTokens The number of output tokens generated by the language model for reasoning.
46
- * @param cacheHitTokens The number of input tokens billed at cached-input rates.
47
- * @returns The cost of calling the language model in USD.
48
- */
49
- export declare function calculateCost(provider: string, model: string, inputTokens: number, outputTokens: number, reasoningTokens?: number, cacheHitTokens?: number): number;
50
- export {};
51
- //# sourceMappingURL=llm-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"llm-config.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