1 | export interface Endpoints {
|
2 | rest: {
|
3 | beta: 'https://data.alpaca.markets/v1beta1';
|
4 | account: 'https://api.alpaca.markets/v2';
|
5 | market_data_v2: 'https://data.alpaca.markets/v2';
|
6 | market_data_v1: 'https://data.alpaca.markets/v1';
|
7 | };
|
8 | websocket: {
|
9 | account: 'wss://api.alpaca.markets/stream';
|
10 | market_data: (source: DataSource) => string;
|
11 | };
|
12 | }
|
13 | /**
|
14 | * Your Alpaca key id and secret.
|
15 | * Can be passed to the AlpacaClient and AlpacaStream.
|
16 | */
|
17 | export interface DefaultCredentials {
|
18 | key: string;
|
19 | secret: string;
|
20 | paper?: boolean;
|
21 | }
|
22 | /**
|
23 | * Client ID for Oauth requests on behalf of users.
|
24 | * Can be passed to the AlpacaClient.
|
25 | */
|
26 | export interface OAuthCredentials {
|
27 | access_token: String;
|
28 | paper?: boolean;
|
29 | }
|
30 | /**
|
31 | * The account information with unparsed types, exactly as Alpaca provides it.
|
32 | * We encourage you to use the Account interface, which has many of these fields parsed.
|
33 | */
|
34 | export interface RawAccount {
|
35 | account_blocked: boolean;
|
36 | account_number: string;
|
37 | buying_power: string;
|
38 | cash: string;
|
39 | created_at: string;
|
40 | currency: string;
|
41 | daytrade_count: number;
|
42 | daytrading_buying_power: string;
|
43 | equity: string;
|
44 | id: string;
|
45 | initial_margin: string;
|
46 | last_equity: string;
|
47 | last_maintenance_margin: string;
|
48 | long_market_value: string;
|
49 | maintenance_margin: string;
|
50 | multiplier: string;
|
51 | pattern_day_trader: boolean;
|
52 | portfolio_value: string;
|
53 | regt_buying_power: string;
|
54 | short_market_value: string;
|
55 | shorting_enabled: boolean;
|
56 | sma: string;
|
57 | status: string;
|
58 | trade_suspended_by_user: boolean;
|
59 | trading_blocked: boolean;
|
60 | transfers_blocked: boolean;
|
61 | }
|
62 | /**
|
63 | * The following are the possible account status values. Most likely, the account status
|
64 | * is ACTIVE unless there is any problem. The account status may get in ACCOUNT_UPDATED
|
65 | * when personal information is being updated from the dashboard, in which case you may
|
66 | * not be allowed trading for a short period of time until the change is approved.
|
67 | */
|
68 | export declare type AccountStatus =
|
69 | /**
|
70 | * The account is onboarding.
|
71 | */
|
72 | 'ONBOARDING'
|
73 | /**
|
74 | * The account application submission failed for some reason.
|
75 | */
|
76 | | 'SUBMISSION_FAILED'
|
77 | /**
|
78 | * The account application has been submitted for review.
|
79 | */
|
80 | | 'SUBMITTED'
|
81 | /**
|
82 | * The account information is being updated.
|
83 | */
|
84 | | 'ACCOUNT_UPDATED'
|
85 | /**
|
86 | * The final account approval is pending.
|
87 | */
|
88 | | 'APPROVAL_PENDING'
|
89 | /**
|
90 | * The account is active for trading.
|
91 | */
|
92 | | 'ACTIVE'
|
93 | /**
|
94 | * The account application has been rejected.
|
95 | */
|
96 | | 'REJECTED';
|
97 | /**
|
98 | * Information related to an Alpaca account, such as account status, funds, and various
|
99 | * flags relevant to an account's ability to trade.
|
100 | */
|
101 | export interface Account {
|
102 | /**
|
103 | * Get the raw data, exactly as it came from Alpaca
|
104 | */
|
105 | raw(): RawAccount;
|
106 | /**
|
107 | * If true, the account activity by user is prohibited.
|
108 | */
|
109 | account_blocked: boolean;
|
110 | /**
|
111 | * Account number.
|
112 | */
|
113 | account_number: string;
|
114 | /**
|
115 | * Current available $ buying power; If multiplier = 4, this is your daytrade buying
|
116 | * power which is calculated as (last_equity - (last) maintenance_margin) * 4; If
|
117 | * multiplier = 2, buying_power = max(equity – initial_margin,0) * 2; If multiplier = 1,
|
118 | * buying_power = cash
|
119 | */
|
120 | buying_power: number;
|
121 | /**
|
122 | * Cash balance
|
123 | */
|
124 | cash: number;
|
125 | /**
|
126 | * Timestamp this account was created at
|
127 | */
|
128 | created_at: Date;
|
129 | /**
|
130 | * "USD"
|
131 | */
|
132 | currency: string;
|
133 | /**
|
134 | * The current number of daytrades that have been made in the last 5 trading days
|
135 | * (inclusive of today)
|
136 | */
|
137 | daytrade_count: number;
|
138 | /**
|
139 | * Your buying power for day trades (continuously updated value)
|
140 | */
|
141 | daytrading_buying_power: number;
|
142 | /**
|
143 | * Cash + long_market_value + short_market_value
|
144 | */
|
145 | equity: number;
|
146 | /**
|
147 | * Account ID.
|
148 | */
|
149 | id: string;
|
150 | /**
|
151 | * Reg T initial margin requirement (continuously updated value)
|
152 | */
|
153 | initial_margin: number;
|
154 | /**
|
155 | * Equity as of previous trading day at 16:00:00 ET
|
156 | */
|
157 | last_equity: number;
|
158 | /**
|
159 | * Your maintenance margin requirement on the previous trading day
|
160 | */
|
161 | last_maintenance_margin: number;
|
162 | /**
|
163 | * Real-time MtM value of all long positions held in the account
|
164 | */
|
165 | long_market_value: number;
|
166 | /**
|
167 | * Maintenance margin requirement (continuously updated value)
|
168 | */
|
169 | maintenance_margin: number;
|
170 | /**
|
171 | * Buying power multiplier that represents account margin classification; valid values 1
|
172 | * (standard limited margin account with 1x buying power), 2 (reg T margin account with
|
173 | * 2x intraday and overnight buying power; this is the default for all non-PDT accounts
|
174 | * with $2,000 or more equity), 4 (PDT account with 4x intraday buying power and 2x reg
|
175 | * T overnight buying power)
|
176 | */
|
177 | multiplier: number;
|
178 | /**
|
179 | * Whether or not the account has been flagged as a pattern day trader
|
180 | */
|
181 | pattern_day_trader: boolean;
|
182 | /**
|
183 | * Total value of cash + holding positions (This field is deprecated. It is equivalent
|
184 | * to the equity field.)
|
185 | */
|
186 | portfolio_value: number;
|
187 | /**
|
188 | * Your buying power under Regulation T (your excess equity - equity minus margin
|
189 | * value - times your margin multiplier)
|
190 | */
|
191 | regt_buying_power: number;
|
192 | /**
|
193 | * Real-time MtM value of all short positions held in the account
|
194 | */
|
195 | short_market_value: number;
|
196 | /**
|
197 | * Flag to denote whether or not the account is permitted to short
|
198 | */
|
199 | shorting_enabled: boolean;
|
200 | /**
|
201 | * Value of special memorandum account (will be used at a later date to provide
|
202 | * additional buying_power)
|
203 | */
|
204 | sma: number;
|
205 | /**
|
206 | * The following are the possible account status values. Most likely, the account status
|
207 | * is ACTIVE unless there is any problem. The account status may get in ACCOUNT_UPDATED
|
208 | * when personal information is being updated from the dashboard, in which case you may
|
209 | * not be allowed trading for a short period of time until the change is approved.
|
210 | */
|
211 | status: AccountStatus;
|
212 | /**
|
213 | * User setting. If true, the account is not allowed to place orders.
|
214 | */
|
215 | trade_suspended_by_user: boolean;
|
216 | /**
|
217 | * If true, the account is not allowed to place orders.
|
218 | */
|
219 | trading_blocked: boolean;
|
220 | /**
|
221 | * If true, the account is not allowed to request money transfers.
|
222 | */
|
223 | transfers_blocked: boolean;
|
224 | }
|
225 | export interface AccountConfigurations {
|
226 | /**
|
227 | * both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks.
|
228 | */
|
229 | dtbp_check: 'both' | 'entry' | 'exit';
|
230 | /**
|
231 | * If true, account becomes long-only mode.
|
232 | */
|
233 | no_shorting: boolean;
|
234 | /**
|
235 | * If true, new orders are blocked.
|
236 | */
|
237 | suspend_trade: boolean;
|
238 | /**
|
239 | * all or none. If none, emails for order fills are not sent.
|
240 | */
|
241 | trade_confirm_email: 'all' | 'none';
|
242 | }
|
243 | export interface AccountUpdate {
|
244 | id: string;
|
245 | created_at: string;
|
246 | updated_at: string;
|
247 | deleted_at: any;
|
248 | status: string;
|
249 | currency: string;
|
250 | cash: string;
|
251 | cash_withdrawable: string;
|
252 | }
|
253 | export interface AggregateMinute {
|
254 | ev: string;
|
255 | T: string;
|
256 | v: number;
|
257 | av: number;
|
258 | op: number;
|
259 | vw: number;
|
260 | o: number;
|
261 | c: number;
|
262 | h: number;
|
263 | l: number;
|
264 | a: number;
|
265 | s: number;
|
266 | e: number;
|
267 | }
|
268 | export declare type AssetExchange = 'AMEX' | 'ARCA' | 'BATS' | 'NYSE' | 'NASDAQ' | 'NYSEARCA';
|
269 | export declare type AssetStatus = 'active' | 'inactive';
|
270 | /**
|
271 | * The assets API serves as the master list of assets available for trade and data
|
272 | * consumption from Alpaca. Assets are sorted by asset class, exchange and symbol. Some
|
273 | * assets are only available for data consumption via Polygon, and are not tradable with
|
274 | * Alpaca. These assets will be marked with the flag tradable=false.
|
275 | */
|
276 | export interface Asset {
|
277 | /**
|
278 | * Asset ID
|
279 | */
|
280 | id: string;
|
281 | /**
|
282 | * "us_equity"
|
283 | */
|
284 | class: string;
|
285 | /**
|
286 | * AMEX, ARCA, BATS, NYSE, NASDAQ or NYSEARCA
|
287 | */
|
288 | exchange: AssetExchange;
|
289 | /**
|
290 | * Asset symbol
|
291 | */
|
292 | symbol: string;
|
293 | /**
|
294 | * active or inactive
|
295 | */
|
296 | status: AssetStatus;
|
297 | /**
|
298 | * Asset is tradable on Alpaca or not
|
299 | */
|
300 | tradable: boolean;
|
301 | /**
|
302 | * Asset is marginable or not
|
303 | */
|
304 | marginable: boolean;
|
305 | /**
|
306 | * Asset is shortable or not
|
307 | */
|
308 | shortable: boolean;
|
309 | /**
|
310 | * Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way
|
311 | * to check whether the name is currently available to short at Alpaca).
|
312 | */
|
313 | easy_to_borrow: boolean;
|
314 | /**
|
315 | * Asset is fractionable or not.
|
316 | */
|
317 | fractionable: boolean;
|
318 | }
|
319 | /**
|
320 | * Contains the time of open and close for a market on a particular day from 1970 to 2029
|
321 | */
|
322 | export interface Calendar {
|
323 | /**
|
324 | * Date string in YYYY-MM-DD format
|
325 | */
|
326 | date: string;
|
327 | /**
|
328 | * The time the market opens at on this date in HH:MM format
|
329 | */
|
330 | open: string;
|
331 | /**
|
332 | * The time the market closes at on this date in HH:MM format
|
333 | */
|
334 | close: string;
|
335 | }
|
336 | export interface RawClock {
|
337 | timestamp: string;
|
338 | is_open: boolean;
|
339 | next_open: string;
|
340 | next_close: string;
|
341 | }
|
342 | /**
|
343 | * The clock API serves the current market timestamp, whether or not the market is
|
344 | * currently open, as well as the times of the next market open and close.
|
345 | */
|
346 | export interface Clock {
|
347 | /**
|
348 | * Get the raw data, exactly as it came from Alpaca
|
349 | */
|
350 | raw(): RawClock;
|
351 | /**
|
352 | * Current timestamp
|
353 | */
|
354 | timestamp: Date;
|
355 | /**
|
356 | * Whether or not the market is open
|
357 | */
|
358 | is_open: boolean;
|
359 | /**
|
360 | * Next market open timestamp
|
361 | */
|
362 | next_open: Date;
|
363 | /**
|
364 | * Next market close timestamp
|
365 | */
|
366 | next_close: Date;
|
367 | }
|
368 | /** A trade which occurred. */
|
369 | export interface RawTrade {
|
370 | /** Trade symbol. */
|
371 | S: string;
|
372 | /** Timestamp in RFC-3339 format with nanosecond precision. */
|
373 | t: string;
|
374 | /** Exchange where the trade happened. */
|
375 | x: string;
|
376 | /** Trade price. */
|
377 | p: number;
|
378 | /** Trade size. */
|
379 | s: number;
|
380 | /** Trade conditions. */
|
381 | c: string[];
|
382 | /** Trade ID. */
|
383 | i: number;
|
384 | /** Tape. */
|
385 | z: string;
|
386 | }
|
387 | /** A page of one or many trades. */
|
388 | export interface RawPageOfTrades {
|
389 | /** Array of trades. */
|
390 | trades: RawTrade[];
|
391 | /** Symbol that was queried. */
|
392 | symbol: string;
|
393 | /** Token that can be used to query the next page. */
|
394 | next_page_token: string;
|
395 | }
|
396 | /** A trade which occurred. */
|
397 | export interface Trade {
|
398 | /** Get the raw data as it came from Alpaca. */
|
399 | raw(): RawTrade;
|
400 | /** Trade symbol. */
|
401 | S: string;
|
402 | /** Timestamp in RFC-3339 format with nanosecond precision. */
|
403 | t: Date;
|
404 | /** Exchange where the trade happened. */
|
405 | x: string;
|
406 | /** Trade price. */
|
407 | p: number;
|
408 | /** Trade size. */
|
409 | s: number;
|
410 | /** Trade conditions. */
|
411 | c: string[];
|
412 | /** Trade ID. */
|
413 | i: number;
|
414 | /** Tape. */
|
415 | z: string;
|
416 | }
|
417 | /** A page of one or many trades. */
|
418 | export interface PageOfTrades {
|
419 | /** Get the raw data as it came from Alpaca. */
|
420 | raw(): RawPageOfTrades;
|
421 | /** Array of trades. */
|
422 | trades: Trade[];
|
423 | /** Symbol that was queried. */
|
424 | symbol: string;
|
425 | /** Token that can be used to query the next page. */
|
426 | next_page_token: string;
|
427 | }
|
428 | /** A quote for a symbol. */
|
429 | export interface RawQuote {
|
430 | /** Quote symbol. */
|
431 | S: string;
|
432 | /** Timestamp in RFC-3339 format with nanosecond precision. */
|
433 | t: string;
|
434 | /** Ask exchange. */
|
435 | ax: string;
|
436 | /** Ask price. */
|
437 | ap: number;
|
438 | /** Ask size. */
|
439 | as: number;
|
440 | /** Bid exchange. */
|
441 | bx: string;
|
442 | /** Bid price. */
|
443 | bp: number;
|
444 | /** Bid size. */
|
445 | bs: number;
|
446 | /** Quote conditions. */
|
447 | c: string[];
|
448 | }
|
449 | /** A page of one or many quotes. */
|
450 | export interface RawPageOfQuotes {
|
451 | /** Array of quotes. */
|
452 | quotes: RawQuote[];
|
453 | /** Symbol that was queried. */
|
454 | symbol: string;
|
455 | /** Token that can be used to query the next page. */
|
456 | next_page_token: string;
|
457 | }
|
458 | /** A quote for a symbol. */
|
459 | export interface Quote {
|
460 | /** Get the raw data as it came from Alpaca. */
|
461 | raw(): RawQuote;
|
462 | /** Quote symbol. */
|
463 | S: string;
|
464 | /** Timestamp in Date format. */
|
465 | t: Date;
|
466 | /** Ask exchange. */
|
467 | ax: string;
|
468 | /** Ask price. */
|
469 | ap: number;
|
470 | /** Ask size. */
|
471 | as: number;
|
472 | /** Bid exchange. */
|
473 | bx: string;
|
474 | /** Bid price. */
|
475 | bp: number;
|
476 | /** Bid size. */
|
477 | bs: number;
|
478 | /** Quote conditions. */
|
479 | c: string[];
|
480 | }
|
481 | /** A page of one or many quotes. */
|
482 | export interface PageOfQuotes {
|
483 | /** Get the raw data as it came from Alpaca. */
|
484 | raw(): RawPageOfQuotes;
|
485 | /** Array of quotes. */
|
486 | quotes: Quote[];
|
487 | /** Symbol that was queried. */
|
488 | symbol: string;
|
489 | /** Token that can be used to query the next page. */
|
490 | next_page_token: string;
|
491 | }
|
492 | /** A bar for a symbol. */
|
493 | export interface RawBar {
|
494 | /** Bar symbol. */
|
495 | S: string;
|
496 | /** Timestamp in RFC-3339 format with nanosecond precision. */
|
497 | t: string;
|
498 | /** Open price. */
|
499 | o: number;
|
500 | /** High price. */
|
501 | h: number;
|
502 | /** Low price. */
|
503 | l: number;
|
504 | /** Close price. */
|
505 | c: number;
|
506 | /** Volume. */
|
507 | v: number;
|
508 | }
|
509 | /** A page of one or many bars. */
|
510 | export interface RawPageOfBars {
|
511 | /** Array of bars. */
|
512 | bars: RawBar[];
|
513 | /** Symbol that was queried. */
|
514 | symbol: string;
|
515 | /** Token that can be used to query the next page. */
|
516 | next_page_token: string;
|
517 | }
|
518 | /** A bar for a symbol. */
|
519 | export interface Bar {
|
520 | /** Get the raw data as it came from Alpaca. */
|
521 | raw(): RawBar;
|
522 | /** Bar symbol. */
|
523 | S: string;
|
524 | /** Timestamp in Date format. */
|
525 | t: Date;
|
526 | /** Open price. */
|
527 | o: number;
|
528 | /** High price. */
|
529 | h: number;
|
530 | /** Low price. */
|
531 | l: number;
|
532 | /** Close price. */
|
533 | c: number;
|
534 | /** Volume. */
|
535 | v: number;
|
536 | }
|
537 | /** A page of one or many bars. */
|
538 | export interface PageOfBars {
|
539 | /** Get the raw data as it came from Alpaca. */
|
540 | raw(): RawPageOfBars;
|
541 | /** Array of bars. */
|
542 | bars: Bar[];
|
543 | /** Symbol that was queried. */
|
544 | symbol: string;
|
545 | /** Token that can be used to query the next page. */
|
546 | next_page_token: string;
|
547 | }
|
548 | /**
|
549 | * The parsed result of an order cancelation request.
|
550 | */
|
551 | export interface OrderCancelation {
|
552 | id: string;
|
553 | status: number;
|
554 | order: Order;
|
555 | }
|
556 | /**
|
557 | * The id, http status code and order as part of the cancel all orders request.
|
558 | */
|
559 | export interface RawOrderCancelation {
|
560 | id: string;
|
561 | status: number;
|
562 | body: RawOrder;
|
563 | }
|
564 | /**
|
565 | * The order entity with unparsed fields, exactly as Alpaca provides it.
|
566 | * We encourage you to use the Order interface, which has many of these fields parsed.
|
567 | */
|
568 | export interface RawOrder {
|
569 | id: string;
|
570 | client_order_id: string;
|
571 | created_at: string;
|
572 | updated_at: string;
|
573 | submitted_at: string;
|
574 | filled_at: string;
|
575 | expired_at: string;
|
576 | canceled_at: string;
|
577 | failed_at: string;
|
578 | replaced_at: string;
|
579 | replaced_by: string;
|
580 | replaces: string;
|
581 | asset_id: string;
|
582 | symbol: string;
|
583 | asset_class: string;
|
584 | qty: string;
|
585 | filled_qty: string;
|
586 | type: string;
|
587 | side: string;
|
588 | time_in_force: string;
|
589 | limit_price: string;
|
590 | stop_price: string;
|
591 | filled_avg_price: string;
|
592 | status: string;
|
593 | extended_hours: boolean;
|
594 | legs: RawOrder[];
|
595 | trail_price: string;
|
596 | trail_percent: string;
|
597 | hwm: string;
|
598 | order_class?: OrderClass;
|
599 | }
|
600 | /**
|
601 | * Price and volume data during a particular time interval
|
602 | */
|
603 | export interface Bar_v1 {
|
604 | /**
|
605 | * the beginning time of this bar as a Unix epoch in seconds
|
606 | */
|
607 | t: number;
|
608 | /**
|
609 | * open price
|
610 | */
|
611 | o: number;
|
612 | /**
|
613 | * high price
|
614 | */
|
615 | h: number;
|
616 | /**
|
617 | * low price
|
618 | */
|
619 | l: number;
|
620 | /**
|
621 | * close price
|
622 | */
|
623 | c: number;
|
624 | /**
|
625 | * volume
|
626 | */
|
627 | v: number;
|
628 | }
|
629 | /**
|
630 | * Last quote details for a symbol
|
631 | */
|
632 | export interface LastQuote_v1 {
|
633 | status: string;
|
634 | symbol: string;
|
635 | last: {
|
636 | /**
|
637 | * the current ask price
|
638 | */
|
639 | askprice: number;
|
640 | /**
|
641 | * the current ask size
|
642 | */
|
643 | asksize: number;
|
644 | /**
|
645 | * the exchange code of the ask quote
|
646 | */
|
647 | askexchange: number;
|
648 | /**
|
649 | * the current bid price
|
650 | */
|
651 | bidprice: number;
|
652 | /**
|
653 | * the current bid size
|
654 | */
|
655 | bidsize: number;
|
656 | /**
|
657 | * the exchange code of the bid quote
|
658 | */
|
659 | bidexchange: number;
|
660 | /**
|
661 | * epoch timestamp in nanoseconds
|
662 | */
|
663 | timestamp: number;
|
664 | };
|
665 | }
|
666 | /**
|
667 | * Last trade details for a symbol
|
668 | */
|
669 | export interface LastTrade_v1 {
|
670 | status: string;
|
671 | symbol: string;
|
672 | last: {
|
673 | /**
|
674 | * last trade price
|
675 | */
|
676 | price: number;
|
677 | /**
|
678 | * last trade volume size
|
679 | */
|
680 | size: number;
|
681 | /**
|
682 | * exchange code where the last trade was made
|
683 | */
|
684 | exchange: number;
|
685 | /**
|
686 | * condition flag 1
|
687 | */
|
688 | cond1: number;
|
689 | /**
|
690 | * condition flag 2
|
691 | */
|
692 | cond2: number;
|
693 | /**
|
694 | * condition flag 3
|
695 | */
|
696 | cond3: number;
|
697 | /**
|
698 | * condition flag 4
|
699 | */
|
700 | cond4: number;
|
701 | /**
|
702 | * epoch timestamp in nanoseconds
|
703 | */
|
704 | timestamp: number;
|
705 | };
|
706 | }
|
707 | export interface RawSnapshot {
|
708 | symbol: string;
|
709 | latestTrade: {
|
710 | t: string;
|
711 | x: string;
|
712 | p: number;
|
713 | s: number;
|
714 | c?: string[] | null;
|
715 | i: number;
|
716 | z: string;
|
717 | };
|
718 | latestQuote: {
|
719 | t: string;
|
720 | ax: string;
|
721 | ap: number;
|
722 | as: number;
|
723 | bx: string;
|
724 | bp: number;
|
725 | bs: number;
|
726 | c?: string[] | null;
|
727 | };
|
728 | minuteBar: {
|
729 | t: string;
|
730 | o: number;
|
731 | h: number;
|
732 | l: number;
|
733 | c: number;
|
734 | v: number;
|
735 | };
|
736 | dailyBar: {
|
737 | t: string;
|
738 | o: number;
|
739 | h: number;
|
740 | l: number;
|
741 | c: number;
|
742 | v: number;
|
743 | };
|
744 | prevDailyBar: {
|
745 | t: string;
|
746 | o: number;
|
747 | h: number;
|
748 | l: number;
|
749 | c: number;
|
750 | v: number;
|
751 | };
|
752 | }
|
753 | export interface Snapshot {
|
754 | /** Get the raw data as it came from Alpaca. */
|
755 | raw(): RawSnapshot;
|
756 | symbol: string;
|
757 | latestTrade: {
|
758 | t: Date;
|
759 | x: string;
|
760 | p: number;
|
761 | s: number;
|
762 | c?: string[] | null;
|
763 | i: number;
|
764 | z: string;
|
765 | };
|
766 | latestQuote: {
|
767 | t: Date;
|
768 | ax: string;
|
769 | ap: number;
|
770 | as: number;
|
771 | bx: string;
|
772 | bp: number;
|
773 | bs: number;
|
774 | c?: string[] | null;
|
775 | };
|
776 | minuteBar: {
|
777 | t: Date;
|
778 | o: number;
|
779 | h: number;
|
780 | l: number;
|
781 | c: number;
|
782 | v: number;
|
783 | };
|
784 | dailyBar: {
|
785 | t: Date;
|
786 | o: number;
|
787 | h: number;
|
788 | l: number;
|
789 | c: number;
|
790 | v: number;
|
791 | };
|
792 | prevDailyBar: {
|
793 | t: Date;
|
794 | o: number;
|
795 | h: number;
|
796 | l: number;
|
797 | c: number;
|
798 | v: number;
|
799 | };
|
800 | }
|
801 | export declare type DataSource = 'iex' | 'sip';
|
802 | export declare type OrderType = 'market' | 'limit' | 'stop' | 'stop_limit' | 'trailing_stop';
|
803 | export declare type OrderClass = 'simple' | 'bracket' | 'oto' | 'oco';
|
804 | export declare type OrderSide = 'buy' | 'sell';
|
805 | export declare type OrderTimeInForce =
|
806 | /**
|
807 | * A day order is eligible for execution only on the day it is live. By default, the
|
808 | * order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled
|
809 | * after the closing auction, it is automatically canceled. If submitted after the
|
810 | * close, it is queued and submitted the following trading day. However, if marked as
|
811 | * eligible for extended hours, the order can also execute during supported extended
|
812 | * hours.
|
813 | */
|
814 | 'day'
|
815 | /**
|
816 | * The order is good until canceled. Non-marketable GTC limit orders are subject to
|
817 | * price adjustments to offset corporate actions affecting the issue. We do not
|
818 | * currently support Do Not Reduce(DNR) orders to opt out of such price adjustments.
|
819 | */
|
820 | | 'gtc'
|
821 | /**
|
822 | * Use this TIF with a market/limit order type to submit "market on open" (MOO) and
|
823 | * "limit on open" (LOO) orders. This order is eligible to execute only in the market
|
824 | * opening auction. Any unfilled orders after the open will be cancelled. OPG orders
|
825 | * submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted
|
826 | * after 7:00pm will be queued and routed to the following day's opening auction. On
|
827 | * open/on close orders are routed to the primary exchange. Such orders do not
|
828 | * necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange's
|
829 | * auction rules.
|
830 | */
|
831 | | 'opg'
|
832 | /**
|
833 | * Use this TIF with a market/limit order type to submit "market on close" (MOC) and
|
834 | * "limit on close" (LOC) orders. This order is eligible to execute only in the market
|
835 | * closing auction. Any unfilled orders after the close will be cancelled. CLS orders
|
836 | * submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted
|
837 | * after 7:00pm will be queued and routed to the following day's closing auction. Only
|
838 | * available with API v2.
|
839 | */
|
840 | | 'cls'
|
841 | /**
|
842 | * An Immediate Or Cancel (IOC) order requires all or part of the order to be executed
|
843 | * immediately. Any unfilled portion of the order is canceled. Only available with API
|
844 | * v2.
|
845 | */
|
846 | | 'ioc'
|
847 | /**
|
848 | * A Fill or Kill (FOK) order is only executed if the entire order quantity can be
|
849 | * filled, otherwise the order is canceled. Only available with API v2.
|
850 | */
|
851 | | 'fok';
|
852 | export declare type OrderStatus =
|
853 | /**
|
854 | * The order has been received by Alpaca, and routed to exchanges for execution. This
|
855 | * is the usual initial state of an order.
|
856 | */
|
857 | 'new'
|
858 | /**
|
859 | * The order has been partially filled.
|
860 | */
|
861 | | 'partially_filled'
|
862 | /**
|
863 | * The order has been filled, and no further updates will occur for the order.
|
864 | */
|
865 | | 'filled'
|
866 | /**
|
867 | * The order is done executing for the day, and will not receive further updates until
|
868 | * the next trading day.
|
869 | */
|
870 | | 'done_for_day'
|
871 | /**
|
872 | * The order has been canceled, and no further updates will occur for the order. This
|
873 | * can be either due to a cancel request by the user, or the order has been canceled by
|
874 | * the exchanges due to its time-in-force.
|
875 | */
|
876 | | 'canceled'
|
877 | /**
|
878 | * The order has expired, and no further updates will occur for the order.
|
879 | */
|
880 | | 'expired'
|
881 | /**
|
882 | * The order was replaced by another order, or was updated due to a market event such
|
883 | * as corporate action.
|
884 | */
|
885 | | 'replaced'
|
886 | /**
|
887 | * The order is waiting to be canceled.
|
888 | */
|
889 | | 'pending_cancel'
|
890 | /**
|
891 | * The order is waiting to be replaced by another order. The order will reject cancel
|
892 | * request while in this state.
|
893 | */
|
894 | | 'pending_replace'
|
895 | /**
|
896 | * (Uncommon) The order has been received by Alpaca, but hasn't yet been routed to the
|
897 | * execution venue. This could be seen often out side of trading session hours.
|
898 | */
|
899 | | 'accepted'
|
900 | /**
|
901 | * (Uncommon) The order has been received by Alpaca, and routed to the exchanges, but
|
902 | * has not yet been accepted for execution. This state only occurs on rare occasions.
|
903 | */
|
904 | | 'pending_new'
|
905 | /**
|
906 | * (Uncommon) The order has been received by exchanges, and is evaluated for pricing.
|
907 | * This state only occurs on rare occasions.
|
908 | */
|
909 | | 'accepted_for_bidding'
|
910 | /**
|
911 | * (Uncommon) The order has been stopped, and a trade is guaranteed for the order,
|
912 | * usually at a stated price or better, but has not yet occurred. This state only
|
913 | * occurs on rare occasions.
|
914 | */
|
915 | | 'stopped'
|
916 | /**
|
917 | * (Uncommon) The order has been rejected, and no further updates will occur for the
|
918 | * order. This state occurs on rare occasions and may occur based on various conditions
|
919 | * decided by the exchanges.
|
920 | */
|
921 | | 'rejected'
|
922 | /**
|
923 | * (Uncommon) The order has been suspended, and is not eligible for trading. This state
|
924 | * only occurs on rare occasions.
|
925 | */
|
926 | | 'suspended'
|
927 | /**
|
928 | * (Uncommon) The order has been completed for the day (either filled or done for day),
|
929 | * but remaining settlement calculations are still pending. This state only occurs on
|
930 | * rare occasions.
|
931 | */
|
932 | | 'calculated';
|
933 | export interface RawLatestTrade {
|
934 | symbol: string;
|
935 | trade: {
|
936 | t: string;
|
937 | x: string;
|
938 | p: number;
|
939 | s: number;
|
940 | c: string[];
|
941 | i: number;
|
942 | z: string;
|
943 | };
|
944 | }
|
945 | export interface LatestTrade {
|
946 | raw(): RawLatestTrade;
|
947 | symbol: string;
|
948 | trade: {
|
949 | t: Date;
|
950 | x: string;
|
951 | p: number;
|
952 | s: number;
|
953 | c: string[];
|
954 | i: number;
|
955 | z: string;
|
956 | };
|
957 | }
|
958 | /**
|
959 | * An Order in Alpaca
|
960 | */
|
961 | export interface Order {
|
962 | /**
|
963 | * Get the raw data, exactly as it came from Alpaca
|
964 | */
|
965 | raw(): RawOrder;
|
966 | /**
|
967 | * Order id
|
968 | */
|
969 | id: string;
|
970 | /**
|
971 | * Client unique order id
|
972 | */
|
973 | client_order_id: string;
|
974 | /**
|
975 | * When the order was created
|
976 | */
|
977 | created_at: Date;
|
978 | /**
|
979 | * When the order was last updated
|
980 | */
|
981 | updated_at: Date;
|
982 | /**
|
983 | * When the order was submitted
|
984 | */
|
985 | submitted_at: Date;
|
986 | /**
|
987 | * When the order was filled
|
988 | */
|
989 | filled_at: Date;
|
990 | /**
|
991 | * When the order expired
|
992 | */
|
993 | expired_at: Date;
|
994 | /**
|
995 | * When the order was canceled
|
996 | */
|
997 | canceled_at: Date;
|
998 | /**
|
999 | * When the order failed
|
1000 | */
|
1001 | failed_at: Date;
|
1002 | /**
|
1003 | * When the order was last replaced
|
1004 | */
|
1005 | replaced_at: Date;
|
1006 | /**
|
1007 | * The order ID that this order was replaced by
|
1008 | */
|
1009 | replaced_by: string;
|
1010 | /**
|
1011 | * The order ID that this order replaces
|
1012 | */
|
1013 | replaces: string;
|
1014 | /**
|
1015 | * Asset ID
|
1016 | */
|
1017 | asset_id: string;
|
1018 | /**
|
1019 | * Asset symbol
|
1020 | */
|
1021 | symbol: string;
|
1022 | /**
|
1023 | * Asset class
|
1024 | */
|
1025 | asset_class: string;
|
1026 | /**
|
1027 | * Ordered quantity
|
1028 | */
|
1029 | qty: number;
|
1030 | /**
|
1031 | * Filled quantity
|
1032 | */
|
1033 | filled_qty: number;
|
1034 | /**
|
1035 | * Order type (market, limit, stop, stop_limit, trailing_stop)
|
1036 | */
|
1037 | type: OrderType;
|
1038 | /**
|
1039 | * Buy or sell
|
1040 | */
|
1041 | side: OrderSide;
|
1042 | /**
|
1043 | * Order Time in Force
|
1044 | */
|
1045 | time_in_force: OrderTimeInForce;
|
1046 | /**
|
1047 | * Limit price
|
1048 | */
|
1049 | limit_price: number;
|
1050 | /**
|
1051 | * Stop price
|
1052 | */
|
1053 | stop_price: number;
|
1054 | /**
|
1055 | * Filled average price
|
1056 | */
|
1057 | filled_avg_price: number;
|
1058 | /**
|
1059 | * The status of the order
|
1060 | */
|
1061 | status: OrderStatus;
|
1062 | /**
|
1063 | * If true, eligible for execution outside regular trading hours.
|
1064 | */
|
1065 | extended_hours: boolean;
|
1066 | /**
|
1067 | * When querying non-simple order_class orders in a nested style, an array of Order
|
1068 | * entities associated with this order. Otherwise, null.
|
1069 | */
|
1070 | legs: Order[];
|
1071 | /**
|
1072 | * The dollar value away from the high water mark for trailing stop orders.
|
1073 | */
|
1074 | trail_price: number;
|
1075 | /**
|
1076 | * The percent value away from the high water mark for trailing stop orders.
|
1077 | */
|
1078 | trail_percent: number;
|
1079 | /**
|
1080 | * The highest (lowest) market price seen since the trailing stop order was submitted.
|
1081 | */
|
1082 | hwm: number;
|
1083 | /**
|
1084 | * Mostly used for non-simple orders such as bracket, one-triggers-other, or one-cancels-other.
|
1085 | */
|
1086 | order_class: OrderClass;
|
1087 | }
|
1088 | /**
|
1089 | * Timeseries data for equity and profit loss information of the account
|
1090 | */
|
1091 | export interface PortfolioHistory {
|
1092 | /**
|
1093 | * time of each data element, left-labeled (the beginning of time window)
|
1094 | */
|
1095 | timestamp: number[];
|
1096 | /**
|
1097 | * equity value of the account in dollar amount as of the end of each time window
|
1098 | */
|
1099 | equity: number[];
|
1100 | /**
|
1101 | * profit/loss in dollar from the base value
|
1102 | */
|
1103 | profit_loss: number[];
|
1104 | /**
|
1105 | * profit/loss in percentage from the base value
|
1106 | */
|
1107 | profit_loss_pct: number[];
|
1108 | /**
|
1109 | * basis in dollar of the profit loss calculation
|
1110 | */
|
1111 | base_value: number;
|
1112 | /**
|
1113 | * time window size of each data element
|
1114 | */
|
1115 | timeframe: '1Min' | '5Min' | '15Min' | '1H' | '1D';
|
1116 | }
|
1117 | /**
|
1118 | * A position with unparsed fields, exactly as Alpaca provides it.
|
1119 | * We encourage you to use the Position interface, which has many of these fields parsed.
|
1120 | */
|
1121 | export interface RawPosition {
|
1122 | asset_id: string;
|
1123 | symbol: string;
|
1124 | exchange: string;
|
1125 | asset_class: string;
|
1126 | avg_entry_price: string;
|
1127 | qty: string;
|
1128 | side: string;
|
1129 | market_value: string | null;
|
1130 | cost_basis: string;
|
1131 | unrealized_pl: string | null;
|
1132 | unrealized_plpc: string | null;
|
1133 | unrealized_intraday_pl: string | null;
|
1134 | unrealized_intraday_plpc: string | null;
|
1135 | current_price: string | null;
|
1136 | lastday_price: string | null;
|
1137 | change_today: string | null;
|
1138 | }
|
1139 | export declare type PositionSide = 'long' | 'short';
|
1140 | /**
|
1141 | * A position in Alpaca
|
1142 | */
|
1143 | export interface Position {
|
1144 | /**
|
1145 | * Get the raw data, exactly as it came from Alpaca
|
1146 | */
|
1147 | raw(): RawPosition;
|
1148 | /**
|
1149 | * Asset ID
|
1150 | */
|
1151 | asset_id: string;
|
1152 | /**
|
1153 | * Symbol name of the asset
|
1154 | */
|
1155 | symbol: string;
|
1156 | /**
|
1157 | * Exchange name of the asset
|
1158 | */
|
1159 | exchange: string;
|
1160 | /**
|
1161 | * Asset class name
|
1162 | */
|
1163 | asset_class: string;
|
1164 | /**
|
1165 | * Average entry price of the position
|
1166 | */
|
1167 | avg_entry_price: number;
|
1168 | /**
|
1169 | * The number of shares
|
1170 | */
|
1171 | qty: number;
|
1172 | /**
|
1173 | * long or short
|
1174 | */
|
1175 | side: PositionSide;
|
1176 | /**
|
1177 | * Total dollar amount of the position
|
1178 | */
|
1179 | market_value: number | null;
|
1180 | /**
|
1181 | * Total cost basis in dollar
|
1182 | */
|
1183 | cost_basis: number;
|
1184 | /**
|
1185 | * Unrealized profit/loss in dollars
|
1186 | */
|
1187 | unrealized_pl: number | null;
|
1188 | /**
|
1189 | * Unrealized profit/loss percent (by a factor of 1)
|
1190 | */
|
1191 | unrealized_plpc: number | null;
|
1192 | /**
|
1193 | * Unrealized profit/loss in dollars for the day
|
1194 | */
|
1195 | unrealized_intraday_pl: number | null;
|
1196 | /**
|
1197 | * Unrealized profit/loss percent (by a factor of 1)
|
1198 | */
|
1199 | unrealized_intraday_plpc: number | null;
|
1200 | /**
|
1201 | * Current asset price per share
|
1202 | */
|
1203 | current_price: number | null;
|
1204 | /**
|
1205 | * Last day's asset price per share based on the closing value of the last trading day
|
1206 | */
|
1207 | lastday_price: number | null;
|
1208 | /**
|
1209 | * Percent change from last day price (by a factor of 1)
|
1210 | */
|
1211 | change_today: number | null;
|
1212 | }
|
1213 | export declare type ActivityType =
|
1214 | /**
|
1215 | * Order fills (both partial and full fills)
|
1216 | */
|
1217 | 'FILL'
|
1218 | /**
|
1219 | * Cash transactions (both CSD and CSR)
|
1220 | */
|
1221 | | 'TRANS'
|
1222 | /**
|
1223 | * Miscellaneous or rarely used activity types (All types except those in TRANS, DIV,
|
1224 | * or FILL)
|
1225 | */
|
1226 | | 'MISC'
|
1227 | /**
|
1228 | * ACATS IN/OUT (Cash)
|
1229 | */
|
1230 | | 'ACATC'
|
1231 | /**
|
1232 | * ACATS IN/OUT (Securities)
|
1233 | */
|
1234 | | 'ACATS'
|
1235 | /**
|
1236 | * Cash disbursement(+)
|
1237 | */
|
1238 | | 'CSD'
|
1239 | /**
|
1240 | * Cash receipt(-)
|
1241 | */
|
1242 | | 'CSR'
|
1243 | /**
|
1244 | * Dividends
|
1245 | */
|
1246 | | 'DIV'
|
1247 | /**
|
1248 | * Dividend (capital gain long term)
|
1249 | */
|
1250 | | 'DIVCGL'
|
1251 | /**
|
1252 | * Dividend (capital gain short term)
|
1253 | */
|
1254 | | 'DIVCGS'
|
1255 | /**
|
1256 | * Dividend fee
|
1257 | */
|
1258 | | 'DIVFEE'
|
1259 | /**
|
1260 | * Dividend adjusted (Foreign Tax Withheld)
|
1261 | */
|
1262 | | 'DIVFT'
|
1263 | /**
|
1264 | * Dividend adjusted (NRA Withheld)
|
1265 | */
|
1266 | | 'DIVNRA'
|
1267 | /**
|
1268 | * Dividend return of capital
|
1269 | */
|
1270 | | 'DIVROC'
|
1271 | /**
|
1272 | * Dividend adjusted (Tefra Withheld)
|
1273 | */
|
1274 | | 'DIVTW'
|
1275 | /**
|
1276 | * Dividend (tax exempt)
|
1277 | */
|
1278 | | 'DIVTXEX'
|
1279 | /**
|
1280 | * Interest (credit/margin)
|
1281 | */
|
1282 | | 'INT'
|
1283 | /**
|
1284 | * Interest adjusted (NRA Withheld)
|
1285 | */
|
1286 | | 'INTNRA'
|
1287 | /**
|
1288 | * Interest adjusted (Tefra Withheld)
|
1289 | */
|
1290 | | 'INTTW'
|
1291 | /**
|
1292 | * Journal entry
|
1293 | */
|
1294 | | 'JNL'
|
1295 | /**
|
1296 | * Journal entry (cash)
|
1297 | */
|
1298 | | 'JNLC'
|
1299 | /**
|
1300 | * Journal entry (stock)
|
1301 | */
|
1302 | | 'JNLS'
|
1303 | /**
|
1304 | * Merger/Acquisition
|
1305 | */
|
1306 | | 'MA'
|
1307 | /**
|
1308 | * Name change
|
1309 | */
|
1310 | | 'NC'
|
1311 | /**
|
1312 | * Option assignment
|
1313 | */
|
1314 | | 'OPASN'
|
1315 | /**
|
1316 | * Option expiration
|
1317 | */
|
1318 | | 'OPEXP'
|
1319 | /**
|
1320 | * Option exercise
|
1321 | */
|
1322 | | 'OPXRC'
|
1323 | /**
|
1324 | * Pass Thru Charge
|
1325 | */
|
1326 | | 'PTC'
|
1327 | /**
|
1328 | * Pass Thru Rebate
|
1329 | */
|
1330 | | 'PTR'
|
1331 | /**
|
1332 | * Reorg CA
|
1333 | */
|
1334 | | 'REORG'
|
1335 | /**
|
1336 | * Symbol change
|
1337 | */
|
1338 | | 'SC'
|
1339 | /**
|
1340 | * Stock spinoff
|
1341 | */
|
1342 | | 'SSO'
|
1343 | /**
|
1344 | * Stock split
|
1345 | */
|
1346 | | 'SSP';
|
1347 | export interface RawTradeActivity {
|
1348 | activity_type: Extract<ActivityType, 'FILL'>;
|
1349 | cum_qty: string;
|
1350 | id: string;
|
1351 | leaves_qty: string;
|
1352 | price: string;
|
1353 | qty: string;
|
1354 | side: string;
|
1355 | symbol: string;
|
1356 | transaction_time: string;
|
1357 | order_id: string;
|
1358 | type: string;
|
1359 | }
|
1360 | export interface RawNonTradeActivity {
|
1361 | activity_type: Exclude<ActivityType, 'FILL'>;
|
1362 | id: string;
|
1363 | date: string;
|
1364 | net_amount: string;
|
1365 | symbol: string;
|
1366 | qty: string;
|
1367 | per_share_amount: string;
|
1368 | }
|
1369 | export declare type TradeActivityType = 'fill' | 'partial_fill';
|
1370 | export declare type TradeActivitySide = 'buy' | 'sell';
|
1371 | export interface TradeActivity {
|
1372 | /**
|
1373 | * Get the raw data, exactly as it came from Alpaca
|
1374 | */
|
1375 | raw(): RawTradeActivity;
|
1376 | /**
|
1377 | * FILL
|
1378 | */
|
1379 | activity_type: Extract<ActivityType, 'FILL'>;
|
1380 | /**
|
1381 | * The cumulative quantity of shares involved in the execution.
|
1382 | */
|
1383 | cum_qty: number;
|
1384 | /**
|
1385 | * An id for the activity. Always in "::" format. Can be sent as page_token in requests
|
1386 | * to facilitate the paging of results.
|
1387 | */
|
1388 | id: string;
|
1389 | /**
|
1390 | * For partially_filled orders, the quantity of shares that are left to be filled.
|
1391 | */
|
1392 | leaves_qty: number;
|
1393 | /**
|
1394 | * The per-share price that the trade was executed at.
|
1395 | */
|
1396 | price: number;
|
1397 | /**
|
1398 | * The number of shares involved in the trade execution.
|
1399 | */
|
1400 | qty: number;
|
1401 | /**
|
1402 | * buy or sell
|
1403 | */
|
1404 | side: TradeActivitySide;
|
1405 | /**
|
1406 | * The symbol of the security being traded.
|
1407 | */
|
1408 | symbol: string;
|
1409 | /**
|
1410 | * The time at which the execution occurred.
|
1411 | */
|
1412 | transaction_time: string;
|
1413 | /**
|
1414 | * The id for the order that filled.
|
1415 | */
|
1416 | order_id: string;
|
1417 | /**
|
1418 | * fill or partial_fill
|
1419 | */
|
1420 | type: TradeActivityType;
|
1421 | }
|
1422 | export interface NonTradeActivity {
|
1423 | /**
|
1424 | * Get the raw data, exactly as it came from Alpaca
|
1425 | */
|
1426 | raw(): RawNonTradeActivity;
|
1427 | /**
|
1428 | * Activity type
|
1429 | */
|
1430 | activity_type: Exclude<ActivityType, 'FILL'>;
|
1431 | /**
|
1432 | * An ID for the activity, always in "::" format. Can be sent as page_token in requests
|
1433 | * to facilitate the paging of results.
|
1434 | */
|
1435 | id: string;
|
1436 | /**
|
1437 | * The date on which the activity occurred or on which the transaction associated with
|
1438 | * the activity settled.
|
1439 | */
|
1440 | date: string;
|
1441 | /**
|
1442 | * The net amount of money (positive or negative) associated with the activity.
|
1443 | */
|
1444 | net_amount: number;
|
1445 | /**
|
1446 | * The symbol of the security involved with the activity. Not present for all activity
|
1447 | * types.
|
1448 | */
|
1449 | symbol: string;
|
1450 | /**
|
1451 | * For dividend activities, the number of shares that contributed to the payment. Not
|
1452 | * present for other activity types.
|
1453 | */
|
1454 | qty: number;
|
1455 | /**
|
1456 | * For dividend activities, the average amount paid per share. Not present for other
|
1457 | * activity types.
|
1458 | */
|
1459 | per_share_amount: number;
|
1460 | }
|
1461 | export declare type RawActivity = RawTradeActivity | RawNonTradeActivity;
|
1462 | export declare type Activity = TradeActivity | NonTradeActivity;
|
1463 | /**
|
1464 | * The following type mirrors OrderStatus almost exactly,
|
1465 | * but differs slightly in its wording for each event.
|
1466 | * See https://alpaca.markets/docs/api-references/broker-api/events/#trade-events
|
1467 | * for an updated list of these events and their detailed descriptions.
|
1468 | */
|
1469 | export declare type TradeUpdateEvent = 'new' | 'fill' | 'partial_fill' | 'canceled' | 'expired' | 'done_for_day' | 'replaced' | 'rejected' | 'pending_new' | 'stopped' | 'pending_cancel' | 'pending_replace' | 'calculated' | 'suspended' | 'order_replace_rejected' | 'order_cancel_rejected';
|
1470 | export interface RawTradeUpdate {
|
1471 | event: TradeUpdateEvent;
|
1472 | execution_id: string;
|
1473 | order: RawOrder;
|
1474 | event_id?: string;
|
1475 | at?: string;
|
1476 | timestamp?: string;
|
1477 | position_qty?: string;
|
1478 | price?: string;
|
1479 | qty?: string;
|
1480 | }
|
1481 | export interface TradeUpdate {
|
1482 | /**
|
1483 | * Get the raw data, exactly as it came from Alpaca
|
1484 | */
|
1485 | raw: () => RawTradeUpdate;
|
1486 | /**
|
1487 | * Trade update event type
|
1488 | */
|
1489 | event: TradeUpdateEvent;
|
1490 | /**
|
1491 | * Corresponding execution of an order.
|
1492 | * If an order gets filled over two executions (a partial_fill for example),
|
1493 | * you will receive two events with different IDs.
|
1494 | */
|
1495 | execution_id: string;
|
1496 | /**
|
1497 | * Monotonically increasing 64-bit integer.
|
1498 | * Haven't yet observed this property in practice, but it is
|
1499 | * on Alpaca's docs here: https://alpaca.markets/docs/api-references/broker-api/events/#trade-events,
|
1500 | * including for completeness.
|
1501 | */
|
1502 | event_id?: number;
|
1503 | /**
|
1504 | * The associated order that a trade_update event comes with
|
1505 | */
|
1506 | order: Order;
|
1507 | /**
|
1508 | * The timestamp of the trade update event.
|
1509 | * Alpaca docs at https://alpaca.markets/docs/api-references/broker-api/events/#trade-events
|
1510 | * are confusing. They say the 'at' property will contain the timestamp of
|
1511 | * the event, but currently as of 3/10/22 this is in the 'timestamp' property
|
1512 | * instead. Including both for completeness.
|
1513 | */
|
1514 | at?: Date;
|
1515 | /**
|
1516 | * The timestamp of the trade update event.
|
1517 | * Alpaca docs at https://alpaca.markets/docs/api-references/broker-api/events/#trade-events
|
1518 | * are confusing. They say the 'at' property will contain the timestamp of
|
1519 | * the event, but currently as of 3/10/22 this is in the 'timestamp' property
|
1520 | * instead. Including both for completeness.
|
1521 | */
|
1522 | timestamp?: Date;
|
1523 | /**
|
1524 | * The size of your total position, after a fill or partial fill event, in shares.
|
1525 | */
|
1526 | position_qty?: number;
|
1527 | /**
|
1528 | * The average price per share at which the order was filled or partially filled
|
1529 | */
|
1530 | price?: number;
|
1531 | /**
|
1532 | * The amount of shares that were filled in a trade update of type fill or partial_fill.
|
1533 | * Equivalent to the order.filled_qty property, which is preferred.
|
1534 | */
|
1535 | qty?: number;
|
1536 | }
|
1537 | export interface Watchlist {
|
1538 | /**
|
1539 | * account ID
|
1540 | */
|
1541 | account_id: string;
|
1542 | /**
|
1543 | * the content of this watchlist, in the order as registered by the client
|
1544 | */
|
1545 | assets: Asset[];
|
1546 | /**
|
1547 | * When the watchlist was created
|
1548 | */
|
1549 | created_at: string;
|
1550 | /**
|
1551 | * watchlist id
|
1552 | */
|
1553 | id: string;
|
1554 | /**
|
1555 | * user-defined watchlist name (up to 64 characters)
|
1556 | */
|
1557 | name: string;
|
1558 | /**
|
1559 | * When the watchlist was last updated
|
1560 | */
|
1561 | updated_at: string;
|
1562 | }
|
1563 | export interface News {
|
1564 | id: number;
|
1565 | headline: string;
|
1566 | author: string;
|
1567 | created_at: Date;
|
1568 | updated_at: Date;
|
1569 | summary: string;
|
1570 | url: string;
|
1571 | images: any[];
|
1572 | symbols: string[];
|
1573 | source: string;
|
1574 | }
|
1575 | export interface NewsPage {
|
1576 | news: News[];
|
1577 | next_page_token: string;
|
1578 | }
|
1579 | export declare type Channel = 'trades' | 'quotes' | 'bars' | 'trade_updates';
|
1580 | export interface Message {
|
1581 | T: 'success' | 'error' | 'subscription';
|
1582 | code?: number;
|
1583 | msg: string;
|
1584 | [key: string]: any;
|
1585 | }
|