@adaptic/utils 0.0.383 → 0.1.0

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 (75) hide show
  1. package/dist/index.cjs +10241 -120
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.mjs +10057 -121
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/types/alpaca/client.d.ts +95 -0
  6. package/dist/types/alpaca/client.d.ts.map +1 -0
  7. package/dist/types/alpaca/crypto/data.d.ts +281 -0
  8. package/dist/types/alpaca/crypto/data.d.ts.map +1 -0
  9. package/dist/types/alpaca/crypto/index.d.ts +75 -0
  10. package/dist/types/alpaca/crypto/index.d.ts.map +1 -0
  11. package/dist/types/alpaca/crypto/orders.d.ts +221 -0
  12. package/dist/types/alpaca/crypto/orders.d.ts.map +1 -0
  13. package/dist/types/alpaca/index.d.ts +201 -0
  14. package/dist/types/alpaca/index.d.ts.map +1 -0
  15. package/dist/types/alpaca/market-data/bars.d.ts +142 -0
  16. package/dist/types/alpaca/market-data/bars.d.ts.map +1 -0
  17. package/dist/types/alpaca/market-data/index.d.ts +13 -0
  18. package/dist/types/alpaca/market-data/index.d.ts.map +1 -0
  19. package/dist/types/alpaca/market-data/news.d.ts +87 -0
  20. package/dist/types/alpaca/market-data/news.d.ts.map +1 -0
  21. package/dist/types/alpaca/market-data/quotes.d.ts +85 -0
  22. package/dist/types/alpaca/market-data/quotes.d.ts.map +1 -0
  23. package/dist/types/alpaca/market-data/trades.d.ts +98 -0
  24. package/dist/types/alpaca/market-data/trades.d.ts.map +1 -0
  25. package/dist/types/alpaca/options/contracts.d.ts +279 -0
  26. package/dist/types/alpaca/options/contracts.d.ts.map +1 -0
  27. package/dist/types/alpaca/options/data.d.ts +126 -0
  28. package/dist/types/alpaca/options/data.d.ts.map +1 -0
  29. package/dist/types/alpaca/options/index.d.ts +17 -0
  30. package/dist/types/alpaca/options/index.d.ts.map +1 -0
  31. package/dist/types/alpaca/options/orders.d.ts +366 -0
  32. package/dist/types/alpaca/options/orders.d.ts.map +1 -0
  33. package/dist/types/alpaca/options/strategies.d.ts +224 -0
  34. package/dist/types/alpaca/options/strategies.d.ts.map +1 -0
  35. package/dist/types/alpaca/streams/base-stream.d.ts +143 -0
  36. package/dist/types/alpaca/streams/base-stream.d.ts.map +1 -0
  37. package/dist/types/alpaca/streams/crypto-stream.d.ts +173 -0
  38. package/dist/types/alpaca/streams/crypto-stream.d.ts.map +1 -0
  39. package/dist/types/alpaca/streams/index.d.ts +54 -0
  40. package/dist/types/alpaca/streams/index.d.ts.map +1 -0
  41. package/dist/types/alpaca/streams/option-stream.d.ts +167 -0
  42. package/dist/types/alpaca/streams/option-stream.d.ts.map +1 -0
  43. package/dist/types/alpaca/streams/stock-stream.d.ts +176 -0
  44. package/dist/types/alpaca/streams/stock-stream.d.ts.map +1 -0
  45. package/dist/types/alpaca/streams/stream-manager.d.ts +277 -0
  46. package/dist/types/alpaca/streams/stream-manager.d.ts.map +1 -0
  47. package/dist/types/alpaca/streams/trading-stream.d.ts +186 -0
  48. package/dist/types/alpaca/streams/trading-stream.d.ts.map +1 -0
  49. package/dist/types/alpaca/streams.d.ts +88 -0
  50. package/dist/types/alpaca/streams.d.ts.map +1 -0
  51. package/dist/types/alpaca/test-imports.d.ts +7 -0
  52. package/dist/types/alpaca/test-imports.d.ts.map +1 -0
  53. package/dist/types/alpaca/trading/account.d.ts +198 -0
  54. package/dist/types/alpaca/trading/account.d.ts.map +1 -0
  55. package/dist/types/alpaca/trading/bracket-orders.d.ts +162 -0
  56. package/dist/types/alpaca/trading/bracket-orders.d.ts.map +1 -0
  57. package/dist/types/alpaca/trading/index.d.ts +13 -0
  58. package/dist/types/alpaca/trading/index.d.ts.map +1 -0
  59. package/dist/types/alpaca/trading/oco-orders.d.ts +203 -0
  60. package/dist/types/alpaca/trading/oco-orders.d.ts.map +1 -0
  61. package/dist/types/alpaca/trading/order-utils.d.ts +404 -0
  62. package/dist/types/alpaca/trading/order-utils.d.ts.map +1 -0
  63. package/dist/types/alpaca/trading/orders.d.ts +199 -0
  64. package/dist/types/alpaca/trading/orders.d.ts.map +1 -0
  65. package/dist/types/alpaca/trading/oto-orders.d.ts +282 -0
  66. package/dist/types/alpaca/trading/oto-orders.d.ts.map +1 -0
  67. package/dist/types/alpaca/trading/positions.d.ts +389 -0
  68. package/dist/types/alpaca/trading/positions.d.ts.map +1 -0
  69. package/dist/types/alpaca/trading/smart-orders.d.ts +301 -0
  70. package/dist/types/alpaca/trading/smart-orders.d.ts.map +1 -0
  71. package/dist/types/alpaca/trading/trailing-stops.d.ts +240 -0
  72. package/dist/types/alpaca/trading/trailing-stops.d.ts.map +1 -0
  73. package/dist/types/index.d.ts +353 -6
  74. package/dist/types/index.d.ts.map +1 -1
  75. package/package.json +4 -4
