@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.
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,199 @@
1
+ /**
2
+ * Alpaca Order Management Module
3
+ * Provides functions for creating, managing, and canceling orders using the official SDK
4
+ */
5
+ import { AlpacaClient } from '../client';
6
+ import { AlpacaOrder, CreateOrderParams, GetOrdersParams, ReplaceOrderParams, OrderStatus } from '../../types/alpaca-types';
7
+ /**
8
+ * Response from cancel all orders operation
9
+ */
10
+ export interface CancelAllOrdersResponse {
11
+ /** Number of orders successfully canceled */
12
+ canceled: number;
13
+ /** Order IDs that failed to cancel */
14
+ failed: string[];
15
+ }
16
+ /**
17
+ * Creates a new order using the Alpaca SDK.
18
+ * Supports market, limit, stop, and stop_limit order types.
19
+ *
20
+ * @param client - The AlpacaClient instance
21
+ * @param params - Order parameters including symbol, qty, side, type, and time_in_force
22
+ * @returns The created order object
23
+ * @throws Error if order creation fails
24
+ *
25
+ * @example
26
+ * // Create a market order
27
+ * const order = await createOrder(client, {
28
+ * symbol: 'AAPL',
29
+ * qty: '10',
30
+ * side: 'buy',
31
+ * type: 'market',
32
+ * time_in_force: 'day',
33
+ * });
34
+ *
35
+ * @example
36
+ * // Create a limit order
37
+ * const order = await createOrder(client, {
38
+ * symbol: 'AAPL',
39
+ * qty: '10',
40
+ * side: 'buy',
41
+ * type: 'limit',
42
+ * limit_price: '150.00',
43
+ * time_in_force: 'gtc',
44
+ * });
45
+ */
46
+ export declare function createOrder(client: AlpacaClient, params: CreateOrderParams): Promise<AlpacaOrder>;
47
+ /**
48
+ * Retrieves a specific order by its ID.
49
+ *
50
+ * @param client - The AlpacaClient instance
51
+ * @param orderId - The unique identifier of the order
52
+ * @returns The order object if found
53
+ * @throws Error if order is not found or request fails
54
+ *
55
+ * @example
56
+ * const order = await getOrder(client, 'order-uuid-here');
57
+ * console.log(`Order status: ${order.status}`);
58
+ */
59
+ export declare function getOrder(client: AlpacaClient, orderId: string): Promise<AlpacaOrder>;
60
+ /**
61
+ * Retrieves all orders matching the specified filters.
62
+ *
63
+ * @param client - The AlpacaClient instance
64
+ * @param params - Optional filter parameters
65
+ * @param params.status - Filter by order status: 'open', 'closed', or 'all'
66
+ * @param params.limit - Maximum number of orders to return (default: 50, max: 500)
67
+ * @param params.after - Filter orders created after this timestamp (RFC-3339 format)
68
+ * @param params.until - Filter orders created before this timestamp (RFC-3339 format)
69
+ * @param params.direction - Sort direction: 'asc' or 'desc' (default: 'desc')
70
+ * @param params.nested - Include nested orders (for bracket orders)
71
+ * @param params.symbols - Filter by specific symbols
72
+ * @param params.side - Filter by order side: 'buy' or 'sell'
73
+ * @returns Array of orders matching the filters
74
+ *
75
+ * @example
76
+ * // Get all open orders
77
+ * const openOrders = await getOrders(client, { status: 'open' });
78
+ *
79
+ * @example
80
+ * // Get recent orders for specific symbols
81
+ * const orders = await getOrders(client, {
82
+ * symbols: ['AAPL', 'GOOGL'],
83
+ * limit: 100,
84
+ * });
85
+ */
86
+ export declare function getOrders(client: AlpacaClient, params?: GetOrdersParams): Promise<AlpacaOrder[]>;
87
+ /**
88
+ * Cancels a specific order by its ID.
89
+ * Only orders that are 'new', 'partially_filled', or 'accepted' can be canceled.
90
+ *
91
+ * @param client - The AlpacaClient instance
92
+ * @param orderId - The unique identifier of the order to cancel
93
+ * @throws Error if order cannot be canceled (e.g., already filled or canceled)
94
+ *
95
+ * @example
96
+ * await cancelOrder(client, 'order-uuid-here');
97
+ * console.log('Order canceled successfully');
98
+ */
99
+ export declare function cancelOrder(client: AlpacaClient, orderId: string): Promise<void>;
100
+ /**
101
+ * Cancels all open orders.
102
+ * This operation is atomic - if any cancellation fails, the function continues
103
+ * with remaining orders and returns information about failures.
104
+ *
105
+ * @param client - The AlpacaClient instance
106
+ * @returns Object containing count of canceled orders and any failures
107
+ *
108
+ * @example
109
+ * const result = await cancelAllOrders(client);
110
+ * console.log(`Canceled ${result.canceled} orders`);
111
+ * if (result.failed.length > 0) {
112
+ * console.log(`Failed to cancel: ${result.failed.join(', ')}`);
113
+ * }
114
+ */
115
+ export declare function cancelAllOrders(client: AlpacaClient): Promise<CancelAllOrdersResponse>;
116
+ /**
117
+ * Replaces (modifies) an existing order with new parameters.
118
+ * Only pending orders can be replaced. The order must not be filled.
119
+ *
120
+ * Common use cases:
121
+ * - Update the quantity of an order
122
+ * - Change the limit price
123
+ * - Adjust the stop price
124
+ * - Update trailing stop parameters
125
+ *
126
+ * @param client - The AlpacaClient instance
127
+ * @param orderId - The unique identifier of the order to replace
128
+ * @param params - New order parameters (qty, limit_price, stop_price, trail, time_in_force, client_order_id)
129
+ * @returns The new order object that replaces the original
130
+ * @throws Error if order cannot be replaced
131
+ *
132
+ * @example
133
+ * // Update limit price
134
+ * const newOrder = await replaceOrder(client, 'order-id', {
135
+ * limit_price: '155.00',
136
+ * });
137
+ *
138
+ * @example
139
+ * // Update quantity and price
140
+ * const newOrder = await replaceOrder(client, 'order-id', {
141
+ * qty: '20',
142
+ * limit_price: '152.50',
143
+ * });
144
+ */
145
+ export declare function replaceOrder(client: AlpacaClient, orderId: string, params: ReplaceOrderParams): Promise<AlpacaOrder>;
146
+ /**
147
+ * Convenience function to get all open orders.
148
+ *
149
+ * @param client - The AlpacaClient instance
150
+ * @param symbols - Optional array of symbols to filter by
151
+ * @returns Array of open orders
152
+ *
153
+ * @example
154
+ * const openOrders = await getOpenOrders(client);
155
+ * console.log(`Found ${openOrders.length} open orders`);
156
+ */
157
+ export declare function getOpenOrders(client: AlpacaClient, symbols?: string[]): Promise<AlpacaOrder[]>;
158
+ /**
159
+ * Convenience function to check if an order is in a terminal state.
160
+ * Terminal states are: filled, canceled, expired, rejected
161
+ *
162
+ * @param status - The order status to check
163
+ * @returns True if the order is in a terminal state
164
+ *
165
+ * @example
166
+ * const order = await getOrder(client, 'order-id');
167
+ * if (isOrderTerminal(order.status)) {
168
+ * console.log('Order is complete');
169
+ * }
170
+ */
171
+ export declare function isOrderTerminal(status: OrderStatus): boolean;
172
+ /**
173
+ * Convenience function to check if an order can be canceled.
174
+ * Orders can be canceled if they are: new, partially_filled, accepted, pending_new
175
+ *
176
+ * @param status - The order status to check
177
+ * @returns True if the order can be canceled
178
+ *
179
+ * @example
180
+ * const order = await getOrder(client, 'order-id');
181
+ * if (isOrderCancelable(order.status)) {
182
+ * await cancelOrder(client, order.id);
183
+ * }
184
+ */
185
+ export declare function isOrderCancelable(status: OrderStatus): boolean;
186
+ /**
187
+ * Gets an order by client order ID.
188
+ * Useful when you need to track orders using your own identifiers.
189
+ *
190
+ * @param client - The AlpacaClient instance
191
+ * @param clientOrderId - Your custom order identifier
192
+ * @returns The order if found
193
+ * @throws Error if order is not found
194
+ *
195
+ * @example
196
+ * const order = await getOrderByClientId(client, 'my-custom-order-123');
197
+ */
198
+ export declare function getOrderByClientId(client: AlpacaClient, clientOrderId: string): Promise<AlpacaOrder>;
199
+ //# sourceMappingURL=orders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/trading/orders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,WAAW,EACZ,MAAM,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AAO,CAG5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAG9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,YAAY,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,WAAW,CAAC,CAoBtB"}
@@ -0,0 +1,282 @@
1
+ /**
2
+ * OTO (One-Triggers-Other) Order Module
3
+ *
4
+ * OTO orders consist of a primary order and a dependent order. When the primary
5
+ * order fills, it automatically triggers the dependent order. This is commonly
6
+ * used for:
7
+ * - Entry orders that automatically set up a stop loss
8
+ * - Entry orders that automatically set up a take profit
9
+ * - Automatic position management after entry
10
+ *
11
+ * Unlike bracket orders, OTO only has one dependent order (not two).
12
+ *
13
+ * @module oto-orders
14
+ */
15
+ import { AlpacaClient } from '../client';
16
+ import { AlpacaOrder, OrderSide, OrderType, TimeInForce } from '../../types/alpaca-types';
17
+ /**
18
+ * Dependent order type options for OTO orders
19
+ */
20
+ export type DependentOrderType = 'limit' | 'stop' | 'stop_limit' | 'trailing_stop';
21
+ /**
22
+ * Configuration for the dependent order in an OTO
23
+ */
24
+ export interface DependentOrderConfig {
25
+ /** Side of the dependent order */
26
+ side: OrderSide;
27
+ /** Type of the dependent order */
28
+ type: DependentOrderType;
29
+ /** Limit price (required for 'limit' and 'stop_limit' types) */
30
+ limitPrice?: number;
31
+ /** Stop price (required for 'stop' and 'stop_limit' types) */
32
+ stopPrice?: number;
33
+ /** Trail percent for trailing stop orders (e.g., 5 for 5%) */
34
+ trailPercent?: number;
35
+ /** Trail price for trailing stop orders (absolute dollar amount) */
36
+ trailPrice?: number;
37
+ }
38
+ /**
39
+ * OTO Order Parameters
40
+ * Primary order triggers secondary order on fill.
41
+ *
42
+ * @example
43
+ * // Buy 100 shares with automatic trailing stop on fill
44
+ * const params: OTOOrderParams = {
45
+ * symbol: 'AAPL',
46
+ * qty: 100,
47
+ * side: 'buy',
48
+ * type: 'limit',
49
+ * limitPrice: 150.00,
50
+ * dependent: {
51
+ * side: 'sell',
52
+ * type: 'trailing_stop',
53
+ * trailPercent: 5
54
+ * },
55
+ * timeInForce: 'gtc'
56
+ * };
57
+ */
58
+ export interface OTOOrderParams {
59
+ /** Symbol of the asset to trade */
60
+ symbol: string;
61
+ /** Quantity of shares to trade */
62
+ qty: number;
63
+ /** Side of the primary order */
64
+ side: OrderSide;
65
+ /** Type of the primary order */
66
+ type: OrderType;
67
+ /** Limit price for primary order (required for 'limit' and 'stop_limit') */
68
+ limitPrice?: number;
69
+ /** Stop price for primary order (required for 'stop' and 'stop_limit') */
70
+ stopPrice?: number;
71
+ /** Configuration for the dependent order that triggers on primary fill */
72
+ dependent: DependentOrderConfig;
73
+ /** Time in force for orders (default: 'day') */
74
+ timeInForce?: TimeInForce;
75
+ /** Allow extended hours trading */
76
+ extendedHours?: boolean;
77
+ /** Client-specified order ID for tracking */
78
+ clientOrderId?: string;
79
+ }
80
+ /**
81
+ * Result of OTO order creation
82
+ */
83
+ export interface OTOOrderResult {
84
+ /** The primary (entry) order */
85
+ primaryOrder: AlpacaOrder;
86
+ /** The dependent order (will be triggered when primary fills) - null until triggered */
87
+ dependentOrder: AlpacaOrder | null;
88
+ /** All orders in the OTO group */
89
+ allOrders: AlpacaOrder[];
90
+ /** Parent order ID (can be used for cancellation and tracking) */
91
+ parentOrderId: string;
92
+ }
93
+ /**
94
+ * Create an OTO order (entry triggers exit)
95
+ *
96
+ * Useful for setting up automatic exit orders when an entry fills.
97
+ * The dependent order remains dormant until the primary order fills.
98
+ *
99
+ * @param client - AlpacaClient instance
100
+ * @param params - OTO order parameters
101
+ * @returns OTO order result with primary and dependent orders
102
+ *
103
+ * @example
104
+ * // Buy entry with automatic stop loss
105
+ * const result = await createOTOOrder(client, {
106
+ * symbol: 'AAPL',
107
+ * qty: 100,
108
+ * side: 'buy',
109
+ * type: 'limit',
110
+ * limitPrice: 150.00,
111
+ * dependent: {
112
+ * side: 'sell',
113
+ * type: 'stop',
114
+ * stopPrice: 145.00
115
+ * },
116
+ * timeInForce: 'gtc'
117
+ * });
118
+ *
119
+ * @example
120
+ * // Market entry with automatic trailing stop
121
+ * const result = await createOTOOrder(client, {
122
+ * symbol: 'TSLA',
123
+ * qty: 50,
124
+ * side: 'buy',
125
+ * type: 'market',
126
+ * dependent: {
127
+ * side: 'sell',
128
+ * type: 'trailing_stop',
129
+ * trailPercent: 3 // 3% trailing stop
130
+ * }
131
+ * });
132
+ *
133
+ * @example
134
+ * // Limit entry with take profit limit order
135
+ * const result = await createOTOOrder(client, {
136
+ * symbol: 'NVDA',
137
+ * qty: 25,
138
+ * side: 'buy',
139
+ * type: 'limit',
140
+ * limitPrice: 400.00,
141
+ * dependent: {
142
+ * side: 'sell',
143
+ * type: 'limit',
144
+ * limitPrice: 440.00 // Take profit at 10% gain
145
+ * },
146
+ * timeInForce: 'gtc'
147
+ * });
148
+ *
149
+ * @example
150
+ * // Short entry with stop-limit protection
151
+ * const result = await createOTOOrder(client, {
152
+ * symbol: 'GOOGL',
153
+ * qty: 10,
154
+ * side: 'sell',
155
+ * type: 'limit',
156
+ * limitPrice: 140.00,
157
+ * dependent: {
158
+ * side: 'buy',
159
+ * type: 'stop_limit',
160
+ * stopPrice: 145.00,
161
+ * limitPrice: 146.00
162
+ * },
163
+ * timeInForce: 'gtc'
164
+ * });
165
+ */
166
+ export declare function createOTOOrder(client: AlpacaClient, params: OTOOrderParams): Promise<OTOOrderResult>;
167
+ /**
168
+ * Cancel an OTO order group by parent order ID
169
+ * This will cancel both the primary order and any pending dependent order
170
+ *
171
+ * @param client - AlpacaClient instance
172
+ * @param parentOrderId - The parent order ID from OTOOrderResult
173
+ *
174
+ * @example
175
+ * const result = await createOTOOrder(client, params);
176
+ * // Later, before primary fills...
177
+ * await cancelOTOOrder(client, result.parentOrderId);
178
+ */
179
+ export declare function cancelOTOOrder(client: AlpacaClient, parentOrderId: string): Promise<void>;
180
+ /**
181
+ * Get the status of an OTO order group
182
+ *
183
+ * @param client - AlpacaClient instance
184
+ * @param parentOrderId - The parent order ID from OTOOrderResult
185
+ * @returns The parent order with dependent order information
186
+ *
187
+ * @example
188
+ * const result = await createOTOOrder(client, params);
189
+ * const status = await getOTOOrderStatus(client, result.parentOrderId);
190
+ * console.log('Primary status:', status.status);
191
+ * if (status.legs && status.legs[0]) {
192
+ * console.log('Dependent status:', status.legs[0].status);
193
+ * }
194
+ */
195
+ export declare function getOTOOrderStatus(client: AlpacaClient, parentOrderId: string): Promise<AlpacaOrder>;
196
+ /**
197
+ * Create a market buy with automatic stop loss
198
+ * Convenience wrapper for common use case
199
+ *
200
+ * @param client - AlpacaClient instance
201
+ * @param symbol - Stock symbol
202
+ * @param qty - Number of shares
203
+ * @param stopLossPrice - Stop loss trigger price
204
+ * @param stopLimitPrice - Optional limit price for stop-limit
205
+ *
206
+ * @example
207
+ * // Buy AAPL with immediate stop loss protection
208
+ * const result = await buyWithStopLoss(client, 'AAPL', 100, 145.00);
209
+ */
210
+ export declare function buyWithStopLoss(client: AlpacaClient, symbol: string, qty: number, stopLossPrice: number, stopLimitPrice?: number): Promise<OTOOrderResult>;
211
+ /**
212
+ * Create a market buy with automatic trailing stop
213
+ * Convenience wrapper for common use case
214
+ *
215
+ * @param client - AlpacaClient instance
216
+ * @param symbol - Stock symbol
217
+ * @param qty - Number of shares
218
+ * @param trailPercent - Trail percentage (e.g., 5 for 5%)
219
+ *
220
+ * @example
221
+ * // Buy TSLA with 3% trailing stop
222
+ * const result = await buyWithTrailingStop(client, 'TSLA', 50, 3);
223
+ */
224
+ export declare function buyWithTrailingStop(client: AlpacaClient, symbol: string, qty: number, trailPercent: number): Promise<OTOOrderResult>;
225
+ /**
226
+ * Create a limit buy with automatic take profit
227
+ * Convenience wrapper for limit entry with profit target
228
+ *
229
+ * @param client - AlpacaClient instance
230
+ * @param symbol - Stock symbol
231
+ * @param qty - Number of shares
232
+ * @param entryPrice - Limit price for entry
233
+ * @param takeProfitPrice - Take profit limit price
234
+ *
235
+ * @example
236
+ * // Buy NVDA at $400 with take profit at $440
237
+ * const result = await limitBuyWithTakeProfit(client, 'NVDA', 25, 400.00, 440.00);
238
+ */
239
+ export declare function limitBuyWithTakeProfit(client: AlpacaClient, symbol: string, qty: number, entryPrice: number, takeProfitPrice: number): Promise<OTOOrderResult>;
240
+ /**
241
+ * Create a short entry with automatic stop loss
242
+ * Convenience wrapper for short selling with protection
243
+ *
244
+ * @param client - AlpacaClient instance
245
+ * @param symbol - Stock symbol
246
+ * @param qty - Number of shares
247
+ * @param entryPrice - Limit price for short entry
248
+ * @param stopLossPrice - Stop loss trigger price (higher than entry)
249
+ *
250
+ * @example
251
+ * // Short GOOGL at $140 with stop at $145
252
+ * const result = await shortWithStopLoss(client, 'GOOGL', 10, 140.00, 145.00);
253
+ */
254
+ export declare function shortWithStopLoss(client: AlpacaClient, symbol: string, qty: number, entryPrice: number, stopLossPrice: number): Promise<OTOOrderResult>;
255
+ /**
256
+ * Create entry with automatic stop loss using percentage
257
+ * Calculates stop price based on entry price and percentage
258
+ *
259
+ * @param client - AlpacaClient instance
260
+ * @param symbol - Stock symbol
261
+ * @param qty - Number of shares
262
+ * @param entryPrice - Limit price for entry (null for market)
263
+ * @param stopLossPercent - Stop loss percentage (e.g., 5 for 5%)
264
+ * @param side - Order side ('buy' or 'sell')
265
+ *
266
+ * @example
267
+ * // Buy AAPL at $150 with 3% stop loss (stop at $145.50)
268
+ * const result = await entryWithPercentStopLoss(client, 'AAPL', 100, 150.00, 3, 'buy');
269
+ */
270
+ export declare function entryWithPercentStopLoss(client: AlpacaClient, symbol: string, qty: number, entryPrice: number | null, stopLossPercent: number, side?: OrderSide): Promise<OTOOrderResult>;
271
+ declare const _default: {
272
+ createOTOOrder: typeof createOTOOrder;
273
+ cancelOTOOrder: typeof cancelOTOOrder;
274
+ getOTOOrderStatus: typeof getOTOOrderStatus;
275
+ buyWithStopLoss: typeof buyWithStopLoss;
276
+ buyWithTrailingStop: typeof buyWithTrailingStop;
277
+ limitBuyWithTakeProfit: typeof limitBuyWithTakeProfit;
278
+ shortWithStopLoss: typeof shortWithStopLoss;
279
+ entryWithPercentStopLoss: typeof entryWithPercentStopLoss;
280
+ };
281
+ export default _default;
282
+ //# sourceMappingURL=oto-orders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oto-orders.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/trading/oto-orders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAQ1F;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,eAAe,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,IAAI,EAAE,SAAS,CAAC;IAChB,kCAAkC;IAClC,IAAI,EAAE,kBAAkB,CAAC;IACzB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,gCAAgC;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,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