@adaptic/utils 0.0.383 → 0.0.900
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.
- package/README.md +153 -61
- package/dist/index.cjs +60090 -5244
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +59829 -5244
- package/dist/index.mjs.map +1 -1
- package/dist/test.js +733 -383
- package/dist/test.js.map +1 -1
- package/dist/types/__tests__/alpaca-functions.test.d.ts +2 -0
- package/dist/types/__tests__/alpaca-functions.test.d.ts.map +1 -0
- package/dist/types/__tests__/api-endpoints.test.d.ts +2 -0
- package/dist/types/__tests__/api-endpoints.test.d.ts.map +1 -0
- package/dist/types/__tests__/asset-allocation.test.d.ts +2 -0
- package/dist/types/__tests__/asset-allocation.test.d.ts.map +1 -0
- package/dist/types/__tests__/auth-validator.test.d.ts +2 -0
- package/dist/types/__tests__/auth-validator.test.d.ts.map +1 -0
- package/dist/types/__tests__/cache.test.d.ts +2 -0
- package/dist/types/__tests__/cache.test.d.ts.map +1 -0
- package/dist/types/__tests__/errors.test.d.ts +2 -0
- package/dist/types/__tests__/errors.test.d.ts.map +1 -0
- package/dist/types/__tests__/financial-regression.test.d.ts +2 -0
- package/dist/types/__tests__/financial-regression.test.d.ts.map +1 -0
- package/dist/types/__tests__/format-tools.test.d.ts +2 -0
- package/dist/types/__tests__/format-tools.test.d.ts.map +1 -0
- package/dist/types/__tests__/http-keep-alive.test.d.ts +2 -0
- package/dist/types/__tests__/http-keep-alive.test.d.ts.map +1 -0
- package/dist/types/__tests__/http-timeout.test.d.ts +2 -0
- package/dist/types/__tests__/http-timeout.test.d.ts.map +1 -0
- package/dist/types/__tests__/logger.test.d.ts +2 -0
- package/dist/types/__tests__/logger.test.d.ts.map +1 -0
- package/dist/types/__tests__/market-time.test.d.ts +2 -0
- package/dist/types/__tests__/market-time.test.d.ts.map +1 -0
- package/dist/types/__tests__/misc-utils.test.d.ts +2 -0
- package/dist/types/__tests__/misc-utils.test.d.ts.map +1 -0
- package/dist/types/__tests__/paginator.test.d.ts +2 -0
- package/dist/types/__tests__/paginator.test.d.ts.map +1 -0
- package/dist/types/__tests__/performance-metrics.test.d.ts +2 -0
- package/dist/types/__tests__/performance-metrics.test.d.ts.map +1 -0
- package/dist/types/__tests__/polygon.test.d.ts +2 -0
- package/dist/types/__tests__/polygon.test.d.ts.map +1 -0
- package/dist/types/__tests__/price-utils.test.d.ts +2 -0
- package/dist/types/__tests__/price-utils.test.d.ts.map +1 -0
- package/dist/types/__tests__/property-based-financial.test.d.ts +2 -0
- package/dist/types/__tests__/property-based-financial.test.d.ts.map +1 -0
- package/dist/types/__tests__/rate-limiter.test.d.ts +2 -0
- package/dist/types/__tests__/rate-limiter.test.d.ts.map +1 -0
- package/dist/types/__tests__/schema-validation.test.d.ts +2 -0
- package/dist/types/__tests__/schema-validation.test.d.ts.map +1 -0
- package/dist/types/__tests__/technical-analysis.test.d.ts +2 -0
- package/dist/types/__tests__/technical-analysis.test.d.ts.map +1 -0
- package/dist/types/__tests__/time-utils.test.d.ts +2 -0
- package/dist/types/__tests__/time-utils.test.d.ts.map +1 -0
- package/dist/types/adaptic.d.ts +2 -2
- package/dist/types/adaptic.d.ts.map +1 -1
- package/dist/types/alpaca/client.d.ts +95 -0
- package/dist/types/alpaca/client.d.ts.map +1 -0
- package/dist/types/alpaca/crypto/data.d.ts +281 -0
- package/dist/types/alpaca/crypto/data.d.ts.map +1 -0
- package/dist/types/alpaca/crypto/index.d.ts +75 -0
- package/dist/types/alpaca/crypto/index.d.ts.map +1 -0
- package/dist/types/alpaca/crypto/orders.d.ts +221 -0
- package/dist/types/alpaca/crypto/orders.d.ts.map +1 -0
- package/dist/types/alpaca/index.d.ts +205 -0
- package/dist/types/alpaca/index.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/account.d.ts +34 -0
- package/dist/types/alpaca/legacy/account.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/assets.d.ts +13 -0
- package/dist/types/alpaca/legacy/assets.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/auth.d.ts +18 -0
- package/dist/types/alpaca/legacy/auth.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/index.d.ts +15 -0
- package/dist/types/alpaca/legacy/index.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/market-data.d.ts +32 -0
- package/dist/types/alpaca/legacy/market-data.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/orders.d.ts +84 -0
- package/dist/types/alpaca/legacy/orders.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/positions.d.ts +66 -0
- package/dist/types/alpaca/legacy/positions.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/utils.d.ts +18 -0
- package/dist/types/alpaca/legacy/utils.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/bars.d.ts +142 -0
- package/dist/types/alpaca/market-data/bars.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/index.d.ts +13 -0
- package/dist/types/alpaca/market-data/index.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/news.d.ts +87 -0
- package/dist/types/alpaca/market-data/news.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/quotes.d.ts +85 -0
- package/dist/types/alpaca/market-data/quotes.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/trades.d.ts +98 -0
- package/dist/types/alpaca/market-data/trades.d.ts.map +1 -0
- package/dist/types/alpaca/options/contracts.d.ts +279 -0
- package/dist/types/alpaca/options/contracts.d.ts.map +1 -0
- package/dist/types/alpaca/options/data.d.ts +126 -0
- package/dist/types/alpaca/options/data.d.ts.map +1 -0
- package/dist/types/alpaca/options/index.d.ts +17 -0
- package/dist/types/alpaca/options/index.d.ts.map +1 -0
- package/dist/types/alpaca/options/orders.d.ts +366 -0
- package/dist/types/alpaca/options/orders.d.ts.map +1 -0
- package/dist/types/alpaca/options/strategies.d.ts +224 -0
- package/dist/types/alpaca/options/strategies.d.ts.map +1 -0
- package/dist/types/alpaca/streams/base-stream.d.ts +143 -0
- package/dist/types/alpaca/streams/base-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams/crypto-stream.d.ts +173 -0
- package/dist/types/alpaca/streams/crypto-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams/index.d.ts +54 -0
- package/dist/types/alpaca/streams/index.d.ts.map +1 -0
- package/dist/types/alpaca/streams/option-stream.d.ts +167 -0
- package/dist/types/alpaca/streams/option-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams/stock-stream.d.ts +176 -0
- package/dist/types/alpaca/streams/stock-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams/stream-manager.d.ts +277 -0
- package/dist/types/alpaca/streams/stream-manager.d.ts.map +1 -0
- package/dist/types/alpaca/streams/trading-stream.d.ts +186 -0
- package/dist/types/alpaca/streams/trading-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams.d.ts +88 -0
- package/dist/types/alpaca/streams.d.ts.map +1 -0
- package/dist/types/alpaca/test-imports.d.ts +7 -0
- package/dist/types/alpaca/test-imports.d.ts.map +1 -0
- package/dist/types/alpaca/trading/account.d.ts +198 -0
- package/dist/types/alpaca/trading/account.d.ts.map +1 -0
- package/dist/types/alpaca/trading/bracket-orders.d.ts +162 -0
- package/dist/types/alpaca/trading/bracket-orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/clock.d.ts +99 -0
- package/dist/types/alpaca/trading/clock.d.ts.map +1 -0
- package/dist/types/alpaca/trading/index.d.ts +15 -0
- package/dist/types/alpaca/trading/index.d.ts.map +1 -0
- package/dist/types/alpaca/trading/oco-orders.d.ts +203 -0
- package/dist/types/alpaca/trading/oco-orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/order-utils.d.ts +404 -0
- package/dist/types/alpaca/trading/order-utils.d.ts.map +1 -0
- package/dist/types/alpaca/trading/orders.d.ts +199 -0
- package/dist/types/alpaca/trading/orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/oto-orders.d.ts +282 -0
- package/dist/types/alpaca/trading/oto-orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/positions.d.ts +389 -0
- package/dist/types/alpaca/trading/positions.d.ts.map +1 -0
- package/dist/types/alpaca/trading/smart-orders.d.ts +301 -0
- package/dist/types/alpaca/trading/smart-orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/trailing-stops.d.ts +240 -0
- package/dist/types/alpaca/trading/trailing-stops.d.ts.map +1 -0
- package/dist/types/alpaca-market-data-api.d.ts +12 -10
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
- package/dist/types/alpaca-trading-api.d.ts +12 -12
- package/dist/types/alpaca-trading-api.d.ts.map +1 -1
- package/dist/types/alphavantage.d.ts +1 -1
- package/dist/types/alphavantage.d.ts.map +1 -1
- package/dist/types/asset-allocation-algorithm.d.ts +7 -1
- package/dist/types/asset-allocation-algorithm.d.ts.map +1 -1
- package/dist/types/cache/stampede-protected-cache.d.ts.map +1 -1
- package/dist/types/config/api-endpoints.d.ts +94 -0
- package/dist/types/config/api-endpoints.d.ts.map +1 -0
- package/dist/types/crypto.d.ts +2 -2
- package/dist/types/crypto.d.ts.map +1 -1
- package/dist/types/display-manager.d.ts +1 -1
- package/dist/types/display-manager.d.ts.map +1 -1
- package/dist/types/errors/index.d.ts +130 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/examples/asset-allocation-example.d.ts +7 -6
- package/dist/types/examples/asset-allocation-example.d.ts.map +1 -1
- package/dist/types/examples/rate-limiter-example.d.ts +7 -0
- package/dist/types/examples/rate-limiter-example.d.ts.map +1 -0
- package/dist/types/format-tools.d.ts.map +1 -1
- package/dist/types/http-timeout.d.ts +37 -0
- package/dist/types/http-timeout.d.ts.map +1 -0
- package/dist/types/index.d.ts +393 -55
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +56 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logging.d.ts +1 -1
- package/dist/types/logging.d.ts.map +1 -1
- package/dist/types/market-hours.d.ts.map +1 -1
- package/dist/types/market-time.d.ts +75 -13
- package/dist/types/market-time.d.ts.map +1 -1
- package/dist/types/metrics-calcs.d.ts.map +1 -1
- package/dist/types/misc-utils.d.ts +4 -1
- package/dist/types/misc-utils.d.ts.map +1 -1
- package/dist/types/performance-metrics.d.ts +4 -4
- package/dist/types/performance-metrics.d.ts.map +1 -1
- package/dist/types/polygon-indices.d.ts +3 -3
- package/dist/types/polygon-indices.d.ts.map +1 -1
- package/dist/types/polygon.d.ts +1 -1
- package/dist/types/polygon.d.ts.map +1 -1
- package/dist/types/price-utils.d.ts.map +1 -1
- package/dist/types/rate-limiter.d.ts +171 -0
- package/dist/types/rate-limiter.d.ts.map +1 -0
- package/dist/types/schemas/alpaca-schemas.d.ts +779 -0
- package/dist/types/schemas/alpaca-schemas.d.ts.map +1 -0
- package/dist/types/schemas/alphavantage-schemas.d.ts +255 -0
- package/dist/types/schemas/alphavantage-schemas.d.ts.map +1 -0
- package/dist/types/schemas/index.d.ts +21 -0
- package/dist/types/schemas/index.d.ts.map +1 -0
- package/dist/types/schemas/polygon-schemas.d.ts +551 -0
- package/dist/types/schemas/polygon-schemas.d.ts.map +1 -0
- package/dist/types/schemas/validate-response.d.ts +88 -0
- package/dist/types/schemas/validate-response.d.ts.map +1 -0
- package/dist/types/technical-analysis.d.ts +9 -9
- package/dist/types/technical-analysis.d.ts.map +1 -1
- package/dist/types/time-utils.d.ts.map +1 -1
- package/dist/types/types/adaptic-types.d.ts +1 -1
- package/dist/types/types/adaptic-types.d.ts.map +1 -1
- package/dist/types/types/alpaca-types.d.ts +172 -98
- package/dist/types/types/alpaca-types.d.ts.map +1 -1
- package/dist/types/types/alphavantage-types.d.ts +2 -2
- package/dist/types/types/asset-allocation-types.d.ts +11 -11
- package/dist/types/types/index.d.ts +8 -8
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/logging-types.d.ts +2 -2
- package/dist/types/types/logging-types.d.ts.map +1 -1
- package/dist/types/types/market-time-types.d.ts +4 -4
- package/dist/types/types/market-time-types.d.ts.map +1 -1
- package/dist/types/types/metrics-types.d.ts +3 -3
- package/dist/types/types/metrics-types.d.ts.map +1 -1
- package/dist/types/types/polygon-indices-types.d.ts +6 -6
- package/dist/types/types/polygon-types.d.ts +3 -3
- package/dist/types/types/ta-types.d.ts +3 -3
- package/dist/types/utils/auth-validator.d.ts +32 -0
- package/dist/types/utils/auth-validator.d.ts.map +1 -0
- package/dist/types/utils/http-keep-alive.d.ts +110 -0
- package/dist/types/utils/http-keep-alive.d.ts.map +1 -0
- package/dist/types/utils/paginator.d.ts +154 -0
- package/dist/types/utils/paginator.d.ts.map +1 -0
- package/dist/types/utils/retry.d.ts +78 -0
- package/dist/types/utils/retry.d.ts.map +1 -0
- package/package.json +25 -5
- package/dist/types/alpaca-functions.d.ts +0 -233
- package/dist/types/alpaca-functions.d.ts.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AlpacaAuth, DataFeed, LatestQuotesResponse, SimpleNews } from "../../types/alpaca-types";
|
|
2
|
+
/**
|
|
3
|
+
* Get the most recent quotes for requested symbols.
|
|
4
|
+
* @param auth - The authentication details for Alpaca
|
|
5
|
+
* @param params - Parameters including symbols array, optional feed and currency
|
|
6
|
+
* @returns Latest quote data for each symbol
|
|
7
|
+
* @throws Error if request fails or rate limit exceeded
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLatestQuotes(auth: AlpacaAuth, params: {
|
|
10
|
+
symbols: string[];
|
|
11
|
+
feed?: DataFeed;
|
|
12
|
+
currency?: string;
|
|
13
|
+
}): Promise<LatestQuotesResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetches news articles from Alpaca API for specified symbols.
|
|
16
|
+
* @param symbols - The symbols to fetch news for (comma-separated for multiple symbols)
|
|
17
|
+
* @param params - Optional parameters for fetching news
|
|
18
|
+
* @returns The fetched news articles and optional pagination token
|
|
19
|
+
*/
|
|
20
|
+
export declare function fetchNews(symbols: string, params?: {
|
|
21
|
+
auth?: AlpacaAuth;
|
|
22
|
+
start?: Date | string;
|
|
23
|
+
end?: Date | string;
|
|
24
|
+
limit?: number;
|
|
25
|
+
sort?: "asc" | "desc";
|
|
26
|
+
page_token?: string;
|
|
27
|
+
include_content?: boolean;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
news: SimpleNews[];
|
|
30
|
+
nextPageToken?: string;
|
|
31
|
+
}>;
|
|
32
|
+
//# sourceMappingURL=market-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"market-data.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/legacy/market-data.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,oBAAoB,EAEpB,UAAU,EACX,MAAM,0BAA0B,CAAC;AAWlC;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAChE,OAAO,CAAC,oBAAoB,CAAC,CA4B/B;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE;IACP,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GACA,OAAO,CAAC;IAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAqIzD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy Alpaca Order Functions
|
|
3
|
+
* Order management using AlpacaAuth pattern with direct fetch calls.
|
|
4
|
+
*/
|
|
5
|
+
import { AlpacaAuth, AlpacaOrder, CreateOrderParams, GetOrdersParams, ReplaceOrderParams } from "../../types/alpaca-types";
|
|
6
|
+
/**
|
|
7
|
+
* Makes a generic authenticated request to the Alpaca API.
|
|
8
|
+
* @param auth - The authentication details for Alpaca
|
|
9
|
+
* @param params - Request parameters including endpoint, method, body, queryString, and apiBaseUrl
|
|
10
|
+
* @returns The parsed JSON response
|
|
11
|
+
* @throws Error if the request fails
|
|
12
|
+
*/
|
|
13
|
+
export declare function makeRequest<T = unknown>(auth: AlpacaAuth, params: {
|
|
14
|
+
endpoint: string;
|
|
15
|
+
method: string;
|
|
16
|
+
body?: Record<string, unknown> | CreateOrderParams;
|
|
17
|
+
queryString?: string;
|
|
18
|
+
apiBaseUrl?: string;
|
|
19
|
+
}): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new order in Alpaca.
|
|
22
|
+
* @param auth - The authentication details for Alpaca
|
|
23
|
+
* @param params - The parameters for creating the order
|
|
24
|
+
* @returns The created order
|
|
25
|
+
*/
|
|
26
|
+
export declare function createOrder(auth: AlpacaAuth, params: CreateOrderParams): Promise<AlpacaOrder>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves a list of orders from Alpaca with automatic pagination.
|
|
29
|
+
* @param auth - The authentication details for Alpaca
|
|
30
|
+
* @param params - The parameters for fetching orders
|
|
31
|
+
* @returns The list of orders
|
|
32
|
+
*/
|
|
33
|
+
export declare function getOrders(auth: AlpacaAuth, params?: GetOrdersParams): Promise<AlpacaOrder[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Cancels all orders in Alpaca.
|
|
36
|
+
* @param auth - The authentication details for Alpaca
|
|
37
|
+
* @returns The list of canceled orders with their statuses
|
|
38
|
+
*/
|
|
39
|
+
export declare function cancelAllOrders(auth: AlpacaAuth): Promise<{
|
|
40
|
+
id: string;
|
|
41
|
+
status: number;
|
|
42
|
+
}[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves a specific order from Alpaca.
|
|
45
|
+
* @param auth - The authentication details for Alpaca
|
|
46
|
+
* @param orderId - The ID of the order to retrieve
|
|
47
|
+
* @param nested - Whether to include nested details
|
|
48
|
+
* @returns The requested order
|
|
49
|
+
*/
|
|
50
|
+
export declare function getOrder(auth: AlpacaAuth, orderId: string, nested?: boolean): Promise<AlpacaOrder>;
|
|
51
|
+
/**
|
|
52
|
+
* Replaces an existing order in Alpaca.
|
|
53
|
+
* @param auth - The authentication details for Alpaca
|
|
54
|
+
* @param orderId - The ID of the order to replace
|
|
55
|
+
* @param params - The parameters for replacing the order
|
|
56
|
+
* @returns The updated order
|
|
57
|
+
*/
|
|
58
|
+
export declare function replaceOrder(auth: AlpacaAuth, orderId: string, params: ReplaceOrderParams): Promise<AlpacaOrder>;
|
|
59
|
+
/**
|
|
60
|
+
* Cancels a specific order in Alpaca.
|
|
61
|
+
* @param auth - The authentication details for Alpaca
|
|
62
|
+
* @param orderId - The ID of the order to cancel
|
|
63
|
+
* @returns Success status and optional message if order not found
|
|
64
|
+
*/
|
|
65
|
+
export declare function cancelOrder(auth: AlpacaAuth, orderId: string): Promise<{
|
|
66
|
+
success: boolean;
|
|
67
|
+
message?: string;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a limit order in Alpaca.
|
|
71
|
+
* @param auth - The authentication details for Alpaca
|
|
72
|
+
* @param params - Order parameters including symbol, qty, side, limitPrice, position_intent, extended_hours
|
|
73
|
+
* @returns The created limit order
|
|
74
|
+
*/
|
|
75
|
+
export declare function createLimitOrder(auth: AlpacaAuth, params?: {
|
|
76
|
+
symbol: string;
|
|
77
|
+
qty: number;
|
|
78
|
+
side: "buy" | "sell";
|
|
79
|
+
limitPrice: number;
|
|
80
|
+
position_intent: "buy_to_open" | "buy_to_close" | "sell_to_open" | "sell_to_close";
|
|
81
|
+
extended_hours: boolean;
|
|
82
|
+
client_order_id?: string;
|
|
83
|
+
}): Promise<AlpacaOrder>;
|
|
84
|
+
//# sourceMappingURL=orders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/legacy/orders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AASlC;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,OAAO,EAC3C,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,iBAAiB,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,CAAC,CAAC,CAkEZ;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,WAAW,CAAC,CA4BtB;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE,eAAoB,GAC3B,OAAO,CAAC,WAAW,EAAE,CAAC,CAoDxB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CA0B3C;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,WAAW,CAAC,CAgCtB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,WAAW,CAAC,CA6BtB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA8BjD;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE;IACN,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EACX,aAAa,GACb,cAAc,GACd,cAAc,GACd,eAAe,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAS1B,GACA,OAAO,CAAC,WAAW,CAAC,CAuCtB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy Alpaca Position Functions
|
|
3
|
+
* Position management using AlpacaAuth pattern with direct fetch calls.
|
|
4
|
+
*/
|
|
5
|
+
import { AlpacaAuth, AlpacaOrder, AlpacaPosition } from "../../types/alpaca-types";
|
|
6
|
+
/**
|
|
7
|
+
* Fetches all positions for an Alpaca trading account.
|
|
8
|
+
* @param auth - The authentication details for Alpaca
|
|
9
|
+
* @returns The list of positions
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchAllPositions(auth: AlpacaAuth): Promise<AlpacaPosition[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Fetches a specific position for an Alpaca account.
|
|
14
|
+
* @param auth - The authentication details for Alpaca
|
|
15
|
+
* @param symbolOrAssetId - The symbol or asset ID to fetch the position for
|
|
16
|
+
* @returns The position details or null with message if not found
|
|
17
|
+
*/
|
|
18
|
+
export declare function fetchPosition(auth: AlpacaAuth, symbolOrAssetId: string): Promise<{
|
|
19
|
+
position: AlpacaPosition | null;
|
|
20
|
+
message?: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Closes a specific position in Alpaca.
|
|
24
|
+
* @param auth - The authentication details for Alpaca
|
|
25
|
+
* @param symbolOrAssetId - The symbol or asset ID of the position to close
|
|
26
|
+
* @param params - Optional parameters for closing the position
|
|
27
|
+
* @returns The order created to close the position
|
|
28
|
+
*/
|
|
29
|
+
export declare function closePosition(auth: AlpacaAuth, symbolOrAssetId: string, params?: {
|
|
30
|
+
qty?: number;
|
|
31
|
+
percentage?: number;
|
|
32
|
+
useLimitOrder?: boolean;
|
|
33
|
+
cancelOrders?: boolean;
|
|
34
|
+
slippagePercent1?: number;
|
|
35
|
+
extendedHours?: boolean;
|
|
36
|
+
}): Promise<AlpacaOrder>;
|
|
37
|
+
/**
|
|
38
|
+
* Closes all positions in Alpaca.
|
|
39
|
+
* @param auth - The authentication details for Alpaca
|
|
40
|
+
* @param params - Optional parameters for closing all positions
|
|
41
|
+
* @returns The status of each position closure attempt
|
|
42
|
+
*/
|
|
43
|
+
export declare function closeAllPositions(auth: AlpacaAuth, params?: {
|
|
44
|
+
cancel_orders?: boolean;
|
|
45
|
+
useLimitOrders?: boolean;
|
|
46
|
+
slippagePercent1?: number;
|
|
47
|
+
}): Promise<Array<{
|
|
48
|
+
symbol: string;
|
|
49
|
+
status: number;
|
|
50
|
+
body?: AlpacaOrder;
|
|
51
|
+
}> | void>;
|
|
52
|
+
/**
|
|
53
|
+
* Closes all positions in Alpaca using limit orders during extended hours trading.
|
|
54
|
+
* @param auth - The authentication details for Alpaca
|
|
55
|
+
* @param params - Optional parameters for closing all positions
|
|
56
|
+
* @returns The status of each position closure attempt
|
|
57
|
+
*/
|
|
58
|
+
export declare function closeAllPositionsAfterHours(auth: AlpacaAuth, params?: {
|
|
59
|
+
cancel_orders?: boolean;
|
|
60
|
+
slippagePercent1?: number;
|
|
61
|
+
}): Promise<Array<{
|
|
62
|
+
symbol: string;
|
|
63
|
+
status: number;
|
|
64
|
+
body?: AlpacaOrder;
|
|
65
|
+
}> | void>;
|
|
66
|
+
//# sourceMappingURL=positions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/legacy/positions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACf,MAAM,0BAA0B,CAAC;AAgBlC;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,cAAc,EAAE,CAAC,CA4B3B;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,UAAU,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC;IAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAsChE;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,UAAU,EAChB,eAAe,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC,WAAW,CAAC,CA6HtB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE;IACN,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC6C,GACxE,OAAO,CAAC,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC,GAAG,IAAI,CAAC,CAuHT;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE;IACN,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACsB,GACjD,OAAO,CAAC,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC,GAAG,IAAI,CAAC,CAoGT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy Alpaca Utility Functions
|
|
3
|
+
* HTML content cleaning and price rounding helpers.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Round a price to the nearest 2 decimal places for Alpaca,
|
|
7
|
+
* or 4 decimal places for prices less than $1.
|
|
8
|
+
* @param price - The price to round
|
|
9
|
+
* @returns The rounded price
|
|
10
|
+
*/
|
|
11
|
+
export declare const roundPriceForAlpaca: (price: number) => number;
|
|
12
|
+
/**
|
|
13
|
+
* Cleans HTML content by removing tags, scripts, styles, and decoding entities.
|
|
14
|
+
* @param htmlContent - The HTML string to clean
|
|
15
|
+
* @returns The cleaned plain-text string
|
|
16
|
+
*/
|
|
17
|
+
export declare function cleanContent(htmlContent: string): string;
|
|
18
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/legacy/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,KAAG,MAInD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAsCxD"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bars Module
|
|
3
|
+
* Historical and real-time OHLCV data using Alpaca SDK
|
|
4
|
+
*/
|
|
5
|
+
import { AlpacaClient } from "../client";
|
|
6
|
+
import { Bar, TimeFrame } from "../../types/alpaca-types";
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when bar operations fail
|
|
9
|
+
*/
|
|
10
|
+
export declare class BarError 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 bars
|
|
18
|
+
*/
|
|
19
|
+
export interface GetBarsParams {
|
|
20
|
+
/** Symbols to fetch bars for */
|
|
21
|
+
symbols: string[];
|
|
22
|
+
/** Bar timeframe (e.g., '1Min', '5Min', '1Hour', '1Day') */
|
|
23
|
+
timeframe: TimeFrame;
|
|
24
|
+
/** Start date/time for the data range */
|
|
25
|
+
start?: Date | string;
|
|
26
|
+
/** End date/time for the data range */
|
|
27
|
+
end?: Date | string;
|
|
28
|
+
/** Maximum number of bars to return per symbol */
|
|
29
|
+
limit?: number;
|
|
30
|
+
/** Price adjustment type */
|
|
31
|
+
adjustment?: "raw" | "split" | "dividend" | "all";
|
|
32
|
+
/** Data feed (sip for premium, iex for free tier) */
|
|
33
|
+
feed?: "sip" | "iex";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Bar analysis summary
|
|
37
|
+
*/
|
|
38
|
+
export interface BarAnalysis {
|
|
39
|
+
/** Opening price of the period */
|
|
40
|
+
open: number;
|
|
41
|
+
/** Highest price during the period */
|
|
42
|
+
high: number;
|
|
43
|
+
/** Lowest price during the period */
|
|
44
|
+
low: number;
|
|
45
|
+
/** Closing price of the period */
|
|
46
|
+
close: number;
|
|
47
|
+
/** Total volume traded */
|
|
48
|
+
volume: number;
|
|
49
|
+
/** Volume-weighted average price */
|
|
50
|
+
vwap: number;
|
|
51
|
+
/** Price change (close - open) */
|
|
52
|
+
change: number;
|
|
53
|
+
/** Price change as percentage */
|
|
54
|
+
changePercent: number;
|
|
55
|
+
/** Number of bars analyzed */
|
|
56
|
+
barCount: number;
|
|
57
|
+
/** Total number of trades */
|
|
58
|
+
totalTrades: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get historical bars with automatic pagination
|
|
62
|
+
* @param client - AlpacaClient instance
|
|
63
|
+
* @param params - Parameters for fetching bars
|
|
64
|
+
* @returns Map of symbol to array of bars
|
|
65
|
+
*/
|
|
66
|
+
export declare function getBars(client: AlpacaClient, params: GetBarsParams): Promise<Map<string, Bar[]>>;
|
|
67
|
+
/**
|
|
68
|
+
* Get latest bars for symbols
|
|
69
|
+
* @param client - AlpacaClient instance
|
|
70
|
+
* @param symbols - Array of stock symbols
|
|
71
|
+
* @returns Map of symbol to latest bar
|
|
72
|
+
*/
|
|
73
|
+
export declare function getLatestBars(client: AlpacaClient, symbols: string[]): Promise<Map<string, Bar>>;
|
|
74
|
+
/**
|
|
75
|
+
* Get daily prices for a symbol
|
|
76
|
+
* @param client - AlpacaClient instance
|
|
77
|
+
* @param symbol - Stock symbol
|
|
78
|
+
* @param days - Number of days of history to fetch
|
|
79
|
+
* @returns Array of daily bars
|
|
80
|
+
*/
|
|
81
|
+
export declare function getDailyPrices(client: AlpacaClient, symbol: string, days: number): Promise<Bar[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Get intraday prices for a symbol
|
|
84
|
+
* @param client - AlpacaClient instance
|
|
85
|
+
* @param symbol - Stock symbol
|
|
86
|
+
* @param timeframe - Bar timeframe
|
|
87
|
+
* @param start - Start date/time
|
|
88
|
+
* @param end - Optional end date/time (defaults to now)
|
|
89
|
+
* @returns Array of intraday bars
|
|
90
|
+
*/
|
|
91
|
+
export declare function getIntradayPrices(client: AlpacaClient, symbol: string, timeframe: TimeFrame, start: Date, end?: Date): Promise<Bar[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Get previous close price for a symbol
|
|
94
|
+
* @param client - AlpacaClient instance
|
|
95
|
+
* @param symbol - Stock symbol
|
|
96
|
+
* @returns Previous close price
|
|
97
|
+
*/
|
|
98
|
+
export declare function getPreviousClose(client: AlpacaClient, symbol: string): Promise<number>;
|
|
99
|
+
/**
|
|
100
|
+
* Analyze bars and return summary statistics
|
|
101
|
+
* @param bars - Array of bars to analyze
|
|
102
|
+
* @returns Analysis summary with OHLCV stats and price change
|
|
103
|
+
*/
|
|
104
|
+
export declare function analyzeBars(bars: Bar[]): BarAnalysis;
|
|
105
|
+
/**
|
|
106
|
+
* Get price range statistics for a symbol over a period
|
|
107
|
+
* @param client - AlpacaClient instance
|
|
108
|
+
* @param symbol - Stock symbol
|
|
109
|
+
* @param days - Number of days to analyze
|
|
110
|
+
* @returns Analysis of the price range
|
|
111
|
+
*/
|
|
112
|
+
export declare function getPriceRange(client: AlpacaClient, symbol: string, days: number): Promise<BarAnalysis>;
|
|
113
|
+
/**
|
|
114
|
+
* Calculate average daily volume for a symbol
|
|
115
|
+
* @param client - AlpacaClient instance
|
|
116
|
+
* @param symbol - Stock symbol
|
|
117
|
+
* @param days - Number of days to average (default 20)
|
|
118
|
+
* @returns Average daily volume
|
|
119
|
+
*/
|
|
120
|
+
export declare function getAverageDailyVolume(client: AlpacaClient, symbol: string, days?: number): Promise<number>;
|
|
121
|
+
/**
|
|
122
|
+
* Check if a symbol has sufficient trading volume
|
|
123
|
+
* @param client - AlpacaClient instance
|
|
124
|
+
* @param symbol - Stock symbol
|
|
125
|
+
* @param minAvgVolume - Minimum average daily volume required (default 100,000)
|
|
126
|
+
* @param days - Number of days to check (default 20)
|
|
127
|
+
* @returns true if average volume meets minimum requirement
|
|
128
|
+
*/
|
|
129
|
+
export declare function hasSufficientVolume(client: AlpacaClient, symbol: string, minAvgVolume?: number, days?: number): Promise<boolean>;
|
|
130
|
+
declare const _default: {
|
|
131
|
+
getBars: typeof getBars;
|
|
132
|
+
getLatestBars: typeof getLatestBars;
|
|
133
|
+
getDailyPrices: typeof getDailyPrices;
|
|
134
|
+
getIntradayPrices: typeof getIntradayPrices;
|
|
135
|
+
getPreviousClose: typeof getPreviousClose;
|
|
136
|
+
analyzeBars: typeof analyzeBars;
|
|
137
|
+
getPriceRange: typeof getPriceRange;
|
|
138
|
+
getAverageDailyVolume: typeof getAverageDailyVolume;
|
|
139
|
+
hasSufficientVolume: typeof hasSufficientVolume;
|
|
140
|
+
};
|
|
141
|
+
export default _default;
|
|
142
|
+
//# sourceMappingURL=bars.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bars.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/market-data/bars.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Market Data Module
|
|
3
|
+
* Exports quotes, bars, trades, and news functionality for market data access
|
|
4
|
+
*/
|
|
5
|
+
export { getLatestQuote, getLatestQuotes, getSpread, getSpreads, hasGoodLiquidity, QuoteError, } from "./quotes";
|
|
6
|
+
export type { SpreadInfo } from "./quotes";
|
|
7
|
+
export { getBars, getLatestBars, getDailyPrices, getIntradayPrices, getPreviousClose, analyzeBars, getPriceRange, getAverageDailyVolume, hasSufficientVolume, BarError, } from "./bars";
|
|
8
|
+
export type { GetBarsParams, BarAnalysis } from "./bars";
|
|
9
|
+
export { getLatestTrade, getLatestTrades, getHistoricalTrades, getCurrentPrice, getCurrentPrices, getTradeVolume, TradeError, } from "./trades";
|
|
10
|
+
export type { GetHistoricalTradesParams } from "./trades";
|
|
11
|
+
export { getNews, getLatestNews, searchNews, getNewsForSymbols, getSymbolSentiment, NewsError, } from "./news";
|
|
12
|
+
export type { GetNewsParams } from "./news";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/market-data/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,eAAe,EACf,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,UAAU,GACX,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EACL,OAAO,EACP,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,QAAQ,GACT,MAAM,QAAQ,CAAC;AAEhB,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGzD,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,GACX,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAG1D,OAAO,EACL,OAAO,EACP,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,GACV,MAAM,QAAQ,CAAC;AAEhB,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -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","sourceRoot":"","sources":["../../../../src/alpaca/market-data/news.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAEL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAQlC;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAGzB,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,aAAa;IAC5B,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,yCAAyC;IACzC,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,uCAAuC;IACvC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACtB,mDAAmD;IACnD,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAkPD;;;;;;GAMG;AACH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,YAAY,EACpB,MAAM,GAAE,aAAkB,GACzB,OAAO,CAAC,UAAU,EAAE,CAAC,CA4HvB;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAW,GACjB,OAAO,CAAC,UAAU,EAAE,CAAC,CAcvB;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAW,GACjB,OAAO,CAAC,UAAU,EAAE,CAAC,CAsDvB;AAED;;;;;;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,CAmDpC;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,CAyBtD;;;;;;;;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;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,QAAQ,EAET,MAAM,0BAA0B,CAAC;AAQlC;;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,UAAU;IACzB,gBAAgB;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,QAAQ,GACd,OAAO,CAAC,WAAW,CAAC,CA8DtB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,CAAC,EAAE,QAAQ,GACd,OAAO,CAAC,oBAAoB,CAAC,CAqF/B;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,CAuCrB;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,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,CAWlB;;;;;;;;AAED,wBAME"}
|