@@ -0,0 +1,87 @@
1
+ /**
2
+ * News Module
3
+ * Market news and analysis using Alpaca SDK
4
+ */
5
+ import { AlpacaClient } from '../client';
6
+ import { SimpleNews } from '../../types/alpaca-types';
7
+ /**
8
+ * Error thrown when news operations fail
9
+ */
10
+ export declare class NewsError extends Error {
11
+ code: string;
12
+ symbol?: string | undefined;
13
+ details?: unknown | undefined;
14
+ constructor(message: string, code: string, symbol?: string | undefined, details?: unknown | undefined);
15
+ }
16
+ /**
17
+ * Parameters for fetching news
18
+ */
19
+ export interface GetNewsParams {
20
+ /** Symbols to filter news by */
21
+ symbols?: string[];
22
+ /** Start date/time for the news range */
23
+ start?: Date;
24
+ /** End date/time for the news range */
25
+ end?: Date;
26
+ /** Maximum number of articles to return (default 10, max 50) */
27
+ limit?: number;
28
+ /** Sort order: 'asc' for oldest first, 'desc' for newest first (default) */
29
+ sort?: 'asc' | 'desc';
30
+ /** Include full article content (default false) */
31
+ includeContent?: boolean;
32
+ }
33
+ /**
34
+ * Get news articles with optional filtering
35
+ * @param client - AlpacaClient instance
36
+ * @param params - Parameters for fetching news
37
+ * @returns Array of simplified news articles
38
+ * @throws NewsError if the request fails
39
+ */
40
+ export declare function getNews(client: AlpacaClient, params?: GetNewsParams): Promise<SimpleNews[]>;
41
+ /**
42
+ * Get latest news for a specific symbol
43
+ * @param client - AlpacaClient instance
44
+ * @param symbol - Stock symbol to get news for
45
+ * @param limit - Maximum number of articles (default 10)
46
+ * @returns Array of simplified news articles
47
+ * @throws NewsError if the request fails
48
+ */
49
+ export declare function getLatestNews(client: AlpacaClient, symbol: string, limit?: number): Promise<SimpleNews[]>;
50
+ /**
51
+ * Search news by keyword in headlines and summaries
52
+ * Note: This performs client-side filtering since Alpaca API doesn't support keyword search
53
+ * @param client - AlpacaClient instance
54
+ * @param query - Search query (case-insensitive)
55
+ * @param limit - Maximum number of articles (default 10)
56
+ * @returns Array of simplified news articles matching the query
57
+ * @throws NewsError if the request fails
58
+ */
59
+ export declare function searchNews(client: AlpacaClient, query: string, limit?: number): Promise<SimpleNews[]>;
60
+ /**
61
+ * Get news for multiple symbols
62
+ * @param client - AlpacaClient instance
63
+ * @param symbols - Array of stock symbols
64
+ * @param limit - Maximum number of articles per symbol (default 5)
65
+ * @returns Map of symbol to news articles
66
+ */
67
+ export declare function getNewsForSymbols(client: AlpacaClient, symbols: string[], limit?: number): Promise<Map<string, SimpleNews[]>>;
68
+ /**
69
+ * Get average sentiment for a symbol based on recent news
70
+ * @param client - AlpacaClient instance
71
+ * @param symbol - Stock symbol
72
+ * @param limit - Number of articles to analyze (default 10)
73
+ * @returns Average sentiment score between -1 and 1
74
+ */
75
+ export declare function getSymbolSentiment(client: AlpacaClient, symbol: string, limit?: number): Promise<{
76
+ sentiment: number;
77
+ articleCount: number;
78
+ }>;
79
+ declare const _default: {
80
+ getNews: typeof getNews;
81
+ getLatestNews: typeof getLatestNews;
82
+ searchNews: typeof searchNews;
83
+ getNewsForSymbols: typeof getNewsForSymbols;
84
+ getSymbolSentiment: typeof getSymbolSentiment;
85
+ };
86
+ export default _default;
87
+ //# sourceMappingURL=news.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"news.d.ts","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;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,EAAE,EACjB,KAAK,GAAE,MAAU,GAChB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CA2CpC;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAW,GACjB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBtD;;;;;;;;AAED,wBAME"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Quotes Module
3
+ * Real-time and snapshot quote data using Alpaca SDK
4
+ */
5
+ import { AlpacaClient } from '../client';
6
+ import { AlpacaQuote, LatestQuotesResponse, DataFeed } from '../../types/alpaca-types';
7
+ /**
8
+ * Error thrown when quote operations fail
9
+ */
10
+ export declare class QuoteError extends Error {
11
+ code: string;
12
+ symbol?: string | undefined;
13
+ details?: unknown | undefined;
14
+ constructor(message: string, code: string, symbol?: string | undefined, details?: unknown | undefined);
15
+ }
16
+ /**
17
+ * Spread information for a symbol
18
+ */
19
+ export interface SpreadInfo {
20
+ /** Bid price */
21
+ bid: number;
22
+ /** Ask price */
23
+ ask: number;
24
+ /** Absolute spread (ask - bid) */
25
+ spread: number;
26
+ /** Spread as percentage of mid price */
27
+ spreadPercent: number;
28
+ /** Mid price ((bid + ask) / 2) */
29
+ midPrice: number;
30
+ /** Bid size */
31
+ bidSize: number;
32
+ /** Ask size */
33
+ askSize: number;
34
+ }
35
+ /**
36
+ * Get latest quote for a single symbol
37
+ * @param client - AlpacaClient instance
38
+ * @param symbol - Stock symbol to get quote for
39
+ * @param feed - Optional data feed (sip, iex, delayed_sip)
40
+ * @returns Latest quote for the symbol
41
+ * @throws QuoteError if the request fails
42
+ */
43
+ export declare function getLatestQuote(client: AlpacaClient, symbol: string, feed?: DataFeed): Promise<AlpacaQuote>;
44
+ /**
45
+ * Get latest quotes for multiple symbols
46
+ * @param client - AlpacaClient instance
47
+ * @param symbols - Array of stock symbols
48
+ * @param feed - Optional data feed (sip, iex, delayed_sip)
49
+ * @returns Object containing quotes for all requested symbols
50
+ * @throws QuoteError if the request fails
51
+ */
52
+ export declare function getLatestQuotes(client: AlpacaClient, symbols: string[], feed?: DataFeed): Promise<LatestQuotesResponse>;
53
+ /**
54
+ * Get bid/ask spread for a symbol
55
+ * Useful for evaluating liquidity and trading costs
56
+ * @param client - AlpacaClient instance
57
+ * @param symbol - Stock symbol
58
+ * @returns Spread information including bid, ask, spread, and percentage
59
+ * @throws QuoteError if the request fails or if prices are invalid
60
+ */
61
+ export declare function getSpread(client: AlpacaClient, symbol: string): Promise<SpreadInfo>;
62
+ /**
63
+ * Get multiple spreads for an array of symbols
64
+ * @param client - AlpacaClient instance
65
+ * @param symbols - Array of stock symbols
66
+ * @returns Map of symbol to spread information
67
+ */
68
+ export declare function getSpreads(client: AlpacaClient, symbols: string[]): Promise<Map<string, SpreadInfo>>;
69
+ /**
70
+ * Check if a symbol has good liquidity based on spread
71
+ * @param client - AlpacaClient instance
72
+ * @param symbol - Stock symbol
73
+ * @param maxSpreadPercent - Maximum acceptable spread percentage (default 1%)
74
+ * @returns true if spread is within acceptable range
75
+ */
76
+ export declare function hasGoodLiquidity(client: AlpacaClient, symbol: string, maxSpreadPercent?: number): Promise<boolean>;
77
+ declare const _default: {
78
+ getLatestQuote: typeof getLatestQuote;
79
+ getLatestQuotes: typeof getLatestQuotes;
80
+ getSpread: typeof getSpread;
81
+ getSpreads: typeof getSpreads;
82
+ hasGoodLiquidity: typeof hasGoodLiquidity;
83
+ };
84
+ export default _default;
85
+ //# sourceMappingURL=quotes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/market-data/quotes.ts"],"names":[],"mappings":"AAAA;;;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,EACpB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CA0BlC;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,gBAAgB,GAAE,MAAY,GAC7B,OAAO,CAAC,OAAO,CAAC,CAQlB;;;;;;;;AAED,wBAME"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Trades Module
3
+ * Real-time and historical trade data using Alpaca SDK
4
+ */
5
+ import { AlpacaClient } from '../client';
6
+ import { AlpacaTrade, LatestTradesResponse, DataFeed } from '../../types/alpaca-types';
7
+ /**
8
+ * Error thrown when trade operations fail
9
+ */
10
+ export declare class TradeError extends Error {
11
+ code: string;
12
+ symbol?: string | undefined;
13
+ details?: unknown | undefined;
14
+ constructor(message: string, code: string, symbol?: string | undefined, details?: unknown | undefined);
15
+ }
16
+ /**
17
+ * Parameters for fetching historical trades
18
+ */
19
+ export interface GetHistoricalTradesParams {
20
+ /** Stock symbol */
21
+ symbol: string;
22
+ /** Start date/time for the data range */
23
+ start: Date;
24
+ /** End date/time for the data range (defaults to now) */
25
+ end?: Date;
26
+ /** Maximum number of trades to return */
27
+ limit?: number;
28
+ /** Data feed (sip for premium, iex for free tier) */
29
+ feed?: DataFeed;
30
+ }
31
+ /**
32
+ * Get latest trade for a single symbol
33
+ * @param client - AlpacaClient instance
34
+ * @param symbol - Stock symbol to get trade for
35
+ * @param feed - Optional data feed (sip, iex, delayed_sip)
36
+ * @returns Latest trade for the symbol
37
+ * @throws TradeError if the request fails
38
+ */
39
+ export declare function getLatestTrade(client: AlpacaClient, symbol: string, feed?: DataFeed): Promise<AlpacaTrade>;
40
+ /**
41
+ * Get latest trades for multiple symbols
42
+ * @param client - AlpacaClient instance
43
+ * @param symbols - Array of stock symbols
44
+ * @param feed - Optional data feed (sip, iex, delayed_sip)
45
+ * @returns Object containing trades for all requested symbols
46
+ * @throws TradeError if the request fails
47
+ */
48
+ export declare function getLatestTrades(client: AlpacaClient, symbols: string[], feed?: DataFeed): Promise<LatestTradesResponse>;
49
+ /**
50
+ * Get historical trades with automatic pagination
51
+ * @param client - AlpacaClient instance
52
+ * @param params - Parameters for fetching historical trades
53
+ * @returns Array of trades for the symbol
54
+ * @throws TradeError if the request fails
55
+ */
56
+ export declare function getHistoricalTrades(client: AlpacaClient, params: GetHistoricalTradesParams): Promise<AlpacaTrade[]>;
57
+ /**
58
+ * Get current price for a symbol
59
+ * Uses mid-point of latest quote if available, otherwise falls back to last trade price
60
+ * @param client - AlpacaClient instance
61
+ * @param symbol - Stock symbol
62
+ * @param feed - Optional data feed (sip, iex, delayed_sip)
63
+ * @returns Current price for the symbol
64
+ * @throws TradeError if unable to get price
65
+ */
66
+ export declare function getCurrentPrice(client: AlpacaClient, symbol: string, feed?: DataFeed): Promise<number>;
67
+ /**
68
+ * Get current prices for multiple symbols
69
+ * Uses mid-point of latest quote if available, otherwise falls back to last trade price
70
+ * @param client - AlpacaClient instance
71
+ * @param symbols - Array of stock symbols
72
+ * @param feed - Optional data feed (sip, iex, delayed_sip)
73
+ * @returns Map of symbol to current price
74
+ */
75
+ export declare function getCurrentPrices(client: AlpacaClient, symbols: string[], feed?: DataFeed): Promise<Map<string, number>>;
76
+ /**
77
+ * Get trade volume summary for a symbol over a time period
78
+ * @param client - AlpacaClient instance
79
+ * @param symbol - Stock symbol
80
+ * @param start - Start date/time
81
+ * @param end - End date/time (defaults to now)
82
+ * @returns Total volume and trade count for the period
83
+ */
84
+ export declare function getTradeVolume(client: AlpacaClient, symbol: string, start: Date, end?: Date): Promise<{
85
+ totalVolume: number;
86
+ tradeCount: number;
87
+ avgTradeSize: number;
88
+ }>;
89
+ declare const _default: {
90
+ getLatestTrade: typeof getLatestTrade;
91
+ getLatestTrades: typeof getLatestTrades;
92
+ getHistoricalTrades: typeof getHistoricalTrades;
93
+ getCurrentPrice: typeof getCurrentPrice;
94
+ getCurrentPrices: typeof getCurrentPrices;
95
+ getTradeVolume: typeof getTradeVolume;
96
+ };
97
+ export default _default;
98
+ //# sourceMappingURL=trades.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trades.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/market-data/trades.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQvF;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAG1B,IAAI,EAAE,MAAM;IACZ,MAAM,CAAC,EAAE,MAAM;IACf,OAAO,CAAC,EAAE,OAAO;gBAHxB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,OAAO,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,KAAK,EAAE,IAAI,CAAC;IACZ,yDAAyD;IACzD,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAYD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,QAAQ,GACd,OAAO,CAAC,WAAW,CAAC,CAqDtB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,CAAC,EAAE,QAAQ,GACd,OAAO,CAAC,oBAAoB,CAAC,CA2E/B;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,WAAW,EAAE,CAAC,CAwExB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,QAAQ,GACd,OAAO,CAAC,MAAM,CAAC,CAwDjB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,CAAC,EAAE,QAAQ,GACd,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgF9B;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,EACX,GAAG,CAAC,EAAE,IAAI,GACT,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CA0B5E;;;;;;;;;AAED,wBAOE"}
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Options Contracts Module
3
+ * Query and analyze option contracts
4
+ */
5
+ import { AlpacaClient } from '../client';
6
+ import { OptionContract, OptionType, GetOptionContractsParams } from '../../types/alpaca-types';
7
+ /**
8
+ * Parameters for getting option chain
9
+ */
10
+ export interface GetOptionChainParams {
11
+ /** Filter by expiration date (YYYY-MM-DD format) */
12
+ expirationDate?: string;
13
+ /** Filter by strike price range */
14
+ strikePrice?: {
15
+ min?: number;
16
+ max?: number;
17
+ };
18
+ /** Filter by option type (call or put) */
19
+ type?: OptionType;
20
+ }
21
+ /**
22
+ * ATM options result containing both call and put
23
+ */
24
+ export interface ATMOptionsResult {
25
+ /** ATM call option if found */
26
+ call: OptionContract | null;
27
+ /** ATM put option if found */
28
+ put: OptionContract | null;
29
+ /** The strike price used for ATM determination */
30
+ strikePrice: number;
31
+ /** Current underlying price used for determination */
32
+ underlyingPrice: number;
33
+ }
34
+ /**
35
+ * Options chain grouped by expiration and strike
36
+ */
37
+ export interface GroupedOptionChain {
38
+ /** The underlying symbol */
39
+ underlying: string;
40
+ /** Chain grouped by expiration date */
41
+ byExpiration: {
42
+ [expirationDate: string]: {
43
+ /** Calls at each strike */
44
+ calls: {
45
+ [strike: string]: OptionContract;
46
+ };
47
+ /** Puts at each strike */
48
+ puts: {
49
+ [strike: string]: OptionContract;
50
+ };
51
+ };
52
+ };
53
+ /** All available expiration dates */
54
+ expirations: string[];
55
+ /** All available strike prices */
56
+ strikes: number[];
57
+ }
58
+ /**
59
+ * Get option contracts for an underlying symbol with filters
60
+ *
61
+ * @param client - The AlpacaClient instance
62
+ * @param params - Query parameters for filtering contracts
63
+ * @returns Array of option contracts matching the criteria
64
+ * @throws Error if API request fails
65
+ *
66
+ * @example
67
+ * // Get all AAPL option contracts
68
+ * const contracts = await getOptionContracts(client, {
69
+ * underlying_symbols: ['AAPL'],
70
+ * });
71
+ *
72
+ * @example
73
+ * // Get AAPL calls expiring in the next 30 days
74
+ * const today = new Date();
75
+ * const thirtyDaysOut = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000);
76
+ * const contracts = await getOptionContracts(client, {
77
+ * underlying_symbols: ['AAPL'],
78
+ * type: 'call',
79
+ * expiration_date_gte: today.toISOString().split('T')[0],
80
+ * expiration_date_lte: thirtyDaysOut.toISOString().split('T')[0],
81
+ * });
82
+ */
83
+ export declare function getOptionContracts(client: AlpacaClient, params: GetOptionContractsParams): Promise<OptionContract[]>;
84
+ /**
85
+ * Get a specific option contract by symbol or ID
86
+ *
87
+ * @param client - The AlpacaClient instance
88
+ * @param symbolOrId - Option contract symbol (e.g., AAPL230120C00150000) or contract ID
89
+ * @returns The option contract details
90
+ * @throws Error if contract not found or API request fails
91
+ *
92
+ * @example
93
+ * // Get contract by OCC symbol
94
+ * const contract = await getOptionContract(client, 'AAPL230120C00150000');
95
+ *
96
+ * @example
97
+ * // Get contract by ID
98
+ * const contract = await getOptionContract(client, 'contract-uuid-here');
99
+ */
100
+ export declare function getOptionContract(client: AlpacaClient, symbolOrId: string): Promise<OptionContract>;
101
+ /**
102
+ * Get option chain for a symbol with optional filters
103
+ *
104
+ * @param client - The AlpacaClient instance
105
+ * @param underlying - The underlying symbol (e.g., 'AAPL')
106
+ * @param params - Optional filter parameters
107
+ * @returns Array of option contracts in the chain
108
+ *
109
+ * @example
110
+ * // Get full option chain for AAPL
111
+ * const chain = await getOptionChain(client, 'AAPL');
112
+ *
113
+ * @example
114
+ * // Get AAPL puts at specific strike range
115
+ * const chain = await getOptionChain(client, 'AAPL', {
116
+ * type: 'put',
117
+ * strikePrice: { min: 140, max: 160 },
118
+ * });
119
+ */
120
+ export declare function getOptionChain(client: AlpacaClient, underlying: string, params?: GetOptionChainParams): Promise<OptionContract[]>;
121
+ /**
122
+ * Get available expiration dates for an underlying symbol
123
+ *
124
+ * @param client - The AlpacaClient instance
125
+ * @param underlying - The underlying symbol (e.g., 'AAPL')
126
+ * @returns Sorted array of expiration dates (YYYY-MM-DD format)
127
+ *
128
+ * @example
129
+ * const expirations = await getExpirationDates(client, 'AAPL');
130
+ * console.log(`Next expiration: ${expirations[0]}`);
131
+ */
132
+ export declare function getExpirationDates(client: AlpacaClient, underlying: string): Promise<string[]>;
133
+ /**
134
+ * Get available strike prices for an underlying at a specific expiration
135
+ *
136
+ * @param client - The AlpacaClient instance
137
+ * @param underlying - The underlying symbol
138
+ * @param expirationDate - The expiration date (YYYY-MM-DD format)
139
+ * @returns Sorted array of available strike prices
140
+ *
141
+ * @example
142
+ * const strikes = await getStrikePrices(client, 'AAPL', '2024-01-19');
143
+ */
144
+ export declare function getStrikePrices(client: AlpacaClient, underlying: string, expirationDate: string): Promise<number[]>;
145
+ /**
146
+ * Find ATM (at-the-money) options for an underlying
147
+ * Returns both call and put options at the strike price closest to current price
148
+ *
149
+ * @param client - The AlpacaClient instance
150
+ * @param underlying - The underlying symbol
151
+ * @param expirationDate - The expiration date (YYYY-MM-DD format)
152
+ * @param currentPrice - Current price of the underlying (required to determine ATM)
153
+ * @param type - Optional filter to return only call or put
154
+ * @returns ATM options result with call and/or put contracts
155
+ *
156
+ * @example
157
+ * // Get both ATM call and put
158
+ * const atm = await findATMOptions(client, 'AAPL', '2024-01-19', 175.50);
159
+ * console.log(`ATM Call: ${atm.call?.symbol}`);
160
+ * console.log(`ATM Put: ${atm.put?.symbol}`);
161
+ *
162
+ * @example
163
+ * // Get only ATM call
164
+ * const atm = await findATMOptions(client, 'AAPL', '2024-01-19', 175.50, 'call');
165
+ */
166
+ export declare function findATMOptions(client: AlpacaClient, underlying: string, expirationDate: string, currentPrice: number, type?: OptionType): Promise<ATMOptionsResult>;
167
+ /**
168
+ * Get grouped option chain organized by expiration and strike
169
+ *
170
+ * @param client - The AlpacaClient instance
171
+ * @param underlying - The underlying symbol
172
+ * @param expirationDates - Optional array of expiration dates to include
173
+ * @returns Grouped option chain structure
174
+ *
175
+ * @example
176
+ * const chain = await getGroupedOptionChain(client, 'AAPL');
177
+ * // Access calls at specific expiration and strike
178
+ * const call = chain.byExpiration['2024-01-19'].calls['175'];
179
+ */
180
+ export declare function getGroupedOptionChain(client: AlpacaClient, underlying: string, expirationDates?: string[]): Promise<GroupedOptionChain>;
181
+ /**
182
+ * Find options contracts within a delta range (approximated by strike distance from current price)
183
+ *
184
+ * @param client - The AlpacaClient instance
185
+ * @param underlying - The underlying symbol
186
+ * @param expirationDate - The expiration date
187
+ * @param currentPrice - Current price of the underlying
188
+ * @param targetDeltaPercent - Target delta as percentage of current price (e.g., 5 for 5%)
189
+ * @param type - Option type (call or put)
190
+ * @returns Array of contracts within the delta range
191
+ *
192
+ * @example
193
+ * // Find calls approximately 5% OTM
194
+ * const otmCalls = await findOptionsByDelta(client, 'AAPL', '2024-01-19', 175, 5, 'call');
195
+ */
196
+ export declare function findOptionsByDelta(client: AlpacaClient, underlying: string, expirationDate: string, currentPrice: number, targetDeltaPercent: number, type: OptionType): Promise<OptionContract[]>;
197
+ /**
198
+ * Find the nearest expiration date to a target number of days out
199
+ *
200
+ * @param client - The AlpacaClient instance
201
+ * @param underlying - The underlying symbol
202
+ * @param targetDays - Target number of days to expiration
203
+ * @returns The nearest available expiration date
204
+ *
205
+ * @example
206
+ * // Find expiration closest to 30 days out
207
+ * const expiration = await findNearestExpiration(client, 'AAPL', 30);
208
+ */
209
+ export declare function findNearestExpiration(client: AlpacaClient, underlying: string, targetDays: number): Promise<string>;
210
+ /**
211
+ * Parse OCC option symbol to extract components
212
+ *
213
+ * @param occSymbol - OCC option symbol (e.g., AAPL230120C00150000)
214
+ * @returns Parsed symbol components
215
+ *
216
+ * @example
217
+ * const parsed = parseOCCSymbol('AAPL230120C00150000');
218
+ * // Returns: { underlying: 'AAPL', expiration: '2023-01-20', type: 'call', strike: 150 }
219
+ */
220
+ export declare function parseOCCSymbol(occSymbol: string): {
221
+ underlying: string;
222
+ expiration: string;
223
+ type: OptionType;
224
+ strike: number;
225
+ } | null;
226
+ /**
227
+ * Build OCC option symbol from components
228
+ *
229
+ * @param underlying - The underlying symbol
230
+ * @param expiration - Expiration date (YYYY-MM-DD format)
231
+ * @param type - Option type (call or put)
232
+ * @param strike - Strike price
233
+ * @returns OCC-formatted option symbol
234
+ *
235
+ * @example
236
+ * const symbol = buildOCCSymbol('AAPL', '2023-01-20', 'call', 150);
237
+ * // Returns: 'AAPL230120C00150000'
238
+ */
239
+ export declare function buildOCCSymbol(underlying: string, expiration: string, type: OptionType, strike: number): string;
240
+ /**
241
+ * Check if an option contract is tradable
242
+ *
243
+ * @param contract - The option contract to check
244
+ * @returns True if the contract is active and tradable
245
+ */
246
+ export declare function isContractTradable(contract: OptionContract): boolean;
247
+ /**
248
+ * Calculate days to expiration for a contract
249
+ *
250
+ * @param contract - The option contract
251
+ * @returns Number of calendar days until expiration
252
+ */
253
+ export declare function getDaysToExpiration(contract: OptionContract): number;
254
+ /**
255
+ * Check if a contract is expiring within N days
256
+ *
257
+ * @param contract - The option contract
258
+ * @param days - Number of days threshold
259
+ * @returns True if contract expires within the specified days
260
+ */
261
+ export declare function isExpiringWithin(contract: OptionContract, days: number): boolean;
262
+ declare const _default: {
263
+ getOptionContracts: typeof getOptionContracts;
264
+ getOptionContract: typeof getOptionContract;
265
+ getOptionChain: typeof getOptionChain;
266
+ getExpirationDates: typeof getExpirationDates;
267
+ getStrikePrices: typeof getStrikePrices;
268
+ findATMOptions: typeof findATMOptions;
269
+ getGroupedOptionChain: typeof getGroupedOptionChain;
270
+ findOptionsByDelta: typeof findOptionsByDelta;
271
+ findNearestExpiration: typeof findNearestExpiration;
272
+ parseOCCSymbol: typeof parseOCCSymbol;
273
+ buildOCCSymbol: typeof buildOCCSymbol;
274
+ isContractTradable: typeof isContractTradable;
275
+ getDaysToExpiration: typeof getDaysToExpiration;
276
+ isExpiringWithin: typeof isExpiringWithin;
277
+ };
278
+ export default _default;
279
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/options/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EACL,cAAc,EACd,UAAU,EACV,wBAAwB,EAEzB,MAAM,0BAA0B,CAAC;AAelC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,WAAW,CAAC,EAAE;QACZ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,0CAA0C;IAC1C,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,IAAI,EAAE,cAAc,GAAG,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