@discomedia/utils 1.0.3
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 +25 -0
- package/dist/index-frontend.cjs +7798 -0
- package/dist/index-frontend.cjs.map +1 -0
- package/dist/index-frontend.mjs +7792 -0
- package/dist/index-frontend.mjs.map +1 -0
- package/dist/index.cjs +17747 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +17741 -0
- package/dist/index.mjs.map +1 -0
- package/dist/test.js +6783 -0
- package/dist/test.js.map +1 -0
- package/dist/types/alpaca-market-data-api.d.ts +384 -0
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -0
- package/dist/types/alpaca-trading-api.d.ts +318 -0
- package/dist/types/alpaca-trading-api.d.ts.map +1 -0
- package/dist/types/format-tools.d.ts +46 -0
- package/dist/types/format-tools.d.ts.map +1 -0
- package/dist/types/index-frontend.d.ts +18 -0
- package/dist/types/index-frontend.d.ts.map +1 -0
- package/dist/types/index.d.ts +150 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/json-tools.d.ts +33 -0
- package/dist/types/json-tools.d.ts.map +1 -0
- package/dist/types/llm-config.d.ts +36 -0
- package/dist/types/llm-config.d.ts.map +1 -0
- package/dist/types/llm-deepseek.d.ts +12 -0
- package/dist/types/llm-deepseek.d.ts.map +1 -0
- package/dist/types/llm-images.d.ts +49 -0
- package/dist/types/llm-images.d.ts.map +1 -0
- package/dist/types/llm-openai.d.ts +64 -0
- package/dist/types/llm-openai.d.ts.map +1 -0
- package/dist/types/llm-utils.d.ts +16 -0
- package/dist/types/llm-utils.d.ts.map +1 -0
- package/dist/types/logging.d.ts +12 -0
- package/dist/types/logging.d.ts.map +1 -0
- package/dist/types/market-hours.d.ts +24 -0
- package/dist/types/market-hours.d.ts.map +1 -0
- package/dist/types/market-time.d.ts +184 -0
- package/dist/types/market-time.d.ts.map +1 -0
- package/dist/types/misc-utils.d.ts +49 -0
- package/dist/types/misc-utils.d.ts.map +1 -0
- package/dist/types/polygon-indices.d.ts +85 -0
- package/dist/types/polygon-indices.d.ts.map +1 -0
- package/dist/types/polygon.d.ts +126 -0
- package/dist/types/polygon.d.ts.map +1 -0
- package/dist/types/technical-analysis.d.ts +90 -0
- package/dist/types/technical-analysis.d.ts.map +1 -0
- package/dist/types/test.d.ts +2 -0
- package/dist/types/test.d.ts.map +1 -0
- package/dist/types/testing/frontend-test.d.ts +2 -0
- package/dist/types/testing/frontend-test.d.ts.map +1 -0
- package/dist/types/time-utils.d.ts +17 -0
- package/dist/types/time-utils.d.ts.map +1 -0
- package/dist/types/types/alpaca-types.d.ts +962 -0
- package/dist/types/types/alpaca-types.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/llm-types.d.ts +82 -0
- package/dist/types/types/llm-types.d.ts.map +1 -0
- package/dist/types/types/logging-types.d.ts +10 -0
- package/dist/types/types/logging-types.d.ts.map +1 -0
- package/dist/types/types/market-time-types.d.ts +59 -0
- package/dist/types/types/market-time-types.d.ts.map +1 -0
- package/dist/types/types/polygon-indices-types.d.ts +190 -0
- package/dist/types/types/polygon-indices-types.d.ts.map +1 -0
- package/dist/types/types/polygon-types.d.ts +204 -0
- package/dist/types/types/polygon-types.d.ts.map +1 -0
- package/dist/types/types/ta-types.d.ts +89 -0
- package/dist/types/types/ta-types.d.ts.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,962 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the configuration of an Alpaca account.
|
|
3
|
+
*/
|
|
4
|
+
export interface AllocationConfig {
|
|
5
|
+
stocks: number;
|
|
6
|
+
crypto: number;
|
|
7
|
+
etfs: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AccountConfiguration {
|
|
10
|
+
marketOpen?: boolean;
|
|
11
|
+
realTime?: boolean;
|
|
12
|
+
suspend_trade: boolean;
|
|
13
|
+
tradeAllocationPct?: number;
|
|
14
|
+
minPercentageChange?: number;
|
|
15
|
+
volumeThreshold?: number;
|
|
16
|
+
cryptoTradingEnabled?: boolean;
|
|
17
|
+
cryptoTradingPairs?: string[];
|
|
18
|
+
cryptoTradeAllocationPct?: number;
|
|
19
|
+
allocation?: AllocationConfig;
|
|
20
|
+
dtbp_check: 'both' | 'entry' | 'exit';
|
|
21
|
+
trade_confirm_email: 'all' | 'none';
|
|
22
|
+
no_shorting: boolean;
|
|
23
|
+
fractional_trading: boolean;
|
|
24
|
+
max_margin_multiplier: '1' | '2' | '4';
|
|
25
|
+
max_options_trading_level?: 0 | 1 | 2 | 3;
|
|
26
|
+
pdt_check: 'both' | 'entry' | 'exit';
|
|
27
|
+
ptp_no_exception_entry: boolean;
|
|
28
|
+
enablePortfolioTrailingStop?: boolean;
|
|
29
|
+
portfolioTrailPercent?: number;
|
|
30
|
+
portfolioProfitThresholdPercent?: number;
|
|
31
|
+
reducedPortfolioTrailPercent?: number;
|
|
32
|
+
defaultTrailingStopPercentage100?: number;
|
|
33
|
+
firstTrailReductionThreshold100?: number;
|
|
34
|
+
secondTrailReductionThreshold100?: number;
|
|
35
|
+
firstReducedTrailPercentage100?: number;
|
|
36
|
+
secondReducedTrailPercentage100?: number;
|
|
37
|
+
minimumPriceChangePercent100?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Represents a single bar of market data.
|
|
41
|
+
*/
|
|
42
|
+
export interface Bar {
|
|
43
|
+
t: string;
|
|
44
|
+
o: number;
|
|
45
|
+
h: number;
|
|
46
|
+
l: number;
|
|
47
|
+
c: number;
|
|
48
|
+
v: number;
|
|
49
|
+
n: number;
|
|
50
|
+
vw: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Represents the history of a portfolio.
|
|
54
|
+
*/
|
|
55
|
+
export interface PortfolioHistory {
|
|
56
|
+
equity: number[];
|
|
57
|
+
timestamp: number[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Represents a single benchmark bar.
|
|
61
|
+
*/
|
|
62
|
+
export interface BenchmarkBar {
|
|
63
|
+
t: number;
|
|
64
|
+
c: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Result of the beta calculation.
|
|
68
|
+
*/
|
|
69
|
+
export interface CalculateBetaResult {
|
|
70
|
+
beta: number;
|
|
71
|
+
covariance: number;
|
|
72
|
+
variance: number;
|
|
73
|
+
averagePortfolioReturn: number;
|
|
74
|
+
averageBenchmarkReturn: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Represents a position in the portfolio.
|
|
78
|
+
*/
|
|
79
|
+
export type AlpacaPosition = {
|
|
80
|
+
asset_id: string;
|
|
81
|
+
symbol: string;
|
|
82
|
+
exchange: string;
|
|
83
|
+
asset_class: string;
|
|
84
|
+
asset_marginable: boolean;
|
|
85
|
+
qty: string;
|
|
86
|
+
qty_available: string;
|
|
87
|
+
avg_entry_price: string;
|
|
88
|
+
side: 'long' | 'short';
|
|
89
|
+
market_value: string;
|
|
90
|
+
cost_basis: string;
|
|
91
|
+
unrealized_pl: string;
|
|
92
|
+
unrealized_plpc: string;
|
|
93
|
+
unrealized_intraday_pl: string;
|
|
94
|
+
unrealized_intraday_plpc: string;
|
|
95
|
+
current_price: string;
|
|
96
|
+
lastday_price: string;
|
|
97
|
+
change_today: string;
|
|
98
|
+
};
|
|
99
|
+
export type OrderSide = 'buy' | 'sell';
|
|
100
|
+
/**
|
|
101
|
+
* Represents the type of order.
|
|
102
|
+
*/
|
|
103
|
+
export type OrderType = 'market' | 'limit' | 'stop' | 'stop_limit' | 'trailing_stop';
|
|
104
|
+
/**
|
|
105
|
+
* Represents the time in force for an order.
|
|
106
|
+
*/
|
|
107
|
+
export type TimeInForce = 'day' | 'gtc' | 'opg' | 'cls' | 'ioc' | 'fok';
|
|
108
|
+
/**
|
|
109
|
+
* Represents the class of an order.
|
|
110
|
+
*/
|
|
111
|
+
export type OrderClass = 'simple' | 'oco' | 'oto' | 'bracket' | 'mleg';
|
|
112
|
+
/**
|
|
113
|
+
* Represents the status of an order.
|
|
114
|
+
*/
|
|
115
|
+
export type OrderStatus = 'new' | 'partially_filled' | 'filled' | 'done_for_day' | 'canceled' | 'expired' | 'replaced' | 'pending_cancel' | 'pending_replace' | 'accepted' | 'pending_new' | 'accepted_for_bidding' | 'stopped' | 'rejected' | 'suspended' | 'calculated';
|
|
116
|
+
/**
|
|
117
|
+
* Represents the class of an asset.
|
|
118
|
+
*/
|
|
119
|
+
export type AssetClass = 'us_equity' | 'us_option' | 'crypto';
|
|
120
|
+
/**
|
|
121
|
+
* Represents the intent of a position.
|
|
122
|
+
*/
|
|
123
|
+
export type PositionIntent = 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close';
|
|
124
|
+
/**
|
|
125
|
+
* Parameters for take profit orders.
|
|
126
|
+
*/
|
|
127
|
+
export interface TakeProfitParams {
|
|
128
|
+
limit_price: string;
|
|
129
|
+
stop_price?: string;
|
|
130
|
+
order_class?: OrderClass;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Parameters for stop loss orders.
|
|
134
|
+
*/
|
|
135
|
+
export interface StopLossParams {
|
|
136
|
+
stop_price: string;
|
|
137
|
+
limit_price?: string;
|
|
138
|
+
order_class?: OrderClass;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Parameters for creating an order.
|
|
142
|
+
*/
|
|
143
|
+
export interface CreateOrderParams {
|
|
144
|
+
symbol: string;
|
|
145
|
+
qty?: string;
|
|
146
|
+
notional?: string;
|
|
147
|
+
side: OrderSide;
|
|
148
|
+
type: OrderType;
|
|
149
|
+
time_in_force: TimeInForce;
|
|
150
|
+
limit_price?: string;
|
|
151
|
+
stop_price?: string;
|
|
152
|
+
trail_price?: string;
|
|
153
|
+
trail_percent?: string;
|
|
154
|
+
extended_hours?: boolean;
|
|
155
|
+
client_order_id?: string;
|
|
156
|
+
order_class?: OrderClass;
|
|
157
|
+
take_profit?: TakeProfitParams;
|
|
158
|
+
stop_loss?: StopLossParams;
|
|
159
|
+
position_intent?: PositionIntent;
|
|
160
|
+
legs?: OrderLeg[];
|
|
161
|
+
}
|
|
162
|
+
export interface CreateMultiLegOrderParams {
|
|
163
|
+
order_class: 'mleg';
|
|
164
|
+
qty: string;
|
|
165
|
+
type: OrderType;
|
|
166
|
+
limit_price?: string;
|
|
167
|
+
time_in_force: TimeInForce;
|
|
168
|
+
legs: Array<{
|
|
169
|
+
symbol: string;
|
|
170
|
+
ratio_qty: string;
|
|
171
|
+
side: OrderSide;
|
|
172
|
+
position_intent: PositionIntent;
|
|
173
|
+
}>;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Parameters for getting orders.
|
|
177
|
+
*/
|
|
178
|
+
export interface GetOrdersParams {
|
|
179
|
+
status?: 'open' | 'closed' | 'all';
|
|
180
|
+
limit?: number;
|
|
181
|
+
after?: string;
|
|
182
|
+
until?: string;
|
|
183
|
+
direction?: 'asc' | 'desc';
|
|
184
|
+
nested?: boolean;
|
|
185
|
+
symbols?: string[];
|
|
186
|
+
side?: OrderSide;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Parameters for replacing an order.
|
|
190
|
+
*/
|
|
191
|
+
export interface ReplaceOrderParams {
|
|
192
|
+
qty?: string;
|
|
193
|
+
time_in_force?: TimeInForce;
|
|
194
|
+
limit_price?: string;
|
|
195
|
+
stop_price?: string;
|
|
196
|
+
trail?: string;
|
|
197
|
+
client_order_id?: string;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Represents an order.
|
|
201
|
+
*/
|
|
202
|
+
export type AlpacaOrder = {
|
|
203
|
+
id: string;
|
|
204
|
+
client_order_id: string;
|
|
205
|
+
created_at: string;
|
|
206
|
+
updated_at: string | null;
|
|
207
|
+
submitted_at: string | null;
|
|
208
|
+
filled_at: string | null;
|
|
209
|
+
expired_at: string | null;
|
|
210
|
+
canceled_at: string | null;
|
|
211
|
+
failed_at: string | null;
|
|
212
|
+
replaced_at: string | null;
|
|
213
|
+
replaced_by: string | null;
|
|
214
|
+
replaces: string | null;
|
|
215
|
+
asset_id: string;
|
|
216
|
+
symbol: string;
|
|
217
|
+
asset_class: AssetClass;
|
|
218
|
+
notional: string | null;
|
|
219
|
+
qty: string | null;
|
|
220
|
+
filled_qty: string;
|
|
221
|
+
filled_avg_price: string | null;
|
|
222
|
+
order_class: OrderClass;
|
|
223
|
+
type: OrderType;
|
|
224
|
+
side: OrderSide;
|
|
225
|
+
time_in_force: TimeInForce;
|
|
226
|
+
limit_price: string | null;
|
|
227
|
+
stop_price: string | null;
|
|
228
|
+
trail_price: string | null;
|
|
229
|
+
trail_percent: string | null;
|
|
230
|
+
hwm: string | null;
|
|
231
|
+
position_intent: PositionIntent | null;
|
|
232
|
+
status: OrderStatus;
|
|
233
|
+
extended_hours: boolean;
|
|
234
|
+
legs: AlpacaOrder[] | null;
|
|
235
|
+
};
|
|
236
|
+
export type CryptoTimeframe = `${number}Min` | `${number}T` | `${number}Hour` | `${number}H` | '1Day' | '1D' | '1Week' | '1W' | `${1 | 2 | 3 | 4 | 6 | 12}Month` | `${1 | 2 | 3 | 4 | 6 | 12}M`;
|
|
237
|
+
/**
|
|
238
|
+
* Represents a single bar of cryptocurrency market data.
|
|
239
|
+
*/
|
|
240
|
+
export interface CryptoBar {
|
|
241
|
+
t: Date;
|
|
242
|
+
o: number;
|
|
243
|
+
h: number;
|
|
244
|
+
l: number;
|
|
245
|
+
c: number;
|
|
246
|
+
v: number;
|
|
247
|
+
n: number;
|
|
248
|
+
vw: number;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Parameters for fetching cryptocurrency bars.
|
|
252
|
+
*/
|
|
253
|
+
export interface CryptoBarsParams {
|
|
254
|
+
symbols: CryptoPair[];
|
|
255
|
+
timeframe: CryptoTimeframe;
|
|
256
|
+
start?: Date;
|
|
257
|
+
end?: Date;
|
|
258
|
+
limit?: number;
|
|
259
|
+
page_token?: string;
|
|
260
|
+
sort?: 'asc' | 'desc';
|
|
261
|
+
}
|
|
262
|
+
export type TimeFrame = '1Min' | '5Min' | '15Min' | '30Min' | '1Hour' | '2Hour' | '4Hour' | '1Day' | '1Week' | '1Month';
|
|
263
|
+
/**
|
|
264
|
+
* Response structure for fetching cryptocurrency bars.
|
|
265
|
+
*/
|
|
266
|
+
export interface CryptoBarsResponse {
|
|
267
|
+
bars: {
|
|
268
|
+
[symbol: string]: CryptoBar[];
|
|
269
|
+
};
|
|
270
|
+
next_page_token?: string;
|
|
271
|
+
}
|
|
272
|
+
export type BTCPairs = 'BCH/BTC' | 'ETH/BTC' | 'LTC/BTC' | 'UNI/BTC';
|
|
273
|
+
export type USDTPairs = 'AAVE/USDT' | 'BCH/USDT' | 'BTC/USDT' | 'DOGE/USDT' | 'ETH/USDT' | 'LINK/USDT' | 'LTC/USDT' | 'SUSHI/USDT' | 'UNI/USDT' | 'YFI/USDT';
|
|
274
|
+
export type USDCPairs = 'AAVE/USDC' | 'AVAX/USDC' | 'BAT/USDC' | 'BCH/USDC' | 'BTC/USDC' | 'CRV/USDC' | 'DOGE/USDC' | 'DOT/USDC' | 'ETH/USDC' | 'GRT/USDC' | 'LINK/USDC' | 'LTC/USDC' | 'MKR/USDC' | 'SHIB/USDC' | 'SUSHI/USDC' | 'UNI/USDC' | 'XTZ/USDC' | 'YFI/USDC';
|
|
275
|
+
export type USDPairs = 'AAVE/USD' | 'AVAX/USD' | 'BAT/USD' | 'BCH/USD' | 'BTC/USD' | 'CRV/USD' | 'DOGE/USD' | 'DOT/USD' | 'ETH/USD' | 'GRT/USD' | 'LINK/USD' | 'LTC/USD' | 'MKR/USD' | 'SHIB/USD' | 'SUSHI/USD' | 'UNI/USD' | 'USDC/USD' | 'USDT/USD' | 'XTZ/USD' | 'YFI/USD';
|
|
276
|
+
/**
|
|
277
|
+
* Represents a cryptocurrency trading pair.
|
|
278
|
+
*/
|
|
279
|
+
export type CryptoPair = BTCPairs | USDTPairs | USDCPairs | USDPairs;
|
|
280
|
+
/**
|
|
281
|
+
* Represents an image associated with a news article.
|
|
282
|
+
*/
|
|
283
|
+
export interface NewsImage {
|
|
284
|
+
size: 'large' | 'small' | 'thumb';
|
|
285
|
+
url: string;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Represents a news article from Alpaca.
|
|
289
|
+
*/
|
|
290
|
+
export interface AlpacaNewsArticle {
|
|
291
|
+
id: number;
|
|
292
|
+
author: string;
|
|
293
|
+
content: string;
|
|
294
|
+
created_at: string;
|
|
295
|
+
updated_at: string;
|
|
296
|
+
headline: string;
|
|
297
|
+
source: string;
|
|
298
|
+
summary: string;
|
|
299
|
+
url: string;
|
|
300
|
+
symbols: string[];
|
|
301
|
+
images: NewsImage[];
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Represents the response structure for fetching news articles.
|
|
305
|
+
*/
|
|
306
|
+
export interface NewsResponse {
|
|
307
|
+
news: AlpacaNewsArticle[];
|
|
308
|
+
next_page_token?: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Represents a simplified news article.
|
|
312
|
+
*/
|
|
313
|
+
export interface SimpleNews {
|
|
314
|
+
symbols: string | string[];
|
|
315
|
+
title: string;
|
|
316
|
+
summary: string;
|
|
317
|
+
content?: string;
|
|
318
|
+
url: string;
|
|
319
|
+
source: string;
|
|
320
|
+
author: string;
|
|
321
|
+
date: string | Date;
|
|
322
|
+
updatedDate: string | Date;
|
|
323
|
+
sentiment: number;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Parameters for fetching portfolio history.
|
|
327
|
+
*/
|
|
328
|
+
export interface PortfolioHistoryParams {
|
|
329
|
+
period?: string;
|
|
330
|
+
timeframe?: '1Min' | '5Min' | '15Min' | '1H' | '1D';
|
|
331
|
+
intraday_reporting?: 'market_hours' | 'extended_hours' | 'continuous';
|
|
332
|
+
start?: string;
|
|
333
|
+
end?: string;
|
|
334
|
+
date_end?: string;
|
|
335
|
+
extended_hours?: boolean;
|
|
336
|
+
pnl_reset?: 'per_day' | 'no_reset';
|
|
337
|
+
cashflow_types?: string;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Response structure for fetching portfolio history.
|
|
341
|
+
*/
|
|
342
|
+
export interface PortfolioHistoryResponse {
|
|
343
|
+
timestamp: number[];
|
|
344
|
+
equity: number[];
|
|
345
|
+
profit_loss: number[];
|
|
346
|
+
profit_loss_pct: number[];
|
|
347
|
+
base_value: number;
|
|
348
|
+
base_value_asof?: string;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Represents the details of an Alpaca account.
|
|
352
|
+
*/
|
|
353
|
+
export interface AlpacaAccountDetails {
|
|
354
|
+
id: string;
|
|
355
|
+
account_number: string;
|
|
356
|
+
status: 'ONBOARDING' | 'SUBMISSION_FAILED' | 'SUBMITTED' | 'ACCOUNT_UPDATED' | 'APPROVAL_PENDING' | 'ACTIVE' | 'REJECTED';
|
|
357
|
+
currency: string;
|
|
358
|
+
cash: string;
|
|
359
|
+
portfolio_value: string;
|
|
360
|
+
non_marginable_buying_power: string;
|
|
361
|
+
accrued_fees: string;
|
|
362
|
+
pending_transfer_in: string;
|
|
363
|
+
pending_transfer_out: string;
|
|
364
|
+
pattern_day_trader: boolean;
|
|
365
|
+
trade_suspended_by_user: boolean;
|
|
366
|
+
trading_blocked: boolean;
|
|
367
|
+
transfers_blocked: boolean;
|
|
368
|
+
account_blocked: boolean;
|
|
369
|
+
created_at: string;
|
|
370
|
+
shorting_enabled: boolean;
|
|
371
|
+
long_market_value: string;
|
|
372
|
+
short_market_value: string;
|
|
373
|
+
equity: string;
|
|
374
|
+
last_equity: string;
|
|
375
|
+
multiplier: '1' | '2' | '4';
|
|
376
|
+
buying_power: string;
|
|
377
|
+
initial_margin: string;
|
|
378
|
+
maintenance_margin: string;
|
|
379
|
+
sma: string;
|
|
380
|
+
daytrade_count: number;
|
|
381
|
+
balance_asof: string;
|
|
382
|
+
last_maintenance_margin: string;
|
|
383
|
+
daytrading_buying_power: string;
|
|
384
|
+
regt_buying_power: string;
|
|
385
|
+
options_buying_power: string;
|
|
386
|
+
options_approved_level: 0 | 1 | 2 | 3;
|
|
387
|
+
options_trading_level: 0 | 1 | 2 | 3;
|
|
388
|
+
intraday_adjustments: string;
|
|
389
|
+
pending_reg_taf_fees: string;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Represents an asset in Alpaca.
|
|
393
|
+
*/
|
|
394
|
+
export interface AlpacaAsset {
|
|
395
|
+
id: string;
|
|
396
|
+
class: 'us_equity' | 'us_option' | 'crypto';
|
|
397
|
+
exchange: string;
|
|
398
|
+
symbol: string;
|
|
399
|
+
name: string;
|
|
400
|
+
status: 'active' | 'inactive';
|
|
401
|
+
tradable: boolean;
|
|
402
|
+
marginable: boolean;
|
|
403
|
+
shortable: boolean;
|
|
404
|
+
easy_to_borrow: boolean;
|
|
405
|
+
fractionable: boolean;
|
|
406
|
+
maintenance_margin_requirement?: number;
|
|
407
|
+
margin_requirement_long?: string;
|
|
408
|
+
margin_requirement_short?: string;
|
|
409
|
+
attributes?: string[];
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Parameters for getting an asset.
|
|
413
|
+
*/
|
|
414
|
+
export interface GetAssetParams {
|
|
415
|
+
symbolOrAssetId: string;
|
|
416
|
+
}
|
|
417
|
+
export type DataFeed = 'sip' | 'iex' | 'delayed_sip';
|
|
418
|
+
export interface AlpacaQuote {
|
|
419
|
+
t: string;
|
|
420
|
+
ap: number;
|
|
421
|
+
as: number;
|
|
422
|
+
ax: string;
|
|
423
|
+
bp: number;
|
|
424
|
+
bs: number;
|
|
425
|
+
bx: string;
|
|
426
|
+
c: string[];
|
|
427
|
+
z: string;
|
|
428
|
+
}
|
|
429
|
+
export interface AlpacaTrade {
|
|
430
|
+
t: string;
|
|
431
|
+
p: number;
|
|
432
|
+
s: number;
|
|
433
|
+
x: string;
|
|
434
|
+
i: number;
|
|
435
|
+
z: string;
|
|
436
|
+
c: string[];
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Response from latest trades endpoint
|
|
440
|
+
* Contains the most recent trade for each requested symbol
|
|
441
|
+
*/
|
|
442
|
+
export interface LatestTradesResponse {
|
|
443
|
+
/**
|
|
444
|
+
* Map of symbol to latest trade data
|
|
445
|
+
* Each trade contains price, size, exchange, and conditions
|
|
446
|
+
*/
|
|
447
|
+
trades: {
|
|
448
|
+
[symbol: string]: AlpacaTrade;
|
|
449
|
+
};
|
|
450
|
+
/** Currency of the price data in ISO 4217 format */
|
|
451
|
+
currency: string;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Response from latest quotes endpoint
|
|
455
|
+
* Contains the most recent bid/ask quotes for each requested symbol
|
|
456
|
+
*/
|
|
457
|
+
export interface LatestQuotesResponse {
|
|
458
|
+
/**
|
|
459
|
+
* Map of symbol to latest quote data
|
|
460
|
+
* Each quote contains bid/ask prices, sizes, and exchange information
|
|
461
|
+
*/
|
|
462
|
+
quotes: {
|
|
463
|
+
[symbol: string]: AlpacaQuote;
|
|
464
|
+
};
|
|
465
|
+
/** Currency of the price data in ISO 4217 format */
|
|
466
|
+
currency: string;
|
|
467
|
+
}
|
|
468
|
+
export type OptionsTradingLevel = 0 | 1 | 2 | 3;
|
|
469
|
+
export type OptionType = 'call' | 'put';
|
|
470
|
+
export type OptionStyle = 'american' | 'european';
|
|
471
|
+
export interface OptionContract {
|
|
472
|
+
id: string;
|
|
473
|
+
symbol: string;
|
|
474
|
+
name: string;
|
|
475
|
+
status: 'active' | 'inactive';
|
|
476
|
+
tradable: boolean;
|
|
477
|
+
expiration_date: string;
|
|
478
|
+
root_symbol: string;
|
|
479
|
+
underlying_symbol: string;
|
|
480
|
+
underlying_asset_id: string;
|
|
481
|
+
type: OptionType;
|
|
482
|
+
style: OptionStyle;
|
|
483
|
+
strike_price: string;
|
|
484
|
+
size: string;
|
|
485
|
+
open_interest?: string;
|
|
486
|
+
open_interest_date?: string;
|
|
487
|
+
close_price?: string;
|
|
488
|
+
close_price_date?: string;
|
|
489
|
+
}
|
|
490
|
+
export interface GetOptionContractsParams {
|
|
491
|
+
underlying_symbols: string[];
|
|
492
|
+
expiration_date_gte?: string;
|
|
493
|
+
expiration_date_lte?: string;
|
|
494
|
+
strike_price_gte?: string;
|
|
495
|
+
strike_price_lte?: string;
|
|
496
|
+
type?: OptionType;
|
|
497
|
+
status?: 'active' | 'inactive';
|
|
498
|
+
limit?: number;
|
|
499
|
+
page_token?: string;
|
|
500
|
+
}
|
|
501
|
+
export interface OptionContractsResponse {
|
|
502
|
+
option_contracts: OptionContract[];
|
|
503
|
+
page_token?: string;
|
|
504
|
+
limit: number;
|
|
505
|
+
}
|
|
506
|
+
export interface OrderLeg {
|
|
507
|
+
symbol: string;
|
|
508
|
+
ratio_qty: string;
|
|
509
|
+
side: 'buy' | 'sell';
|
|
510
|
+
position_intent: 'buy_to_open' | 'buy_to_close' | 'sell_to_open' | 'sell_to_close';
|
|
511
|
+
}
|
|
512
|
+
export interface OptionGreeks {
|
|
513
|
+
delta?: number;
|
|
514
|
+
gamma?: number;
|
|
515
|
+
theta?: number;
|
|
516
|
+
vega?: number;
|
|
517
|
+
rho?: number;
|
|
518
|
+
}
|
|
519
|
+
export interface OptionTrade {
|
|
520
|
+
t: string;
|
|
521
|
+
p: number;
|
|
522
|
+
s: number;
|
|
523
|
+
x: string;
|
|
524
|
+
i: number;
|
|
525
|
+
c: string[];
|
|
526
|
+
}
|
|
527
|
+
export interface OptionQuote {
|
|
528
|
+
t: string;
|
|
529
|
+
ap: number;
|
|
530
|
+
as: number;
|
|
531
|
+
ax: string;
|
|
532
|
+
bp: number;
|
|
533
|
+
bs: number;
|
|
534
|
+
bx: string;
|
|
535
|
+
c: string[];
|
|
536
|
+
}
|
|
537
|
+
export interface OptionBar {
|
|
538
|
+
t: string;
|
|
539
|
+
o: number;
|
|
540
|
+
h: number;
|
|
541
|
+
l: number;
|
|
542
|
+
c: number;
|
|
543
|
+
v: number;
|
|
544
|
+
n: number;
|
|
545
|
+
vw: number;
|
|
546
|
+
}
|
|
547
|
+
export interface OptionSnapshot {
|
|
548
|
+
latestTrade?: OptionTrade;
|
|
549
|
+
latestQuote?: OptionQuote;
|
|
550
|
+
greeks?: OptionGreeks;
|
|
551
|
+
impliedVolatility?: number;
|
|
552
|
+
openInterest?: number;
|
|
553
|
+
}
|
|
554
|
+
export interface OptionsChainResponse {
|
|
555
|
+
snapshots: {
|
|
556
|
+
[symbol: string]: OptionSnapshot;
|
|
557
|
+
};
|
|
558
|
+
next_page_token?: string;
|
|
559
|
+
}
|
|
560
|
+
export interface LatestOptionsTradesResponse {
|
|
561
|
+
trades: {
|
|
562
|
+
[symbol: string]: OptionTrade;
|
|
563
|
+
};
|
|
564
|
+
next_page_token?: string;
|
|
565
|
+
}
|
|
566
|
+
export interface LatestOptionsQuotesResponse {
|
|
567
|
+
quotes: {
|
|
568
|
+
[symbol: string]: OptionQuote;
|
|
569
|
+
};
|
|
570
|
+
next_page_token?: string;
|
|
571
|
+
}
|
|
572
|
+
export interface HistoricalOptionsBarsResponse {
|
|
573
|
+
bars: {
|
|
574
|
+
[symbol: string]: OptionBar[];
|
|
575
|
+
};
|
|
576
|
+
next_page_token?: string;
|
|
577
|
+
}
|
|
578
|
+
export interface HistoricalOptionsTradesResponse {
|
|
579
|
+
trades: {
|
|
580
|
+
[symbol: string]: OptionTrade[];
|
|
581
|
+
};
|
|
582
|
+
next_page_token?: string;
|
|
583
|
+
}
|
|
584
|
+
export interface OptionsSnapshotsResponse {
|
|
585
|
+
snapshots: {
|
|
586
|
+
[symbol: string]: OptionSnapshot;
|
|
587
|
+
};
|
|
588
|
+
next_page_token?: string;
|
|
589
|
+
}
|
|
590
|
+
export interface OptionsChainParams {
|
|
591
|
+
/** The underlying symbol for the options chain */
|
|
592
|
+
underlying_symbol: string;
|
|
593
|
+
/**
|
|
594
|
+
* The source feed of the data. opra is the official OPRA feed, indicative is a free indicative feed
|
|
595
|
+
* where trades are delayed and quotes are modified. Default: opra if the user has a subscription, otherwise indicative.
|
|
596
|
+
*/
|
|
597
|
+
feed?: 'opra' | 'indicative';
|
|
598
|
+
/**
|
|
599
|
+
* Number of maximum snapshots to return in a response (1 to 1000)
|
|
600
|
+
* The limit applies to the total number of data points, not the number per symbol!
|
|
601
|
+
* Use next_page_token to fetch the next set of responses.
|
|
602
|
+
*/
|
|
603
|
+
limit?: number;
|
|
604
|
+
/**
|
|
605
|
+
* Filter to snapshots that were updated since this timestamp, meaning that the timestamp
|
|
606
|
+
* of the trade or the quote is greater than or equal to this value.
|
|
607
|
+
* Format: RFC-3339 or YYYY-MM-DD. If missing, all values are returned.
|
|
608
|
+
*/
|
|
609
|
+
updated_since?: string;
|
|
610
|
+
/**
|
|
611
|
+
* The pagination token from which to continue. The value to pass here is returned in specific
|
|
612
|
+
* requests when more data is available, usually because of a response result limit.
|
|
613
|
+
*/
|
|
614
|
+
page_token?: string;
|
|
615
|
+
/** Filter contracts by the type (call or put) */
|
|
616
|
+
type?: OptionType;
|
|
617
|
+
/** Filter contracts with strike price greater than or equal to the specified value */
|
|
618
|
+
strike_price_gte?: number;
|
|
619
|
+
/** Filter contracts with strike price less than or equal to the specified value */
|
|
620
|
+
strike_price_lte?: number;
|
|
621
|
+
/** Filter contracts by the exact expiration date (format: YYYY-MM-DD) */
|
|
622
|
+
expiration_date?: string;
|
|
623
|
+
/** Filter contracts with expiration date greater than or equal to the specified date */
|
|
624
|
+
expiration_date_gte?: string;
|
|
625
|
+
/** Filter contracts with expiration date less than or equal to the specified date */
|
|
626
|
+
expiration_date_lte?: string;
|
|
627
|
+
/** Filter contracts by the root symbol */
|
|
628
|
+
root_symbol?: string;
|
|
629
|
+
}
|
|
630
|
+
export interface LatestOptionsTradesParams {
|
|
631
|
+
/** Comma-separated list of option contract symbols */
|
|
632
|
+
symbols: string[];
|
|
633
|
+
/** Number of results to return (not supported by this endpoint) */
|
|
634
|
+
limit?: number;
|
|
635
|
+
/** Pagination token for next page (not supported by this endpoint) */
|
|
636
|
+
page_token?: string;
|
|
637
|
+
}
|
|
638
|
+
export interface LatestOptionsQuotesParams {
|
|
639
|
+
/** Comma-separated list of option contract symbols */
|
|
640
|
+
symbols: string[];
|
|
641
|
+
/** Number of results to return (not supported by this endpoint) */
|
|
642
|
+
limit?: number;
|
|
643
|
+
/** Pagination token for next page (not supported by this endpoint) */
|
|
644
|
+
page_token?: string;
|
|
645
|
+
}
|
|
646
|
+
export interface HistoricalOptionsBarsParams {
|
|
647
|
+
/** Comma-separated list of option contract symbols */
|
|
648
|
+
symbols: string[];
|
|
649
|
+
/**
|
|
650
|
+
* Bar duration/timeframe
|
|
651
|
+
* Format: [1-59]Min/T, [1-23]Hour/H, 1Day/D, 1Week/W, [1,2,3,4,6,12]Month/M
|
|
652
|
+
* Examples: "1Min", "5Min", "1Hour", "1Day", "1Week", "1Month"
|
|
653
|
+
*/
|
|
654
|
+
timeframe: TimeFrame;
|
|
655
|
+
/**
|
|
656
|
+
* Start datetime in RFC-3339 format (YYYY-MM-DD)
|
|
657
|
+
* Example: "2024-02-11T09:00:00Z"
|
|
658
|
+
*/
|
|
659
|
+
start?: string;
|
|
660
|
+
/**
|
|
661
|
+
* End datetime in RFC-3339 format (YYYY-MM-DD)
|
|
662
|
+
* Example: "2024-02-11T16:00:00Z"
|
|
663
|
+
*/
|
|
664
|
+
end?: string;
|
|
665
|
+
/** Number of results to return (max 10000) */
|
|
666
|
+
limit?: number;
|
|
667
|
+
/** Pagination token for next page */
|
|
668
|
+
page_token?: string;
|
|
669
|
+
/** Sort order (asc or desc) */
|
|
670
|
+
sort?: 'asc' | 'desc';
|
|
671
|
+
}
|
|
672
|
+
export interface HistoricalOptionsTradesParams {
|
|
673
|
+
/** Comma-separated list of option contract symbols */
|
|
674
|
+
symbols: string[];
|
|
675
|
+
/**
|
|
676
|
+
* Start datetime in RFC-3339 format (YYYY-MM-DD)
|
|
677
|
+
* Example: "2024-02-11T09:00:00Z"
|
|
678
|
+
*/
|
|
679
|
+
start?: string;
|
|
680
|
+
/**
|
|
681
|
+
* End datetime in RFC-3339 format (YYYY-MM-DD)
|
|
682
|
+
* Example: "2024-02-11T16:00:00Z"
|
|
683
|
+
*/
|
|
684
|
+
end?: string;
|
|
685
|
+
/** Number of results to return (max 10000) */
|
|
686
|
+
limit?: number;
|
|
687
|
+
/** Pagination token for next page */
|
|
688
|
+
page_token?: string;
|
|
689
|
+
/** Sort order (asc or desc) */
|
|
690
|
+
sort?: 'asc' | 'desc';
|
|
691
|
+
}
|
|
692
|
+
export interface OptionsSnapshotsParams {
|
|
693
|
+
/** Comma-separated list of option contract symbols */
|
|
694
|
+
symbols: string[];
|
|
695
|
+
/** Number of results to return (may not be supported by this endpoint) */
|
|
696
|
+
limit?: number;
|
|
697
|
+
/** Pagination token for next page (may not be supported by this endpoint) */
|
|
698
|
+
page_token?: string;
|
|
699
|
+
}
|
|
700
|
+
export interface OptionsConditionCodesResponse {
|
|
701
|
+
[conditionCode: string]: string;
|
|
702
|
+
}
|
|
703
|
+
export interface OptionsExchangeCodesResponse {
|
|
704
|
+
[exchangeCode: string]: string;
|
|
705
|
+
}
|
|
706
|
+
export type OptionTickType = 'trade' | 'quote';
|
|
707
|
+
/**
|
|
708
|
+
* Configuration for options spread trading strategies.
|
|
709
|
+
* Now includes a field to target a predicted stock price movement (in percent, scale 100).
|
|
710
|
+
*/
|
|
711
|
+
export interface OptionsSpreadConfig {
|
|
712
|
+
/** Strategy type to use - only spreads allowed */
|
|
713
|
+
strategy: 'call_spread' | 'put_spread';
|
|
714
|
+
/** Days to expiration target (will find closest available) */
|
|
715
|
+
daysToExpiration: number;
|
|
716
|
+
/** Delta target for the long leg (0.1-0.9 range) */
|
|
717
|
+
longLegDeltaTarget: number;
|
|
718
|
+
/** Strike width in dollars between long and short legs */
|
|
719
|
+
strikeWidthDollars: number;
|
|
720
|
+
/** Maximum net debit to pay as percentage of underlying price */
|
|
721
|
+
maxNetDebitPercent100: number;
|
|
722
|
+
/** Use market orders for better execution (vs limit orders) */
|
|
723
|
+
useMarketOrders: boolean;
|
|
724
|
+
/** Maximum number of spreads per trade */
|
|
725
|
+
maxSpreads: number;
|
|
726
|
+
/**
|
|
727
|
+
* Target predicted stock price movement in percent (scale 100, e.g. 1 = 1%).
|
|
728
|
+
* Used to select spreads that best match the expected move.
|
|
729
|
+
*/
|
|
730
|
+
targetMovePercent100?: number;
|
|
731
|
+
}
|
|
732
|
+
export type OptionActivityType = 'OPEXC' | 'OPASN' | 'OPEXP';
|
|
733
|
+
export interface OptionAccountActivity {
|
|
734
|
+
id: string;
|
|
735
|
+
activity_type: OptionActivityType;
|
|
736
|
+
date: string;
|
|
737
|
+
net_amount: string;
|
|
738
|
+
description: string;
|
|
739
|
+
symbol: string;
|
|
740
|
+
qty: string;
|
|
741
|
+
price?: string;
|
|
742
|
+
status: 'executed';
|
|
743
|
+
}
|
|
744
|
+
export interface TradeUpdate {
|
|
745
|
+
event: 'new' | 'fill' | 'partial_fill' | 'canceled' | 'expired' | 'pending_new' | 'pending_cancel' | 'pending_replace' | 'replaced' | 'done_for_day';
|
|
746
|
+
price?: string;
|
|
747
|
+
timestamp: string;
|
|
748
|
+
qty?: string;
|
|
749
|
+
position_qty?: string;
|
|
750
|
+
order: AlpacaOrder;
|
|
751
|
+
}
|
|
752
|
+
export type AlpacaAccountType = 'PAPER' | 'LIVE';
|
|
753
|
+
export type AlpacaOrderType = 'limit' | 'market' | 'options';
|
|
754
|
+
export type EngineType = 'brain' | 'quant';
|
|
755
|
+
export interface AlpacaCredentials {
|
|
756
|
+
accountName: string;
|
|
757
|
+
apiKey: string;
|
|
758
|
+
apiSecret: string;
|
|
759
|
+
type: AlpacaAccountType;
|
|
760
|
+
orderType: AlpacaOrderType;
|
|
761
|
+
engine: EngineType;
|
|
762
|
+
}
|
|
763
|
+
export type { AlpacaTradingAPI } from '../alpaca-trading-api';
|
|
764
|
+
export type { AlpacaMarketDataAPI } from '../alpaca-market-data-api';
|
|
765
|
+
/**
|
|
766
|
+
* Base interface for all real-time stream messages from Alpaca.
|
|
767
|
+
* All stream messages will have a 'T' (Type) and 'S' (Symbol) property.
|
|
768
|
+
*/
|
|
769
|
+
export interface AlpacaStreamMessage {
|
|
770
|
+
T: string;
|
|
771
|
+
S: string;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Real-time stock trade message. (T: 't')
|
|
775
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#trades
|
|
776
|
+
*/
|
|
777
|
+
export interface AlpacaTradeStream extends AlpacaStreamMessage {
|
|
778
|
+
T: 't';
|
|
779
|
+
i: number;
|
|
780
|
+
x: string;
|
|
781
|
+
p: number;
|
|
782
|
+
s: number;
|
|
783
|
+
c: string[];
|
|
784
|
+
t: string;
|
|
785
|
+
z: string;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Real-time stock quote message. (T: 'q')
|
|
789
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#quotes
|
|
790
|
+
*/
|
|
791
|
+
export interface AlpacaQuoteStream extends AlpacaStreamMessage {
|
|
792
|
+
T: 'q';
|
|
793
|
+
ax: string;
|
|
794
|
+
ap: number;
|
|
795
|
+
as: number;
|
|
796
|
+
bx: string;
|
|
797
|
+
bp: number;
|
|
798
|
+
bs: number;
|
|
799
|
+
c: string[];
|
|
800
|
+
t: string;
|
|
801
|
+
z: string;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Real-time stock bar message. (T: 'b')
|
|
805
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#bars
|
|
806
|
+
*/
|
|
807
|
+
export interface AlpacaBarStream extends AlpacaStreamMessage {
|
|
808
|
+
T: 'b';
|
|
809
|
+
o: number;
|
|
810
|
+
h: number;
|
|
811
|
+
l: number;
|
|
812
|
+
c: number;
|
|
813
|
+
v: number;
|
|
814
|
+
t: string;
|
|
815
|
+
vw: number;
|
|
816
|
+
n: number;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Real-time daily stock bar message. (T: 'd')
|
|
820
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#bars
|
|
821
|
+
*/
|
|
822
|
+
export interface AlpacaDailyBarStream extends Omit<AlpacaBarStream, 'T'> {
|
|
823
|
+
T: 'd';
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Real-time updated stock bar message. (T: 'u')
|
|
827
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#bars
|
|
828
|
+
*/
|
|
829
|
+
export interface AlpacaUpdatedBarStream extends Omit<AlpacaBarStream, 'T'> {
|
|
830
|
+
T: 'u';
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Real-time trading status message. (T: 's')
|
|
834
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#trading-status
|
|
835
|
+
*/
|
|
836
|
+
export interface AlpacaTradingStatusStream extends AlpacaStreamMessage {
|
|
837
|
+
T: 's';
|
|
838
|
+
sc: string;
|
|
839
|
+
sm: string;
|
|
840
|
+
rc: string;
|
|
841
|
+
rm: string;
|
|
842
|
+
t: string;
|
|
843
|
+
z: string;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Real-time LULD (Limit Up/Limit Down) message. (T: 'l')
|
|
847
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#lulds
|
|
848
|
+
*/
|
|
849
|
+
export interface AlpacaLULDStream extends AlpacaStreamMessage {
|
|
850
|
+
T: 'l';
|
|
851
|
+
ldp: number;
|
|
852
|
+
lup: number;
|
|
853
|
+
i: string;
|
|
854
|
+
t: string;
|
|
855
|
+
z: string;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Real-time trade correction message. (T: 'c')
|
|
859
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#trade-corrections
|
|
860
|
+
*/
|
|
861
|
+
export interface AlpacaTradeCorrectionStream extends AlpacaStreamMessage {
|
|
862
|
+
T: 'c';
|
|
863
|
+
oi: number;
|
|
864
|
+
ci: number;
|
|
865
|
+
ox: string;
|
|
866
|
+
cx: string;
|
|
867
|
+
op: number;
|
|
868
|
+
cp: number;
|
|
869
|
+
os: number;
|
|
870
|
+
cs: number;
|
|
871
|
+
oc: string[];
|
|
872
|
+
cc: string[];
|
|
873
|
+
t: string;
|
|
874
|
+
z: string;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Real-time trade cancel/error message. (T: 'x')
|
|
878
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#trade-cancelserros
|
|
879
|
+
*/
|
|
880
|
+
export interface AlpacaTradeCancelStream extends AlpacaStreamMessage {
|
|
881
|
+
T: 'x';
|
|
882
|
+
i: number;
|
|
883
|
+
p: number;
|
|
884
|
+
s: number;
|
|
885
|
+
t: string;
|
|
886
|
+
z: string;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Real-time order imbalance message. (T: 'i')
|
|
890
|
+
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#order-imbalances
|
|
891
|
+
*/
|
|
892
|
+
export interface AlpacaOrderImbalanceStream extends AlpacaStreamMessage {
|
|
893
|
+
T: 'i';
|
|
894
|
+
p: number;
|
|
895
|
+
z: string;
|
|
896
|
+
t: string;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Real-time option trade message. (T: 't')
|
|
900
|
+
* @see https://docs.alpaca.markets/docs/real-time-option-data#trades
|
|
901
|
+
*/
|
|
902
|
+
export interface AlpacaOptionTradeStream extends AlpacaStreamMessage {
|
|
903
|
+
T: 't';
|
|
904
|
+
p: number;
|
|
905
|
+
s: number;
|
|
906
|
+
c: string[];
|
|
907
|
+
x: string;
|
|
908
|
+
t: string;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Real-time option quote message. (T: 'q')
|
|
912
|
+
* @see https://docs.alpaca.markets/docs/real-time-option-data#quotes
|
|
913
|
+
*/
|
|
914
|
+
export interface AlpacaOptionQuoteStream extends AlpacaStreamMessage {
|
|
915
|
+
T: 'q';
|
|
916
|
+
ap: number;
|
|
917
|
+
as: number;
|
|
918
|
+
ax: string;
|
|
919
|
+
bp: number;
|
|
920
|
+
bs: number;
|
|
921
|
+
bx: string;
|
|
922
|
+
t: string;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Real-time option bar message. (T: 'b')
|
|
926
|
+
* @see https://docs.alpaca.markets/docs/real-time-option-data#bars
|
|
927
|
+
*/
|
|
928
|
+
export interface AlpacaOptionBarStream extends AlpacaStreamMessage {
|
|
929
|
+
T: 'b';
|
|
930
|
+
o: number;
|
|
931
|
+
h: number;
|
|
932
|
+
l: number;
|
|
933
|
+
c: number;
|
|
934
|
+
v: number;
|
|
935
|
+
t: string;
|
|
936
|
+
vw: number;
|
|
937
|
+
n: number;
|
|
938
|
+
}
|
|
939
|
+
export type AlpacaStockStreamMessage = AlpacaTradeStream | AlpacaQuoteStream | AlpacaBarStream | AlpacaDailyBarStream | AlpacaUpdatedBarStream | AlpacaTradingStatusStream | AlpacaLULDStream | AlpacaTradeCorrectionStream | AlpacaTradeCancelStream | AlpacaOrderImbalanceStream;
|
|
940
|
+
export type AlpacaOptionStreamMessage = AlpacaOptionTradeStream | AlpacaOptionQuoteStream | AlpacaOptionBarStream;
|
|
941
|
+
export type StockStreamEventName = 'stock-t' | 'stock-q' | 'stock-b' | 'stock-d' | 'stock-u' | 'stock-s' | 'stock-l' | 'stock-c' | 'stock-x' | 'stock-i' | 'stock-data';
|
|
942
|
+
export type OptionStreamEventName = 'option-t' | 'option-q' | 'option-b' | 'option-data';
|
|
943
|
+
export interface StockStreamEventMap {
|
|
944
|
+
'stock-t': AlpacaTradeStream;
|
|
945
|
+
'stock-q': AlpacaQuoteStream;
|
|
946
|
+
'stock-b': AlpacaBarStream;
|
|
947
|
+
'stock-d': AlpacaDailyBarStream;
|
|
948
|
+
'stock-u': AlpacaUpdatedBarStream;
|
|
949
|
+
'stock-s': AlpacaTradingStatusStream;
|
|
950
|
+
'stock-l': AlpacaLULDStream;
|
|
951
|
+
'stock-c': AlpacaTradeCorrectionStream;
|
|
952
|
+
'stock-x': AlpacaTradeCancelStream;
|
|
953
|
+
'stock-i': AlpacaOrderImbalanceStream;
|
|
954
|
+
'stock-data': AlpacaStockStreamMessage;
|
|
955
|
+
}
|
|
956
|
+
export interface OptionStreamEventMap {
|
|
957
|
+
'option-t': AlpacaOptionTradeStream;
|
|
958
|
+
'option-q': AlpacaOptionQuoteStream;
|
|
959
|
+
'option-b': AlpacaOptionBarStream;
|
|
960
|
+
'option-data': AlpacaOptionStreamMessage;
|
|
961
|
+
}
|
|
962
|
+
//# sourceMappingURL=alpaca-types.d.ts.map
|