@adaptic/utils 0.0.382 → 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.
- package/dist/index.cjs +10241 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10057 -121
- package/dist/index.mjs.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 +201 -0
- package/dist/types/alpaca/index.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/index.d.ts +13 -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/index.d.ts +353 -6
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { createBracketOrder, createProtectiveBracket, createExecutorFromTradingAPI, BracketOrderParams, BracketOrderResult, BracketOrderExecutor, ProtectiveBracketParams, } from './bracket-orders';
|
|
2
|
+
export { default as bracketOrders } from './bracket-orders';
|
|
3
|
+
export { getAccountDetails, getAccountConfiguration, updateAccountConfiguration, getPortfolioHistory, checkTradingEligibility, getBuyingPower, getOptionsTradingLevel, getPDTStatus, getDailyReturns, calculatePeriodPerformance, getEquityCurve, getAccountSummary, isMarginAccount, getMarginInfo, TradingEligibility, BuyingPowerBreakdown, PDTStatus, DailyReturn, PeriodPerformance, EquityCurvePoint, } from './account';
|
|
4
|
+
export { default as account } from './account';
|
|
5
|
+
export { getOrdersBySymbol, getOpenOrders as getOpenOrdersQuery, getFilledOrders, getOrderHistory, getAllOrders, waitForOrderFill, isOrderFillable, isOrderFilled, isOrderTerminal as isOrderTerminalStatus, isOrderOpen, calculateOrderValue, calculateTotalFilledValue, formatOrderSummary, formatOrderForLog, roundPriceForAlpaca, roundPriceForAlpacaNumber, groupOrdersBySymbol, groupOrdersByStatus, filterOrdersByDateRange, sortOrdersByDate, GetAllOrdersParams, GetFilledOrdersParams, GetOrderHistoryParams, OrderHistoryResult, WaitForOrderFillParams, WaitForOrderFillResult, OrderSummary, } from './order-utils';
|
|
6
|
+
export { default as orderUtils } from './order-utils';
|
|
7
|
+
export { createTrailingStop, updateTrailingStop, getTrailingStopHWM, cancelTrailingStop, createPortfolioTrailingStops, getOpenTrailingStops, hasActiveTrailingStop, cancelTrailingStopsForSymbol, TrailingStopParams, TrailingStopHWMResult, PortfolioTrailingStopParams, TrailingStopValidationError, } from './trailing-stops';
|
|
8
|
+
export { default as trailingStops } from './trailing-stops';
|
|
9
|
+
export { createOCOOrder, cancelOCOOrder, getOCOOrderStatus, protectLongPosition, protectShortPosition, OCOOrderParams, OCOOrderResult, } from './oco-orders';
|
|
10
|
+
export { default as ocoOrders } from './oco-orders';
|
|
11
|
+
export { createOTOOrder, cancelOTOOrder, getOTOOrderStatus, buyWithStopLoss, buyWithTrailingStop, limitBuyWithTakeProfit, shortWithStopLoss, entryWithPercentStopLoss, OTOOrderParams, OTOOrderResult, DependentOrderConfig, DependentOrderType, } from './oto-orders';
|
|
12
|
+
export { default as otoOrders } from './oto-orders';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/trading/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EA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|
+
/**
|
|
2
|
+
* OCO (One-Cancels-Other) Order Module
|
|
3
|
+
*
|
|
4
|
+
* OCO orders consist of two orders where filling one automatically cancels the other.
|
|
5
|
+
* This is commonly used for protective strategies where you want to either:
|
|
6
|
+
* - Take profit at a target price, OR
|
|
7
|
+
* - Stop loss at a predetermined level
|
|
8
|
+
*
|
|
9
|
+
* When either order fills, Alpaca automatically cancels the other order.
|
|
10
|
+
*
|
|
11
|
+
* @module oco-orders
|
|
12
|
+
*/
|
|
13
|
+
import { AlpacaClient } from '../client';
|
|
14
|
+
import { AlpacaOrder, OrderSide, TimeInForce } from '../../types/alpaca-types';
|
|
15
|
+
/**
|
|
16
|
+
* OCO Order Parameters
|
|
17
|
+
* Creates two orders where filling one cancels the other.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Protect a long position with take profit at $150 OR stop loss at $130
|
|
21
|
+
* const params: OCOOrderParams = {
|
|
22
|
+
* symbol: 'AAPL',
|
|
23
|
+
* qty: 100,
|
|
24
|
+
* side: 'sell', // Selling to close long position
|
|
25
|
+
* takeProfit: {
|
|
26
|
+
* limitPrice: 150.00
|
|
27
|
+
* },
|
|
28
|
+
* stopLoss: {
|
|
29
|
+
* stopPrice: 130.00,
|
|
30
|
+
* limitPrice: 129.50 // Optional: creates stop-limit instead of stop
|
|
31
|
+
* },
|
|
32
|
+
* timeInForce: 'gtc'
|
|
33
|
+
* };
|
|
34
|
+
*/
|
|
35
|
+
export interface OCOOrderParams {
|
|
36
|
+
/** Symbol of the asset to trade */
|
|
37
|
+
symbol: string;
|
|
38
|
+
/** Quantity of shares to trade */
|
|
39
|
+
qty: number;
|
|
40
|
+
/** Order side - typically 'sell' for protecting long positions, 'buy' for short */
|
|
41
|
+
side: OrderSide;
|
|
42
|
+
/** Take profit limit order configuration */
|
|
43
|
+
takeProfit: {
|
|
44
|
+
/** Limit price for take profit order */
|
|
45
|
+
limitPrice: number;
|
|
46
|
+
};
|
|
47
|
+
/** Stop loss order configuration */
|
|
48
|
+
stopLoss: {
|
|
49
|
+
/** Stop trigger price */
|
|
50
|
+
stopPrice: number;
|
|
51
|
+
/** Optional limit price - if provided, creates stop-limit instead of stop market */
|
|
52
|
+
limitPrice?: number;
|
|
53
|
+
};
|
|
54
|
+
/** Time in force for both orders (default: 'gtc') */
|
|
55
|
+
timeInForce?: TimeInForce;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Result of OCO order creation
|
|
59
|
+
* Contains both leg orders and helper accessors
|
|
60
|
+
*/
|
|
61
|
+
export interface OCOOrderResult {
|
|
62
|
+
/** The take profit limit order */
|
|
63
|
+
takeProfitOrder: AlpacaOrder;
|
|
64
|
+
/** The stop loss order */
|
|
65
|
+
stopLossOrder: AlpacaOrder;
|
|
66
|
+
/** All orders in the OCO group */
|
|
67
|
+
allOrders: AlpacaOrder[];
|
|
68
|
+
/** Parent order ID (can be used for cancellation) */
|
|
69
|
+
parentOrderId: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create an OCO order (take profit OR stop loss)
|
|
73
|
+
*
|
|
74
|
+
* Use this to protect an existing position with automatic cancellation
|
|
75
|
+
* of the remaining order when one fills.
|
|
76
|
+
*
|
|
77
|
+
* @param client - AlpacaClient instance
|
|
78
|
+
* @param params - OCO order parameters
|
|
79
|
+
* @returns OCO order result with both leg orders
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // Protect 100 shares of AAPL long position
|
|
83
|
+
* // Take profit at $155, stop loss at $145
|
|
84
|
+
* const result = await createOCOOrder(client, {
|
|
85
|
+
* symbol: 'AAPL',
|
|
86
|
+
* qty: 100,
|
|
87
|
+
* side: 'sell',
|
|
88
|
+
* takeProfit: { limitPrice: 155.00 },
|
|
89
|
+
* stopLoss: { stopPrice: 145.00 },
|
|
90
|
+
* timeInForce: 'gtc'
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* console.log('Take profit order:', result.takeProfitOrder.id);
|
|
94
|
+
* console.log('Stop loss order:', result.stopLossOrder.id);
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* // Use stop-limit instead of stop-market for stop loss
|
|
98
|
+
* const result = await createOCOOrder(client, {
|
|
99
|
+
* symbol: 'TSLA',
|
|
100
|
+
* qty: 50,
|
|
101
|
+
* side: 'sell',
|
|
102
|
+
* takeProfit: { limitPrice: 280.00 },
|
|
103
|
+
* stopLoss: {
|
|
104
|
+
* stopPrice: 240.00,
|
|
105
|
+
* limitPrice: 238.00 // Limit price for stop-limit order
|
|
106
|
+
* },
|
|
107
|
+
* timeInForce: 'gtc'
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // Protect a short position (buying to close)
|
|
112
|
+
* const result = await createOCOOrder(client, {
|
|
113
|
+
* symbol: 'NVDA',
|
|
114
|
+
* qty: 25,
|
|
115
|
+
* side: 'buy', // Buy to close short
|
|
116
|
+
* takeProfit: { limitPrice: 380.00 }, // Take profit at lower price
|
|
117
|
+
* stopLoss: { stopPrice: 420.00 }, // Stop loss at higher price
|
|
118
|
+
* timeInForce: 'gtc'
|
|
119
|
+
* });
|
|
120
|
+
*/
|
|
121
|
+
export declare function createOCOOrder(client: AlpacaClient, params: OCOOrderParams): Promise<OCOOrderResult>;
|
|
122
|
+
/**
|
|
123
|
+
* Cancel an OCO order group by parent order ID
|
|
124
|
+
* This will cancel both the take profit and stop loss orders
|
|
125
|
+
*
|
|
126
|
+
* @param client - AlpacaClient instance
|
|
127
|
+
* @param parentOrderId - The parent order ID from OCOOrderResult
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* const result = await createOCOOrder(client, params);
|
|
131
|
+
* // Later...
|
|
132
|
+
* await cancelOCOOrder(client, result.parentOrderId);
|
|
133
|
+
*/
|
|
134
|
+
export declare function cancelOCOOrder(client: AlpacaClient, parentOrderId: string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Get the status of an OCO order group
|
|
137
|
+
*
|
|
138
|
+
* @param client - AlpacaClient instance
|
|
139
|
+
* @param parentOrderId - The parent order ID from OCOOrderResult
|
|
140
|
+
* @returns The parent order with leg status information
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* const result = await createOCOOrder(client, params);
|
|
144
|
+
* const status = await getOCOOrderStatus(client, result.parentOrderId);
|
|
145
|
+
* console.log('Order status:', status.status);
|
|
146
|
+
* status.legs?.forEach(leg => {
|
|
147
|
+
* console.log(`Leg ${leg.id}: ${leg.status}`);
|
|
148
|
+
* });
|
|
149
|
+
*/
|
|
150
|
+
export declare function getOCOOrderStatus(client: AlpacaClient, parentOrderId: string): Promise<AlpacaOrder>;
|
|
151
|
+
/**
|
|
152
|
+
* Helper to create OCO order for protecting a long position
|
|
153
|
+
* Convenience wrapper with sensible defaults for long protection
|
|
154
|
+
*
|
|
155
|
+
* @param client - AlpacaClient instance
|
|
156
|
+
* @param symbol - Stock symbol
|
|
157
|
+
* @param qty - Number of shares to protect
|
|
158
|
+
* @param takeProfitPrice - Price to take profit
|
|
159
|
+
* @param stopLossPrice - Price to stop loss
|
|
160
|
+
* @param stopLimitPrice - Optional limit price for stop-limit order
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* // Simple long protection
|
|
164
|
+
* const result = await protectLongPosition(
|
|
165
|
+
* client,
|
|
166
|
+
* 'AAPL',
|
|
167
|
+
* 100,
|
|
168
|
+
* 155.00, // Take profit
|
|
169
|
+
* 145.00 // Stop loss
|
|
170
|
+
* );
|
|
171
|
+
*/
|
|
172
|
+
export declare function protectLongPosition(client: AlpacaClient, symbol: string, qty: number, takeProfitPrice: number, stopLossPrice: number, stopLimitPrice?: number): Promise<OCOOrderResult>;
|
|
173
|
+
/**
|
|
174
|
+
* Helper to create OCO order for protecting a short position
|
|
175
|
+
* Convenience wrapper with sensible defaults for short protection
|
|
176
|
+
*
|
|
177
|
+
* @param client - AlpacaClient instance
|
|
178
|
+
* @param symbol - Stock symbol
|
|
179
|
+
* @param qty - Number of shares to cover
|
|
180
|
+
* @param takeProfitPrice - Price to take profit (lower than current)
|
|
181
|
+
* @param stopLossPrice - Price to stop loss (higher than current)
|
|
182
|
+
* @param stopLimitPrice - Optional limit price for stop-limit order
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* // Simple short protection
|
|
186
|
+
* const result = await protectShortPosition(
|
|
187
|
+
* client,
|
|
188
|
+
* 'TSLA',
|
|
189
|
+
* 50,
|
|
190
|
+
* 200.00, // Take profit at lower price
|
|
191
|
+
* 260.00 // Stop loss at higher price
|
|
192
|
+
* );
|
|
193
|
+
*/
|
|
194
|
+
export declare function protectShortPosition(client: AlpacaClient, symbol: string, qty: number, takeProfitPrice: number, stopLossPrice: number, stopLimitPrice?: number): Promise<OCOOrderResult>;
|
|
195
|
+
declare const _default: {
|
|
196
|
+
createOCOOrder: typeof createOCOOrder;
|
|
197
|
+
cancelOCOOrder: typeof cancelOCOOrder;
|
|
198
|
+
getOCOOrderStatus: typeof getOCOOrderStatus;
|
|
199
|
+
protectLongPosition: typeof protectLongPosition;
|
|
200
|
+
protectShortPosition: typeof protectShortPosition;
|
|
201
|
+
};
|
|
202
|
+
export default _default;
|
|
203
|
+
//# sourceMappingURL=oco-orders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oco-orders.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/trading/oco-orders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAQ/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,mFAAmF;IACnF,IAAI,EAAE,SAAS,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BG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,cAAc,CAAC,CAYzB;;;;;;;;AAED,wBAME"}
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order Query Utilities for Alpaca Trading
|
|
3
|
+
*
|
|
4
|
+
* Provides utility functions for querying, filtering, and managing Alpaca orders.
|
|
5
|
+
* Includes auto-pagination, order status helpers, and formatting utilities.
|
|
6
|
+
*
|
|
7
|
+
* @module order-utils
|
|
8
|
+
*/
|
|
9
|
+
import { AlpacaClient } from '../client';
|
|
10
|
+
import { AlpacaOrder, GetOrdersParams } from '../../types/alpaca-types';
|
|
11
|
+
/**
|
|
12
|
+
* Parameters for getAllOrders with pagination support
|
|
13
|
+
*/
|
|
14
|
+
export interface GetAllOrdersParams extends GetOrdersParams {
|
|
15
|
+
/** If true, fetches all orders by paginating through results */
|
|
16
|
+
fetchAll?: boolean;
|
|
17
|
+
/** Delay between pagination requests in ms (default: 300) */
|
|
18
|
+
paginationDelayMs?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parameters for getFilledOrders
|
|
22
|
+
*/
|
|
23
|
+
export interface GetFilledOrdersParams {
|
|
24
|
+
/** Start date for the date range (inclusive) */
|
|
25
|
+
startDate: Date;
|
|
26
|
+
/** End date for the date range (inclusive) */
|
|
27
|
+
endDate: Date;
|
|
28
|
+
/** Optional symbols to filter by */
|
|
29
|
+
symbols?: string[];
|
|
30
|
+
/** Optional side filter */
|
|
31
|
+
side?: 'buy' | 'sell';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Parameters for getOrderHistory with pagination
|
|
35
|
+
*/
|
|
36
|
+
export interface GetOrderHistoryParams {
|
|
37
|
+
/** Number of orders per page (max 500) */
|
|
38
|
+
pageSize?: number;
|
|
39
|
+
/** Starting page number (1-indexed) */
|
|
40
|
+
page?: number;
|
|
41
|
+
/** Optional symbols to filter by */
|
|
42
|
+
symbols?: string[];
|
|
43
|
+
/** Optional status filter */
|
|
44
|
+
status?: 'open' | 'closed' | 'all';
|
|
45
|
+
/** Optional side filter */
|
|
46
|
+
side?: 'buy' | 'sell';
|
|
47
|
+
/** Sort direction */
|
|
48
|
+
direction?: 'asc' | 'desc';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Result of paginated order history
|
|
52
|
+
*/
|
|
53
|
+
export interface OrderHistoryResult {
|
|
54
|
+
/** Orders for the current page */
|
|
55
|
+
orders: AlpacaOrder[];
|
|
56
|
+
/** Current page number */
|
|
57
|
+
page: number;
|
|
58
|
+
/** Number of orders per page */
|
|
59
|
+
pageSize: number;
|
|
60
|
+
/** Total number of orders fetched so far */
|
|
61
|
+
totalFetched: number;
|
|
62
|
+
/** Whether there are more orders to fetch */
|
|
63
|
+
hasMore: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parameters for waitForOrderFill
|
|
67
|
+
*/
|
|
68
|
+
export interface WaitForOrderFillParams {
|
|
69
|
+
/** Order ID to monitor */
|
|
70
|
+
orderId: string;
|
|
71
|
+
/** Maximum time to wait in milliseconds (default: 60000) */
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
/** Polling interval in milliseconds (default: 1000) */
|
|
74
|
+
pollIntervalMs?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Result of waitForOrderFill
|
|
78
|
+
*/
|
|
79
|
+
export interface WaitForOrderFillResult {
|
|
80
|
+
/** Whether the order was filled */
|
|
81
|
+
filled: boolean;
|
|
82
|
+
/** The final order state */
|
|
83
|
+
order: AlpacaOrder;
|
|
84
|
+
/** Time elapsed in milliseconds */
|
|
85
|
+
elapsedMs: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Order summary for display/logging
|
|
89
|
+
*/
|
|
90
|
+
export interface OrderSummary {
|
|
91
|
+
id: string;
|
|
92
|
+
symbol: string;
|
|
93
|
+
side: string;
|
|
94
|
+
type: string;
|
|
95
|
+
status: string;
|
|
96
|
+
qty: string;
|
|
97
|
+
filledQty: string;
|
|
98
|
+
limitPrice: string | null;
|
|
99
|
+
stopPrice: string | null;
|
|
100
|
+
avgFillPrice: string | null;
|
|
101
|
+
createdAt: string;
|
|
102
|
+
filledAt: string | null;
|
|
103
|
+
timeInForce: string;
|
|
104
|
+
assetClass: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get all orders for a specific symbol
|
|
108
|
+
*
|
|
109
|
+
* @param client - AlpacaClient instance
|
|
110
|
+
* @param symbol - Symbol to filter orders by (e.g., 'AAPL', 'BTCUSD')
|
|
111
|
+
* @param params - Optional additional filter parameters
|
|
112
|
+
* @returns Promise resolving to array of orders for the symbol
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const client = createAlpacaClient({ apiKey, apiSecret, accountType: 'PAPER' });
|
|
117
|
+
* const orders = await getOrdersBySymbol(client, 'AAPL', { status: 'all' });
|
|
118
|
+
* console.log(`Found ${orders.length} orders for AAPL`);
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function getOrdersBySymbol(client: AlpacaClient, symbol: string, params?: Omit<GetOrdersParams, 'symbols'>): Promise<AlpacaOrder[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Get only open orders
|
|
124
|
+
*
|
|
125
|
+
* @param client - AlpacaClient instance
|
|
126
|
+
* @param params - Optional filter parameters
|
|
127
|
+
* @returns Promise resolving to array of open orders
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const openOrders = await getOpenOrders(client);
|
|
132
|
+
* console.log(`You have ${openOrders.length} open orders`);
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare function getOpenOrders(client: AlpacaClient, params?: Omit<GetOrdersParams, 'status'>): Promise<AlpacaOrder[]>;
|
|
136
|
+
/**
|
|
137
|
+
* Get only filled orders within a date range
|
|
138
|
+
*
|
|
139
|
+
* @param client - AlpacaClient instance
|
|
140
|
+
* @param params - Date range and optional filter parameters
|
|
141
|
+
* @returns Promise resolving to array of filled orders in the date range
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const startDate = new Date('2024-01-01');
|
|
146
|
+
* const endDate = new Date('2024-01-31');
|
|
147
|
+
* const filledOrders = await getFilledOrders(client, { startDate, endDate });
|
|
148
|
+
* console.log(`Found ${filledOrders.length} filled orders in January`);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function getFilledOrders(client: AlpacaClient, params: GetFilledOrdersParams): Promise<AlpacaOrder[]>;
|
|
152
|
+
/**
|
|
153
|
+
* Get paginated order history with auto-pagination support
|
|
154
|
+
*
|
|
155
|
+
* @param client - AlpacaClient instance
|
|
156
|
+
* @param params - Pagination and filter parameters
|
|
157
|
+
* @returns Promise resolving to order history result with pagination info
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* // Get first page
|
|
162
|
+
* const result = await getOrderHistory(client, { pageSize: 100, page: 1 });
|
|
163
|
+
*
|
|
164
|
+
* // Get all pages
|
|
165
|
+
* let allOrders: AlpacaOrder[] = [];
|
|
166
|
+
* let page = 1;
|
|
167
|
+
* let hasMore = true;
|
|
168
|
+
*
|
|
169
|
+
* while (hasMore) {
|
|
170
|
+
* const result = await getOrderHistory(client, { pageSize: 100, page });
|
|
171
|
+
* allOrders = allOrders.concat(result.orders);
|
|
172
|
+
* hasMore = result.hasMore;
|
|
173
|
+
* page++;
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export declare function getOrderHistory(client: AlpacaClient, params?: GetOrderHistoryParams): Promise<OrderHistoryResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Get all orders with automatic pagination
|
|
180
|
+
* Alpaca limits to 500 orders per request, so this function handles
|
|
181
|
+
* pagination automatically when fetchAll is true.
|
|
182
|
+
*
|
|
183
|
+
* @param client - AlpacaClient instance
|
|
184
|
+
* @param params - Query parameters with optional fetchAll flag
|
|
185
|
+
* @returns Promise resolving to array of all orders matching the criteria
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* // Fetch all closed orders
|
|
190
|
+
* const allOrders = await getAllOrders(client, {
|
|
191
|
+
* status: 'closed',
|
|
192
|
+
* fetchAll: true
|
|
193
|
+
* });
|
|
194
|
+
* console.log(`Total orders: ${allOrders.length}`);
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export declare function getAllOrders(client: AlpacaClient, params?: GetAllOrdersParams): Promise<AlpacaOrder[]>;
|
|
198
|
+
/**
|
|
199
|
+
* Wait for an order to be filled or timeout
|
|
200
|
+
*
|
|
201
|
+
* @param client - AlpacaClient instance
|
|
202
|
+
* @param params - Order ID and timeout parameters
|
|
203
|
+
* @returns Promise resolving to fill result with order state and timing info
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const order = await submitOrder(client, { ... });
|
|
208
|
+
*
|
|
209
|
+
* const result = await waitForOrderFill(client, {
|
|
210
|
+
* orderId: order.id,
|
|
211
|
+
* timeoutMs: 30000, // 30 seconds
|
|
212
|
+
* pollIntervalMs: 500 // Poll every 500ms
|
|
213
|
+
* });
|
|
214
|
+
*
|
|
215
|
+
* if (result.filled) {
|
|
216
|
+
* console.log(`Order filled at ${result.order.filled_avg_price}`);
|
|
217
|
+
* } else {
|
|
218
|
+
* console.log(`Order not filled, status: ${result.order.status}`);
|
|
219
|
+
* }
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export declare function waitForOrderFill(client: AlpacaClient, params: WaitForOrderFillParams): Promise<WaitForOrderFillResult>;
|
|
223
|
+
/**
|
|
224
|
+
* Check if an order can still be filled
|
|
225
|
+
*
|
|
226
|
+
* @param order - AlpacaOrder to check
|
|
227
|
+
* @returns True if the order can potentially still be filled
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const order = await getOrder(client, orderId);
|
|
232
|
+
* if (isOrderFillable(order)) {
|
|
233
|
+
* console.log('Order is still active and may be filled');
|
|
234
|
+
* } else {
|
|
235
|
+
* console.log('Order cannot be filled anymore');
|
|
236
|
+
* }
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
export declare function isOrderFillable(order: AlpacaOrder): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Check if an order has been filled
|
|
242
|
+
*
|
|
243
|
+
* @param order - AlpacaOrder to check
|
|
244
|
+
* @returns True if the order has been filled
|
|
245
|
+
*/
|
|
246
|
+
export declare function isOrderFilled(order: AlpacaOrder): boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Check if an order is in a terminal state
|
|
249
|
+
*
|
|
250
|
+
* @param order - AlpacaOrder to check
|
|
251
|
+
* @returns True if the order is in a terminal state (no longer active)
|
|
252
|
+
*/
|
|
253
|
+
export declare function isOrderTerminal(order: AlpacaOrder): boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Check if an order is open (active, waiting to be filled)
|
|
256
|
+
*
|
|
257
|
+
* @param order - AlpacaOrder to check
|
|
258
|
+
* @returns True if the order is open
|
|
259
|
+
*/
|
|
260
|
+
export declare function isOrderOpen(order: AlpacaOrder): boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Calculate the total value of an order
|
|
263
|
+
* For filled orders, uses the filled quantity and average price.
|
|
264
|
+
* For unfilled orders, uses the order quantity and limit/stop price.
|
|
265
|
+
*
|
|
266
|
+
* @param order - AlpacaOrder to calculate value for
|
|
267
|
+
* @returns Total order value, or null if cannot be calculated
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const order = await getOrder(client, orderId);
|
|
272
|
+
* const value = calculateOrderValue(order);
|
|
273
|
+
* if (value !== null) {
|
|
274
|
+
* console.log(`Order value: $${value.toFixed(2)}`);
|
|
275
|
+
* }
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export declare function calculateOrderValue(order: AlpacaOrder): number | null;
|
|
279
|
+
/**
|
|
280
|
+
* Format an order for logging or display
|
|
281
|
+
*
|
|
282
|
+
* @param order - AlpacaOrder to format
|
|
283
|
+
* @returns OrderSummary with formatted fields
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* const order = await getOrder(client, orderId);
|
|
288
|
+
* const summary = formatOrderSummary(order);
|
|
289
|
+
* console.log(`${summary.side.toUpperCase()} ${summary.qty} ${summary.symbol} @ ${summary.avgFillPrice || summary.limitPrice || 'MARKET'}`);
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
export declare function formatOrderSummary(order: AlpacaOrder): OrderSummary;
|
|
293
|
+
/**
|
|
294
|
+
* Format order summary as a single-line string for logging
|
|
295
|
+
*
|
|
296
|
+
* @param order - AlpacaOrder to format
|
|
297
|
+
* @returns Formatted string for logging
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* const order = await getOrder(client, orderId);
|
|
302
|
+
* console.log(formatOrderForLog(order));
|
|
303
|
+
* // Output: "BUY 100 AAPL LIMIT @ $150.00 [filled] - filled 100 @ $149.95"
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
export declare function formatOrderForLog(order: AlpacaOrder): string;
|
|
307
|
+
/**
|
|
308
|
+
* Round prices correctly for Alpaca API
|
|
309
|
+
* Uses 2 decimal places for prices >= $1
|
|
310
|
+
* Uses 4 decimal places for prices < $1 (penny stocks, crypto)
|
|
311
|
+
*
|
|
312
|
+
* @param price - Price to round
|
|
313
|
+
* @returns Formatted price string
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* roundPriceForAlpaca(150.12345) // "150.12"
|
|
318
|
+
* roundPriceForAlpaca(0.12345) // "0.1235"
|
|
319
|
+
* roundPriceForAlpaca(0.00123) // "0.0012"
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
export declare function roundPriceForAlpaca(price: number): string;
|
|
323
|
+
/**
|
|
324
|
+
* Round price as a number for calculations
|
|
325
|
+
*
|
|
326
|
+
* @param price - Price to round
|
|
327
|
+
* @returns Rounded price as number
|
|
328
|
+
*/
|
|
329
|
+
export declare function roundPriceForAlpacaNumber(price: number): number;
|
|
330
|
+
/**
|
|
331
|
+
* Get orders grouped by symbol
|
|
332
|
+
*
|
|
333
|
+
* @param orders - Array of orders to group
|
|
334
|
+
* @returns Map of symbol to orders
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```typescript
|
|
338
|
+
* const orders = await getAllOrders(client, { fetchAll: true });
|
|
339
|
+
* const bySymbol = groupOrdersBySymbol(orders);
|
|
340
|
+
*
|
|
341
|
+
* for (const [symbol, symbolOrders] of bySymbol) {
|
|
342
|
+
* console.log(`${symbol}: ${symbolOrders.length} orders`);
|
|
343
|
+
* }
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
export declare function groupOrdersBySymbol(orders: AlpacaOrder[]): Map<string, AlpacaOrder[]>;
|
|
347
|
+
/**
|
|
348
|
+
* Get orders grouped by status
|
|
349
|
+
*
|
|
350
|
+
* @param orders - Array of orders to group
|
|
351
|
+
* @returns Map of status to orders
|
|
352
|
+
*/
|
|
353
|
+
export declare function groupOrdersByStatus(orders: AlpacaOrder[]): Map<string, AlpacaOrder[]>;
|
|
354
|
+
/**
|
|
355
|
+
* Calculate total filled value across multiple orders
|
|
356
|
+
*
|
|
357
|
+
* @param orders - Array of orders
|
|
358
|
+
* @returns Total filled value
|
|
359
|
+
*/
|
|
360
|
+
export declare function calculateTotalFilledValue(orders: AlpacaOrder[]): number;
|
|
361
|
+
/**
|
|
362
|
+
* Filter orders by date range
|
|
363
|
+
*
|
|
364
|
+
* @param orders - Array of orders to filter
|
|
365
|
+
* @param startDate - Start of date range (inclusive)
|
|
366
|
+
* @param endDate - End of date range (inclusive)
|
|
367
|
+
* @returns Filtered orders
|
|
368
|
+
*/
|
|
369
|
+
export declare function filterOrdersByDateRange(orders: AlpacaOrder[], startDate: Date, endDate: Date): AlpacaOrder[];
|
|
370
|
+
/**
|
|
371
|
+
* Sort orders by created date
|
|
372
|
+
*
|
|
373
|
+
* @param orders - Array of orders to sort
|
|
374
|
+
* @param direction - Sort direction ('asc' or 'desc')
|
|
375
|
+
* @returns Sorted orders (new array)
|
|
376
|
+
*/
|
|
377
|
+
export declare function sortOrdersByDate(orders: AlpacaOrder[], direction?: 'asc' | 'desc'): AlpacaOrder[];
|
|
378
|
+
/**
|
|
379
|
+
* Default export containing all order utility functions
|
|
380
|
+
*/
|
|
381
|
+
declare const _default: {
|
|
382
|
+
getOrdersBySymbol: typeof getOrdersBySymbol;
|
|
383
|
+
getOpenOrders: typeof getOpenOrders;
|
|
384
|
+
getFilledOrders: typeof getFilledOrders;
|
|
385
|
+
getOrderHistory: typeof getOrderHistory;
|
|
386
|
+
getAllOrders: typeof getAllOrders;
|
|
387
|
+
waitForOrderFill: typeof waitForOrderFill;
|
|
388
|
+
isOrderFillable: typeof isOrderFillable;
|
|
389
|
+
isOrderFilled: typeof isOrderFilled;
|
|
390
|
+
isOrderTerminal: typeof isOrderTerminal;
|
|
391
|
+
isOrderOpen: typeof isOrderOpen;
|
|
392
|
+
calculateOrderValue: typeof calculateOrderValue;
|
|
393
|
+
calculateTotalFilledValue: typeof calculateTotalFilledValue;
|
|
394
|
+
formatOrderSummary: typeof formatOrderSummary;
|
|
395
|
+
formatOrderForLog: typeof formatOrderForLog;
|
|
396
|
+
roundPriceForAlpaca: typeof roundPriceForAlpaca;
|
|
397
|
+
roundPriceForAlpacaNumber: typeof roundPriceForAlpacaNumber;
|
|
398
|
+
groupOrdersBySymbol: typeof groupOrdersBySymbol;
|
|
399
|
+
groupOrdersByStatus: typeof groupOrdersByStatus;
|
|
400
|
+
filterOrdersByDateRange: typeof filterOrdersByDateRange;
|
|
401
|
+
sortOrdersByDate: typeof sortOrdersByDate;
|
|
402
|
+
};
|
|
403
|
+
export default _default;
|
|
404
|
+
//# sourceMappingURL=order-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-utils.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/trading/order-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EACL,WAAW,EACX,eAAe,EAEhB,MAAM,0BAA0B,CAAC;AAwDlC;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,SAAS,EAAE,IAAI,CAAC;IAChB,8CAA8C;IAC9C,OAAO,EAAE,IAAI,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,2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