This repository has been archived by the owner on Mar 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
openapi.yaml
3549 lines (3549 loc) · 96.4 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.0
info:
title: Alpaca Broker API
description: 'Open brokerage accounts, enable commission-free trading, and manage the ongoing user experience with Alpaca Broker API'
version: 1.0.0
servers:
- url: 'https://broker-api.sandbox.alpaca.markets/v1'
description: Sandbox endpoint
- url: 'https://broker-api.alpaca.markets/v1'
description: Production endpoint
components:
securitySchemes:
BasicAuth:
type: http
scheme: basic
parameters:
ActivityType:
in: path
name: activity_type
required: true
schema:
type: string
enum:
- FILL
- ACATC
- ACATS
- CSD
- CSR
- CSW
- DIV
- DIVCGL
- DIVCGS
- DIVNRA
- DIVROC
- DIVTXEX
- INT
- JNLC
- JNLS
- MA
- NC
- PTC
- REORG
- SSO
- SSP
Status:
name: status
in: query
description: Status of the orders to list.
schema:
type: string
enum:
- open
- closed
- all
Limit:
name: limit
in: query
description: The maximum number of orders in response.
schema:
type: integer
example: 500
After:
name: after
in: query
description: The response will include only ones submitted after this timestamp (exclusive.)
schema:
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
Until:
name: until
in: query
description: The response will include only ones submitted until this timestamp (exclusive.)
schema:
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
Direction:
name: direction
in: query
description: The chronological order of response based on the submission time. asc or desc. Defaults to desc.
schema:
type: string
enum:
- asc
- desc
example: desc
Nested:
name: nested
in: query
description: 'If true, the result will roll up multi-leg orders under the legs field of primary order.'
schema:
type: boolean
example: false
Symbols:
name: symbols
in: query
description: A comma-separated list of symbols to filter by.
schema:
type: string
example: 'AAPL,TSLA,MSFT'
AccountID:
name: account_id
in: path
required: true
description: Account identifier.
schema:
type: string
format: uuid
OrderID:
name: order_id
in: path
required: true
description: Order identifier.
schema:
type: string
DocumentID:
name: document_id
in: path
required: true
description: Document identifier.
schema:
type: string
format: uuid
schemas:
Account:
type: object
properties:
id:
type: string
format: uuid
account_number:
type: string
status:
$ref: '#/components/schemas/AccountStatus'
currency:
type: string
description: Always "USD"
created_at:
type: string
format: date-time
last_equity:
type: string
format: decimal
kyc_results:
$ref: '#/components/schemas/KYCResult'
example:
id: 0d18ae51-3c94-4511-b209-101e1666416b
account_number: '9034005019'
status: APPROVED
currency: USD
created_at: '2019-09-30T23:55:31.185998Z'
last_equity: '1500.65'
AccountStatus:
type: string
example: ACTIVE
enum:
- SUBMITTED
- ACTION_REQUIRED
- APPROVAL_PENDING
- APPROVED
- REJECTED
- ACTIVE
- DISABLED
- ACCOUNT_CLOSED
description: |
- **SUBMITTED**
The application has been submitted and in process.
- **ACTION_REQUIRED**
The application requires manual action.
- **APPROVAL_PENDING**
Initial value. The application approval process is in process.
- **APPROVED**
The account application has been approved, and waiting to be ACTIVE
- **REJECTED**
The account application is rejected for some reason
- **ACTIVE**
The account is fully active. Trading and funding are processed under this status.
- **DISABLED**
The account is disabled after ACTIVE status.
- **ACCOUNT_CLOSED**
The account is closed.
AccountExtended:
type: object
properties:
id:
type: string
format: uuid
account_number:
type: string
status:
$ref: '#/components/schemas/AccountStatus'
currency:
type: string
description: Always "USD"
created_at:
type: string
format: date-time
last_equity:
type: string
format: decimal
kyc_results:
$ref: '#/components/schemas/KYCResult'
contact:
$ref: '#/components/schemas/Contact'
identity:
$ref: '#/components/schemas/Identity'
disclosures:
$ref: '#/components/schemas/Disclosures'
agreements:
$ref: '#/components/schemas/Agreements'
documents:
type: array
items:
$ref: '#/components/schemas/ApplicationDocument'
trusted_contact:
$ref: '#/components/schemas/TrustedContact'
AccountUpdateRequest:
type: object
properties:
contact:
$ref: '#/components/schemas/Contact'
identity:
$ref: '#/components/schemas/Identity'
disclosures:
$ref: '#/components/schemas/Disclosures'
trustedContact:
$ref: '#/components/schemas/TrustedContact'
AccountDocument:
type: object
description: |
If an account has documents on the application submission,
it has the ApplicationDocument model in exchange with
DocumentUploadRequest.
properties:
id:
type: string
format: uuid
document_type:
$ref: '#/components/schemas/DocumentType'
document_sub_type:
type: string
mime_type:
type: string
created_at:
type: string
format: date-time
required:
- id
- document_type
- created_at
example:
id: 0d18ae51-3c94-4511-b209-101e1666416b
document_type: identity_verification
document_sub_type: passport
mime_type: image/jpeg
created_at: '2019-09-30T23:55:31.185998Z'
AccountCreationRequest:
type: object
properties:
contact:
$ref: '#/components/schemas/Contact'
identity:
$ref: '#/components/schemas/Identity'
disclosures:
$ref: '#/components/schemas/Disclosures'
agreements:
$ref: '#/components/schemas/Agreements'
documents:
type: array
items:
$ref: '#/components/schemas/DocumentUploadRequest'
trusted_contact:
$ref: '#/components/schemas/TrustedContact'
title: AccountCreationRequest
ApplicationDocument:
type: object
description: |
If an account has documents on the application submission,
it has the ApplicationDocument model in exchange with
DocumentUpload.
properties:
id:
type: string
format: uuid
document_type:
$ref: '#/components/schemas/DocumentType'
document_sub_type:
type: string
mime_type:
type: string
created_at:
type: string
format: date-time
required:
- id
- document_type
- created_at
example:
id: 0d18ae51-3c94-4511-b209-101e1666416b
document_type: identity_verification
document_sub_type: passport
mime_type: image/jpeg
created_at: '2019-09-30T23:55:31.185998Z'
DocumentUpload:
type: object
description: |
If an account has documents after the submission, it has
the Document model in exchange with DocumentUpload.
properties:
document_type:
$ref: '#/components/schemas/DocumentType'
document_sub_type:
type: string
example: passport
content:
type: string
format: base64
example: QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=
mime_type:
type: string
example: image/jpeg
required:
- document_type
- content
- mime_type
example:
document_type: identity_verification
document_sub_type: passport
content: QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=
mime_type: image/jpeg
Activity:
title: Activity
type: object
description: Base for activity types
properties:
id:
type: string
format: uuid
example: 88b5f678-fef5-447b-af15-f21e367e6d8c
account_id:
type: string
format: uuid
example: c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4
activity_type:
$ref: '#/components/schemas/ActivityType'
ActivityType:
title: ActivityType
type: string
enum:
- FILL
- ACATC
- ACATS
- CSD
- CSR
- CSW
- DIV
- DIVCGL
- DIVCGS
- DIVNRA
- DIVROC
- DIVTXEX
- INT
- JNLC
- JNLS
- MA
- NC
- PTC
- REORG
- SSO
- SSP
TradeActivity:
title: TradeActivity
allOf:
- $ref: '#/components/schemas/Activity'
- type: object
properties:
transaction_time:
type: string
format: timestamp
example: '2021-05-10T14:01:04.650275Z'
type:
type: string
enum:
- fill
- partial_fill
example: fill
price:
type: string
example: '3.1415'
qty:
type: string
example: '0.38921'
side:
type: string
enum:
- buy
- sell
example: sell
symbol:
type: string
example: AAPL
leaves_qty:
type: string
example: '0.5123'
order_id:
type: string
format: uuid
example: fe060a1b-5b45-4eba-ba46-c3a3345d8255
cum_qty:
type: string
example: '0.9723'
order_status:
type: string
enum:
- new
- partially_filled
- filled
- done_for_day
- canceled
- expired
- replaced
- pending_cancel
- pending_replace
- accepted
- pending_new
- accepted_for_bidding
- stopped
- rejected
- suspended
- calculated
example: filled
NonTradeActivity:
title: NonTradeActivity
allOf:
- $ref: '#/components/schemas/Activity'
- type: object
properties:
date:
type: string
format: date
example: '2021-05-21'
net_amount:
type: string
example: '1234'
description:
type: string
example: Example description
status:
type: string
enum:
- executed
- correct
- canceled
example: executed
symbol:
type: string
example: AAPL
qty:
type: string
example: '0.38921'
per_share_amount:
type: string
example: '0.38921'
ActivityItem:
title: ActivityItem
anyOf:
- $ref: '#/components/schemas/TradeActivity'
- $ref: '#/components/schemas/NonTradeActivity'
DocumentType:
type: string
enum:
- identity_verification
- address_verification
- date_of_birth_verification
- tax_id_verification
- account_approval_letter
- cip_result
description: |
- identity_verification:
identity verification document
- address_verification:
address verification document
- date_of_birth_verification:
date of birth verification document
- tax_id_verification:
tax ID verification document
- account_approval_letter:
407 approval letter
- cip_result:
initial CIP result
example: identity_verification
DocumentUploadRequest:
type: object
description: |
If an account has documents after the submission, it has
the Document model in exchange with DocumentUploadRequest.
properties:
document_type:
$ref: '#/components/schemas/DocumentType'
document_sub_type:
type: string
example: passport
content:
type: string
format: base64
example: QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=
mime_type:
type: string
example: image/jpeg
required:
- document_type
- content
- mime_type
example:
document_type: identity_verification
document_sub_type: passport
content: QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=
mime_type: image/jpeg
title: DocumentUploadRequest
KYCResult:
type: object
description: Hold information about the result of KYC.
properties:
reject:
type: object
accept:
type: object
indeterminate:
type: object
addidional_information:
type: string
StreetAddress:
type: string
example: 20 N San Mateo Dr
Contact:
type: object
description: |
Contact is the model for the account owner contact information.
properties:
email_address:
type: string
format: email
example: john.doe@example.com
phone_number:
type: string
description: 'with country code, no hyphen or space'
example: '+15556667788'
street_address:
type: array
items:
$ref: '#/components/schemas/StreetAddress'
city:
type: string
example: San Mateo
state:
type: string
example: CA
postal_code:
type: string
example: '94401'
Identity:
type: object
description: |
Identity is the model to provide account owner’s identity information.
properties:
given_name:
type: string
example: John
family_name:
type: string
example: Doe
date_of_birth:
type: string
format: date
example: '1990-01-01'
tax_id:
type: string
example: 666-55-4321
tax_id_type:
type: string
enum:
- USA_SSN
- AUS_TFN
- AUS_ABN
- DEU_TAX_ID
- FRA_SPI
- GBR_UTR
- GBR_NINO
- HUN_TIN
- IND_PAN
- ISR_TAX_ID
- ITA_TAX_ID
- JPN_TAX_ID
- NLD_TIN
- SGP_NRIC
- SGP_FIN
- SGP_ASGD
- SGP_ITR
- SWE_TAX_ID
- NOT_SPECIFIED
country_of_citizenship:
type: string
description: |
[ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html).
example: USA
country_of_birth:
type: string
description: |
[ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html).
example: USA
country_of_tax_residence:
type: string
description: |
[ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html).
example: USA
funding_source:
type: array
items:
type: string
enum:
- employment_income
- investments
- inheritance
- business_income
- savings
- family
annual_income_min:
type: number
annual_income_max:
type: number
liquid_net_worth_min:
type: number
liquid_net_worth_max:
type: number
total_net_worth_min:
type: number
total_net_worth_max:
type: number
extra:
type: object
description: |
any extra information used for KYC purposes
required:
- given_name
- family_name
- date_of_birth
- country_of_tax_residence
- funding_source
example:
given_name: John
family_name: Doe
date_of_birth: '1990-01-01'
tax_id: 666-55-4321
tax_id_type: USA_SSN
country_of_citizenship: AUS
country_of_birth: AUS
country_of_tax_residence: USA
funding_source:
- employment_income
Disclosures:
type: object
description: |
Disclosures fields denote if the account owner falls under
each category defined by FINRA rule. The client has to ask
questions for the end user and the values should reflect
their answers.
If one of the answers is true (yes), the account goes into
ACTION_REQUIRED status.
properties:
employment_status:
type: string
enum:
- unemployed
- employed
- student
- retired
employer_name:
type: string
employer_address:
type: string
employment_position:
type: string
is_control_person:
type: boolean
is_affiliated_exchange_or_finra:
type: boolean
is_politically_exposed:
type: boolean
immediate_family_exposed:
type: boolean
required:
- is_control_person
- is_affiliated_exchange_or_finra
- is_politically_exposed
- immediate_family_exposed
example:
is_control_person: false
is_affiliated_exchange_or_finra: false
is_politically_exposed: false
immediate_family_exposed: false
Agreement:
type: object
properties:
agreement:
type: string
enum:
- margin_agreement
- account_agreement
- customer_agreement
description: |
- margin_agreement: Alpaca Margin Agreement
- account_agreement: Alpaca Account Agreement
- customer_agreement: Alpaca Customer Agreement
signed_at:
type: string
example: '2019-09-11T18:09:33Z'
ip_address:
type: string
format: ipv4
example: 185.13.21.99
required:
- agreement
- signed_at
- ip_address
Agreements:
type: array
description: |
The client has to present Alpaca Account Agreement and
Margin Agreement to the end user, and have them read
full sentences.
items:
$ref: '#/components/schemas/Agreement'
TrustedContact:
type: object
description: |
This model input is optional. However, the client should
make reasonable effort to obtain the trusted contact information.
See more details in [FINRA Notice 17-11](https://www.finra.org/sites/default/files/Regulatory-Notice-17-11.pdf)
properties:
given_name:
type: string
example: Jane
family_name:
type: string
example: Doe
email_address:
type: string
format: email
description: |
at least one of `email_address`, `phone_number` or
`street_address` is required
example: jane.doe@example.com
phone_number:
type: string
description: |
at least one of `email_address`, `phone_number` or
`street_address` is required
street_address:
type: array
items:
type: string
description: |
at least one of `email_address`, `phone_number` or
`street_address` is required
city:
type: string
description: |
required if `street_address` is set
state:
type: string
description: |
required if `street_address` is set
postal_code:
type: string
description: |
required if `street_address` is set
country:
type: string
description: |
[ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html).
required if `street_address` is set
required:
- given_name
- family_name
example:
given_name: Jane
family_name: Doe
email_address: jane.doe@example.com
CreateOrderRequest:
type: object
properties:
symbol:
type: string
example: AAPL
qty:
type: string
format: decimal
example: '4.124'
notional:
type: string
format: decimal
example: '3'
side:
type: string
enum:
- buy
- sell
example: buy
type:
type: string
enum:
- market
- limit
- stop
- stop_limit
- trailing_stop
example: limit
time_in_force:
type: string
enum:
- day
- gtc
- opg
- cls
- ioc
- fok
example: gtc
limit_price:
type: string
format: decimal
example: '3.14'
stop_price:
type: string
format: decimal
example: '3.14'
trail_price:
type: string
format: decimal
example: '3.14'
trail_percent:
type: string
format: decimal
example: '5.0'
extended_hours:
type: boolean
example: false
client_order_id:
type: string
example: eb9e2aaa-f71a-4f51-b5b4-52a6c565dad4
order_class:
type: string
enum:
- simple
- bracket
- oco
- oto
example: simple
take_profit:
type: object
properties:
limit_price:
type: string
format: decimal
example: '3.14'
stop_loss:
type: object
properties:
stop_price:
type: string
format: decimal
example: '3.14'
limit_price:
type: string
format: decimal
example: '3.14'
commission:
type: string
format: decimal
example: '1.0'
required:
- symbol
- side
- type
- time_in_force
Order:
type: object
properties:
id:
type: string
format: uuid
example: 61e69015-8549-4bfd-b9c3-01e75843f47d
client_order_id:
type: string
example: 61e69015-8549-4bfd-b9c3-01e75843f47d
created_at:
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
updated_at:
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
submitted_at:
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
filled_at:
nullable: true
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
expired_at:
nullable: true
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
canceled_at:
nullable: true
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
failed_at:
nullable: true
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
replaced_at:
nullable: true
type: string
format: date-time
example: '2021-03-16T18:38:01.942282Z'
replaced_by:
nullable: true
type: string
format: uuid
example: 61e69015-8549-4bfd-b9c3-01e75843f47d
replaces:
nullable: true
type: string
format: uuid
example: 61e69015-8549-4bfd-b9c3-01e75843f47d
asset_id:
type: string
format: uuid
example: 61e69015-8549-4bfd-b9c3-01e75843f47d
symbol:
type: string
example: AALP
asset_class:
type: string
enum:
- us_equity
- crypto
notional:
nullable: true
type: string
format: decimal
example: '4.2'
qty:
nullable: true
type: string
format: decimal
example: '4.2'
filled_qty:
type: string
format: decimal
example: '4.2'
filled_avg_price:
nullable: true
type: string
format: decimal
example: '4.2'
order_class:
type: string
enum:
- simple
- bracket
- oco
- oto
example: bracket
order_type:
type: string
enum:
- market
- limit
- stop
- stop_limit
- trailing_stop
example: stop
type:
type: string
enum:
- market
- limit
- stop
- stop_limit
- trailing_stop
example: stop
side: