diff --git a/.codestyle/IntelliJ IDEA.xml b/.codestyle/IntelliJ IDEA.xml new file mode 100644 index 00000000..8e25288f --- /dev/null +++ b/.codestyle/IntelliJ IDEA.xml @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index e835e84c..00000000 --- a/.editorconfig +++ /dev/null @@ -1,721 +0,0 @@ -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -max_line_length = 120 -tab_width = 4 -ij_continuation_indent_size = 8 -ij_formatter_off_tag = @formatter:off -ij_formatter_on_tag = @formatter:on -ij_formatter_tags_enabled = true -ij_smart_tabs = false -ij_wrap_on_typing = false - -[*.java] -ij_java_align_consecutive_assignments = false -ij_java_align_consecutive_variable_declarations = false -ij_java_align_group_field_declarations = false -ij_java_align_multiline_annotation_parameters = false -ij_java_align_multiline_array_initializer_expression = false -ij_java_align_multiline_assignment = false -ij_java_align_multiline_binary_operation = false -ij_java_align_multiline_chained_methods = false -ij_java_align_multiline_extends_list = false -ij_java_align_multiline_for = false -ij_java_align_multiline_method_parentheses = false -ij_java_align_multiline_parameters = false -ij_java_align_multiline_parameters_in_calls = false -ij_java_align_multiline_parenthesized_expression = false -ij_java_align_multiline_resources = false -ij_java_align_multiline_ternary_operation = false -ij_java_align_multiline_throws_list = false -ij_java_align_subsequent_simple_methods = false -ij_java_align_throws_keyword = false -ij_java_annotation_parameter_wrap = normal -ij_java_array_initializer_new_line_after_left_brace = false -ij_java_array_initializer_right_brace_on_new_line = false -ij_java_array_initializer_wrap = normal -ij_java_assert_statement_colon_on_next_line = false -ij_java_assert_statement_wrap = normal -ij_java_assignment_wrap = normal -ij_java_binary_operation_sign_on_next_line = false -ij_java_binary_operation_wrap = normal -ij_java_blank_lines_after_anonymous_class_header = 0 -ij_java_blank_lines_after_class_header = 1 -ij_java_blank_lines_after_imports = 1 -ij_java_blank_lines_after_package = 1 -ij_java_blank_lines_around_class = 1 -ij_java_blank_lines_around_field = 0 -ij_java_blank_lines_around_field_in_interface = 0 -ij_java_blank_lines_around_initializer = 1 -ij_java_blank_lines_around_method = 1 -ij_java_blank_lines_around_method_in_interface = 1 -ij_java_blank_lines_before_class_end = 0 -ij_java_blank_lines_before_imports = 1 -ij_java_blank_lines_before_method_body = 0 -ij_java_blank_lines_before_package = 0 -ij_java_block_brace_style = end_of_line -ij_java_block_comment_at_first_column = true -ij_java_call_parameters_new_line_after_left_paren = false -ij_java_call_parameters_right_paren_on_new_line = false -ij_java_call_parameters_wrap = normal -ij_java_case_statement_on_separate_line = true -ij_java_catch_on_new_line = false -ij_java_class_annotation_wrap = split_into_lines -ij_java_class_brace_style = end_of_line -ij_java_class_count_to_use_import_on_demand = 50 -ij_java_class_names_in_javadoc = 1 -ij_java_do_not_indent_top_level_class_members = false -ij_java_do_not_wrap_after_single_annotation = false -ij_java_do_while_brace_force = always -ij_java_doc_add_blank_line_after_description = true -ij_java_doc_add_blank_line_after_param_comments = true -ij_java_doc_add_blank_line_after_return = true -ij_java_doc_add_p_tag_on_empty_lines = true -ij_java_doc_align_exception_comments = true -ij_java_doc_align_param_comments = true -ij_java_doc_do_not_wrap_if_one_line = true -ij_java_doc_enable_formatting = true -ij_java_doc_enable_leading_asterisks = true -ij_java_doc_indent_on_continuation = false -ij_java_doc_keep_empty_lines = true -ij_java_doc_keep_empty_parameter_tag = true -ij_java_doc_keep_empty_return_tag = true -ij_java_doc_keep_empty_throws_tag = true -ij_java_doc_keep_invalid_tags = true -ij_java_doc_param_description_on_new_line = false -ij_java_doc_preserve_line_breaks = false -ij_java_doc_use_throws_not_exception_tag = true -ij_java_else_on_new_line = false -ij_java_enum_constants_wrap = normal -ij_java_extends_keyword_wrap = normal -ij_java_extends_list_wrap = normal -ij_java_field_annotation_wrap = split_into_lines -ij_java_finally_on_new_line = false -ij_java_for_brace_force = always -ij_java_for_statement_new_line_after_left_paren = false -ij_java_for_statement_right_paren_on_new_line = false -ij_java_for_statement_wrap = normal -ij_java_generate_final_locals = false -ij_java_generate_final_parameters = false -ij_java_if_brace_force = always -ij_java_imports_layout = *,|,javax.**,java.**,|,$* -ij_java_indent_case_from_switch = true -ij_java_insert_inner_class_imports = false -ij_java_insert_override_annotation = true -ij_java_keep_blank_lines_before_right_brace = 1 -ij_java_keep_blank_lines_between_package_declaration_and_header = 1 -ij_java_keep_blank_lines_in_code = 1 -ij_java_keep_blank_lines_in_declarations = 1 -ij_java_keep_control_statement_in_one_line = true -ij_java_keep_first_column_comment = true -ij_java_keep_indents_on_empty_lines = false -ij_java_keep_line_breaks = true -ij_java_keep_multiple_expressions_in_one_line = true -ij_java_keep_simple_blocks_in_one_line = true -ij_java_keep_simple_classes_in_one_line = true -ij_java_keep_simple_lambdas_in_one_line = true -ij_java_keep_simple_methods_in_one_line = true -ij_java_lambda_brace_style = end_of_line -ij_java_layout_static_imports_separately = true -ij_java_line_comment_add_space = true -ij_java_line_comment_at_first_column = false -ij_java_method_annotation_wrap = split_into_lines -ij_java_method_brace_style = end_of_line -ij_java_method_call_chain_wrap = normal -ij_java_method_parameters_new_line_after_left_paren = false -ij_java_method_parameters_right_paren_on_new_line = false -ij_java_method_parameters_wrap = normal -ij_java_modifier_list_wrap = false -ij_java_names_count_to_use_import_on_demand = 3 -ij_java_parameter_annotation_wrap = normal -ij_java_parentheses_expression_new_line_after_left_paren = false -ij_java_parentheses_expression_right_paren_on_new_line = false -ij_java_place_assignment_sign_on_next_line = false -ij_java_prefer_longer_names = true -ij_java_prefer_parameters_wrap = false -ij_java_repeat_synchronized = true -ij_java_replace_instanceof_and_cast = false -ij_java_replace_null_check = true -ij_java_replace_sum_lambda_with_method_ref = true -ij_java_resource_list_new_line_after_left_paren = false -ij_java_resource_list_right_paren_on_new_line = false -ij_java_resource_list_wrap = normal -ij_java_space_after_closing_angle_bracket_in_type_argument = false -ij_java_space_after_colon = true -ij_java_space_after_comma = true -ij_java_space_after_comma_in_type_arguments = true -ij_java_space_after_for_semicolon = true -ij_java_space_after_quest = true -ij_java_space_after_type_cast = true -ij_java_space_before_annotation_array_initializer_left_brace = false -ij_java_space_before_annotation_parameter_list = false -ij_java_space_before_array_initializer_left_brace = false -ij_java_space_before_catch_keyword = true -ij_java_space_before_catch_left_brace = true -ij_java_space_before_catch_parentheses = true -ij_java_space_before_class_left_brace = true -ij_java_space_before_colon = true -ij_java_space_before_colon_in_foreach = true -ij_java_space_before_comma = false -ij_java_space_before_do_left_brace = true -ij_java_space_before_else_keyword = true -ij_java_space_before_else_left_brace = true -ij_java_space_before_finally_keyword = true -ij_java_space_before_finally_left_brace = true -ij_java_space_before_for_left_brace = true -ij_java_space_before_for_parentheses = true -ij_java_space_before_for_semicolon = false -ij_java_space_before_if_left_brace = true -ij_java_space_before_if_parentheses = true -ij_java_space_before_method_call_parentheses = false -ij_java_space_before_method_left_brace = true -ij_java_space_before_method_parentheses = false -ij_java_space_before_opening_angle_bracket_in_type_parameter = false -ij_java_space_before_quest = true -ij_java_space_before_switch_left_brace = true -ij_java_space_before_switch_parentheses = true -ij_java_space_before_synchronized_left_brace = true -ij_java_space_before_synchronized_parentheses = true -ij_java_space_before_try_left_brace = true -ij_java_space_before_try_parentheses = true -ij_java_space_before_type_parameter_list = false -ij_java_space_before_while_keyword = true -ij_java_space_before_while_left_brace = true -ij_java_space_before_while_parentheses = true -ij_java_space_inside_one_line_enum_braces = false -ij_java_space_within_empty_array_initializer_braces = false -ij_java_space_within_empty_method_call_parentheses = false -ij_java_space_within_empty_method_parentheses = false -ij_java_spaces_around_additive_operators = true -ij_java_spaces_around_assignment_operators = true -ij_java_spaces_around_bitwise_operators = true -ij_java_spaces_around_equality_operators = true -ij_java_spaces_around_lambda_arrow = true -ij_java_spaces_around_logical_operators = true -ij_java_spaces_around_method_ref_dbl_colon = false -ij_java_spaces_around_multiplicative_operators = true -ij_java_spaces_around_relational_operators = true -ij_java_spaces_around_shift_operators = true -ij_java_spaces_around_type_bounds_in_type_parameters = true -ij_java_spaces_around_unary_operator = false -ij_java_spaces_within_angle_brackets = false -ij_java_spaces_within_annotation_parentheses = false -ij_java_spaces_within_array_initializer_braces = false -ij_java_spaces_within_braces = false -ij_java_spaces_within_brackets = false -ij_java_spaces_within_cast_parentheses = false -ij_java_spaces_within_catch_parentheses = false -ij_java_spaces_within_for_parentheses = false -ij_java_spaces_within_if_parentheses = false -ij_java_spaces_within_method_call_parentheses = false -ij_java_spaces_within_method_parentheses = false -ij_java_spaces_within_parentheses = false -ij_java_spaces_within_switch_parentheses = false -ij_java_spaces_within_synchronized_parentheses = false -ij_java_spaces_within_try_parentheses = false -ij_java_spaces_within_while_parentheses = false -ij_java_special_else_if_treatment = true -ij_java_subclass_name_suffix = Impl -ij_java_ternary_operation_signs_on_next_line = false -ij_java_ternary_operation_wrap = normal -ij_java_test_name_suffix = Test -ij_java_throws_keyword_wrap = normal -ij_java_throws_list_wrap = normal -ij_java_use_external_annotations = false -ij_java_use_fq_class_names = false -ij_java_use_single_class_imports = true -ij_java_variable_annotation_wrap = normal -ij_java_visibility = public -ij_java_while_brace_force = always -ij_java_while_on_new_line = false -ij_java_wrap_comments = true -ij_java_wrap_first_method_in_call_chain = false -ij_java_wrap_long_lines = true - -[*.json] -indent_size = 2 -ij_json_keep_blank_lines_in_code = 0 -ij_json_keep_indents_on_empty_lines = false -ij_json_keep_line_breaks = true -ij_json_space_after_colon = true -ij_json_space_after_comma = true -ij_json_space_before_colon = true -ij_json_space_before_comma = false -ij_json_spaces_within_braces = false -ij_json_spaces_within_brackets = false -ij_json_wrap_long_lines = false - -[*.properties] -ij_properties_align_group_field_declarations = false - -[*.scala] -indent_size = 2 -tab_width = 2 -ij_continuation_indent_size = 2 -ij_scala_align_composite_pattern = true -ij_scala_align_extends_with = 0 -ij_scala_align_group_field_declarations = false -ij_scala_align_if_else = false -ij_scala_align_in_columns_case_branch = false -ij_scala_align_multiline_binary_operation = false -ij_scala_align_multiline_chained_methods = false -ij_scala_align_multiline_for = true -ij_scala_align_multiline_parameters = true -ij_scala_align_multiline_parameters_in_calls = false -ij_scala_align_multiline_parenthesized_expression = false -ij_scala_align_tuple_elements = false -ij_scala_align_types_in_multiline_declarations = false -ij_scala_all_other_imports = all other imports -ij_scala_alternate_continuation_indent_for_params = 4 -ij_scala_binary_operation_wrap = off -ij_scala_blank_line = _______ blank line _______ -ij_scala_blank_lines_after_anonymous_class_header = 0 -ij_scala_blank_lines_after_class_header = 0 -ij_scala_blank_lines_after_imports = 1 -ij_scala_blank_lines_after_package = 1 -ij_scala_blank_lines_around_class = 1 -ij_scala_blank_lines_around_field = 0 -ij_scala_blank_lines_around_field_in_inner_scopes = 0 -ij_scala_blank_lines_around_field_in_interface = 0 -ij_scala_blank_lines_around_method = 1 -ij_scala_blank_lines_around_method_in_inner_scopes = 1 -ij_scala_blank_lines_around_method_in_interface = 1 -ij_scala_blank_lines_before_imports = 1 -ij_scala_blank_lines_before_method_body = 0 -ij_scala_blank_lines_before_package = 0 -ij_scala_block_brace_style = end_of_line -ij_scala_block_comment_at_first_column = true -ij_scala_call_parameters_new_line_after_lparen = 0 -ij_scala_call_parameters_right_paren_on_new_line = false -ij_scala_call_parameters_wrap = off -ij_scala_case_clause_brace_force = never -ij_scala_catch_on_new_line = false -ij_scala_class_annotation_wrap = split_into_lines -ij_scala_class_brace_style = end_of_line -ij_scala_closure_brace_force = never -ij_scala_do_not_align_block_expr_params = true -ij_scala_do_not_indent_case_clause_body = false -ij_scala_do_not_indent_tuples_close_brace = true -ij_scala_do_while_brace_force = never -ij_scala_else_on_new_line = false -ij_scala_enable_scaladoc_formatting = true -ij_scala_enforce_functional_syntax_for_unit = true -ij_scala_exclude_prefix = exclude: -ij_scala_extends_keyword_wrap = off -ij_scala_extends_list_wrap = off -ij_scala_field_annotation_wrap = split_into_lines -ij_scala_finally_brace_force = never -ij_scala_finally_on_new_line = false -ij_scala_for_brace_force = never -ij_scala_for_statement_wrap = off -ij_scala_formatter = 0 -ij_scala_if_brace_force = never -ij_scala_indent_braced_function_args = true -ij_scala_indent_case_from_switch = true -ij_scala_indent_first_parameter = true -ij_scala_indent_first_parameter_clause = false -ij_scala_indent_type_arguments = true -ij_scala_indent_type_parameters = true -ij_scala_insert_whitespaces_in_simple_one_line_method = true -ij_scala_keep_blank_lines_before_right_brace = 2 -ij_scala_keep_blank_lines_in_code = 2 -ij_scala_keep_blank_lines_in_declarations = 2 -ij_scala_keep_comments_on_same_line = true -ij_scala_keep_first_column_comment = false -ij_scala_keep_indents_on_empty_lines = false -ij_scala_keep_line_breaks = true -ij_scala_keep_one_line_lambdas_in_arg_list = false -ij_scala_keep_simple_blocks_in_one_line = false -ij_scala_keep_simple_methods_in_one_line = false -ij_scala_keep_xml_formatting = false -ij_scala_line_comment_at_first_column = true -ij_scala_method_annotation_wrap = split_into_lines -ij_scala_method_brace_force = never -ij_scala_method_brace_style = end_of_line -ij_scala_method_call_chain_wrap = off -ij_scala_method_parameters_new_line_after_left_paren = false -ij_scala_method_parameters_right_paren_on_new_line = false -ij_scala_method_parameters_wrap = off -ij_scala_modifier_list_wrap = false -ij_scala_multiline_string_align_dangling_closing_quotes = false -ij_scala_multiline_string_closing_quotes_on_new_line = true -ij_scala_multiline_string_insert_margin_on_enter = true -ij_scala_multiline_string_margin_char = | -ij_scala_multiline_string_margin_indent = 2 -ij_scala_multiline_string_opening_quotes_on_new_line = true -ij_scala_multiline_string_process_margin_on_copy_paste = true -ij_scala_newline_after_annotations = false -ij_scala_not_continuation_indent_for_params = false -ij_scala_parameter_annotation_wrap = off -ij_scala_parentheses_expression_new_line_after_left_paren = false -ij_scala_parentheses_expression_right_paren_on_new_line = false -ij_scala_place_closure_parameters_on_new_line = false -ij_scala_place_self_type_on_new_line = true -ij_scala_prefer_parameters_wrap = false -ij_scala_preserve_space_after_method_declaration_name = false -ij_scala_reformat_on_compile = false -ij_scala_replace_case_arrow_with_unicode_char = false -ij_scala_replace_for_generator_arrow_with_unicode_char = false -ij_scala_replace_lambda_with_greek_letter = false -ij_scala_replace_map_arrow_with_unicode_char = false -ij_scala_scalafmt_reformat_on_files_save = false -ij_scala_scalafmt_show_invalid_code_warnings = true -ij_scala_scalafmt_use_intellij_formatter_for_range_format = true -ij_scala_sd_align_exception_comments = true -ij_scala_sd_align_other_tags_comments = true -ij_scala_sd_align_parameters_comments = true -ij_scala_sd_align_return_comments = true -ij_scala_sd_blank_line_after_parameters_comments = false -ij_scala_sd_blank_line_after_return_comments = false -ij_scala_sd_blank_line_before_parameters = false -ij_scala_sd_blank_line_before_tags = true -ij_scala_sd_blank_line_between_parameters = false -ij_scala_sd_keep_blank_lines_between_tags = false -ij_scala_sd_preserve_spaces_in_tags = false -ij_scala_space_after_comma = true -ij_scala_space_after_for_semicolon = true -ij_scala_space_after_modifiers_constructor = false -ij_scala_space_after_type_colon = true -ij_scala_space_before_brace_method_call = true -ij_scala_space_before_class_left_brace = true -ij_scala_space_before_infix_like_method_parentheses = false -ij_scala_space_before_infix_method_call_parentheses = false -ij_scala_space_before_infix_operator_like_method_call_parentheses = true -ij_scala_space_before_method_call_parentheses = false -ij_scala_space_before_method_left_brace = true -ij_scala_space_before_method_parentheses = false -ij_scala_space_before_type_colon = false -ij_scala_space_before_type_parameter_in_def_list = false -ij_scala_space_before_type_parameter_list = false -ij_scala_space_inside_closure_braces = true -ij_scala_space_inside_self_type_braces = true -ij_scala_space_within_empty_method_call_parentheses = false -ij_scala_spaces_around_at_in_patterns = false -ij_scala_spaces_in_imports = false -ij_scala_spaces_in_one_line_blocks = false -ij_scala_spaces_within_brackets = false -ij_scala_spaces_within_for_parentheses = false -ij_scala_spaces_within_if_parentheses = false -ij_scala_spaces_within_method_call_parentheses = false -ij_scala_spaces_within_method_parentheses = false -ij_scala_spaces_within_parentheses = false -ij_scala_spaces_within_while_parentheses = false -ij_scala_special_else_if_treatment = true -ij_scala_trailing_comma_arg_list_enabled = true -ij_scala_trailing_comma_import_selector_enabled = false -ij_scala_trailing_comma_mode = trailing_comma_keep -ij_scala_trailing_comma_params_enabled = true -ij_scala_trailing_comma_pattern_arg_list_enabled = false -ij_scala_trailing_comma_tuple_enabled = false -ij_scala_trailing_comma_tuple_type_enabled = false -ij_scala_trailing_comma_type_params_enabled = false -ij_scala_try_brace_force = never -ij_scala_type_annotation_exclude_constant = true -ij_scala_type_annotation_exclude_in_dialect_sources = true -ij_scala_type_annotation_exclude_in_test_sources = false -ij_scala_type_annotation_exclude_member_of_anonymous_class = false -ij_scala_type_annotation_exclude_member_of_private_class = false -ij_scala_type_annotation_exclude_when_type_is_stable = true -ij_scala_type_annotation_function_parameter = false -ij_scala_type_annotation_implicit_modifier = true -ij_scala_type_annotation_local_definition = false -ij_scala_type_annotation_private_member = false -ij_scala_type_annotation_protected_member = true -ij_scala_type_annotation_public_member = true -ij_scala_type_annotation_structural_type = true -ij_scala_type_annotation_underscore_parameter = false -ij_scala_type_annotation_unit_type = true -ij_scala_use_alternate_continuation_indent_for_params = false -ij_scala_use_scaladoc2_formatting = false -ij_scala_variable_annotation_wrap = off -ij_scala_while_brace_force = never -ij_scala_while_on_new_line = false -ij_scala_wrap_before_with_keyword = false -ij_scala_wrap_first_method_in_call_chain = false -ij_scala_wrap_long_lines = false - -[.editorconfig] -ij_editorconfig_align_group_field_declarations = false -ij_editorconfig_space_after_colon = false -ij_editorconfig_space_after_comma = true -ij_editorconfig_space_before_colon = false -ij_editorconfig_space_before_comma = false -ij_editorconfig_spaces_around_assignment_operators = true - -[{*.gant,*.groovy,*.gradle,*.gdsl,*.gy}] -ij_groovy_align_group_field_declarations = false -ij_groovy_align_multiline_array_initializer_expression = false -ij_groovy_align_multiline_assignment = false -ij_groovy_align_multiline_binary_operation = false -ij_groovy_align_multiline_chained_methods = false -ij_groovy_align_multiline_extends_list = false -ij_groovy_align_multiline_for = true -ij_groovy_align_multiline_method_parentheses = false -ij_groovy_align_multiline_parameters = true -ij_groovy_align_multiline_parameters_in_calls = false -ij_groovy_align_multiline_resources = true -ij_groovy_align_multiline_ternary_operation = false -ij_groovy_align_multiline_throws_list = false -ij_groovy_align_throws_keyword = false -ij_groovy_array_initializer_new_line_after_left_brace = false -ij_groovy_array_initializer_right_brace_on_new_line = false -ij_groovy_array_initializer_wrap = off -ij_groovy_assert_statement_wrap = off -ij_groovy_assignment_wrap = off -ij_groovy_binary_operation_wrap = off -ij_groovy_blank_lines_after_class_header = 0 -ij_groovy_blank_lines_after_imports = 1 -ij_groovy_blank_lines_after_package = 1 -ij_groovy_blank_lines_around_class = 1 -ij_groovy_blank_lines_around_field = 0 -ij_groovy_blank_lines_around_field_in_interface = 0 -ij_groovy_blank_lines_around_method = 1 -ij_groovy_blank_lines_around_method_in_interface = 1 -ij_groovy_blank_lines_before_imports = 1 -ij_groovy_blank_lines_before_method_body = 0 -ij_groovy_blank_lines_before_package = 0 -ij_groovy_block_brace_style = end_of_line -ij_groovy_block_comment_at_first_column = true -ij_groovy_call_parameters_new_line_after_left_paren = false -ij_groovy_call_parameters_right_paren_on_new_line = false -ij_groovy_call_parameters_wrap = off -ij_groovy_catch_on_new_line = false -ij_groovy_class_annotation_wrap = split_into_lines -ij_groovy_class_brace_style = end_of_line -ij_groovy_do_while_brace_force = never -ij_groovy_else_on_new_line = false -ij_groovy_enum_constants_wrap = off -ij_groovy_extends_keyword_wrap = off -ij_groovy_extends_list_wrap = off -ij_groovy_field_annotation_wrap = split_into_lines -ij_groovy_finally_on_new_line = false -ij_groovy_for_brace_force = never -ij_groovy_for_statement_new_line_after_left_paren = false -ij_groovy_for_statement_right_paren_on_new_line = false -ij_groovy_for_statement_wrap = off -ij_groovy_if_brace_force = never -ij_groovy_indent_case_from_switch = true -ij_groovy_keep_blank_lines_before_right_brace = 2 -ij_groovy_keep_blank_lines_in_code = 2 -ij_groovy_keep_blank_lines_in_declarations = 2 -ij_groovy_keep_control_statement_in_one_line = true -ij_groovy_keep_first_column_comment = true -ij_groovy_keep_indents_on_empty_lines = false -ij_groovy_keep_line_breaks = true -ij_groovy_keep_multiple_expressions_in_one_line = false -ij_groovy_keep_simple_blocks_in_one_line = false -ij_groovy_keep_simple_classes_in_one_line = true -ij_groovy_keep_simple_lambdas_in_one_line = true -ij_groovy_keep_simple_methods_in_one_line = true -ij_groovy_lambda_brace_style = end_of_line -ij_groovy_line_comment_add_space = false -ij_groovy_line_comment_at_first_column = true -ij_groovy_method_annotation_wrap = split_into_lines -ij_groovy_method_brace_style = end_of_line -ij_groovy_method_call_chain_wrap = off -ij_groovy_method_parameters_new_line_after_left_paren = false -ij_groovy_method_parameters_right_paren_on_new_line = false -ij_groovy_method_parameters_wrap = off -ij_groovy_modifier_list_wrap = false -ij_groovy_parameter_annotation_wrap = off -ij_groovy_parentheses_expression_new_line_after_left_paren = false -ij_groovy_parentheses_expression_right_paren_on_new_line = false -ij_groovy_prefer_parameters_wrap = false -ij_groovy_resource_list_new_line_after_left_paren = false -ij_groovy_resource_list_right_paren_on_new_line = false -ij_groovy_resource_list_wrap = off -ij_groovy_space_after_colon = true -ij_groovy_space_after_comma = true -ij_groovy_space_after_comma_in_type_arguments = true -ij_groovy_space_after_for_semicolon = true -ij_groovy_space_after_quest = true -ij_groovy_space_after_type_cast = true -ij_groovy_space_before_annotation_parameter_list = false -ij_groovy_space_before_array_initializer_left_brace = false -ij_groovy_space_before_catch_keyword = true -ij_groovy_space_before_catch_left_brace = true -ij_groovy_space_before_catch_parentheses = true -ij_groovy_space_before_class_left_brace = true -ij_groovy_space_before_colon = true -ij_groovy_space_before_comma = false -ij_groovy_space_before_do_left_brace = true -ij_groovy_space_before_else_keyword = true -ij_groovy_space_before_else_left_brace = true -ij_groovy_space_before_finally_keyword = true -ij_groovy_space_before_finally_left_brace = true -ij_groovy_space_before_for_left_brace = true -ij_groovy_space_before_for_parentheses = true -ij_groovy_space_before_for_semicolon = false -ij_groovy_space_before_if_left_brace = true -ij_groovy_space_before_if_parentheses = true -ij_groovy_space_before_method_call_parentheses = false -ij_groovy_space_before_method_left_brace = true -ij_groovy_space_before_method_parentheses = false -ij_groovy_space_before_quest = true -ij_groovy_space_before_switch_left_brace = true -ij_groovy_space_before_switch_parentheses = true -ij_groovy_space_before_synchronized_left_brace = true -ij_groovy_space_before_synchronized_parentheses = true -ij_groovy_space_before_try_left_brace = true -ij_groovy_space_before_try_parentheses = true -ij_groovy_space_before_while_keyword = true -ij_groovy_space_before_while_left_brace = true -ij_groovy_space_before_while_parentheses = true -ij_groovy_space_within_empty_array_initializer_braces = false -ij_groovy_space_within_empty_method_call_parentheses = false -ij_groovy_spaces_around_additive_operators = true -ij_groovy_spaces_around_assignment_operators = true -ij_groovy_spaces_around_bitwise_operators = true -ij_groovy_spaces_around_equality_operators = true -ij_groovy_spaces_around_lambda_arrow = true -ij_groovy_spaces_around_logical_operators = true -ij_groovy_spaces_around_multiplicative_operators = true -ij_groovy_spaces_around_relational_operators = true -ij_groovy_spaces_around_shift_operators = true -ij_groovy_spaces_within_annotation_parentheses = false -ij_groovy_spaces_within_array_initializer_braces = false -ij_groovy_spaces_within_braces = true -ij_groovy_spaces_within_brackets = false -ij_groovy_spaces_within_cast_parentheses = false -ij_groovy_spaces_within_catch_parentheses = false -ij_groovy_spaces_within_for_parentheses = false -ij_groovy_spaces_within_if_parentheses = false -ij_groovy_spaces_within_method_call_parentheses = false -ij_groovy_spaces_within_method_parentheses = false -ij_groovy_spaces_within_parentheses = false -ij_groovy_spaces_within_switch_parentheses = false -ij_groovy_spaces_within_synchronized_parentheses = false -ij_groovy_spaces_within_try_parentheses = false -ij_groovy_spaces_within_while_parentheses = false -ij_groovy_special_else_if_treatment = true -ij_groovy_ternary_operation_wrap = off -ij_groovy_throws_keyword_wrap = off -ij_groovy_throws_list_wrap = off -ij_groovy_variable_annotation_wrap = off -ij_groovy_while_brace_force = never -ij_groovy_while_on_new_line = false -ij_groovy_wrap_long_lines = false - -[{*.jhm,*.xslt,*.xul,*.tagx,*.rng,*.xsl,*.xsd,*.jspx,*.ant,*.xml,*.tld,*.fxml,*.wsdl,*.jrxml,*.jnlp,*.pom}] -ij_xml_block_comment_at_first_column = true -ij_xml_keep_indents_on_empty_lines = false -ij_xml_line_comment_at_first_column = true - -[{*.kt,*.kts}] -ij_kotlin_align_in_columns_case_branch = false -ij_kotlin_align_multiline_binary_operation = false -ij_kotlin_align_multiline_extends_list = false -ij_kotlin_align_multiline_method_parentheses = false -ij_kotlin_align_multiline_parameters = true -ij_kotlin_align_multiline_parameters_in_calls = false -ij_kotlin_assignment_wrap = off -ij_kotlin_blank_lines_after_class_header = 0 -ij_kotlin_blank_lines_around_block_when_branches = 0 -ij_kotlin_block_comment_at_first_column = true -ij_kotlin_call_parameters_new_line_after_left_paren = false -ij_kotlin_call_parameters_right_paren_on_new_line = false -ij_kotlin_call_parameters_wrap = off -ij_kotlin_catch_on_new_line = false -ij_kotlin_class_annotation_wrap = split_into_lines -ij_kotlin_continuation_indent_for_chained_calls = true -ij_kotlin_continuation_indent_for_expression_bodies = true -ij_kotlin_continuation_indent_in_argument_lists = true -ij_kotlin_continuation_indent_in_elvis = true -ij_kotlin_continuation_indent_in_if_conditions = true -ij_kotlin_continuation_indent_in_parameter_lists = true -ij_kotlin_continuation_indent_in_supertype_lists = true -ij_kotlin_else_on_new_line = false -ij_kotlin_enum_constants_wrap = off -ij_kotlin_extends_list_wrap = off -ij_kotlin_field_annotation_wrap = split_into_lines -ij_kotlin_finally_on_new_line = false -ij_kotlin_if_rparen_on_new_line = false -ij_kotlin_import_nested_classes = false -ij_kotlin_insert_whitespaces_in_simple_one_line_method = true -ij_kotlin_keep_blank_lines_before_right_brace = 2 -ij_kotlin_keep_blank_lines_in_code = 2 -ij_kotlin_keep_blank_lines_in_declarations = 2 -ij_kotlin_keep_first_column_comment = true -ij_kotlin_keep_indents_on_empty_lines = false -ij_kotlin_keep_line_breaks = true -ij_kotlin_lbrace_on_next_line = false -ij_kotlin_line_comment_add_space = false -ij_kotlin_line_comment_at_first_column = true -ij_kotlin_method_annotation_wrap = split_into_lines -ij_kotlin_method_call_chain_wrap = off -ij_kotlin_method_parameters_new_line_after_left_paren = false -ij_kotlin_method_parameters_right_paren_on_new_line = false -ij_kotlin_method_parameters_wrap = off -ij_kotlin_name_count_to_use_star_import = 5 -ij_kotlin_name_count_to_use_star_import_for_members = 3 -ij_kotlin_parameter_annotation_wrap = off -ij_kotlin_space_after_comma = true -ij_kotlin_space_after_extend_colon = true -ij_kotlin_space_after_type_colon = true -ij_kotlin_space_before_catch_parentheses = true -ij_kotlin_space_before_comma = false -ij_kotlin_space_before_extend_colon = true -ij_kotlin_space_before_for_parentheses = true -ij_kotlin_space_before_if_parentheses = true -ij_kotlin_space_before_lambda_arrow = true -ij_kotlin_space_before_type_colon = false -ij_kotlin_space_before_when_parentheses = true -ij_kotlin_space_before_while_parentheses = true -ij_kotlin_spaces_around_additive_operators = true -ij_kotlin_spaces_around_assignment_operators = true -ij_kotlin_spaces_around_equality_operators = true -ij_kotlin_spaces_around_function_type_arrow = true -ij_kotlin_spaces_around_logical_operators = true -ij_kotlin_spaces_around_multiplicative_operators = true -ij_kotlin_spaces_around_range = false -ij_kotlin_spaces_around_relational_operators = true -ij_kotlin_spaces_around_unary_operator = false -ij_kotlin_spaces_around_when_arrow = true -ij_kotlin_variable_annotation_wrap = off -ij_kotlin_while_on_new_line = false -ij_kotlin_wrap_elvis_expressions = 1 -ij_kotlin_wrap_expression_body_functions = 0 -ij_kotlin_wrap_first_method_in_call_chain = false - -[{*.shtm,*.htm,*.sht,*.shtml,*.html}] -ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3 -ij_html_align_attributes = true -ij_html_align_text = false -ij_html_attribute_wrap = normal -ij_html_block_comment_at_first_column = true -ij_html_do_not_align_children_of_min_lines = 0 -ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p -ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot -ij_html_enforce_quotes = false -ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var -ij_html_keep_blank_lines = 2 -ij_html_keep_indents_on_empty_lines = false -ij_html_keep_line_breaks = true -ij_html_keep_line_breaks_in_text = true -ij_html_keep_whitespaces = false -ij_html_keep_whitespaces_inside = span,pre,textarea -ij_html_line_comment_at_first_column = true -ij_html_new_line_after_last_attribute = never -ij_html_new_line_before_first_attribute = never -ij_html_quote_style = double -ij_html_remove_new_line_before_tags = br -ij_html_space_after_tag_name = false -ij_html_space_around_equality_in_attribute = false -ij_html_space_inside_empty_tag = false -ij_html_text_wrap = normal - -[{*.yml,*.yaml}] -indent_size = 2 -ij_continuation_indent_size = 2 -ij_yaml_keep_indents_on_empty_lines = false -ij_yaml_keep_line_breaks = true - -[{*.zsh,*.bash,*.sh}] -ij_shell_binary_ops_start_line = false -ij_shell_keep_column_alignment_padding = false -ij_shell_minify_program = false -ij_shell_redirect_followed_by_space = false -ij_shell_switch_cases_indented = false diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 536966dd..00000000 --- a/.gitattributes +++ /dev/null @@ -1,42 +0,0 @@ -# https://www.gitattributes.io/api/java -# -# Handle line endings automatically for files detected as text -# and leave all files detected as binary untouched. -* text=auto - -# -# The above will handle all files NOT found below -# -# These files are text and should be normalized (Convert crlf => lf) -*.css text -*.df text -*.htm text -*.html text -*.java text -*.js text -*.json text -*.jsp text -*.jspf text -*.jspx text -*.properties text -*.sh text -*.tld text -*.txt text -*.tag text -*.tagx text -*.xml text -*.yml text - -# These files are binary and should be left untouched -# (binary is a macro for -text -diff) -*.class binary -*.dll binary -*.ear binary -*.gif binary -*.ico binary -*.jar binary -*.jpg binary -*.jpeg binary -*.png binary -*.so binary -*.war binary diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..f1180668 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: Petersoj diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f13589c7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +name: release +on: + workflow_dispatch: +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Setup Java + uses: actions/setup-java@v5 + with: + java-version: 25 + distribution: corretto + cache: gradle + cache-dependency-path: gradle/wrapper/gradle-wrapper.properties + - name: Gradle Build and Release + run: ./gradlew clean build publish jreleaserFullRelease --no-daemon --no-configuration-cache + env: + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} + JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 12a5664a..499dc333 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ -/bin/ -build/ -.gradle/ -.settings .DS_Store +.gradle/ +.kotlin/ .idea/ +build/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 45d725d0..00000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: java -install: true -dist: trusty - -jdk: - - oraclejdk8 - -script: - - ./gradlew build --scan -s - -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ - -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 415ddac0..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env groovy - -node { - stage('checkout') { - checkout scm - } - - stage('check java') { - sh "java -version" - } - - stage('clean') { - sh "chmod +x gradlew" - sh "./gradlew clean" - } - - - stage('install') { - try { - sh "./gradlew build publishToMavenLocal" - } catch (err) { - throw err - } - } -} - diff --git a/LICENSE b/LICENSE.txt similarity index 96% rename from LICENSE rename to LICENSE.txt index 2e9f22a3..38f23352 100644 --- a/LICENSE +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 mainstringargs +Copyright (c) Jacob Peterson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md deleted file mode 100644 index 58656ece..00000000 --- a/README.md +++ /dev/null @@ -1,409 +0,0 @@ -

-

-Maven Central Javadocs Build Status - GitHub -

- -# Overview -This is a Java implementation for Alpaca. Alpaca lets you build and trade with real-time market data for free. This library is community developed and if you have any questions, please ask them on the [Alpaca Slack #dev-alpaca-java channel](https://alpaca.markets/slack) or on the [Alpaca Forums](https://forum.alpaca.markets/). - -## Table of Contents -1. [Alpaca Java Building](#alpaca-java-building) -2. [Alpaca Java Gradle Integration](#alpaca-java-gradle-integration) -3. [Alpaca Java Maven Integration](#alpaca-java-maven-integration) -4. [Configuration](#configuration) -5. [AlpacaAPI Example](#alpacaapi-example) -7. [PolygonAPI Example](#polygonapi-example) - -## Alpaca Java Building - -This project exposes that data as a Java project. - -To build this project yourself, clone the project and run: - -``` -./gradlew build -``` - -## Alpaca Java Gradle Integration - -Add the following dependency to your build.gradle file: - -``` -dependencies { - compile "io.github.mainstringargs:alpaca-java:5.0.13" -} -``` - -## Alpaca Java Maven Integration - -Add the following dependency to your pom.xml file: - -``` - - io.github.mainstringargs - alpaca-java - 5.0.13 - compile - -``` -## Configuration - -If you plan on using the alpaca.properties, set the following properties in an alpaca.properties file on the classpath: -``` -api_version = -key_id = -secret = -base_api_url = https://paper-api.alpaca.markets -base_data_url = https://data.alpaca.markets -user_agent=a_user_agent -``` -The default values for `alpaca.properties` can be found [here](https://github.com/mainstringargs/alpaca-java/tree/master/src/main/resources). - -Similarly, set the following properties in a polygon.properties file on the classpath for using the PolygonAPI: -``` -#key_id will default to what is set in alpaca.properties -key_id = -base_api_url = https://api.polygon.io -web_socket_server_url = wss://alpaca.socket.polygon.io/stocks -user_agent=a_user_agent -``` -The default values for `polygon.properties` can be found [here](https://github.com/mainstringargs/alpaca-java/tree/master/src/main/resources). - -## AlpacaAPI Example - -This example uses the `AlpacaAPI` class to subscribe to the Account and Trade Updates stream, print out the account information, submit a limit order, create a watchlist, and print out bars data. Click [here](https://docs.alpaca.markets/api-documentation/api-v2/) for the general Alpaca API documentation and click [here](https://javadoc.io/doc/io.github.mainstringargs/alpaca-java/latest/io/github/mainstringargs/alpaca/AlpacaAPI.html) for the `AlpacaAPI` javadoc. - -```java -// This logs into Alpaca using the alpaca.properties file on the classpath. -AlpacaAPI alpacaAPI = new AlpacaAPI(); - -// Register explicitly for ACCOUNT_UPDATES and ORDER_UPDATES Messages via stream listener -alpacaAPI.addAlpacaStreamListener(new AlpacaStreamListenerAdapter( - AlpacaStreamMessageType.ACCOUNT_UPDATES, - AlpacaStreamMessageType.TRADE_UPDATES) { - @Override - public void onStreamUpdate(AlpacaStreamMessageType streamMessageType, AlpacaStreamMessage streamMessage) { - switch (streamMessageType) { - case ACCOUNT_UPDATES: - AccountUpdateMessage accountUpdateMessage = (AccountUpdateMessage) streamMessage; - System.out.println("\nReceived Account Update: \n\t" + - accountUpdateMessage.toString().replace(",", ",\n\t")); - break; - case TRADE_UPDATES: - TradeUpdateMessage tradeUpdateMessage = (TradeUpdateMessage) streamMessage; - System.out.println("\nReceived Order Update: \n\t" + - tradeUpdateMessage.toString().replace(",", ",\n\t")); - break; - } - } -}); - -// Get Account Information -try { - Account alpacaAccount = alpacaAPI.getAccount(); - - System.out.println("\n\nAccount Information:"); - System.out.println("\t" + alpacaAccount.toString().replace(",", ",\n\t")); -} catch (AlpacaAPIRequestException e) { - e.printStackTrace(); -} - -// Request an Order -try { - Order aaplLimitOrder = alpacaAPI.requestNewLimitOrder("AAPL", 1, OrderSide.BUY, OrderTimeInForce.DAY, - 201.30, true, null); - - System.out.println("\n\nNew AAPL Order:"); - System.out.println("\t" + aaplLimitOrder.toString().replace(",", ",\n\t")); -} catch (AlpacaAPIRequestException e) { - e.printStackTrace(); -} - -// Create watchlist -try { - Watchlist dayTradeWatchlist = alpacaAPI.createWatchlist("Day Trade", "AAPL"); - - System.out.println("\n\nDay Trade Watchlist:"); - System.out.println("\t" + dayTradeWatchlist.toString().replace(",", ",\n\t")); -} catch (AlpacaAPIRequestException e) { - e.printStackTrace(); -} - -// Get bars -try { - ZonedDateTime start = ZonedDateTime.of(2019, 11, 18, 0, 0, 0, 0, ZoneId.of("America/New_York")); - ZonedDateTime end = ZonedDateTime.of(2019, 11, 22, 23, 59, 0, 0, ZoneId.of("America/New_York")); - - Map> bars = alpacaAPI.getBars(BarsTimeFrame.ONE_DAY, "AAPL", null, start, end, - null, null); - - System.out.println("\n\nBars response:"); - for (Bar bar : bars.get("AAPL")) { - System.out.println("\t=========="); - System.out.println("\tUnix Time " + ZonedDateTime.ofInstant(Instant.ofEpochSecond(bar.getT()), - ZoneOffset.UTC)); - System.out.println("\tOpen: $" + bar.getO()); - System.out.println("\tHigh: $" + bar.getH()); - System.out.println("\tLow: $" + bar.getL()); - System.out.println("\tClose: $" + bar.getC()); - System.out.println("\tVolume: " + bar.getV()); - } -} catch (AlpacaAPIRequestException e) { - e.printStackTrace(); -} - -// Keep the Alpaca websocket stream open for 5 seconds -try { - Thread.sleep(5000); -} catch (InterruptedException e) { - e.printStackTrace(); -} -``` - -This code will output the following: - -``` -Account Information: - io.github.mainstringargs.domain.alpaca.account.Account@626abbd0[id=, - accountNumber=, - status=ACTIVE, - currency=USD, - cash=6982.96, - portfolioValue=99717.04, - patternDayTrader=false, - tradeSuspendedByUser=false, - tradingBlocked=false, - transfersBlocked=false, - accountBlocked=false, - createdAt=2019-08-11T22:19:17.959522Z, - shortingEnabled=true, - longMarketValue=106700, - shortMarketValue=0, - equity=99717.04, - lastEquity=97753.04, - multiplier=4, - buyingPower=265328.96, - initialMargin=53350, - maintenanceMargin=32010, - sma=0, - daytradeCount=0, - lastMaintenanceMargin=31420.8, - daytradingBuyingPower=265328.96, - regtBuyingPower=92734.08] - -New AAPL Order: - io.github.mainstringargs.domain.alpaca.order.Order@37313c65[id=, - clientOrderId=929e412f-32b6-4ddf-9729-d77a59c19ec8, - createdAt=2019-11-26T03:41:10.475959154Z, - updatedAt=2019-11-26T03:41:10.481465924Z, - submittedAt=2019-11-26T03:41:10.464752859Z, - filledAt=, - expiredAt=, - canceledAt=, - failedAt=, - assetId=b0b6dd9d-8b9b-48a9-ba46-b9d54906e415, - symbol=AAPL, - assetClass=us_equity, - qty=1, - filledQty=0, - type=limit, - side=buy, - timeInForce=day, - limitPrice=201.3, - stopPrice=, - filledAvgPrice=, - status=new, - extendedHours=true] - -Received Order Update: - OrderUpdateMessage [event=NEW, - price=null, - timestamp=null, - order=io.github.mainstringargs.alpaca.domain.Order@5c728415[id=, - clientOrderId=e23ca503-ebec-4754-b65a-ee42806fc67d, - createdAt=2019-11-23T14:41:05.503352Z, - updatedAt=2019-11-23T14:41:05.599835871Z, - submittedAt=2019-11-23T14:41:05.445148Z, - filledAt=, - expiredAt=, - canceledAt=, - failedAt=, - assetId=b0b6dd9d-8b9b-48a9-ba46-b9d54906e415, - symbol=AAPL, - exchange=, - assetClass=us_equity, - qty=1, - filledQty=0, - type=limit, - side=buy, - timeInForce=day, - limitPrice=100, - stopPrice=, - filledAvgPrice=, - status=new]] - - -Day Trade Watchlist: - io.github.mainstringargs.domain.alpaca.watchlist.Watchlist@34bde49d[id=7c414350-79d8-4527-8892-f1667faa712a, - createdAt=2019-11-26T03:20:31.953679Z, - updatedAt=2019-11-26T03:20:31.953679Z, - name=Day Trade, - accountId=, - assets=[io.github.mainstringargs.domain.alpaca.asset.Asset@1b1cfb87[id=b0b6dd9d-8b9b-48a9-ba46-b9d54906e415, - _class=us_equity, - exchange=NASDAQ, - symbol=AAPL, - status=active, - tradable=true, - marginable=true, - shortable=true, - easyToBorrow=true]]] - -Bars response: - ========== - Unix Time 2019-11-18T05:00Z - Open: $265.8 - High: $267.43 - Low: $264.23 - Close: $267.12 - Volume: 1.8045658E7 - ========== - Unix Time 2019-11-19T05:00Z - Open: $267.9 - High: $268.0 - Low: $265.3926 - Close: $266.29 - Volume: 1.4685205E7 - ========== - Unix Time 2019-11-20T05:00Z - Open: $265.54 - High: $266.083 - Low: $260.4 - Close: $263.22 - Volume: 2.2181038E7 - ========== - Unix Time 2019-11-21T05:00Z - Open: $263.71 - High: $264.005 - Low: $261.18 - Close: $262.01 - Volume: 2.5411879E7 - ========== - Unix Time 2019-11-22T05:00Z - Open: $262.59 - High: $263.18 - Low: $260.84 - Close: $261.84 - Volume: 1.4021695E7 -``` - -# PolygonAPI Example - -This example uses the `PolygonAPI` class to subscribe to the Polygon websocket stream, get stocks splits, and get aggregates. Click [here](https://polygon.io/docs/) for the general Polygon API documentation and click [here](https://javadoc.io/doc/io.github.mainstringargs/alpaca-java/latest/io/github/mainstringargs/polygon/PolygonAPI.html) for the `PolygonAPI` javadoc. - -```java -// This will use the key_id in the alpaca.properties file by default -PolygonAPI polygonAPI = new PolygonAPI(); - -String aaplTicker = "AAPL"; - -// Add a Polygon stream listener to listen to "T.AAPL", "Q.AAPL", "A.AAPL", "AM.AAPL", and status messages -polygonAPI.addPolygonStreamListener(new PolygonStreamListenerAdapter(aaplTicker, - PolygonStreamMessageType.values()) { - @Override - public void onStreamUpdate(PolygonStreamMessageType streamMessageType, PolygonStreamMessage streamMessage) { - System.out.println("===> streamUpdate " + streamMessageType + " " + streamMessage); - } -}); - -// Sleep the current thread for 2 seconds so we can see some trade/quote/aggregates updates on the stream! -try { - Thread.sleep(2000); -} catch (InterruptedException e) { - e.printStackTrace(); -} - -try { - StockSplitsResponse stockSplitsResponse = polygonAPI.getStockSplits(aaplTicker); - - System.out.println(aaplTicker + " Stock Split Response:"); - System.out.println("\tStatus: " + stockSplitsResponse.getStatus()); - System.out.println("\tCount: " + stockSplitsResponse.getCount()); - for (StockSplit stockSplit : stockSplitsResponse.getResults()) { - System.out.println("\t" + stockSplit.toString().replace(",", ",\n\t")); - } -} catch (PolygonAPIRequestException e) { - e.printStackTrace(); -} - -try { - AggregatesResponse aggregatesResponse = polygonAPI.getAggregates(aaplTicker, 1, Timespan.DAY, - LocalDate.of(2019, 11, 18), LocalDate.of(2019, 11, 25), false); - - System.out.println("Aggregate Response:"); - System.out.println("\tStatus: " + aggregatesResponse.getStatus()); - System.out.println("\tCount: " + aggregatesResponse.getResultsCount()); - for (Aggregate aggregate : aggregatesResponse.getResults()) { - System.out.println("\t" + aggregate.toString().replace(",", ",\n\t")); - } -} catch (PolygonAPIRequestException e) { - e.printStackTrace(); -} -``` -This code will output the following: - -``` -[INFO ] 2019-11-25 21:33:20.456 [main] PolygonWebsocketClient - Connected. -[DEBUG] 2019-11-25 21:33:20.485 [main] PolygonWebsocketClientEndpoint - sendMessage {"action":"auth","params":""} -[INFO ] 2019-11-25 21:33:20.489 [main] PolygonWebsocketClient - Subscribing to A.AAPL -[INFO ] 2019-11-25 21:33:20.489 [main] PolygonWebsocketClient - Subscribing to T.AAPL -[INFO ] 2019-11-25 21:33:20.489 [main] PolygonWebsocketClient - Subscribing to AM.AAPL -[INFO ] 2019-11-25 21:33:20.489 [main] PolygonWebsocketClient - Subscribing to Q.AAPL -[DEBUG] 2019-11-25 21:33:20.491 [main] PolygonWebsocketClientEndpoint - sendMessage {"action":"subscribe","params":"A.AAPL,T.AAPL,AM.AAPL,Q.AAPL"} -[INFO ] 2019-11-25 21:33:20.492 [main] PolygonWebsocketClient - Subscriptions updated to {AAPL=[AGGREGATE_PER_SECOND, TRADES, AGGREGATE_PER_MINUTE, QUOTES]} -[INFO] 2019-11-25 21:33:20.508 [PolygonWebsocketThread] PolygonWebsocketClient - Channel status: io.github.mainstringargs.domain.polygon.websocket.ChannelStatus@78428bcb[ev=status,status=connected,message=Connected Successfully] -[INFO] 2019-11-25 21:33:20.667 [PolygonWebsocketThread] PolygonWebsocketClient - Channel status: io.github.mainstringargs.domain.polygon.websocket.ChannelStatus@629dc521[ev=status,status=auth_success,message=authenticated] -[INFO] 2019-11-25 21:33:20.735 [PolygonWebsocketThread] PolygonWebsocketClient - Channel status: io.github.mainstringargs.domain.polygon.websocket.ChannelStatus@7f4d9c50[ev=status,status=success,message=subscribed to: A.AAPL] -[INFO] 2019-11-25 21:33:20.737 [PolygonWebsocketThread] PolygonWebsocketClient - Channel status: io.github.mainstringargs.domain.polygon.websocket.ChannelStatus@2aa9728c[ev=status,status=success,message=subscribed to: T.AAPL] -[INFO] 2019-11-25 21:33:20.738 [PolygonWebsocketThread] PolygonWebsocketClient - Channel status: io.github.mainstringargs.domain.polygon.websocket.ChannelStatus@4659b8c1[ev=status,status=success,message=subscribed to: AM.AAPL] -[INFO] 2019-11-25 21:33:20.738 [PolygonWebsocketThread] PolygonWebsocketClient - Channel status: io.github.mainstringargs.domain.polygon.websocket.ChannelStatus@4a61d9e6[ev=status,status=success,message=subscribed to: Q.AAPL] -===> streamUpdate QUOTES QuotesMessage [ticker=AAPL, channelType=QUOTES, stockQuote=io.github.mainstringargs.polygon.domain.StockQuote@4d5b710e[ev=,sym=AAPL,bx=12,bp=124.86,bs=6,ax=12,ap=124.87,as=5,c=1,t=1559143439610], timestamp=2019-05-29T10:23:59.610] -===> streamUpdate QUOTES QuotesMessage [ticker=AAPL, channelType=QUOTES, stockQuote=io.github.mainstringargs.polygon.domain.StockQuote@16b79976[ev=,sym=AAPL,bx=12,bp=124.86,bs=4,ax=12,ap=124.87,as=5,c=1,t=1559143439712], timestamp=2019-05-29T10:23:59.712] -===> streamUpdate TRADES TradesMessage [ticker=AAPL, channelType=TRADES, stockTrade=io.github.mainstringargs.polygon.domain.StockTrade@32b4aa49[ev=,sym=AAPL,x=4,p=124.86,s=100,c=[],t=1559143439772], timestamp=2019-05-29T10:23:59.772] -===> streamUpdate AGGREGATE_PER_SECOND AggregateMessage [ticker=AAPL, channelType=AGGREGATE_PER_SECOND, stockAggregate=io.github.mainstringargs.polygon.domain.StockAggregate@5ace47f7[ev=,sym=AAPL,v=1131,av=6602041,op=125.5,vw=124.9778,o=124.8665,c=124.86,h=124.8665,l=124.86,a=124.8636,s=1559143439000,e=1559143440000], start=2019-05-29T10:23:59, end=2019-05-29T10:24] - -AAPL Stock Split Response: - Status: OK - Count: 3 - io.github.mainstringargs.domain.polygon.stocksplits.StockSplit@6b09fb41[ticker=AAPL, - exDate=2014-06-09, - paymentDate=2014-06-09, - recordDate=, - declaredDate=, - ratio=0.14285714285714285, - tofactor=, - forfactor=] - ... - -Aggregate Response: - Status: OK - Count: 5.0 - io.github.mainstringargs.domain.polygon.aggregates.Aggregate@6cd24612[ticker=, - v=23984783, - o=265.8, - c=267.1, - h=267.43, - l=264.23, - t=1574053200000, - n=1] - io.github.mainstringargs.domain.polygon.aggregates.Aggregate@5dafbe45[ticker=, - v=21208039, - o=267.9, - c=266.29, - h=268.0, - l=265.3926, - t=1574139600000, - n=1] - ... -``` diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c7418817..00000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-slate \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 007107ec..00000000 --- a/build.gradle +++ /dev/null @@ -1,188 +0,0 @@ -/* - * This build file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java project to get you started. - * For more details take a look at the Java Quickstart chapter in the Gradle - * user guide available at https://docs.gradle.org/3.4.1/userguide/tutorial_java_projects.html - */ - -buildscript { - repositories { - mavenLocal() - mavenCentral() - jcenter() - } - - dependencies { - classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1' - // add additional dependencies here if you wish to reference instead of generate them (see example directory) - } -} - -plugins { - id 'maven-publish' - id 'io.codearte.nexus-staging' version '0.11.0' -} - -// Apply the java plugin to add support for Java -apply plugin: 'java' - -// Apply the application plugin to add support for building an application -apply plugin: 'application' - -apply plugin: 'eclipse' - -apply plugin: 'com.bmuschko.nexus' - -archivesBaseName = 'alpaca-java' -group = 'io.github.mainstringargs' -version = '5.0.13-SNAPSHOT' - - -// In this section you declare where to find the dependencies of your project -repositories { - // Use jcenter for resolving your dependencies. - // You can declare any Maven/Ivy/file repository here. - maven { url "https://repo.maven.apache.org/maven2" } - jcenter() - //maven { url "http://mvnrepository.com/artifact" } -} - -dependencies { - // This dependency is found on compile classpath of this component and consumers. - compile 'com.google.guava:guava:20.0' - compile "com.mashape.unirest:unirest-java:1.4.9" - compile "com.google.code.gson:gson:2.8.5" - compile "commons-lang:commons-lang:2.6" - compile 'org.apache.logging.log4j:log4j-api:2.11.1' - compile 'org.apache.logging.log4j:log4j-core:2.11.1' - - compile "org.eclipse.jetty.websocket:javax-websocket-client-impl:9.4.28.v20200408" - - // Use JUnit test framework - testCompile 'junit:junit:4.12' -} - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 -[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8' - -modifyPom { - project { - name 'alpaca-java' - description 'Java API for Alpaca trading' - url 'https://github.com/mainstringargs/alpaca-java' - inceptionYear '2018' - scm { - url 'https://github.com/mainstringargs/alpaca-java' - connection 'https://github.com/mainstringargs/alpaca-java.git' - developerConnection 'https://github.com/mainstringargs/alpaca-java.git' - } - licenses { - license { - name 'MIT License' - url 'https://opensource.org/licenses/MIT' - distribution 'repo' - } - } - developers { - developer { - id 'mainstringargs' - name 'main(String[] args)' - email 'mainstringargs@github.io' - } - } - } -} - -// https://stackoverflow.com/questions/52205209/configure-gradle-build-to-suppress-javadoc-console-warnings -javadoc.options.addStringOption('Xdoclint:none', '-quiet') -javadoc.options.addStringOption("charset", "UTF-8") - - -publishing { - publications { - maven(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - } - } -} - -extraArchive { - sources = true - tests = true - javadoc = true -} -nexus { - sign = true - repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' - snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' -} - -nexusStaging { - packageGroup = "io.github.mainstringargs" //optional if packageGroup == project.getGroup() -} - -processResources { - exclude('alpaca.properties', 'polygon.properties') -} - -sourceSets { - main { - java { - srcDir 'src/main/java' - srcDir 'build/generated-sources/schemajson' - } - } -} - -// The generated POJOs will be in a package structure analogous to the path in the 'schema_json/' directory -// See: https://github.com/joelittlejohn/jsonschema2pojo/wiki/Reference -task generatePOJOs() { - final def targetDirectory = "${project.buildDir}" + File.separator + "generated-sources" + File.separator + "schemajson" - final def jsonSourceDirectory = "${project.projectDir}" + File.separator + "schema_json" + File.separator - final def jsonPackageNameStart = "io.github.mainstringargs.domain." - - // Clear all generated sources - delete targetDirectory - - // Loop through all files in schema JSON file tree - file(jsonSourceDirectory).eachFileRecurse { file -> - if (file.getName().endsWith(".json")) { - def startPackageIndex = file.getAbsolutePath().indexOf(jsonSourceDirectory) + jsonSourceDirectory.length() - def targetPackage = jsonPackageNameStart + file.getParentFile().getAbsolutePath() - .substring(startPackageIndex) - .replace(File.separator, '.').replace('-', '').replace('_', '') - .toLowerCase() - - def jsonToPOJOTask = tasks.create('json2POJOTask-' + targetPackage + "." + file.getName(), GradleBuild) { - startParameter.projectProperties = ['source' : file.getAbsolutePath(), - 'targetPackage' : targetPackage, - 'targetDirectory': targetDirectory] - buildFile = 'schemaJson2Pojo.gradle' - tasks = ['generateJsonSchema2Pojo'] - } - - dependsOn jsonToPOJOTask - } - } -} - -compileJava { - dependsOn generatePOJOs -} - -build.finalizedBy(publishToMavenLocal) - -if (hasProperty('buildScan')) { - buildScan { licenseAgreementUrl = 'https://gradle.com/terms-of-service'; licenseAgree = 'yes' } -} - -startScripts { - classpath += files('resources') -} - -//mainClassName = 'io.github.mainstringargs.alpaca.AlpacaExample' -mainClassName = 'io.github.mainstringargs.polygon.PolygonExample' diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..5faf0426 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,48 @@ +import org.jreleaser.model.Active.ALWAYS +import org.jreleaser.model.Active.NEVER + +plugins { + java + id("org.jreleaser") version "1.26.0" +} + +group = PROJECT_GROUP +version = PROJECT_VERSION + +repositories { + mavenCentral() +} + +jreleaser { + signing { + pgp { + active = ALWAYS + armored = true + } + } + deploy { + maven { + mavenCentral { + create("sonatype") { + active = ALWAYS + url = "https://central.sonatype.com/api/v1/publisher" + stagingRepositories.add(layout.buildDirectory.dir(JRELEASER_MAVEN_REPOSITORY_DIRECTORY) + .map { it.asFile.path }) + skipPublicationCheck = true + } + } + } + } + release { + github { + uploadAssets = NEVER + } + } +} +subprojects { + tasks.configureEach { + rootProject.tasks.jreleaserFullRelease.configure { + mustRunAfter(this@configureEach) + } + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..b807c7c4 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() + gradlePluginPortal() +} + +dependencies { + implementation("com.google.guava:guava:33.7.1-jre") + + // Define versions for `module-common.gradle.kts` plugins: + implementation("io.freefair.lombok:io.freefair.lombok.gradle.plugin:9.7.0") + implementation("net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:5.1.1") + implementation("io.github.ben-manes.versions:io.github.ben-manes.versions.gradle.plugin:0.61.0") + + // Define versions for `openapi-generator-adapted.gradle.kts` plugins: + implementation("org.openapi.generator:org.openapi.generator.gradle.plugin:7.25.0") +} diff --git a/buildSrc/src/main/kotlin/ModuleCommon.kt b/buildSrc/src/main/kotlin/ModuleCommon.kt new file mode 100644 index 00000000..5feeb092 --- /dev/null +++ b/buildSrc/src/main/kotlin/ModuleCommon.kt @@ -0,0 +1,3 @@ +const val PROJECT_GROUP = "net.jacobpeterson.alpaca-java" +const val PROJECT_VERSION = "11.0.0-pre.1" +const val JRELEASER_MAVEN_REPOSITORY_DIRECTORY = "jreleaser-staging" diff --git a/buildSrc/src/main/kotlin/OpenApiGeneratorAdaptedExtension.kt b/buildSrc/src/main/kotlin/OpenApiGeneratorAdaptedExtension.kt new file mode 100644 index 00000000..2e297991 --- /dev/null +++ b/buildSrc/src/main/kotlin/OpenApiGeneratorAdaptedExtension.kt @@ -0,0 +1,7 @@ +import org.gradle.api.provider.Property + +interface OpenApiGeneratorAdaptedExtension { + + val environmentUrlProduction: Property + val environmentUrlDevelopment: Property +} diff --git a/buildSrc/src/main/kotlin/module-common.gradle.kts b/buildSrc/src/main/kotlin/module-common.gradle.kts new file mode 100644 index 00000000..5a76e412 --- /dev/null +++ b/buildSrc/src/main/kotlin/module-common.gradle.kts @@ -0,0 +1,124 @@ +import net.ltgt.gradle.errorprone.CheckSeverity.WARN +import net.ltgt.gradle.errorprone.errorprone +import org.gradle.api.JavaVersion.VERSION_25 + +plugins { + `java-library` + id("io.freefair.lombok") + id("net.ltgt.errorprone") + id("com.github.ben-manes.versions") + `maven-publish` +} + +group = PROJECT_GROUP +version = PROJECT_VERSION + +java { + sourceCompatibility = VERSION_25 + targetCompatibility = VERSION_25 + withJavadocJar() + withSourcesJar() +} + +repositories { + mavenCentral() +} + +val guavaVersion = "33.7.1-jre" + +dependencies { + api("org.jspecify:jspecify:1.0.0") + api("com.google.guava:guava:$guavaVersion") + + implementation("org.slf4j:slf4j-api:2.0.20") + + errorprone("com.google.errorprone:error_prone_core:2.50.0") + errorprone("com.uber.nullaway:nullaway:0.14.2") + errorprone("net.jacobpeterson:final-coat:1.2.3") +} + +tasks.withType(JavaCompile::class).configureEach { + options.errorprone { + allErrorsAsWarnings = true + allSuggestionsAsWarnings = true + disableWarningsInGeneratedCode = true + excludedPaths = ".*/build/.*" + + disable("MissingSummary") + disable("NullableOptional") + check("Varifier", WARN) + check("IdentifierName", WARN) + check("MissingBraces", WARN) + check("FieldCanBeFinal", WARN) + check("MissingDefault", WARN) + check("SwitchDefault", WARN) + check("RedundantNullCheck", WARN) + check("FieldMissingNullable", WARN) + check("ParameterMissingNullable", WARN) + check("ReturnMissingNullable", WARN) + + check("NullAway", WARN) + option("NullAway:OnlyNullMarked", true) + option("NullAway:JSpecifyMode", true) + check("RequireExplicitNullMarking", WARN) + + check("FinalCoat", WARN) + } +} + +tasks.withType(Javadoc::class).configureEach { + options { + (this as StandardJavadocDocletOptions).addBooleanOption("Xdoclint:none", true) + links("https://docs.oracle.com/en/java/javase/${java.targetCompatibility.majorVersion}/docs/api/", + "https://jspecify.dev/docs/api/", + "https://guava.dev/releases/$guavaVersion/api/docs/", + "https://errorprone.info/api/latest/") + } + project.configurations + .flatMap { it.dependencies.withType(ProjectDependency::class) } + .map { project(it.path) } + .filter { it != this@configureEach.project } + .forEach { + it.tasks.withType(Javadoc::class).forEach { dependencyJavadocTask -> + this@configureEach.dependsOn(dependencyJavadocTask) + this@configureEach.options { + (this as StandardJavadocDocletOptions).linksOffline( + "https://javadoc.io/doc/${it.group}/${it.name}/${it.version}/", + dependencyJavadocTask.destinationDir!!.path) + } + } + } +} + +publishing { + publications.create("jreleaser", MavenPublication::class) { + from(components["java"]) + pom { + name = provider { artifactId } + description = provider { project.description } + url = "https://github.com/Petersoj/alpaca-java" + inceptionYear = "2025" + licenses { + license { + name = "MIT License" + url = "https://opensource.org/licenses/MIT" + } + } + developers { + developer { + id = "Petersoj" + name = "Jacob Peterson" + } + } + scm { + connection = pom.url.map { "scm:git:$it.git" } + developerConnection = connection + url = pom.url + } + } + } + repositories.maven { + name = "jreleaser" + url = uri(rootProject.layout.buildDirectory.dir(JRELEASER_MAVEN_REPOSITORY_DIRECTORY)) + } +} diff --git a/buildSrc/src/main/kotlin/openapi-generator-adapted.gradle.kts b/buildSrc/src/main/kotlin/openapi-generator-adapted.gradle.kts new file mode 100644 index 00000000..773e0a59 --- /dev/null +++ b/buildSrc/src/main/kotlin/openapi-generator-adapted.gradle.kts @@ -0,0 +1,329 @@ +import com.google.common.base.CaseFormat.LOWER_CAMEL +import com.google.common.base.CaseFormat.LOWER_HYPHEN +import com.google.common.base.CaseFormat.UPPER_CAMEL +import com.google.common.base.Splitter + +plugins { + `java-library` + id("org.openapi.generator") +} + +val jacksonVersion = "3.2.3" +val jacksonAnnotationsVersion = "2.22" + +dependencies { + api(project(":module:common")) + + api("tools.jackson.core:jackson-core:$jacksonVersion") + api("tools.jackson.core:jackson-databind:$jacksonVersion") + api("com.fasterxml.jackson.core:jackson-annotations:$jacksonAnnotationsVersion") +} + +val extension = extensions.create("openApiGeneratorAdapted", OpenApiGeneratorAdaptedExtension::class) +tasks.openApiGenerate.configure { + inputSpec = file("openapi.json") + generatorName = "java" + val outputPackageName = "${project.group}.${project.name}".replace("-", "") + configOptions.put("invokerPackage", outputPackageName) + val apiPackageName = "api" + configOptions.put("apiPackage", "$outputPackageName.$apiPackageName") + configOptions.put("modelPackage", "$outputPackageName.model") + configOptions.put("library", "native") + configOptions.put("documentationProvider", "none") + configOptions.put("useJackson3", "true") + configOptions.put("openApiNullable", "false") + cleanupOutput = true + skipValidateSpec = true + generateModelTests = false + generateModelDocumentation = false + generateApiTests = false + generateApiDocumentation = false + val projectName = project.name + val projectDescription = project.description + val environmentUrlProduction = extension.environmentUrlProduction.get() + val environmentUrlDevelopment = extension.environmentUrlDevelopment.get() + doLast { + val srcMainJava = outputDir.get().asFile.resolve("src/main/java/") + srcMainJava.walkTopDown().filter { it.isFile }.forEach { sourceFile -> + var source = sourceFile.readText() + .replaceFirst("\nimport", """ + import org.jspecify.annotations.*; + import net.jacobpeterson.alpacajava.common.sse.*; + import com.google.common.collect.ImmutableMap; + import java.util.Arrays; + import java.util.Locale; + import + """.trimIndent()) + .replace("@javax.annotation.Nullable", "@Nullable") + .replace("@javax.annotation.Nonnull", "@NonNull") + .replace("@javax.annotation.Generated", "@javax.annotation.processing.Generated") + .replace("if (memberVarResponseInterceptor != null) {\n " + + "memberVarResponseInterceptor.accept(localVarResponse);\n }\n " + + "InputStream localVarResponseBody = null;\n try {", + "InputStream localVarResponseBody = null;\n try {\n " + + "if (memberVarResponseInterceptor != null) {\n " + + "memberVarResponseInterceptor.accept(localVarResponse);\n }") + Regex("@JsonCreator\\n {2}public static ([\\w_]*)[\\s\\S]*?\\n {2}}").find(source)?.run { + val type = groupValues[1] + source = source.replaceRange(range.first, range.last + 1, """ + public static final ImmutableMap VALUES_OF_UPPERCASED_STRINGS = Arrays.stream(values()) + .collect(ImmutableMap.toImmutableMap(value -> value.toString().toUpperCase(Locale.ROOT), e -> e)); + @JsonCreator + public static $type fromValue(String value) { + return VALUES_OF_UPPERCASED_STRINGS.get(value.toUpperCase(Locale.ROOT)); + } + """.trimIndent()) + } + val headersCall = ".headers()" + source = source.replace("$headersCall.map()", headersCall) + val httpRequestNewBuilder = "HttpRequest.newBuilder()" + source = source.replace(httpRequestNewBuilder, + "$httpRequestNewBuilder.header(\"Accept-Encoding\", \"gzip\")") + var acceptCommaTextEventStreamIndex = 0 + while (source.indexOf("\"Accept\", \"text/event-stream\"", acceptCommaTextEventStreamIndex + 1) + .also { acceptCommaTextEventStreamIndex = it } != -1) { + val privateHttpRequestBuilder = "private HttpRequest.Builder " + val methodNameStartIndex = source.lastIndexOf(privateHttpRequestBuilder, + acceptCommaTextEventStreamIndex) + val methodName = source.substring(methodNameStartIndex + privateHttpRequestBuilder.length, + source.indexOf("RequestBuilder(", methodNameStartIndex)) + val methodIndex = source.indexOf(" $methodName(") + val methodJavadocAndAnnotations = source.substring(source.lastIndexOf("/**", methodIndex), + source.lastIndexOf("public", methodIndex)) + val methodLine = source.substring(source.lastIndexOf('\n', methodIndex) + 1, + source.indexOf('\n', methodIndex)) + val methodReturnType = Regex(" (?:List<)?([\\w_]*)>? $methodName").find(methodLine)!!.groupValues[1] + val methodArguments = Regex("$methodName\\((.*)\\)").find(methodLine)!!.groupValues[1] + val methodArgumentNames = Splitter.on(", ").split(methodArguments) + .joinToString { it.substring(it.lastIndexOf(' ')) } + val methodEndBrace = "\n }" + val methodRemove = IntRange(source.lastIndexOf("/**", methodIndex), + source.indexOf(methodEndBrace, source.indexOf(methodEndBrace, methodIndex) + 1) + + methodEndBrace.length) + source = source.removeRange(methodRemove) + acceptCommaTextEventStreamIndex -= methodRemove.last - methodRemove.first + val methodHttpInfoIndex = source.indexOf(" ${methodName}WithHttpInfo(") + val methodHttpInfoRemove = IntRange(source.lastIndexOf("/**", methodHttpInfoIndex), + source.indexOf(methodEndBrace, source.indexOf(methodEndBrace, methodHttpInfoIndex) + 1) + + methodEndBrace.length) + val sseMethods = """ + $methodJavadocAndAnnotations + public SseResponse $methodName($methodArguments, SseListener<$methodReturnType> sseListener) + throws ApiException { + return $methodName($methodArgumentNames, sseListener, null); + } + + $methodJavadocAndAnnotations + public SseResponse $methodName($methodArguments, SseListener<$methodReturnType> sseListener, + @Nullable Map headers) throws ApiException { + try { + var response = memberVarHttpClient.send( + ${methodName}RequestBuilder($methodArgumentNames, headers) + .setHeader("Accept-Encoding", "identity").build(), + HttpResponse.BodyHandlers.ofInputStream()); + try { + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(response); + } + if (response.statusCode() / 100 != 2) { + throw getApiException("$methodName", response); + } + return new SseResponse(memberVarHttpClient, response, sseListener, s -> { + try { + return memberVarObjectMapper.readValue(s, new TypeReference<$methodReturnType>() {}); + } catch (JacksonException e) { + throw new ApiException(e); + } + }); + } catch (Throwable throwable) { + response.body().close(); + throw throwable; + } + } catch (IOException e) { + throw new ApiException(e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + """.trimIndent() + source = source.replaceRange(methodHttpInfoRemove, sseMethods) + acceptCommaTextEventStreamIndex -= methodHttpInfoRemove.last - methodHttpInfoRemove.first + acceptCommaTextEventStreamIndex += sseMethods.length + } + sourceFile.writeText(source) + } + val outputPackageDirectory = srcMainJava.resolve(outputPackageName.replace('.', '/')) + outputPackageDirectory.resolve("ApiClient.java").apply { + val apiClientConstructor = "public ApiClient() {" + writeText(readText().replace(apiClientConstructor, + "public ApiClient(ObjectMapper mapper) { this.mapper = mapper; }$apiClientConstructor")) + } + outputPackageDirectory.resolve("ApiException.java").apply { + writeText(readText().replace("extends Exception {", "extends RuntimeException {")) + } + outputPackageDirectory.resolve("ApiResponse.java").apply { + writeText(readText().replace("Map>", "java.net.http.HttpHeaders")) + } + val apiClassNamesOfMethodNames = outputPackageDirectory.resolve(apiPackageName).list()!! + .map { it.replace(".java", "") } + .associateBy { UPPER_CAMEL.to(LOWER_CAMEL, it.substring(0, it.length - 3)) } + val className = "${LOWER_HYPHEN.to(UPPER_CAMEL, projectName)}Api" + outputPackageDirectory.resolve("${className}.java").writeText(""" + package ${outputPackageName}; + + import com.google.errorprone.annotations.concurrent.LazyInit; + import lombok.Getter; + import net.jacobpeterson.alpacajava.common.ApiHeader; + import net.jacobpeterson.alpacajava.common.ApiEnvironment; + import ${outputPackageName}.${apiPackageName}.*; + import org.jspecify.annotations.NullMarked; + import org.jspecify.annotations.Nullable; + import tools.jackson.databind.ObjectMapper; + import com.google.common.net.HttpHeaders; + + import java.io.InputStream; + import java.net.http.HttpClient; + import java.net.http.HttpRequest; + import java.net.http.HttpResponse; + import java.util.function.Consumer; + + import static java.time.Duration.ofSeconds; + import static java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor; + + /** + * {@link ${className}}: $projectDescription + */ + @NullMarked + public class $className { + + /** + * The URL for {@link ApiEnvironment#PRODUCTION}: "$environmentUrlProduction" + */ + public static final String ENVIRONMENT_URL_PRODUCTION ="$environmentUrlProduction"; + + /** + * The URL for {@link ApiEnvironment#DEVELOPMENT}: "$environmentUrlDevelopment" + */ + public static final String ENVIRONMENT_URL_DEVELOPMENT = "$environmentUrlDevelopment"; + + private final @Getter HttpClient httpClient; + private final ApiClient apiClient; + ${apiClassNamesOfMethodNames.entries.joinToString(separator = "\n ") { (methodName, apiClassName) -> + "private @Nullable @LazyInit $apiClassName $methodName;" }} + + /** + * Calls {@link #${className}(HttpClient, ObjectMapper, String, String, String, ApiEnvironment, Consumer, Consumer)} + * with everything set to null except authenticationKeyID, + * authenticationSecretKey, and apiEnvironment. + */ + public ${className}(final @Nullable String authenticationKeyID, final @Nullable String authenticationSecretKey, + final @Nullable ApiEnvironment apiEnvironment) { + this(null, null, authenticationKeyID, authenticationSecretKey, null, apiEnvironment, null, null); + } + + /** + * Calls {@link #${className}(HttpClient, ObjectMapper, String, String, String, ApiEnvironment, Consumer, Consumer)} + * with everything set to null except authorizationToken and apiEnvironment. + */ + public ${className}(final @Nullable String authorizationToken, final @Nullable ApiEnvironment apiEnvironment) { + this(null, null, null, null, authorizationToken, apiEnvironment, null, null); + } + + /** + * Instantiates a new {@link ${className}}. + * + * @param httpClient the {@link HttpClient}, or null to use a new default instance + * @param objectMapper the {@link ObjectMapper}, or null to use a new default instance + * @param authenticationKeyID the {@link ApiHeader#API_KEY_ID} value + * @param authenticationSecretKey the {@link ApiHeader#API_SECRET_KEY} value + * @param authorizationToken the {@link HttpHeaders#AUTHORIZATION} value (should start with + * {@link ApiHeader#AUTHORIZATION_BASIC_PREFIX} or + * {@link ApiHeader#AUTHORIZATION_BEARER_PREFIX}) + * @param apiEnvironment the {@link ApiEnvironment}. If {@link ApiEnvironment#PRODUCTION}, then + * {@link #ENVIRONMENT_URL_PRODUCTION} is used. If + * {@link ApiEnvironment#DEVELOPMENT}, then {@link #ENVIRONMENT_URL_DEVELOPMENT} + * is used. + * @param requestInterceptor the {@link HttpRequest.Builder} {@link Consumer} to invoke before sending a + * request + * @param responseInterceptor the {@link HttpResponse} {@link Consumer} to invoke before processing a response + */ + public ${className}(final @Nullable HttpClient httpClient, final @Nullable ObjectMapper objectMapper, + final @Nullable String authenticationKeyID, final @Nullable String authenticationSecretKey, + final @Nullable String authorizationToken, final @Nullable ApiEnvironment apiEnvironment, + final @Nullable Consumer requestInterceptor, + final @Nullable Consumer> responseInterceptor) { + this.httpClient = httpClient != null ? httpClient : HttpClient.newBuilder() + .connectTimeout(ofSeconds(10)) + .executor(newVirtualThreadPerTaskExecutor()) + .build(); + final var baseUri = apiEnvironment == ApiEnvironment.PRODUCTION ? ENVIRONMENT_URL_PRODUCTION : + ENVIRONMENT_URL_DEVELOPMENT; + apiClient = new ApiClient(objectMapper != null ? objectMapper : ApiClient.createDefaultObjectMapper()) { + + @Override + public HttpClient getHttpClient() { + // Re-use `HttpClient` instead of building a new one for each tag + return ${className}.this.httpClient; + } + + @Override + public String getBaseUri() { + return baseUri; + } + }; + apiClient.setReadTimeout(ofSeconds(10)); + apiClient.setRequestInterceptor(builder -> { + if (authenticationKeyID != null) { + builder.header(ApiHeader.API_KEY_ID, authenticationKeyID); + } + if (authenticationSecretKey != null) { + builder.header(ApiHeader.API_SECRET_KEY, authenticationSecretKey); + } + if (authorizationToken != null) { + builder.header(HttpHeaders.AUTHORIZATION, authorizationToken); + } + if (requestInterceptor != null) { + requestInterceptor.accept(builder); + } + }); + apiClient.setResponseInterceptor(responseInterceptor); + } + + ${apiClassNamesOfMethodNames.entries.joinToString(separator = "\n") { (methodName, apiClassName) -> """ + /** + * @return {@link ${apiClassName}} internally-cached instance + */ + public $apiClassName ${methodName}() { + if (${methodName} == null) { + $methodName = new ${apiClassName}(apiClient); + } + return ${methodName}; + } + """.trimIndent() }} + } + """.trimIndent()) + } +} +tasks.withType(JavaCompile::class).configureEach { + dependsOn(tasks.openApiGenerate) +} +tasks.withType(Jar::class).configureEach { + dependsOn(tasks.openApiGenerate) +} +sourceSets { + main { + java { + srcDir(openApiGenerate.outputDir.file("src/main/java/")) + } + } +} + +tasks.withType(Javadoc::class).configureEach { + options { + (this as StandardJavadocDocletOptions).links( + "https://javadoc.io/doc/tools.jackson.core/jackson-core/$jacksonVersion", + "https://javadoc.io/doc/tools.jackson.core/jackson-databind/$jacksonVersion", + "https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-annotations/$jacksonAnnotationsVersion") + } +} diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..3abdbb56 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,328 @@ +

+
+ + Logo +



+ + GitHub Repository + + GitHub Pages + + GitHub Discussions +
+ + Maven Central + + javadoc +
+ + Java Version + + License +
+
+ +# Table of Contents + +- [Introduction](#introduction) +- [Logging](#logging) +- [Number Representation for Currency Values](#number-representation-for-currency-values) +- [⚠️ WebSocket Support is Coming Soon ⚠️](#-websocket-support-is-coming-soon-) +- [Modules](#modules) + - [Trading](#trading) + - [Installation](#installation) + - [Example](#example) + - [Market Data](#market-data) + - [Installation](#installation-1) + - [Example](#example-1) + - [Broker](#broker) + - [Installation](#installation-2) + - [Example](#example-2) + +# Introduction + +This project is a Java client library for the [Alpaca](https://alpaca.markets) API. Alpaca is a brokerage platform that +lets you trade with algorithms, connect with apps, and build services all with a commission-free trading API for stocks, +crypto, options, and more. This library uses the [Alpaca OpenAPI Specifications](https://docs.alpaca.markets/us/openapi) +to generate clients for the REST API and provides a custom implementation for WebSocket and SSE support. This library is +community developed and if you have any questions, please ask them on +[GitHub Discussions](https://github.com/Petersoj/alpaca-java/discussions), the +[Alpaca Slack #dev-alpaca-java channel](https://alpaca.markets/slack), or on the +[Alpaca Forums](https://forum.alpaca.markets/). + +Alpaca Java offers three modules: [Trading](#trading), [Market Data](#market-data), and [Broker](#broker). + +Some awesome things about Alpaca Java: + +- Exhaustive Javadoc documentation +- Uses Java's native `HttpClient` (which also enables you to provide a different HTTP client implementation) +- Lightweight with minimal dependencies (only dependencies are: SLF4j, Guava, Jackson, MessagePack) +- Releases are built directly from this source repository using GitHub Actions CI +- Kotlin friendly +- MIT licensed + +Give this repository a star ⭐ and consider [sponsoring](https://github.com/sponsors/Petersoj) ❤️ + +# Logging + +For logging, this library uses [SLF4j](http://www.slf4j.org/) which serves as an interface for various logging +frameworks. This enables you to use whatever logging framework you would like. However, if you do not add a logging +framework as a dependency in your project, the console will output a message stating that SLF4j is defaulting to a +no-operation (NOP) logger implementation. To enable logging, add a logging framework of your choice as a runtime +dependency to your project such as [Logback](http://logback.qos.ch/), +[Log4j 2](http://logging.apache.org/log4j/2.x/index.html), [SLF4j-simple](http://www.slf4j.org/manual.html), or +[Apache Commons Logging](https://commons.apache.org/proper/commons-logging/). + +# Number Representation for Currency Values + +When working with currency values in computer memory, you may find yourself going back-and-forth between the `Double` +and `BigDecimal` number representations. This is a common issue. Consider using the +[Num](https://github.com/invision-trading/num) library to abstract this problem away as you develop your algorithmic +trading application. + +# ⚠️ WebSocket Support is Coming Soon ⚠️ + +Version 11 is a pre-release that provides the REST API and SSE support for the latest Alpaca OpenAPI specifications. +WebSocket support for streaming market data and trade updates is coming soon. Previous versions had WebSocket support +via OkHttp, but this library has switched to using Java's native `HttpClient` and WebSocket support is still a WIP. + +# Modules + +## Trading + +This module is for the Alpaca brokerage platform [Trading API](https://docs.alpaca.markets/us/docs/trading-api). + +### Installation + +For `build.gradle.kts`: + +```kotlin +dependencies { + implementation("net.jacobpeterson.alpaca-java:trading:11.0.0-pre.1") +} +``` + +For `build.gradle`: + +```groovy +dependencies { + implementation 'net.jacobpeterson.alpaca-java:trading:11.0.0-pre.1' +} +``` + +For `pom.xml`: + +```xml + + net.jacobpeterson.alpaca-java + trading + 11.0.0-pre.1 + +``` + +### Example + +```java +import net.jacobpeterson.alpacajava.common.ApiEnvironment; +import net.jacobpeterson.alpacajava.trading.TradingApi; +import net.jacobpeterson.alpacajava.trading.model.OrderSide; +import net.jacobpeterson.alpacajava.trading.model.OrderType; +import net.jacobpeterson.alpacajava.trading.model.PostOrderRequest; +import net.jacobpeterson.alpacajava.trading.model.TimeInForce; + +import java.math.BigDecimal; + +import static java.lang.Thread.sleep; +import static java.time.Duration.ofSeconds; +import static java.util.Objects.requireNonNull; + +public class Launcher { + + static void main() throws Exception { + final var keyID = ""; + final var secretKey = ""; + final var apiEnvironment = ApiEnvironment.DEVELOPMENT; // or `PRODUCTION` + final var tradingApi = new TradingApi(keyID, secretKey, apiEnvironment); + + // Print out account info + System.out.println(tradingApi.accounts().getAccount()); + + // Place a market order to buy one share of Apple + final var openingOrder = tradingApi.orders() + .postOrder(new PostOrderRequest() + .symbol("AAPL") + .qty("1") + .side(OrderSide.BUY) + .type(OrderType.MARKET) + .timeInForce(TimeInForce.GTC)); + System.out.println("Opening Apple order: " + openingOrder); + + // Wait for massive gains + sleep(ofSeconds(10)); + + // Close the Apple position + final var closingOrder = tradingApi.positions() + .deleteOpenPosition("AAPL", null, new BigDecimal("100")); + System.out.println("Closing Apple order: " + closingOrder); + + // Wait for closing trade to fill. For this example, we're sleeping, but in production, + // this should be done using polling or listening to the trade updates stream + sleep(ofSeconds(10)); + + // Print out the PnL of our Apple trade + final var openFillPrice = tradingApi.orders() + .getOrderByOrderID(requireNonNull(openingOrder.getId()), false) + .getFilledAvgPrice(); + final var closeFillPrice = tradingApi.orders() + .getOrderByOrderID(requireNonNull(closingOrder.getId()), false) + .getFilledAvgPrice(); + System.out.println("PnL from Apple trade: " + new BigDecimal(requireNonNull(closeFillPrice)) + .subtract(new BigDecimal(requireNonNull(openFillPrice)))); + } +} +``` + +## Market Data + +This module is for the Alpaca brokerage platform +[Market Data API](https://docs.alpaca.markets/us/docs/about-market-data-api). + +### Installation + +For `build.gradle.kts`: + +```kotlin +dependencies { + implementation("net.jacobpeterson.alpaca-java:market-data:11.0.0-pre.1") +} +``` + +For `build.gradle`: + +```groovy +dependencies { + implementation 'net.jacobpeterson.alpaca-java:market-data:11.0.0-pre.1' +} +``` + +For `pom.xml`: + +```xml + + net.jacobpeterson.alpaca-java + market-data + 11.0.0-pre.1 + +``` + +### Example + +```java +import net.jacobpeterson.alpacajava.common.ApiEnvironment; +import net.jacobpeterson.alpacajava.marketdata.MarketDataApi; +import net.jacobpeterson.alpacajava.marketdata.model.CryptoLatestLoc; +import net.jacobpeterson.alpacajava.marketdata.model.CryptoOrderbookEntry; +import net.jacobpeterson.alpacajava.marketdata.model.StockLatestFeed; + +public class Launcher { + + static void main() throws Exception { + final var keyID = ""; + final var secretKey = ""; + final var apiEnvironment = ApiEnvironment.PRODUCTION; // or `DEVELOPMENT` for Broker Sandbox + final var marketDataApi = new MarketDataApi(keyID, secretKey, apiEnvironment); + + // Print out the latest Tesla trade + System.out.println(marketDataApi.stock() + .stockLatestTradeSingle("TSLA", StockLatestFeed.IEX, null)); + + // Print out the lowest Bitcoin ask price on the order book + System.out.println("Bitcoin lowest ask price: " + marketDataApi.crypto() + .cryptoLatestOrderbooks(CryptoLatestLoc.US, "BTC/USD").getOrderbooks().get("BTC/USD") + .getA().stream() + .map(CryptoOrderbookEntry::getP) + .min(Double::compare) + .orElseThrow()); + } +} +``` + +## Broker + +This module is for the Alpaca brokerage platform [Broker API](https://docs.alpaca.markets/us/docs/about-broker-api). + +### Installation + +For `build.gradle.kts`: + +```kotlin +dependencies { + implementation("net.jacobpeterson.alpaca-java:broker:11.0.0-pre.1") +} +``` + +For `build.gradle`: + +```groovy +dependencies { + implementation 'net.jacobpeterson.alpaca-java:broker:11.0.0-pre.1' +} +``` + +For `pom.xml`: + +```xml + + net.jacobpeterson.alpaca-java + broker + 11.0.0-pre.1 + +``` + +### Example + +```java +import net.jacobpeterson.alpacajava.broker.BrokerApi; +import net.jacobpeterson.alpacajava.broker.BrokerApiUtil; +import net.jacobpeterson.alpacajava.broker.model.CreateOrderRequest; +import net.jacobpeterson.alpacajava.broker.model.OrderSide; +import net.jacobpeterson.alpacajava.broker.model.OrderType; +import net.jacobpeterson.alpacajava.broker.model.TimeInForce; +import net.jacobpeterson.alpacajava.common.ApiEnvironment; +import net.jacobpeterson.alpacajava.common.ApiHeader; +import net.jacobpeterson.alpacajava.common.sse.SseListenerAdapter; + +import java.math.BigDecimal; +import java.util.UUID; + +import static java.lang.Thread.sleep; +import static java.time.Duration.ofSeconds; + +public class Launcher { + + static void main() throws Exception { + final var authorizationToken = BrokerApiUtil.getAuthorizationToken("", ""); + final var apiEnvironment = ApiEnvironment.DEVELOPMENT; // or `PRODUCTION` + final var brokerApi = new BrokerApi(ApiHeader.AUTHORIZATION_BASIC_PREFIX + authorizationToken, apiEnvironment); + + // Listen to the trade events via SSE and print them out + final var tradesStream = brokerApi.events() + .subscribeToTradeV2SSE(null, null, null, null, new SseListenerAdapter<>()); + + // Buy one share of GME for an account + System.out.println(brokerApi.trading() + .createOrderForAccount(UUID.fromString(""), new CreateOrderRequest() + .symbol("GME") + .qty(BigDecimal.ONE) + .side(OrderSide.BUY) + .timeInForce(TimeInForce.GTC) + .type(OrderType.MARKET))); + + // Wait a little bit + sleep(ofSeconds(10)); + + // Close the SSE stream + tradesStream.close(); + } +} +``` diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 00000000..9258ea5d --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1,5 @@ +plugins: + - jekyll-remote-theme +remote_theme: jekyll/minima@4de3223 +minima: + skin: auto diff --git a/docs/_layouts/base.html b/docs/_layouts/base.html new file mode 100644 index 00000000..5f621aa7 --- /dev/null +++ b/docs/_layouts/base.html @@ -0,0 +1,12 @@ + + + +{%- include head.html -%} + +
+
+ {{ content }} +
+
+ + diff --git a/docs/logo.svg b/docs/logo.svg new file mode 100644 index 00000000..6a2c6b10 --- /dev/null +++ b/docs/logo.svg @@ -0,0 +1 @@ + diff --git a/eclipse-java-google-style.xml b/eclipse-java-google-style.xml deleted file mode 100644 index 2a9faacc..00000000 --- a/eclipse-java-google-style.xml +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..64701b8a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.jvmargs=-XX:MaxRAMPercentage=100 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=15 -XX:+UseG1GC -XX:G1PeriodicGCInterval=60000 +org.gradle.logging.level=info +org.gradle.logging.stacktrace=all +org.gradle.configuration-cache=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7855f0a6..b1b8ef56 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7acf1540..ad7845be 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,9 @@ -#Mon Jun 18 11:04:32 CDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip +networkTimeout=10000 +retries=0 +retryBackOffMs=500 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip diff --git a/gradlew b/gradlew index 4453ccea..b9bb139f 100755 --- a/gradlew +++ b/gradlew @@ -1,78 +1,128 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,92 +131,118 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save ( ) { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f9553162..aa5f10b0 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,84 +1,82 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/lombok.config b/lombok.config new file mode 100644 index 00000000..d266d7ff --- /dev/null +++ b/lombok.config @@ -0,0 +1,8 @@ +config.stopBubbling = true +lombok.accessors.chain = true +lombok.addLombokGeneratedAnnotation = true +lombok.addNullAnnotations = jspecify +lombok.toString.callSuper = call +lombok.equalsAndHashCode.callSuper = call +lombok.builder.className = Builder +lombok.log.fieldName = LOGGER diff --git a/module/broker/build.gradle.kts b/module/broker/build.gradle.kts new file mode 100644 index 00000000..0aafcbe5 --- /dev/null +++ b/module/broker/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("module-common") + id("openapi-generator-adapted") +} + +description = "A Java library for the Alpaca brokerage platform Broker API." + +openApiGeneratorAdapted { + environmentUrlProduction = "https://broker-api.alpaca.markets" + environmentUrlDevelopment = "https://broker-api.sandbox.alpaca.markets" +} diff --git a/module/broker/openapi.json b/module/broker/openapi.json new file mode 100644 index 00000000..3e61e7cd --- /dev/null +++ b/module/broker/openapi.json @@ -0,0 +1,26508 @@ +{ + "components": { + "examples": { + "CryptoOrderResponse": { + "value": { + "asset_class": "crypto", + "asset_id": "a1733398-6acc-4e92-af24-0d0667f78713", + "canceled_at": null, + "client_order_id": "5b5d3d67-06ad-4ffa-af65-a117d0fc5a59", + "created_at": "2023-12-12T22:36:51.337711497Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "38e482f3-79a8-4f75-a057-f07a1ec6a397", + "legs": null, + "limit_price": "2100", + "notional": null, + "order_class": "", + "order_type": "limit", + "qty": "0.02", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "pending_new", + "stop_price": null, + "submitted_at": "2023-12-12T22:36:51.313261061Z", + "subtag": null, + "symbol": "ETH/USD", + "time_in_force": "gtc", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2023-12-12T22:36:51.337754768Z" + } + }, + "EquityOrderResponse": { + "value": { + "asset_class": "us_equity", + "asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "canceled_at": null, + "client_order_id": "5680c4bc-9ac1-4a12-a44c-df427ba53032", + "created_at": "2023-12-12T22:31:24.668464435Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "7b08df51-c1ac-453c-99f9-323a5f075f0d", + "legs": null, + "limit_price": "150", + "notional": null, + "order_class": "", + "order_type": "limit", + "qty": "2", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "accepted", + "stop_price": null, + "submitted_at": "2023-12-12T22:31:24.577215743Z", + "subtag": null, + "symbol": "AAPL", + "time_in_force": "gtc", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2023-12-12T22:31:24.668464435Z" + } + }, + "IPOEventAllocation": { + "summary": "Final allocation result for an account (account-scoped event)", + "value": { + "account_id": "6221407b-32b2-3e6b-a7fe-cd79e1b68ba3", + "at": "2026-03-20T00:15:42.318901Z", + "correspondent": "COR1", + "event_id": "01J9RTPZGHKVB8M3X4F5J7LCQ9", + "offering_reference": "FI111225", + "payload": { + "allocated_amount": "1764", + "allocated_shares": "42", + "cusip_id": "123456789", + "final_price": "42", + "subject": "IPO Allocation: Example Corp" + }, + "received_at": "2026-03-20T00:15:42.103572Z", + "verb": "Allocation" + } + }, + "IPOEventOffering": { + "summary": "New IPO offering published", + "value": { + "at": "2026-03-20T12:24:58.807230Z", + "event_id": "01J9RPMV5TKB8WX3M4F1KZ7QH2", + "offering_reference": "FI111225", + "payload": { + "available_to_order": "Available", + "max_price": "42", + "min_price": "42", + "name": "Example Corp", + "source": "example source", + "ticker_symbol": "EXMP" + }, + "received_at": "2026-03-20T12:24:58.500000Z", + "verb": "Offering" + } + }, + "IPOEventOfferingCancellation": { + "summary": "Offering was cancelled (no payload field)", + "value": { + "at": "2026-03-20T12:24:52.325158Z", + "event_id": "01J9RVB6Y4ZK8M3N7QD2WX1RFP", + "offering_reference": "FI111225", + "received_at": "2026-03-20T12:24:52.110430Z", + "verb": "OfferingCancellation" + } + }, + "IPOEventOfferingUpdate": { + "summary": "Existing offering updated (e.g. price range narrowed)", + "value": { + "at": "2026-03-20T15:42:11.118274Z", + "event_id": "01J9RQ5HNZQK7M3RDVJ8XBPCT1", + "offering_reference": "FI111225", + "payload": { + "available_to_order": "Available", + "max_price": "44", + "min_price": "40", + "name": "Example Corp", + "source": "example source", + "ticker_symbol": "EXMP" + }, + "received_at": "2026-03-20T15:42:10.892140Z", + "verb": "OfferingUpdate" + } + }, + "IPOEventProspectus": { + "summary": "Prospectus document is now available", + "value": { + "at": "2026-03-19T23:26:46.853262Z", + "event_id": "01J9RSGD8JR2A4K7MZNTPVQ5XW", + "offering_reference": "FI111225", + "payload": { + "prospectus_url": "https://example.com/prospectus/example-corp.pdf", + "subject": "IPO Prospectus: Example Corp" + }, + "received_at": "2026-03-19T23:26:46.612880Z", + "verb": "Prospectus" + } + }, + "IPOEventSixtyMinMail": { + "summary": "60-minute pricing window opened (no new orders accepted)", + "value": { + "at": "2026-03-19T22:50:11.729329Z", + "event_id": "01J9RT9P3WYH8KCJM2LFQX5ZRD", + "offering_reference": "FI111225", + "payload": { + "sixty_minute_expiration_time": "2026-03-19T23:50:11.729329Z", + "subject": "IPO 60 Minute Mail: Example Corp" + }, + "received_at": "2026-03-19T22:50:11.512640Z", + "verb": "SixtyMinMail" + } + }, + "IPOOfferingGetExample": { + "summary": "Single IPO offering", + "value": { + "data": { + "anticipated_shares": 5000000, + "availability": "available", + "cusip_id": "123456789", + "description": "Example Corp is a leading provider of example services.", + "ipo_reference": "FI111225", + "logo_small": "https://example.com/logos/exmp-small.png", + "max_price": "44", + "max_ticket_size": "100000", + "min_price": "40", + "min_ticket_size": "100", + "name": "Example Corp", + "no_new_orders": false, + "offering_type": "IPO", + "prospectus_url": "https://example.com/prospectus/example-corp.pdf", + "settlement_date": "2026-04-04", + "ticker_symbol": "EXMP", + "trade_date": "2026-04-02", + "underwriters": [ + "Goldman Sachs", + "Morgan Stanley" + ], + "unit_step_size": "1" + } + } + }, + "IPOOfferingListExample": { + "summary": "Page of available IPO offerings", + "value": { + "data": [ + { + "anticipated_shares": 5000000, + "availability": "available", + "cusip_id": "123456789", + "description": "Example Corp is a leading provider of example services.", + "ipo_reference": "FI111225", + "logo_small": "https://example.com/logos/exmp-small.png", + "max_price": "44", + "max_ticket_size": "100000", + "min_price": "40", + "min_ticket_size": "100", + "name": "Example Corp", + "no_new_orders": false, + "offering_type": "IPO", + "prospectus_url": "https://example.com/prospectus/example-corp.pdf", + "settlement_date": "2026-04-04", + "ticker_symbol": "EXMP", + "trade_date": "2026-04-02", + "underwriters": [ + "Goldman Sachs", + "Morgan Stanley" + ], + "unit_step_size": "1" + } + ], + "next_page_token": null + } + }, + "IPOOrderResponse": { + "value": { + "asset_class": "ipo", + "asset_id": "9b6c7c1a-9eb2-4d4a-8a3a-1bf4c1d5cbaa", + "canceled_at": null, + "client_order_id": "0b3a90b6-6b5c-4d83-8c0e-9b3eaf4a8d11", + "created_at": "2025-09-15T13:30:42.117344821Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "5e2a8f1a-9c10-4d3a-8c64-7f59c1d18c11", + "legs": null, + "limit_price": null, + "notional": "500", + "order_class": "", + "order_type": "market", + "qty": null, + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "accepted", + "stop_price": null, + "submitted_at": "2025-09-15T13:30:42.094518219Z", + "subtag": null, + "symbol": "FI111225", + "time_in_force": "gtc", + "trail_percent": null, + "trail_price": null, + "type": "market", + "updated_at": "2025-09-15T13:30:42.117344821Z" + } + }, + "MultilegOptionsOrderResponse": { + "value": { + "asset_class": "", + "asset_id": "", + "canceled_at": null, + "client_order_id": "646b1fe6-b212-4f54-94c6-429e7bcdee04", + "created_at": "2024-12-10T16:15:53.677230742Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": "2024-12-10T16:15:53.694Z", + "filled_avg_price": "1.28", + "filled_qty": "1", + "hwm": null, + "id": "83f37e9f-6b1f-49ed-8fc6-3e6af716323f", + "legs": [ + { + "asset_class": "us_option", + "asset_id": "f0ea14b2-8a49-4e9b-89d1-894c6e518a76", + "canceled_at": null, + "client_order_id": "cc8cc104-fe43-476c-b25c-f62650fb73f9", + "created_at": "2024-12-10T16:15:53.677230742Z", + "expired_at": null, + "expires_at": "2024-12-10T21:00:00Z", + "extended_hours": false, + "failed_at": null, + "filled_at": "2024-12-10T16:15:53.694Z", + "filled_avg_price": "0.43", + "filled_qty": "3", + "hwm": null, + "id": "df4ff24a-c58a-4e37-8b9f-ef32b83a11f2", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "mleg", + "order_type": "", + "position_intent": "buy_to_open", + "qty": "3", + "ratio_qty": "3", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "filled", + "stop_price": null, + "submitted_at": "2024-12-10T16:15:53.684952901Z", + "subtag": null, + "symbol": "AAPL241213C00250000", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "", + "updated_at": "2024-12-10T16:15:53.725091158Z" + }, + { + "asset_class": "us_option", + "asset_id": "f89940db-eeb1-46e6-8f9b-bb1f27a0b395", + "canceled_at": null, + "client_order_id": "0bd2d36d-4af2-4dfb-8418-333a5d5026fa", + "created_at": "2024-12-10T16:15:53.677230742Z", + "expired_at": null, + "expires_at": "2024-12-10T21:00:00Z", + "extended_hours": false, + "failed_at": null, + "filled_at": "2024-12-10T16:15:53.694Z", + "filled_avg_price": "0.01", + "filled_qty": "1", + "hwm": null, + "id": "ecd91110-c34d-4e9d-a7bf-a9c27c40f8b5", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "mleg", + "order_type": "", + "position_intent": "sell_to_open", + "qty": "1", + "ratio_qty": "1", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "sell", + "source": null, + "status": "filled", + "stop_price": null, + "submitted_at": "2024-12-10T16:15:53.684952901Z", + "subtag": null, + "symbol": "AAPL241213C00260000", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "", + "updated_at": "2024-12-10T16:15:53.708983759Z" + } + ], + "limit_price": "10", + "notional": null, + "order_class": "mleg", + "order_type": "limit", + "qty": "1", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "", + "source": null, + "status": "filled", + "stop_price": null, + "submitted_at": "2024-12-10T16:15:53.684952901Z", + "subtag": null, + "symbol": "", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2024-12-10T16:15:53.725139688Z" + } + }, + "OptionOrderResponse": { + "value": { + "asset_class": "us_option", + "asset_id": "98359ef7-5124-49f3-85ea-5cf02df6defa", + "canceled_at": null, + "client_order_id": "58cd43a7-029e-457e-b77f-cd4f61f00f2a", + "created_at": "2023-12-12T21:35:49.102449524Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "30a077fa-96f6-4f20-a052-4b921ee2f243", + "legs": null, + "limit_price": "10", + "notional": null, + "order_class": "simple", + "order_type": "limit", + "qty": "2", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "pending_new", + "stop_price": null, + "submitted_at": "2023-12-12T21:35:49.056332248Z", + "subtag": null, + "symbol": "AAPL250620C00100000", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2023-12-12T21:35:49.102504673Z" + } + }, + "TradeUpdateEventV2MultilegOptionsFill": { + "value": { + "account_id": "529248ad-c4cc-4a50-bea4-6bfd2953f83a", + "at": "2025-01-14T16:05:51.872012Z", + "event": "fill", + "event_id": "01G112NTT0XAXKDZK3AABK68TH", + "legs": [ + { + "execution_id": "ccf7d1dc-78e1-4eb5-92c6-5c86b2bcca8f", + "order_id": "8d58279f-7dc8-415f-8495-32f394935509", + "price": "0.04", + "qty": "1", + "symbol": "AAPL250117P00200000", + "timestamp": "2025-01-14T16:05:51.867802561Z" + }, + { + "execution_id": "06f94555-6db7-4059-a4c4-0b993084ccd0", + "order_id": "8b0e2cff-eace-4e6a-8810-cad42c63df59", + "price": "0.03", + "qty": "1", + "symbol": "AAPL250117C00250000", + "timestamp": "2025-01-14T16:05:51.867813051Z" + } + ], + "order": { + "asset_class": "", + "asset_id": "00000000-0000-0000-0000-000000000000", + "cancel_requested_at": null, + "canceled_at": null, + "client_order_id": "9d2f39de-adae-4dae-a67e-838bf21fb5ae", + "created_at": "2025-01-14T16:05:51.79424769Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": "2025-01-14T16:05:51.867813051Z", + "filled_avg_price": "0.07", + "filled_qty": "1", + "hwm": null, + "id": "8af45a94-0b35-4053-ad4e-716c6783fcc9", + "legs": [ + { + "asset_class": "us_option", + "asset_id": "8d1ba989-d98b-4551-889f-4647c2e86e20", + "cancel_requested_at": null, + "canceled_at": null, + "client_order_id": "9c5ce763-bd6f-41eb-b1b1-ed2c0b99d268", + "created_at": "2025-01-14T16:05:51.79424769Z", + "expired_at": null, + "expires_at": "2025-01-14T21:00:00Z", + "extended_hours": false, + "failed_at": null, + "filled_at": "2025-01-14T16:05:51.867802561Z", + "filled_avg_price": "0.04", + "filled_qty": "1", + "hwm": null, + "id": "8d58279f-7dc8-415f-8495-32f394935509", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "mleg", + "order_type": "", + "position_intent": "buy_to_open", + "qty": "1", + "ratio_qty": "1", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "status": "filled", + "stop_price": null, + "submitted_at": "2025-01-14T16:05:51.800245966Z", + "symbol": "AAPL250117P00200000", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "", + "updated_at": "2025-01-14T16:05:51.869810922Z" + }, + { + "asset_class": "us_option", + "asset_id": "e9f8c9ba-de7c-4e51-9eef-629f4cb79049", + "cancel_requested_at": null, + "canceled_at": null, + "client_order_id": "9cda9826-8fd5-4c01-8ee1-30c5286e2387", + "created_at": "2025-01-14T16:05:51.79424769Z", + "expired_at": null, + "expires_at": "2025-01-14T21:00:00Z", + "extended_hours": false, + "failed_at": null, + "filled_at": "2025-01-14T16:05:51.867813051Z", + "filled_avg_price": "0.03", + "filled_qty": "1", + "hwm": null, + "id": "8b0e2cff-eace-4e6a-8810-cad42c63df59", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "mleg", + "order_type": "", + "position_intent": "buy_to_open", + "qty": "1", + "ratio_qty": "1", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "status": "filled", + "stop_price": null, + "submitted_at": "2025-01-14T16:05:51.802310606Z", + "symbol": "AAPL250117C00250000", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "", + "updated_at": "2025-01-14T16:05:51.870879612Z" + } + ], + "limit_price": "0.6", + "notional": null, + "order_class": "mleg", + "order_type": "limit", + "position_intent": "", + "qty": "1", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "status": "filled", + "stop_price": null, + "submitted_at": "2025-01-14T16:05:51.802310606Z", + "symbol": "", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2025-01-14T16:05:51.870937762Z" + }, + "position_qtys": { + "AAPL250117C00250000": "1", + "AAPL250117P00200000": "1" + }, + "price": "0.07", + "qty": "1", + "timestamp": "2025-01-14T16:05:51.867813051Z" + } + }, + "TradeUpdateEventV2New": { + "value": { + "account_id": "529248ad-c4cc-4a50-bea4-6bfd2953f83a", + "at": "2022-04-19T14:12:30.656741Z", + "event": "new", + "event_id": "01G112NTT0XAXKDZK3AABK68TH", + "execution_id": "7e544af3-3104-4e1a-8cbc-dab2624949ff", + "order": { + "asset_class": "us_equity", + "asset_id": "a4778bc8-fad1-47b7-87fe-d5cde10d43f4", + "cancel_requested_at": null, + "canceled_at": null, + "client_order_id": "6d873193-dac6-4f72-8e13-c57853a9339d", + "commission": "1", + "created_at": "2022-04-19T10:12:30.57117938-04:00", + "expired_at": null, + "expires_at": "2022-04-19T21:00:00Z", + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "edada91a-8b55-4916-a153-8c7a9817e708", + "legs": null, + "limit_price": "700", + "notional": null, + "order_class": "", + "order_type": "limit", + "position_intent": "buy_to_open", + "qty": "4", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "status": "new", + "stop_price": null, + "submitted_at": "2022-04-19T10:12:30.403135025-04:00", + "symbol": "TSLA", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2022-04-19T10:12:30.609783218-04:00" + }, + "previous_execution_id": "aeb60660-412f-4537-8d1f-1101b3fc8f64", + "timestamp": "2022-04-19T14:12:30.602193534Z" + } + }, + "TravelRuleValidationError": { + "description": "The request requires the beneficiary's name before the transfer can proceed.", + "summary": "Missing beneficiary name", + "value": { + "error_code": "BENEFICIARY_NAME_REQUIRED", + "message": "Please provide the beneficiary's name. Select one of the following options.", + "next_actions": [ + { + "description": "Provide the recipient's first and last name.", + "name": "supply_beneficiaryName_naturalPerson", + "required_fields": [ + { + "description": "The recipient's first name.", + "field": "beneficiary_given_name", + "value_type": "string" + }, + { + "description": "The recipient's last name.", + "field": "beneficiary_family_name", + "value_type": "string" + } + ], + "type": "ONE_OF" + }, + { + "description": "Provide the entity's legal name.", + "name": "supply_beneficiaryName_legalEntity", + "required_fields": [ + { + "description": "The legal name of the receiving entity.", + "field": "beneficiary_entity_name", + "value_type": "string" + } + ], + "type": "ONE_OF" + } + ] + } + } + }, + "headers": { + "ratelimit_limit": { + "description": "Request limit per minute.", + "example": 100, + "schema": { + "type": "integer" + } + }, + "ratelimit_remaining": { + "description": "Request limit per minute remaining.", + "example": 90, + "schema": { + "type": "integer" + } + }, + "ratelimit_reset": { + "description": "The UNIX epoch when the remaining quota changes.", + "example": 1674044551, + "schema": { + "type": "integer" + } + } + }, + "parameters": { + "AccountDocumentType": { + "description": "The type of the account document", + "in": "query", + "name": "type", + "required": false, + "schema": { + "enum": [ + "account_application", + "account_statement", + "crypto_account_statement", + "options_application", + "tax_statement", + "trade_confirmation_json", + "trade_confirmation" + ], + "example": "account_statement", + "type": "string" + } + }, + "AccountID": { + "description": "Account identifier.", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + "ActivityType": { + "description": "see ActivityType model for details about what the different types mean", + "in": "path", + "name": "activity_type", + "required": true, + "schema": { + "enum": [ + "FILL", + "ACATC", + "ACATS", + "CGD", + "CIL", + "CSD", + "CSW", + "DIV", + "DIVCGL", + "DIVCGS", + "DIVNRA", + "DIVROC", + "DIVTXEX", + "FEE", + "INT", + "MEM", + "JNLC", + "JNLS", + "MA", + "OPASN", + "OPCA", + "OPCSH", + "OPEXC", + "OPEXP", + "OPTRD", + "PTC", + "REO", + "REORG", + "SPIN", + "SPLIT", + "FOPT", + "OCT" + ], + "type": "string" + } + }, + "After": { + "description": "The response will include only ones submitted after this timestamp (exclusive)", + "in": "query", + "name": "after", + "schema": { + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + }, + "AssetClass": { + "description": "A comma-separated list of asset classes, the response will include only orders in the specified asset classes. By specifying `us_option` as the class, you can query option orders by underlying symbol using the symbols parameter.", + "in": "query", + "name": "asset_class", + "schema": { + "items": { + "enum": [ + "us_equity", + "us_option", + "crypto", + "all" + ], + "type": "string" + }, + "type": "array" + } + }, + "Direction": { + "description": "The chronological order of response based on the submission time. asc or desc. Defaults to desc.", + "in": "query", + "name": "direction", + "schema": { + "enum": [ + "asc", + "desc" + ], + "example": "desc", + "type": "string" + } + }, + "DocumentID": { + "description": "Document identifier.", + "in": "path", + "name": "document_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + "LegacyIdempotencyKey": { + "description": "Optional client-generated key for safe retries and duplicate request detection.\nThis endpoint currently accepts keys up to 128 characters. Alpaca is moving toward\na 36-character maximum; new implementations should generate a unique UUIDv7 or\nUUIDv4 value (36 characters including hyphens) for each logical operation. Do not\nreuse a key across operations.\n", + "in": "header", + "name": "Idempotency-Key", + "required": false, + "schema": { + "maxLength": 128, + "type": "string" + } + }, + "OrderID": { + "description": "Order identifier.", + "in": "path", + "name": "order_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + "PageToken": { + "description": "Used for pagination, this token retrieves the next page of results. It is obtained from the response of the preceding page when additional pages are available.", + "in": "query", + "name": "page_token", + "required": false, + "schema": { + "example": "MA==", + "type": "string" + } + }, + "Sort": { + "description": "The chronological order of response based on the submission time. asc or desc. Defaults to desc.", + "in": "query", + "name": "sort", + "schema": { + "enum": [ + "asc", + "desc" + ], + "example": "desc", + "type": "string" + } + }, + "Symbols": { + "description": "A comma-separated list of symbols to filter by.", + "in": "query", + "name": "symbols", + "schema": { + "example": "AAPL,TSLA,MSFT", + "type": "string" + } + }, + "Until": { + "description": "The response will include only ones submitted until this timestamp (exclusive)", + "in": "query", + "name": "until", + "schema": { + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + }, + "end": { + "description": "The last date to retrieve data for (inclusive). Default: one week from the start date.\n", + "example": "2030-01-01", + "in": "query", + "name": "end", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + "legacy_date_type": { + "description": "Indicates what start and end mean. Default: TRADING. If TRADING is specified, returns a calendar whose trading date matches start, end. If SETTLEMENT is specified, returns the calendar whose settlement date matches start and end.\n", + "in": "query", + "name": "date_type", + "schema": { + "enum": [ + "TRADING", + "SETTLEMENT" + ], + "type": "string" + } + }, + "legacy_end": { + "description": "The last date to retrieve data for (inclusive).", + "in": "query", + "name": "end", + "schema": { + "format": "date-time", + "type": "string" + } + }, + "legacy_start": { + "description": "The first date to retrieve data for (inclusive).", + "in": "query", + "name": "start", + "schema": { + "format": "date-time", + "type": "string" + } + }, + "market": { + "description": "The market identifier. MIC, BIC, or acronym.\n\nAvailable market codes by region:\n\n**United States**\n- `BMO`: Bank of Montreal. US banking calendar (US operations).\n- `BNYM`: The Bank of New York Mellon. US banking calendar.\n- `BOATS`: Blue Ocean Alternative Trading System. US overnight trading.\n- `IEX`: Investors Exchange. US equities.\n- `IEXG`: Investors Exchange. US equities.\n- `NASDAQ`: National Association of Securities Dealers Automated Quotations. US equities.\n- `NYSE`: New York Stock Exchange. US equities.\n- `OCEA`: BlueOcean ATS. US overnight trading.\n- `OPRA`: Options Price Reporting Authority. US options.\n- `OTC`: Over-The-Counter. US OTC equities.\n- `OTCM`: OTC Markets. US OTC equities.\n- `SIFMA`: Securities Industry and Financial Markets Association. US bonds.\n- `XNAS`: NASDAQ. US equities.\n- `XNYS`: New York Stock Exchange. US equities.\n\n**Europe**\n- `CEUX`: Cboe CEUX Europe. European equities (Cboe Netherlands).\n- `CHIX`: Cboe CHIX Europe. European equities (Cboe UK).\n- `ISE`: Euronext Dublin. Irish equities.\n- `LSE`: London Stock Exchange. UK equities.\n- `MTA`: Euronext Milan. Italian equities.\n- `MTAA`: Euronext Milan. Italian equities.\n- `XAMS`: Euronext Amsterdam. Dutch equities.\n- `XBRU`: Euronext Brussels. Belgian equities.\n- `XDUB`: Euronext Dublin. Irish equities.\n- `XETR`: Frankfurt Stock Exchange. German equities.\n- `XETRA`: Frankfurt Stock Exchange. German equities.\n- `XLIS`: Euronext Lisbon. Portuguese equities.\n- `XLON`: London Stock Exchange. UK equities.\n- `XPAR`: Euronext Paris. French equities.\n\n**Asia & Middle East**\n- `HKEX`: Hong Kong Stock Exchange. Hong Kong equities.\n- `JPX`: Japan Exchange Group. Japanese equities.\n- `TADAWUL`: Saudi Stock Exchange. Saudi equities.\n- `XHKG`: Hong Kong Stock Exchange. Hong Kong equities.\n- `XSAU`: Saudi Stock Exchange. Saudi equities.\n- `XTKS`: Japan Exchange Group. Japanese equities.\n", + "in": "path", + "name": "market", + "required": true, + "schema": { + "$ref": "#/components/schemas/market" + } + }, + "markets": { + "description": "Comma-separated list of markets. Available market codes by region:\n\n**United States**\n- `BMO`: Bank of Montreal. US banking calendar (US operations).\n- `BNYM`: The Bank of New York Mellon. US banking calendar.\n- `BOATS`: Blue Ocean Alternative Trading System. US overnight trading.\n- `IEX`: Investors Exchange. US equities.\n- `IEXG`: Investors Exchange. US equities.\n- `NASDAQ`: National Association of Securities Dealers Automated Quotations. US equities.\n- `NYSE`: New York Stock Exchange. US equities.\n- `OCEA`: BlueOcean ATS. US overnight trading.\n- `OPRA`: Options Price Reporting Authority. US options.\n- `OTC`: Over-The-Counter. US OTC equities.\n- `OTCM`: OTC Markets. US OTC equities.\n- `SIFMA`: Securities Industry and Financial Markets Association. US bonds.\n- `XNAS`: NASDAQ. US equities.\n- `XNYS`: New York Stock Exchange. US equities.\n\n**Europe**\n- `CEUX`: Cboe CEUX Europe. European equities (Cboe Netherlands).\n- `CHIX`: Cboe CHIX Europe. European equities (Cboe UK).\n- `ISE`: Euronext Dublin. Irish equities.\n- `LSE`: London Stock Exchange. UK equities.\n- `MTA`: Euronext Milan. Italian equities.\n- `MTAA`: Euronext Milan. Italian equities.\n- `XAMS`: Euronext Amsterdam. Dutch equities.\n- `XBRU`: Euronext Brussels. Belgian equities.\n- `XDUB`: Euronext Dublin. Irish equities.\n- `XETR`: Frankfurt Stock Exchange. German equities.\n- `XETRA`: Frankfurt Stock Exchange. German equities.\n- `XLIS`: Euronext Lisbon. Portuguese equities.\n- `XLON`: London Stock Exchange. UK equities.\n- `XPAR`: Euronext Paris. French equities.\n\n**Asia & Middle East**\n- `HKEX`: Hong Kong Stock Exchange. Hong Kong equities.\n- `JPX`: Japan Exchange Group. Japanese equities.\n- `TADAWUL`: Saudi Stock Exchange. Saudi equities.\n- `XHKG`: Hong Kong Stock Exchange. Hong Kong equities.\n- `XSAU`: Saudi Stock Exchange. Saudi equities.\n- `XTKS`: Japan Exchange Group. Japanese equities.\n", + "example": "NYSE,LSE", + "in": "query", + "name": "markets", + "schema": { + "type": "string" + } + }, + "start": { + "description": "The first date to retrieve data for (inclusive). Default: today.\n", + "example": "2025-01-01", + "in": "query", + "name": "start", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + "time": { + "description": "Instead of the current time, use this time for the clock.", + "in": "query", + "name": "time", + "required": false, + "schema": { + "format": "date-time", + "type": "string" + } + }, + "timezone": { + "description": "Timezone of the times. Default: the timezone of the market.\n", + "in": "query", + "name": "timezone", + "required": false, + "schema": { + "enum": [ + "UTC" + ], + "type": "string" + } + } + }, + "responses": { + "400": { + "description": "One of the request parameters is invalid. See the returned message for details.\n", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "401": { + "description": "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key.\n" + }, + "403": { + "description": "The requested resource is forbidden.\n" + }, + "429": { + "description": "Too many requests. You hit the rate limit. Use the X-RateLimit-... response headers to make sure you're under the rate limit.\n", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "500": { + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on Slack or on the Community Forum.\n" + }, + "BadRequest": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Malformed input." + }, + "Forbidden": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Request is forbidden" + }, + "IdempotencyKeyConflict": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The idempotency key was already used with a different request payload." + }, + "NotAuthorized": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Client is not authorized for this operation." + }, + "NotFound": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Resource does not exist." + } + }, + "schemas": { + "ACHRelationship": { + "properties": { + "account_id": { + "format": "uuid", + "type": "string" + }, + "account_owner_name": { + "description": "Name of the account owner", + "minLength": 1, + "type": "string" + }, + "bank_account_number": { + "minLength": 1, + "type": "string" + }, + "bank_account_type": { + "description": "Must be CHECKING or SAVINGS", + "enum": [ + "CHECKING", + "SAVINGS" + ], + "minLength": 1, + "type": "string" + }, + "bank_routing_number": { + "minLength": 1, + "type": "string" + }, + "created_at": { + "description": "Format: 2020-01-01T01:01:01Z", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "id": { + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": "string" + }, + "nickname": { + "minLength": 1, + "type": "string" + }, + "status": { + "enum": [ + "QUEUED", + "APPROVED", + "REJECTED", + "PENDING", + "CANCEL_REQUESTED" + ], + "type": "string" + }, + "updated_at": { + "description": "Format: 2020-01-01T01:01:01Z", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "created_at", + "updated_at", + "account_id", + "status", + "account_owner_name" + ], + "title": "ACHRelationship", + "type": "object" + }, + "APRTier": { + "properties": { + "account_rate_bps": { + "description": "The annualized account interest rate, in basis points.", + "example": 450, + "type": "integer" + }, + "correspondent_rate_bps": { + "description": "The annualized correspondent fee rate, in basis points.", + "example": 25, + "type": "integer" + }, + "created_at": { + "description": "The timestamp the APR tier was created, in RFC 3339 format.", + "example": "2024-09-16T20:06:32.207729Z", + "format": "date-time", + "type": "string" + }, + "currency": { + "description": "The currency of the APR tier", + "example": "USD", + "type": "string" + }, + "details": { + "$ref": "#/components/schemas/APRTierDetails" + }, + "id": { + "description": "The unique identifier of the APR tier", + "example": "150df7eb-31e7-46b3-8848-a54ca21ff3bc", + "format": "uuid", + "type": "string" + }, + "is_default": { + "description": "True if this is the default APR tier. Only one APR tier can be default per currency.\n", + "example": true, + "type": "boolean" + }, + "name": { + "description": "The unique name of the APR tier", + "example": "gold", + "type": "string" + }, + "updated_at": { + "description": "The timestamp of the last update to the APR tier, in RFC 3339 format.", + "example": "2024-09-16T20:06:32.207729Z", + "format": "date-time", + "type": "string" + } + }, + "type": "object" + }, + "APRTierDetails": { + "description": "Additional details of the APR tier\n", + "properties": { + "as_of": { + "description": "The date on which the total balance was recorded, at the end of the day. YYYY-MM-DD format.\n", + "example": "2024-09-27", + "format": "date", + "type": "string" + }, + "total_accounts": { + "description": "The total number of accounts assigned this APR tier.", + "example": 42, + "type": "integer" + }, + "total_balance": { + "description": "The total balance of funds in this APR tier.", + "example": "10485.76", + "format": "decimal", + "type": "string" + } + }, + "type": "object" + }, + "AcatcActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonAcatActivityV2" + } + ], + "description": "Automated customer account transfer service (cash)", + "type": "object" + }, + "AcatsAccountType": { + "description": "Account type, as represented by DTCC", + "enum": [ + "AGENCY", + "BANK_CUSTODY", + "BENEFICIARY", + "BENEFICIARY_ROTH_IRA", + "CORPORATE", + "CO_TRUSTEE", + "COVERDELL_IRA", + "CUSTODIAN_UGMA", + "DIRECT_ROLLOVER", + "ESTATE", + "HSA", + "IRA", + "JOINT", + "MEDICAL_SAVINGS_ACCOUNT", + "OTHER", + "QUALIFIED_OR_PROFIT_SHARING_OR_PENSION", + "ROTH_401K", + "ROTH_IRA", + "ROTH_SEP", + "ROTH_SIMPLE", + "ROTH_SOLO_401K", + "SARSEP", + "SEP_IRA", + "SIMPLE_IRA", + "SINGLE", + "SOLO_401K", + "TRUST", + "TYPE_401K", + "TYPE_403B", + "TYPE_457_PLAN", + "TYPE_529_PLAN" + ], + "type": "string" + }, + "AcatsActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonAcatActivityV2" + }, + { + "properties": { + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Automated customer account transfer service (stock)", + "type": "object" + }, + "AcatsAsset": { + "description": "An asset included in an ACATS transfer.", + "example": { + "amount": "24223.62", + "asset_class": "EQUITY", + "asset_description": "APPLE INC", + "currency_code": "USD", + "cusip": "037833100", + "position": "LONG", + "qty": "123", + "status": "SETTLED", + "symbol": "AAPL" + }, + "properties": { + "amount": { + "description": "Positive number indicating the market value of the assets being transferred", + "format": "decimal", + "type": "string" + }, + "asset_class": { + "description": "Asset type", + "enum": [ + "EQUITY", + "CASH", + "OPTION", + "OTHER" + ], + "type": "string" + }, + "asset_description": { + "description": "Description, usually from DTCC's Security Master File", + "type": "string" + }, + "currency_code": { + "description": "ISO currency code in which amount is denominated", + "type": "string" + }, + "cusip": { + "description": "CUSIP security identifier for the asset. Only returned when a CUSIP was provided for this asset at the time the transfer was initiated, in which case it is returned alongside `symbol`.", + "type": "string" + }, + "isin": { + "deprecated": true, + "description": "ISIN for the asset. DEPRECATED -- will be removed in a future version; use `symbol` or `cusip` instead. Temporarily returned with all assets for backward compatibility.", + "type": "string", + "x-deprecation": { + "reason": "Use `symbol` or `cusip` instead. Returned with all assets only for backward compatibility while consumers migrate.", + "since": "2026-08-04", + "sunset": "2027-02-04" + } + }, + "position": { + "$ref": "#/components/schemas/AcatsPosition" + }, + "qty": { + "description": "Positive number indicating how many shares or units are being transferred", + "format": "decimal", + "type": "string" + }, + "rejection_message": { + "description": "Human readable reason for why an asset is considered ineligible for transfer", + "type": "string" + }, + "status": { + "description": "Status", + "enum": [ + "NOT_VALIDATED", + "REQUESTED", + "DELETED", + "SETTLED", + "REVERSED", + "INTERFACE_REJECTED" + ], + "type": "string" + }, + "symbol": { + "description": "Symbol identifier for the asset. Always returned when a symbol is known for the asset, including when the transfer was initiated with a CUSIP.", + "type": "string" + } + }, + "required": [ + "asset_class", + "asset_description", + "status", + "position" + ], + "type": "object" + }, + "AcatsCashBalance": { + "description": "Cash balance", + "example": { + "amount": "10000", + "currency": "USD" + }, + "properties": { + "amount": { + "description": "Amount of cash to be transferred. Can be positive or negative. Use `transfer_all` to transfer the entire balance instead of specifying an amount -- `amount` and `transfer_all: true` are mutually exclusive, and sending both is rejected with HTTP 400.", + "format": "decimal", + "type": "string" + }, + "currency": { + "description": "Currency of the cash balance. Only `USD` is currently supported; any other value is rejected with HTTP 400. Each currency may appear at most once in the `cash` array.", + "enum": [ + "USD" + ], + "type": "string" + }, + "transfer_all": { + "description": "Set to true to transfer the entire balance of this currency. Must not be combined with `amount`. Setting it to `false` without an `amount` is rejected with HTTP 400.", + "type": "boolean" + } + }, + "required": [ + "currency" + ], + "type": "object" + }, + "AcatsContraAccountDetails": { + "description": "Contra account details", + "example": { + "account_number": "12345678A", + "broker_number": "1234", + "customer_name": "John Smith", + "customer_tax_id": "911923333" + }, + "properties": { + "account_number": { + "description": "Account number at the contra broker", + "type": "string" + }, + "broker_name": { + "description": "Name of the contra broker (non-functional, used for auditability and display purposes)", + "maxLength": 100, + "minLength": 1, + "type": "string" + }, + "broker_number": { + "description": "Clearing number of the contra broker", + "type": "string" + }, + "customer_name": { + "description": "Name on the account at the contra broker", + "type": "string" + }, + "customer_tax_id": { + "description": "Tax ID on the account at the contra broker", + "type": "string" + } + }, + "required": [ + "account_number", + "customer_name", + "customer_tax_id", + "broker_number" + ], + "type": "object" + }, + "AcatsContraBroker": { + "description": "A contra broker or bank participating in ACATS, identified by its DTCC account number.", + "properties": { + "name": { + "description": "Participant name", + "type": "string" + }, + "number": { + "description": "DTCC account number", + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/AcatsContraBrokerType" + } + }, + "required": [ + "number", + "type", + "name" + ], + "type": "object" + }, + "AcatsContraBrokerType": { + "description": "ACATS participant type", + "enum": [ + "BANK", + "BROKER" + ], + "type": "string" + }, + "AcatsDtccStatus": { + "description": "Transfer status as tracked by DTCC", + "enum": [ + "REQUEST", + "REQUEST_ADJUST", + "REQUEST_ADJUST_PAST", + "REQUEST_PAST", + "REQUEST_REJECT", + "REVIEW", + "REVIEW_ADJUST_DELIVERER", + "REVIEW_ERROR", + "REVIEW_ACCELERATE", + "REVIEW_ADJUST_RECEIVER_ACCELERATE", + "SETTLE_PREP", + "SETTLE_CLOSE", + "CLOSE_PURGE", + "REQUEST_PTR", + "MEMO_PURGE_PARTIAL_TRANSFER_REQUEST_RECEIVER", + "REJECT", + "SYSTEM_REJECTED" + ], + "type": "string" + }, + "AcatsDtccTransferType": { + "description": "ACATS transfer type", + "enum": [ + "FUL", + "FRV", + "MFC", + "PTD", + "PTR", + "RCL", + "RCR", + "PTF" + ], + "type": "string" + }, + "AcatsEquity": { + "description": "Equity asset requested in a partial transfer. Identify the security with either `cusip` or `symbol` -- provide one, not both. Prefer `cusip` when you have it: it is a stable, unambiguous identifier. Use `symbol` only when a CUSIP is not available, as ticker symbols can change or be reused over time.", + "example": { + "position": "LONG", + "qty": "2", + "symbol": "AAPL" + }, + "oneOf": [ + { + "required": [ + "cusip", + "position" + ] + }, + { + "required": [ + "symbol", + "position" + ] + } + ], + "properties": { + "cusip": { + "description": "CUSIP security identifier for the asset -- 8 uppercase alphanumeric characters followed by a check character, which may be a digit or one of `*`, `@`, `#`. Recommended over `symbol` for unambiguous identification. Provide either `cusip` or `symbol`, not both.", + "pattern": "^[0-9A-Z]{8}[0-9*@#]$", + "type": "string" + }, + "position": { + "description": "Position type. Only `LONG` and `SHORT` are accepted for equities -- `CREDIT` and `DEBIT` apply to cash positions and are rejected with HTTP 400 here.", + "enum": [ + "LONG", + "SHORT" + ], + "type": "string" + }, + "qty": { + "description": "Quantity of assets to transfer. Use `transfer_all` to transfer the entire position instead of specifying a quantity -- `qty` and `transfer_all: true` are mutually exclusive, and sending both is rejected with HTTP 400. Note that the ACATS system will only transfer whole shares.", + "format": "decimal", + "type": "string" + }, + "symbol": { + "description": "Stock ticker symbol (e.g. `AAPL`, `BRK.B`, `GOOGL`). Up to 6 alphanumeric characters, optionally followed by a single `.` or `-` separator and a 1-5 letter suffix. Values are trimmed and upper-cased before validation. Use only when a CUSIP is not available, since symbols can change or be reused over time. Provide either `cusip` or `symbol`, not both.", + "pattern": "^[A-Z0-9]{1,6}([-.][A-Z]{1,5})?$", + "type": "string" + }, + "transfer_all": { + "description": "Set to true to transfer the entire balance of this asset. Must not be combined with `qty`. Setting it to `false` without a `qty` is rejected with HTTP 400.", + "type": "boolean" + } + }, + "type": "object" + }, + "AcatsError": { + "description": "Body for responses with HTTP status codes indicating an error", + "example": { + "message": "contra broker number is required" + }, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "AcatsInitiateTransferDetails": { + "description": "Transfer details. The two transfer types are mutually exclusive in what they accept:\n- `FULL`: do not include the `cash` or `securities` objects (the entire account will be transferred). Including either is rejected with HTTP 400.\n- `PARTIAL`: specify which assets to transfer using the `cash` and/or `securities` objects. At least one of the two must be present and non-empty, otherwise the request is rejected with HTTP 400.\n", + "example": { + "cash": [ + { + "amount": "10000", + "currency": "USD" + } + ], + "securities": { + "equities": [ + { + "cusip": "037833100", + "position": "LONG", + "qty": "2" + }, + { + "cusip": "78462F103", + "position": "SHORT" + } + ] + }, + "type": "PARTIAL" + }, + "oneOf": [ + { + "description": "Transfers the entire account. Must not carry `cash` or `securities`.", + "not": { + "anyOf": [ + { + "required": [ + "cash" + ] + }, + { + "required": [ + "securities" + ] + } + ] + }, + "properties": { + "type": { + "enum": [ + "FULL" + ], + "type": "string" + } + }, + "title": "Full transfer" + }, + { + "anyOf": [ + { + "properties": { + "cash": { + "minItems": 1, + "type": "array" + } + }, + "required": [ + "cash" + ] + }, + { + "properties": { + "securities": { + "properties": { + "equities": { + "minItems": 1, + "type": "array" + } + }, + "required": [ + "equities" + ], + "type": "object" + } + }, + "required": [ + "securities" + ] + } + ], + "description": "Transfers selected assets. Must carry a non-empty `cash` array, a non-empty `securities.equities` array, or both.", + "properties": { + "type": { + "enum": [ + "PARTIAL" + ], + "type": "string" + } + }, + "title": "Partial transfer" + } + ], + "properties": { + "cash": { + "description": "Cash amounts to transfer. Only used for PARTIAL transfers. Must not be included for FULL transfers.", + "items": { + "$ref": "#/components/schemas/AcatsCashBalance" + }, + "type": "array" + }, + "securities": { + "allOf": [ + { + "description": "Securities to transfer. Only used for PARTIAL transfers. Must not be included for FULL transfers." + }, + { + "$ref": "#/components/schemas/AcatsSecurities" + } + ] + }, + "type": { + "$ref": "#/components/schemas/AcatsInitiateTransferType" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "AcatsInitiateTransferRequest": { + "description": "Request body for initiating an incoming ACATS transfer.", + "example": { + "contra_account_details": { + "account_number": "A00000123", + "broker_number": "0158", + "customer_name": "Jane Doe", + "customer_tax_id": "123456789" + }, + "ip_address": "203.0.113.42", + "signed_at": "2026-04-29T13:00:00Z", + "transfer_details": { + "cash": [ + { + "amount": "10000", + "currency": "USD" + } + ], + "securities": { + "equities": [ + { + "position": "LONG", + "qty": "2", + "symbol": "AAPL" + }, + { + "cusip": "123456789", + "position": "LONG", + "qty": "5" + }, + { + "position": "SHORT", + "symbol": "TSLA" + } + ] + }, + "type": "PARTIAL" + } + }, + "properties": { + "contra_account_details": { + "$ref": "#/components/schemas/AcatsContraAccountDetails" + }, + "ip_address": { + "description": "IP address from which the account holder initiated the transfer (IPv4 or IPv6)", + "example": "203.0.113.42", + "type": "string" + }, + "signed_at": { + "description": "Timestamp at which the account holder signed/authorized the transfer. Must be within the last week and must not be in the future (a 5 minute grace period absorbs clock skew); values outside that window are rejected with HTTP 400.", + "example": "2026-04-29T13:00:00Z", + "format": "date-time", + "type": "string" + }, + "transfer_details": { + "$ref": "#/components/schemas/AcatsInitiateTransferDetails" + }, + "validate_account_number": { + "default": false, + "description": "Whether to validate the contra account number against the contra broker's configured format rules. Defaults to false (no per-broker format check). Set to true to opt in, in which case a number that matches none of the broker's enabled rules is rejected with HTTP 422.", + "type": "boolean" + } + }, + "required": [ + "contra_account_details", + "transfer_details", + "ip_address", + "signed_at" + ], + "type": "object" + }, + "AcatsInitiateTransferResponse": { + "description": "Response returned when an ACATS transfer has been accepted for processing.", + "properties": { + "acats_id": { + "description": "The ID of the ACATS transfer that was just initiated", + "example": "2c827687-ddd3-4ad9-bee8-0a3cdad35301", + "type": "string" + } + }, + "required": [ + "acats_id" + ], + "type": "object" + }, + "AcatsInitiateTransferType": { + "description": "Transfer type", + "enum": [ + "FULL", + "PARTIAL" + ], + "type": "string" + }, + "AcatsListAssetsResponse": { + "description": "The list of assets associated with an ACATS transfer.", + "example": [ + { + "asset_class": "EQUITY", + "asset_description": "APPLE INC", + "cusip": "037833100", + "position": "LONG", + "qty": "10", + "status": "SETTLED", + "symbol": "AAPL" + }, + { + "amount": "1250.75", + "asset_class": "CASH", + "asset_description": "US DOLLAR", + "currency_code": "USD", + "position": "CREDIT", + "status": "SETTLED" + } + ], + "items": { + "$ref": "#/components/schemas/AcatsAsset" + }, + "type": "array" + }, + "AcatsListContraBrokersResponse": { + "description": "Response containing the list of valid ACATS contra brokers.", + "example": { + "brokers": [ + { + "name": "Example Brokerage Inc.", + "number": "0001", + "type": "BROKER" + }, + { + "name": "Example Bank, N.A.", + "number": "0002", + "type": "BANK" + } + ] + }, + "properties": { + "brokers": { + "items": { + "$ref": "#/components/schemas/AcatsContraBroker" + }, + "type": "array" + } + }, + "type": "object" + }, + "AcatsListTransfersResponse": { + "description": "A page of ACATS transfers, with optional pagination tokens.", + "example": { + "page_token_next": "eyJjcmVhdGVkX2F0IjoiMjAyNi0wNC0yOFQxNDozMDowMFoiLCJpZCI6IjAxQUJDIn0=", + "pending_transfers": 37, + "transfers": [ + { + "acats_id": "2c827687-ddd3-4ad9-bee8-0a3cdad35301", + "account_id": "9ac16d7d-1f6e-445b-8e51-807e77ba2902", + "account_name": "John Doe", + "account_number": "12345678", + "account_type": "SINGLE", + "contra_account_number": "A00000123", + "contra_broker_name": "Alpaca Clearing", + "contra_broker_number": "00001234", + "contra_broker_type": "BANK", + "created_at": "2026-04-21T12:41:03.505862Z", + "direction": "INCOMING", + "ip_address": "203.0.113.42", + "rejection_details": { + "rejection_message": "SS# Tax ID Mismatch", + "rejection_reason": "SS_TAX_ID_MISMATCH" + }, + "status": { + "dtcc_status": "REJECT", + "transfer_status": "REJECTED" + }, + "total_transfer_value": "24223.62", + "transfer_identifier": "03251237654321", + "transfer_type": "FUL" + } + ] + }, + "properties": { + "page_token_next": { + "allOf": [ + { + "description": "Page token for the next page of transfers. Pass it back in the `page_token` query parameter to fetch that page. Not returned when the caller is on the last page." + }, + { + "$ref": "#/components/schemas/AcatsPageToken" + } + ] + }, + "page_token_previous": { + "allOf": [ + { + "description": "Page token for the previous page of transfers. Pass it back in the `page_token` query parameter to fetch that page. Not returned when the caller is on the first page." + }, + { + "$ref": "#/components/schemas/AcatsPageToken" + } + ] + }, + "pending_transfers": { + "description": "The count of ACATS transfers pending review", + "example": 37, + "format": "int32", + "type": "integer" + }, + "transfers": { + "items": { + "$ref": "#/components/schemas/AcatsTransfer" + }, + "type": "array" + } + }, + "required": [ + "transfers" + ], + "type": "object" + }, + "AcatsPageToken": { + "description": "Page token, pass it back unchanged in the `page_token` query parameter to fetch the next or previous page.", + "example": "eyJjcmVhdGVkX2F0IjoiMjAyNi0wNC0yOFQxNDozMDowMFoiLCJpZCI6IjAxQUJDIn0=", + "type": "string" + }, + "AcatsPosition": { + "description": "Position type. `LONG` and `SHORT` apply to security positions; `CREDIT` and `DEBIT` apply to cash positions.", + "enum": [ + "LONG", + "SHORT", + "CREDIT", + "DEBIT" + ], + "type": "string" + }, + "AcatsRejectionDetails": { + "description": "Why the transfer was rejected, only present on transfers in rejected status", + "properties": { + "rejection_message": { + "description": "Human readable message regarding the reason for the rejection", + "type": "string" + }, + "rejection_reason": { + "description": "Rejection reason, as returned by DTCC", + "enum": [ + "SS_TAX_ID_MISMATCH", + "ACCOUNT_TITLE_MISMATCH", + "DOCUMENTATION_NEEDED", + "ACCOUNT_FLAT", + "INVALID_ACCOUNT_NUMBER", + "DUPLICATE", + "ACCOUNT_IN_DISTRIBUTION_OR_TRANSFER", + "CLIENT_RESCINDED", + "MISSING_AUTHORIZATION_SIGNATURE", + "ACCOUNT_VIOLATES_CREDIT_POLICY_OF_RECEIVING_FIRM", + "UNRECOGNIZED_FOR_RESIDUAL_CREDIT_BALANCE", + "PARTIAL_TRANSFER_DELIVERER_INITIATED_REJECT", + "FAIL_REVERSAL_REJECT", + "RECLAIM_REJECT", + "MUTUAL_FUND_CLEANUP", + "SYSTEM_REJECTED", + "INVALID_PARTICIPANT", + "ASSOCIATED_RECORD_NOT_PRESENT_OR_INVALID", + "MISSED_CUTOFF" + ], + "type": "string" + } + }, + "type": "object" + }, + "AcatsSecurities": { + "description": "List of securities to transfer", + "properties": { + "equities": { + "items": { + "$ref": "#/components/schemas/AcatsEquity" + }, + "type": "array" + } + }, + "type": "object" + }, + "AcatsSortDirection": { + "default": "DESC", + "description": "Sort direction for list results.", + "enum": [ + "ASC", + "DESC" + ], + "type": "string" + }, + "AcatsStatusDetails": { + "description": "Status details", + "properties": { + "dtcc_status": { + "$ref": "#/components/schemas/AcatsDtccStatus" + }, + "transfer_status": { + "$ref": "#/components/schemas/AcatsTransferStatus" + } + }, + "type": "object" + }, + "AcatsTimestamp": { + "description": "Timestamp in RFC-3339 format with microsecond precision", + "example": "2026-01-01T00:00:00Z", + "format": "date-time", + "type": "string" + }, + "AcatsTransfer": { + "description": "An ACATS transfer and its current status.", + "example": { + "acats_id": "2c827687-ddd3-4ad9-bee8-0a3cdad35301", + "account_id": "9ac16d7d-1f6e-445b-8e51-807e77ba2902", + "account_name": "John Doe", + "account_number": "12345678", + "account_type": "SINGLE", + "contra_account_number": "A00000123", + "contra_broker_name": "Alpaca Clearing", + "contra_broker_number": "00001234", + "contra_broker_type": "BANK", + "created_at": "2026-04-21T12:41:03.505862Z", + "direction": "INCOMING", + "ip_address": "203.0.113.42", + "rejection_details": { + "rejection_message": "SS# Tax ID Mismatch", + "rejection_reason": "SS_TAX_ID_MISMATCH" + }, + "status": { + "dtcc_status": "REJECT", + "transfer_status": "REJECTED" + }, + "total_transfer_value": "24223.62", + "transfer_identifier": "03251237654321", + "transfer_type": "FUL" + }, + "properties": { + "acats_id": { + "description": "The ID of the ACATS transfer", + "format": "uuid", + "type": "string" + }, + "account_id": { + "description": "Account ID associated with the ACATS transfer", + "format": "uuid", + "type": "string" + }, + "account_name": { + "description": "Name on the Alpaca account associated with the transfer", + "type": "string" + }, + "account_number": { + "description": "Account number at Alpaca", + "type": "string" + }, + "account_type": { + "$ref": "#/components/schemas/AcatsAccountType" + }, + "contra_account_number": { + "description": "Account number at the contra broker", + "type": "string" + }, + "contra_broker_name": { + "description": "Name of the contra broker", + "type": "string" + }, + "contra_broker_number": { + "description": "DTCC account number for the contra broker", + "type": "string" + }, + "contra_broker_type": { + "$ref": "#/components/schemas/AcatsContraBrokerType" + }, + "created_at": { + "$ref": "#/components/schemas/AcatsTimestamp" + }, + "direction": { + "$ref": "#/components/schemas/AcatsTransferDirection" + }, + "ip_address": { + "description": "User's IP address (IPv4 or IPv6) at time of submission", + "type": "string" + }, + "original_transfer_identifier": { + "description": "DTCC transfer identifier for a previous, related transfer", + "type": "string" + }, + "rejection_details": { + "$ref": "#/components/schemas/AcatsRejectionDetails" + }, + "settlement_date": { + "$ref": "#/components/schemas/AcatsTimestamp" + }, + "status": { + "$ref": "#/components/schemas/AcatsStatusDetails" + }, + "total_transfer_value": { + "description": "Total transfer value is the sum of the market value of all assets and securities in an ACAT at the time of settlement, plus any cash balance.", + "format": "decimal", + "type": "string" + }, + "transfer_identifier": { + "description": "DTCC transfer identifier, also known as the control number", + "type": "string" + }, + "transfer_type": { + "$ref": "#/components/schemas/AcatsDtccTransferType" + } + }, + "required": [ + "acats_id", + "account_id", + "account_number", + "created_at", + "contra_account_number", + "contra_broker_number", + "transfer_type", + "direction", + "status" + ], + "type": "object" + }, + "AcatsTransferDirection": { + "description": "Transfer direction", + "enum": [ + "INCOMING", + "OUTGOING" + ], + "type": "string" + }, + "AcatsTransferStatus": { + "description": "Transfer status as tracked by Alpaca", + "enum": [ + "PENDING", + "IN_PROGRESS", + "REJECTED", + "SETTLED" + ], + "type": "string" + }, + "Account": { + "description": "Represents high level account info. Used when returning entire account information would not be useful like the getAllAccounts operation", + "examples": [ + { + "account_number": "9034005019", + "created_at": "2019-09-30T23:55:31.185998Z", + "currency": "USD", + "id": "0d18ae51-3c94-4511-b209-101e1666416b", + "last_equity": "1500.65", + "primary_account_holder_id": null, + "status": "APPROVED" + } + ], + "properties": { + "account_number": { + "description": "A human-readable account number that can be shown to the end user", + "type": [ + "string", + "null" + ] + }, + "account_type": { + "$ref": "#/components/schemas/AccountType" + }, + "agreements": { + "items": { + "$ref": "#/components/schemas/Agreement" + }, + "type": "array" + }, + "allow_instant_ach": { + "description": "Determines whether the account is enabled for Instant ACH by the partner.", + "type": "boolean" + }, + "cash_interest": { + "$ref": "#/components/schemas/AccountCashInterestResponse" + }, + "contact": { + "$ref": "#/components/schemas/Contact" + }, + "created_at": { + "description": "Timestamp (RFC3339) of account creation.", + "format": "date-time", + "type": "string" + }, + "crypto_status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "disclosures": { + "$ref": "#/components/schemas/Disclosures" + }, + "documents": { + "description": "The documents associated with the primary owner of the account", + "items": { + "$ref": "#/components/schemas/OwnerDocument" + }, + "type": "array" + }, + "enabled_assets": { + "description": "Assets the user has enabled and is able to trade once status and/or crypto_status are ACTIVE", + "items": { + "$ref": "#/components/schemas/EnabledAssetClass" + }, + "type": "array" + }, + "fpsl": { + "$ref": "#/components/schemas/AccountFPSLResponse" + }, + "id": { + "description": "UUID that identifies the account for later reference", + "format": "uuid", + "type": "string" + }, + "identity": { + "$ref": "#/components/schemas/Identity" + }, + "instant_ach_blocked": { + "description": "Indicates whether the account is blocked for Instant ACH by Alpaca. Defaults to false when the partner creates the account. If the partner has set allow_instant_ach to true but instant_ach_blocked is true, then the account is blocked for Instant ACH irrespective of the fact that the partner has it enabled.", + "type": "boolean" + }, + "last_equity": { + "description": "EOD equity calculation (cash + long market value + short market value)", + "format": "decimal", + "type": "string" + }, + "primary_account_holder_id": { + "description": "UUID of the account's primary holder when available; otherwise `null`.", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "trusted_contact": { + "$ref": "#/components/schemas/TrustedContact" + } + }, + "required": [ + "id", + "account_number", + "status", + "currency", + "created_at", + "last_equity" + ], + "type": "object" + }, + "AccountCashInterestEvent": { + "description": "This property is included when the account's cash interest program had changed due to an enrollment, APR tier change, or unenrollment.\nThe from and to status or APR tier name will be included in the event, depending on the change.\n", + "properties": { + "apr_tier_name_from": { + "description": "The APR tier name before the change", + "type": "string" + }, + "apr_tier_name_to": { + "description": "The APR tier name after the change", + "type": "string" + }, + "currency": { + "description": "The currency of the cash interest program that changed.", + "example": "USD", + "type": "string" + }, + "status_from": { + "description": "The cash_interest program status of the account before the change", + "type": "string" + }, + "status_to": { + "description": "The cash_interest program status of the account after the change", + "type": "string" + } + }, + "type": "object" + }, + "AccountCashInterestPatch": { + "description": "Use this property to change the account's configuration for the USD cash interest program.\nTo enroll the account, specify the apr_tier_name. The status should not be specified on enrollment.\nTo change the APR tier, specify the new apr_tier_name. The status should not be specified on tier changes.\nThe unenroll, set the status to INACTIVE.\nAfter any change, the response will contain a status of PENDING_CHANGE.\nAn event showing the status change to ACTIVE (for enrollment or tier changes) or INACTIVE (for unenrollment) will be generated when the change is complete.\n", + "properties": { + "USD": { + "$ref": "#/components/schemas/AccountCashInterestProgram" + } + }, + "type": "object" + }, + "AccountCashInterestPost": { + "description": "The configuration of the account's USD cash interest program when creating an account.\nIf cash_interest is not provided and there is a default APR tier defined, that tier will be used.\nTo enroll the account in a non-default APR tier, provide the cash_interest object with the desired apr_tier_name. The status should not be specified on enrollment.\nThe response will contain a status of PENDING_CHANGE. An event showing the status change to ACTIVE will be generated when the enrollment is complete.\n", + "properties": { + "USD": { + "$ref": "#/components/schemas/AccountCashInterestProgram" + } + }, + "type": "object" + }, + "AccountCashInterestProgram": { + "properties": { + "apr_tier_name": { + "description": "The unique name of the APR tier for a specific program", + "example": "gold", + "type": "string" + }, + "status": { + "description": "The status of the account within a cash interest program. One of:\n- **ACTIVE**\nThe account is enrolled and eligible for idle cash to be swept at the end of day (EOD).\n- **INACTIVE**\nThe account is not enrolled due to it either not being eligible (e.g. the updated Alpaca Customer Agreement has not been signed), an APR tier needs to be assigned, or they have been unenrolled.\n- **PENDING_CHANGE**\nAn enrollment, APR Tier change, or unenrollment is in progress\n", + "example": "ACTIVE", + "type": "string" + } + }, + "type": "object" + }, + "AccountCashInterestResponse": { + "description": "The configuration and status of the account's USD cash interest program\n", + "properties": { + "USD": { + "$ref": "#/components/schemas/AccountCashInterestProgram" + } + }, + "type": "object" + }, + "AccountConfigurations": { + "description": "Represents additional configuration settings for an account", + "properties": { + "disable_overnight_trading": { + "description": "If true, overnight trading is disabled.", + "type": "boolean" + }, + "fractional_trading": { + "description": "If true, account is able to participate in fractional trading", + "type": "boolean" + }, + "max_margin_multiplier": { + "description": "Can be \"1\" or \"2\"", + "type": "string" + }, + "max_options_trading_level": { + "description": "The desired maximum options trading level. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.", + "enum": [ + 0, + 1, + 2, + 3 + ], + "type": "integer" + }, + "no_shorting": { + "description": "If true, account becomes long-only mode.", + "type": "boolean" + }, + "ptp_no_exception_entry": { + "description": "If set to true then Alpaca will accept orders for PTP symbols with no exception. Default is false.", + "type": "string" + }, + "suspend_trade": { + "description": "If true, new orders are blocked.", + "type": "boolean" + }, + "trade_confirm_email": { + "description": "all or none. If none, emails for order fills are not sent.", + "enum": [ + "all", + "none" + ], + "type": "string" + } + }, + "title": "AccountConfigurations", + "type": "object" + }, + "AccountCreationRequest": { + "description": "Fields accepted when creating an account. Requirements vary by account type, enabled assets, existing holder agreements, and correspondent configuration. The server enforces conditional requirements that are not represented statically in this schema.\n\nAccount-specific requirements:\n- Trading accounts require inline `identity` plus `contact`, or an existing holder through `primary_account_holder_id`. Individual US equity accounts created with inline identity also require `disclosures`.\n- Custodial accounts require `identity` and `minor_identity`. US equity accounts also require `disclosures`.\n- IRA accounts require `account_sub_type`, US equity, and either inline `identity` or an existing holder through `primary_account_holder_id`; they do not support crypto. IRA accounts created with inline identity also require `disclosures`.\n- Donor-advised accounts require `entity_id`.\n", + "properties": { + "account_sub_type": { + "allOf": [ + { + "$ref": "#/components/schemas/AccountSubType" + } + ], + "description": "The account subtype. Required for IRA accounts." + }, + "account_type": { + "allOf": [ + { + "$ref": "#/components/schemas/AccountCreationType" + } + ], + "default": "trading", + "description": "The account type. Defaults to `trading` when omitted." + }, + "agreements": { + "description": "Agreements submitted for the account or holder. Required agreement types depend on account type, enabled assets, existing holder agreements, and correspondent configuration. The server validates required coverage.", + "items": { + "$ref": "#/components/schemas/Agreement" + }, + "type": "array" + }, + "allow_instant_ach": { + "default": false, + "description": "Determines whether the account will be enabled for Instant ACH by the partner. Defaults to false if not provided.", + "type": "boolean" + }, + "beneficiaries": { + "description": "IRA Account only. A user can submit max 6 beneficiaries.", + "items": { + "$ref": "#/components/schemas/Beneficiary" + }, + "type": "array" + }, + "cash_interest": { + "$ref": "#/components/schemas/AccountCashInterestPost" + }, + "contact": { + "$ref": "#/components/schemas/Contact" + }, + "disclosures": { + "$ref": "#/components/schemas/Disclosures" + }, + "documents": { + "items": { + "$ref": "#/components/schemas/OwnerDocumentUploadRequest" + }, + "type": "array" + }, + "enabled_assets": { + "description": "Will default to `us_equity`. Alpaca has the ability to update the default value upon request.", + "items": { + "$ref": "#/components/schemas/EnabledAssetClass" + }, + "type": "array" + }, + "entity_id": { + "description": "UUID of an existing legal entity used as the holder of a donor-advised account. Required for donor-advised accounts.", + "format": "uuid", + "type": "string" + }, + "fpsl": { + "$ref": "#/components/schemas/AccountFPSLPost" + }, + "identity": { + "$ref": "#/components/schemas/Identity" + }, + "investment_objective": { + "description": "The user's investment objective. This field should be used instead of the deprecated `investment_objective` under identity.\n", + "enum": [ + "generate_income", + "preserve_wealth", + "market_speculation", + "growth", + "balance_preserve_wealth_with_growth" + ], + "type": "string" + }, + "investment_time_horizon": { + "description": "The expected period of time the user plan to invest to achieve his/her financial goal(s). This field should be used instead of the deprecated `investment_time_horizon` under identity.\n", + "enum": [ + "less_than_1_year", + "1_to_2_years", + "3_to_5_years", + "6_to_10_years", + "more_than_10_years" + ], + "type": "string" + }, + "liquidity_needs": { + "description": "The user's ability to quickly and easily convert to cash all or a portion of the investments in this account without experiencing significant loss in value. This field should be used instead of the deprecated `liquidity_needs` under identity.\n", + "enum": [ + "very_important", + "important", + "somewhat_important", + "does_not_matter" + ], + "type": "string" + }, + "minor_identity": { + "allOf": [ + { + "$ref": "#/components/schemas/CustodialAccountMinorIdentity" + } + ], + "description": "Identity information for the minor. Required for custodial accounts." + }, + "primary_account_holder_id": { + "description": "UUID of an existing party to use as the primary account holder. Among the documented account types, existing holders are supported for trading and IRA accounts.\n\nWhen provided, omit inline holder fields such as `contact`, `identity`, `disclosures`, and `minor_identity`. The server validates the referenced party, account-type compatibility, eligibility, and required agreements.\n", + "format": "uuid", + "type": "string" + }, + "risk_tolerance": { + "description": "The user's investment risk tolerance. This field should be used instead of the deprecated `risk_tolerance` under identity.\n", + "enum": [ + "conservative", + "moderate", + "significant_risk" + ], + "type": "string" + }, + "trading_configurations": { + "$ref": "#/components/schemas/AccountConfigurations" + }, + "trusted_contact": { + "$ref": "#/components/schemas/TrustedContact" + } + }, + "title": "AccountCreationRequest", + "type": "object" + }, + "AccountCreationType": { + "description": "The account type to create.", + "enum": [ + "trading", + "custodial", + "donor_advised", + "ira" + ], + "example": "trading", + "title": "AccountCreationType", + "type": "string" + }, + "AccountDocument": { + "description": "A document associated with an account", + "example": { + "date": "2019-09-30", + "id": "0d18ae51-3c94-4511-b209-101e1666416b", + "sub_type": "1099-Comp", + "type": "account_statement" + }, + "properties": { + "date": { + "format": "date", + "type": "string" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "name": { + "type": "string" + }, + "sub_type": { + "description": "The sub-type of the document. This is a free-form property.", + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/AccountDocumentType" + } + }, + "required": [ + "id", + "type", + "date" + ], + "type": "object" + }, + "AccountDocumentType": { + "description": "The type of the account document\n", + "enum": [ + "account_application", + "account_statement", + "crypto_account_statement", + "options_application", + "tax_statement", + "trade_confirmation_json", + "trade_confirmation" + ], + "example": "account_application", + "type": "string" + }, + "AccountExtended": { + "description": "Represents an account with all data available. If your api response is missing some of these fields, there is a good chance you are using a route that returns `Account` instances instead of these.", + "examples": [ + { + "account_number": "601842165", + "account_type": "trading", + "agreements": [ + { + "agreement": "margin_agreement", + "ip_address": "127.0.0.1", + "revision": "16.2021.05", + "signed_at": "2022-01-21T21:25:26.579487214Z" + }, + { + "agreement": "customer_agreement", + "ip_address": "127.0.0.1", + "revision": "22.2024.08", + "signed_at": "2022-01-21T21:25:26.579487214Z" + } + ], + "beneficiaries": [ + { + "date_of_birth": "1970-01-01", + "family_name": "Smith", + "given_name": "John", + "middle_name": "P", + "relationship": "spouse", + "share_pct": "100", + "tax_id": "xxx-xx-xxxx", + "tax_id_type": "USA_SSN", + "type": "primary" + } + ], + "contact": { + "city": "San Mateo", + "country": "USA", + "email_address": "strange_elbakyan_97324509@example.com", + "phone_number": "614-555-0697", + "postal_code": "94401", + "state": "CA", + "street_address": [ + "20 N San Mateo Dr" + ] + }, + "created_at": "2022-01-21T21:25:26.583576Z", + "crypto_status": "INACTIVE", + "currency": "USD", + "disclosures": { + "immediate_family_exposed": false, + "is_affiliated_exchange_or_finra": false, + "is_control_person": false, + "is_discretionary": false, + "is_politically_exposed": false + }, + "documents": [ + { + "content": "https://example.com/documents/identity-verification.jpg", + "created_at": "2022-01-21T21:25:28.184231Z", + "document_sub_type": "passport", + "document_type": "identity_verification", + "id": "d5af1585-6c60-494d-9ea5-c5df62704229" + } + ], + "id": "3dcb795c-3ccc-402a-abb9-07e26a1b1326", + "identity": { + "country_of_birth": "USA", + "country_of_citizenship": "USA", + "country_of_tax_residence": "USA", + "date_of_birth": "1970-01-01", + "family_name": "Elbakyan", + "funding_source": [ + "employment_income" + ], + "given_name": "Strange", + "tax_id_type": "USA_SSN" + }, + "last_equity": "40645.13", + "primary_account_holder_id": null, + "status": "ACTIVE", + "trusted_contact": { + "email_address": "strange_elbakyan_97324509@example.com", + "family_name": "Doe", + "given_name": "Jane" + } + } + ], + "properties": { + "account_name": { + "type": "string" + }, + "account_number": { + "type": [ + "string", + "null" + ] + }, + "account_sub_type": { + "$ref": "#/components/schemas/AccountSubType" + }, + "account_type": { + "$ref": "#/components/schemas/AccountType" + }, + "agreements": { + "items": { + "$ref": "#/components/schemas/Agreement" + }, + "type": "array" + }, + "allow_instant_ach": { + "description": "Determines whether the account is enabled for Instant ACH by the partner.", + "type": "boolean" + }, + "beneficiaries": { + "items": { + "$ref": "#/components/schemas/Beneficiary" + }, + "type": "array" + }, + "cash_interest": { + "$ref": "#/components/schemas/AccountCashInterestResponse" + }, + "contact": { + "$ref": "#/components/schemas/Contact" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "crypto_status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "custodial_account_type": { + "$ref": "#/components/schemas/CustodialAccountType" + }, + "disclosures": { + "$ref": "#/components/schemas/Disclosures" + }, + "documents": { + "description": "The documents associated with the primary owner of the account", + "items": { + "$ref": "#/components/schemas/OwnerDocument" + }, + "type": "array" + }, + "enabled_assets": { + "items": { + "$ref": "#/components/schemas/EnabledAssetClass" + }, + "type": "array" + }, + "fpsl": { + "$ref": "#/components/schemas/AccountFPSLResponse" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "identity": { + "$ref": "#/components/schemas/Identity" + }, + "instant_ach_blocked": { + "description": "Indicates whether the account is blocked for Instant ACH by Alpaca. Defaults to false when the partner creates the account. If the partner has set allow_instant_ach to true but instant_ach_blocked is true, then the account is blocked for Instant ACH irrespective of the fact that the partner has it enabled.", + "type": "boolean" + }, + "investment_objective": { + "description": "The user's investment objective. This field should be used instead of the deprecated `investment_objective` under identity.\n", + "enum": [ + "generate_income", + "preserve_wealth", + "market_speculation", + "growth", + "balance_preserve_wealth_with_growth" + ], + "type": "string" + }, + "investment_time_horizon": { + "description": "The expected period of time the user plan to invest to achieve his/her financial goal(s). This field should be used instead of the deprecated `investment_time_horizon` under identity.\n", + "enum": [ + "less_than_1_year", + "1_to_2_years", + "3_to_5_years", + "6_to_10_years", + "more_than_10_years" + ], + "type": "string" + }, + "kyc_results": { + "$ref": "#/components/schemas/KYCResults" + }, + "last_equity": { + "format": "decimal", + "type": "string" + }, + "liquidity_needs": { + "description": "The user's ability to quickly and easily convert to cash all or a portion of the investments in this account without experiencing significant loss in value. This field should be used instead of the deprecated `liquidity_needs` under identity.\n", + "enum": [ + "very_important", + "important", + "somewhat_important", + "does_not_matter" + ], + "type": "string" + }, + "minor_identity": { + "$ref": "#/components/schemas/CustodialAccountMinorIdentity" + }, + "primary_account_holder_id": { + "description": "UUID of the account's primary holder when available; otherwise `null`.", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "risk_tolerance": { + "description": "The user's investment risk tolerance. This field should be used instead of the deprecated `risk_tolerance` under identity.\n", + "enum": [ + "conservative", + "moderate", + "significant_risk" + ], + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "trading_configurations": { + "$ref": "#/components/schemas/AccountConfigurations" + }, + "trusted_contact": { + "$ref": "#/components/schemas/TrustedContact" + }, + "usd": { + "description": "values in USD. This is returned for LCT (non-USD) accounts only.", + "properties": { + "last_equity": { + "example": "123.45", + "format": "decimal", + "type": "string" + } + }, + "type": "object" + } + }, + "required": [ + "id", + "account_number", + "status", + "currency", + "last_equity", + "created_at", + "account_type" + ], + "type": "object" + }, + "AccountFPSLEvent": { + "description": "This property is included when the account's FPSL information had changed due to an enrollment, tier change, or unenrollment.\nThe from and to status or tier id will be included in the event, depending on the change.\n", + "properties": { + "US": { + "properties": { + "status_from": { + "description": "The FPSL program status of the account before the change", + "type": "string" + }, + "status_to": { + "description": "The FPSL program status of the account after the change", + "type": "string" + }, + "tier_from": { + "description": "The tier id before the change", + "type": "string" + }, + "tier_to": { + "description": "The tier id after the change", + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "AccountFPSLItem": { + "properties": { + "status": { + "description": "The status of the account for this FPSL market. One of:\n- **ACTIVE**\nThe account is successfully enrolled for FPSL for this market.\n- **INACTIVE**\nThe account is not enrolled for FPSL for this market due to it either not being eligible, an FPSL tier has not been assigned, or it has been unenrolled.\n", + "example": "ACTIVE", + "type": "string" + }, + "tier_id": { + "description": "The id of the FPSL tier for this market", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": "string" + } + }, + "type": "object" + }, + "AccountFPSLItemPost": { + "properties": { + "tier_id": { + "description": "The id of the FPSL tier for this market", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": "string" + } + }, + "type": "object" + }, + "AccountFPSLPatch": { + "description": "The account's Fully Paid Securities Lending (FPSL) configuration.\nUse this property to change the account's configuration for the FPSL program.\nTo enroll the account for a market, specify the tier_id. The status should not be specified on enrollment.\nTo change the tier, specify the new tier_id. The status should not be specified on tier changes.\nTo unenroll, set the status to INACTIVE.\nTo re-enroll the account, set the status to ACTIVE. You can also specify the tier_id in case you want to change it.\nCurrently only US market is supported.\n", + "properties": { + "US": { + "$ref": "#/components/schemas/AccountFPSLItem" + } + }, + "type": "object" + }, + "AccountFPSLPost": { + "description": "The account's Fully Paid Securities Lending (FPSL) configuration.\nTo enroll the account for a market, specify the tier_id. The status should not be specified on enrollment.\nCurrently only the US market is supported.\n", + "properties": { + "US": { + "$ref": "#/components/schemas/AccountFPSLItemPost" + } + }, + "type": "object" + }, + "AccountFPSLResponse": { + "description": "The account's Fully Paid Securities Lending (FPSL) configuration.\nThis is only returned for accounts that have FPSL enabled.\n", + "properties": { + "US": { + "$ref": "#/components/schemas/AccountFPSLItem" + } + }, + "type": "object" + }, + "AccountLimit": { + "properties": { + "account_no": { + "type": "string" + }, + "amount_available": { + "format": "decimal", + "type": "string" + }, + "amount_in_use": { + "format": "decimal", + "type": "string" + }, + "amount_limit": { + "format": "decimal", + "type": "string" + } + }, + "required": [ + "account_no", + "amount_in_use", + "amount_available", + "amount_limit" + ], + "type": "object" + }, + "AccountStatus": { + "description": "Designates the current status of this account\n\nPossible Values:\n- **INACTIVE**\nAccount not set to trade given asset.\n- **PAPER_ONLY**\nThe account is limited to paper trading.\n- **ONBOARDING**\nAn application is expected for this user, but has not been submitted yet.\n- **SUBMITTED**\nThe application has been submitted and is being processed.\n- **SUBMISSION_FAILED**\nUsed to display if failure on submission\n- **ACTION_REQUIRED**\nThe application requires manual action.\n- **ACCOUNT_UPDATED**\nUsed to display when Account has been modified by user\n- **APPROVAL_PENDING**\nInitial value. The application approval process is in progress.\n- **APPROVED**\nThe account application has been approved, and waiting to be ACTIVE\n- **REJECTED**\nThe account application is rejected for some reason\n- **ACTIVE**\nThe account is fully active. Trading and funding are processed under this status.\n- **ACCOUNT_CLOSED**\nThe account is closed.\n", + "enum": [ + "INACTIVE", + "PAPER_ONLY", + "ONBOARDING", + "SUBMITTED", + "SUBMISSION_FAILED", + "ACTION_REQUIRED", + "ACCOUNT_UPDATED", + "APPROVAL_PENDING", + "APPROVED", + "REJECTED", + "ACTIVE", + "ACCOUNT_CLOSED" + ], + "example": "ACTIVE", + "type": "string" + }, + "AccountStatusEvent": { + "description": "Represents a change to certain account properties, sent over the events streaming API.\n", + "examples": [ + { + "account_id": "4db36989-6565-4011-9126-39fe6b3d9bf6", + "at": "2021-06-14T09:59:15.232782Z", + "event_id": 122039, + "event_ulid": "01F84ZC0H0Q1QN7XPNWX44HF5J", + "status_from": "", + "status_to": "APPROVED" + } + ], + "properties": { + "account_blocked": { + "description": "If true the account was blocked, if false, the account got unblocked", + "type": "boolean" + }, + "account_id": { + "description": "The unique identifier of the account that was changed", + "minLength": 1, + "type": "string" + }, + "account_number": { + "description": "The account number of the account that was changed", + "minLength": 1, + "type": "string" + }, + "admin_configurations": { + "$ref": "#/components/schemas/AdminConfigurationsEvent" + }, + "at": { + "description": "timestamp of event", + "minLength": 1, + "type": "string" + }, + "cash_interest": { + "$ref": "#/components/schemas/AccountCashInterestEvent" + }, + "crypto_status_from": { + "description": "account crypto_status changed from", + "type": "string" + }, + "crypto_status_to": { + "description": "account crypto_status changed to", + "type": "string" + }, + "event_id": { + "description": "Monotonically increasing 64-bit integer not available to new partners, and for backward compatibility purposes only; use `event_ulid` as the stable identifier where possible\n", + "type": "integer" + }, + "event_ulid": { + "description": "lexically sortable, monotonically increasing character array", + "format": "ulid", + "type": "string" + }, + "fpsl": { + "$ref": "#/components/schemas/AccountFPSLEvent" + }, + "kyc_results": { + "$ref": "#/components/schemas/KYCResults" + }, + "options": { + "$ref": "#/components/schemas/OptionsApprovalEvent" + }, + "reason": { + "deprecated": true, + "minLength": 1, + "type": "string" + }, + "status_from": { + "description": "The account status before the change", + "example": "APPROVED", + "type": "string" + }, + "status_to": { + "description": "The account status after the change", + "example": "ACTIVE", + "type": "string" + }, + "trading_blocked": { + "description": "If true the account cannot trade going forward, if false, the ban has been lifed", + "type": "boolean" + } + }, + "required": [ + "account_id", + "at", + "event_ulid" + ], + "title": "AccountStatusEvent", + "type": "object" + }, + "AccountSubType": { + "description": "IRA Account only\n\nPossible values are:\n\n- traditional\n- roth", + "enum": [ + "traditional", + "roth" + ], + "example": "traditional", + "title": "AccountSubType", + "type": "string" + }, + "AccountTradingLimit": { + "properties": { + "available": { + "description": "The remaining net buying limit that can be used for trading.", + "format": "decimal", + "type": "string" + }, + "daily_net_limit": { + "description": "The net buying limit that can be reached before further trading activity is restricted. Please reach out to learn more about how this limit is determined.", + "format": "decimal", + "type": "string" + }, + "held": { + "description": "The limit that is currently being held for open orders", + "format": "decimal", + "type": "string" + }, + "swap_rate": { + "description": "The swap rate is applicable for Local Currency Trading (LCT) accounts", + "format": "decimal", + "type": "string" + }, + "usd": { + "$ref": "#/components/schemas/USDAccountTradingLimit" + }, + "used": { + "description": "The real time net value of cash inflows (buy trades, etc.) with cash outflows (sell trades, etc). This will be dynamic throughout the day based on user activity, with executed orders being reset at the start of the next trading day.", + "format": "decimal", + "type": "string" + } + }, + "title": "AccountTradingLimit", + "type": "object" + }, + "AccountType": { + "description": "The account type returned for the account.", + "enum": [ + "trading", + "custodial", + "donor_advised", + "ira", + "trust", + "omnibus_non_disclosed", + "omnibus_sub", + "hsa", + "joint" + ], + "example": "trading", + "title": "AccountType", + "type": "string" + }, + "AccountUpdateRequest": { + "examples": [ + { + "beneficiaries": [ + { + "date_of_birth": "1970-01-01", + "family_name": "Smith", + "given_name": "John", + "middle_name": "P", + "relationship": "spouse", + "share_pct": "100", + "tax_id": "xxx-xx-xxxx", + "tax_id_type": "USA_SSN", + "type": "primary" + } + ], + "contact": { + "city": "San Mateo", + "country": "USA", + "email_address": "john.doe@example.com", + "phone_number": "+15556667788", + "postal_code": "94401", + "state": "CA", + "street_address": [ + "20 N San Mateo Dr" + ] + }, + "disclosures": { + "immediate_family_exposed": false, + "is_affiliated_exchange_or_finra": false, + "is_control_person": false, + "is_politically_exposed": false + }, + "enabled_assets": [ + "us_equity", + "crypto" + ], + "identity": { + "country_of_birth": "AUS", + "country_of_citizenship": "AUS", + "country_of_tax_residence": "USA", + "date_of_birth": "1990-01-01", + "family_name": "Doe", + "funding_source": [ + "employment_income" + ], + "given_name": "John", + "tax_id": "666-55-4321", + "tax_id_type": "USA_SSN" + }, + "trusted_contact": { + "email_address": "jane.doe@example.com", + "family_name": "Doe", + "given_name": "Jane" + } + } + ], + "properties": { + "agreements": { + "description": "Additional agreements, or new revisions of existing agreements, read and signed by the account holder.", + "items": { + "$ref": "#/components/schemas/Agreement" + }, + "type": "array" + }, + "allow_instant_ach": { + "description": "If provided, updates whether the account is enabled for Instant ACH by the partner. Omitting the field leaves the current setting unchanged.", + "type": "boolean" + }, + "beneficiaries": { + "items": { + "$ref": "#/components/schemas/Beneficiary" + }, + "type": "array" + }, + "cash_interest": { + "$ref": "#/components/schemas/AccountCashInterestPatch" + }, + "contact": { + "$ref": "#/components/schemas/Contact" + }, + "disclosures": { + "$ref": "#/components/schemas/Disclosures" + }, + "enabled_assets": { + "description": "The asset classes enabled on the account. Omit this field to leave the\naccount's enabled assets unchanged. Updates are additive only: the\nsubmitted list must contain every asset class already enabled on the account,\nbecause asset removal is not supported. For example, to enable\ncrypto for an account that currently trades only equities, submit\n`[\"us_equity\", \"crypto\"]` together with the signed crypto agreement.\n`us_option` may appear in this list for options-enabled accounts and\nmust be re-listed on additive updates, but options cannot be enabled\nthrough this endpoint.\n", + "items": { + "$ref": "#/components/schemas/EnabledAssetClass" + }, + "type": "array" + }, + "fpsl": { + "$ref": "#/components/schemas/AccountFPSLPatch" + }, + "identity": { + "$ref": "#/components/schemas/Identity" + }, + "primary_account_holder_id": { + "description": "The UUID of the primary account holder. This field is immutable after the account is created.\n\n- Omitting the field, or supplying the value already associated with the account, is a no-op.\n- Supplying a value different from the current primary account holder returns HTTP 403.\n", + "format": "uuid", + "type": "string" + }, + "trusted_contact": { + "$ref": "#/components/schemas/TrustedContact" + } + }, + "type": "object" + }, + "Activity": { + "allOf": [ + { + "properties": { + "account_id": { + "example": "c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4", + "format": "uuid", + "type": "string" + }, + "activity_type": { + "$ref": "#/components/schemas/ActivityType" + }, + "id": { + "example": "20220208125959696::88b5f678-fef5-447b-af15-f21e367e6d8c", + "type": "string" + } + }, + "type": "object" + }, + { + "oneOf": [ + { + "$ref": "#/components/schemas/TradeActivity" + }, + { + "$ref": "#/components/schemas/NonTradeActivity" + } + ] + } + ], + "description": "Base for activity types", + "required": [ + "id", + "activity_type" + ], + "title": "Activity" + }, + "ActivityEventV2": { + "allOf": [ + { + "$ref": "#/components/schemas/ActivityEventV2CommonFields" + }, + { + "properties": { + "details": { + "oneOf": [ + { + "$ref": "#/components/schemas/ActivityV2DetailTRD" + }, + { + "$ref": "#/components/schemas/ActivityV2DetailNTA" + } + ] + } + }, + "required": [ + "details" + ], + "type": "object" + } + ], + "description": "Represents an account activity, sent over the Event Streaming API.", + "title": "ActivityEventV2", + "type": "object" + }, + "ActivityEventV2CommonFields": { + "description": "Represents the common fields for all Activity V2 Events", + "properties": { + "account_id": { + "description": "Account UUID", + "format": "uuid", + "type": "string" + }, + "activity_subtype": { + "description": "Sub category for activity type, if any", + "type": "string" + }, + "activity_type": { + "description": "The type of the activity, which can be trade or any of the non trade activities", + "type": "string" + }, + "at": { + "description": "Timestamp of event", + "format": "date-time", + "minLength": 1, + "type": "string" + }, + "currency": { + "description": "Currency code in ISO format", + "type": "string" + }, + "event_id": { + "description": "Lexically sortable, monotonically increasing character string", + "format": "ulid", + "type": "string" + }, + "executed_at": { + "description": "Execution time for the activity event", + "format": "date-time", + "minLength": 1, + "type": "string" + }, + "net_amount": { + "description": "The net amount of money (positive or negative) associated with the activity", + "format": "decimal", + "type": "string" + }, + "previous_id": { + "description": "Previous ID is presented if this activity corrects or cancels a previous trade or non trade activity. It contains execution_id or trns_id respectively", + "format": "uuid", + "type": "string" + }, + "price": { + "description": "The price of the security involved with the activity", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "The quantity of the security involved with the activity", + "format": "decimal", + "type": "string" + }, + "ref_id": { + "description": "The unique identifier for the activity. For trades, the execution_id is used, for other activities the trns_id is used.", + "format": "uuid", + "type": "string" + }, + "settle_date": { + "description": "Date when the activity settled", + "format": "date", + "minLength": 1, + "type": "string" + }, + "status": { + "description": "Status of the activity", + "type": "string" + }, + "swap_fee_bps": { + "description": "Currency conversion fee rate base-point in case of local currency activity", + "format": "decimal", + "type": "string" + }, + "swap_rate": { + "description": "Conversion rate for local currency activities", + "format": "decimal", + "type": "string" + } + }, + "required": [ + "account_id", + "at", + "event_id", + "activity_type", + "executed_at", + "status", + "settle_date", + "currency", + "ref_id" + ], + "type": "object" + }, + "ActivitySubType": { + "description": "Represents a more specific classification to the `activity_type`.\nThis field is optional and may not always be populated, depending on the activity type and the available data.\nEach `activity_type` has a set of valid `activity_sub_type` values.\n\nFull mapping of `activity_type` to `activity_sub_type`:\n\n- **CGD**: Capital Gains Distribution activity sub-types:\n - **LTCG**: Long-Term Capital Gain\n - **STCG**: Short-Term Capital Gain\n\n- **DIV**: Dividend activity sub-types:\n - **CDIV**: Cash Dividend\n - **ROC**: Return of Capital\n - **SDIV**: Stock Dividend\n - **SPD**: Substitute Payment In Lieu Of Dividend\n\n- **FEE**: Fee-related activity sub-types:\n - **REG**: Regulatory Fee\n - **TAF**: Trading Activity Fee\n - **LCT**: Local Currency Trading Fee\n - **ORF**: Options Regulatory Fee\n - **OCC**: Options Clearing Corporation Fee\n - **NRC**: Non-Retail Commission Fee\n - **NRV**: Non-Retail Venue Fee\n - **COM**: Commission\n - **CAT**: Consolidated Audit Trail Fee\n\n- **INT**: Interest-related activity sub-types:\n - **MGN**: Margin Interest\n - **CDT**: Credit Interest\n - **SWP**: Sweep Interest\n - **QII**: Qualified Interest\n - **FI**: Fixed Income Interest (coupon or accrued)\n\n- **MA**: Merger and Acquisition activity sub-types:\n - **CMA**: Cash Merger\n - **SMA**: Stock Merger\n - **SCMA**: Stock & Cash Merger\n\n- **NC**: Name Change activity sub types\n - **SNC**: Symbol Name Change\n - **CNC**: CUSIP Name Change\n - **SCNC**: Symbol & CUSIP Name Change\n\n- **OPCA**: Option Corporate Action activity sub-types:\n - **DIV.CDIV**: Cash Dividend\n - **DIV.ROC**: Return of Capital\n - **DIV.SDIV**: Stock Dividend\n - **MA.CMA**: Cash Merger\n - **MA.SMA**: Stock Merger\n - **MA.SCMA**: Stock & Cash Merger\n - **NC.CNC**: CUSIP Name Change\n - **NC.SNC**: Symbol Name Change\n - **NC.SCNC**: Symbol & CUSIP Name Change\n - **SPIN**: Spin-off\n - **SPLIT.FSPLIT**: Forward Stock Split\n - **SPLIT.RSPLIT**: Reverse Stock Split\n - **SPLIT.USPLIT**: Unit Split\n\n- **REO**: Reorganization activity sub-types:\n - **REOS**: Stock only (1 or more stock legs)\n - **REOC**: Cash only (one cash leg)\n - **REOSC**: Stock and cash\n\n- **REORG**: Activity sub-types:\n - **WRM**: Worthless Removal\n\n- **SPLIT**: Stock Split activity sub-types:\n - **FSPLIT**: Forward Stock Split\n - **RSPLIT**: Reverse Stock Split\n - **USPLIT**: Unit Split\n\n- **VOF**: Voluntary Offering activity sub-types:\n - **VTND**: Tender Offer\n - **VWRT**: Warrant Exercise\n - **VRGT**: Rights Offer\n - **VEXH**: Exchange Offer\n\n- **WH**: Withholding activity sub-types:\n - **SWH**: State Withholding\n - **FWH**: Federal Withholding\n - **SLWH**: Sales Withholding", + "title": "ActivitySubType", + "type": "string" + }, + "ActivityType": { + "description": "Represents the various kinds of activity.\n\nTradeActivity's will always have the type `FILL`\n\n- **FILL**\n Order Fills (Partial/Full)\n- **ACATC**\n ACATS IN/OUT (Cash)\n- **ACATS**\n ACATS IN/OUT (Securities)\n- **CGD**\n Capital Gains Distribution\n- **CIL**\n Cash in Lieu of Stock\n- **CSD**\n Cash Disbursement (+)\n- **CSW**\n Cash Withdrawable\n- **DIV**\n Dividend\n- **DIVCGL**\n Dividend (Capital Gains Long Term)\n- **DIVCGS**\n Dividend (Capital Gains Short Term)\n- **DIVNRA**\n Dividend Adjusted (NRA Withheld)\n- **DIVROC**\n Dividend Return of Capital\n- **DIVTXEX**\n Dividend (Tax Exempt)\n- **FEE**\n REG and TAF Fees\n- **INT**\n Interest (Credit/Margin)\n- **JNLC**\n Journal Entry (Cash)\n- **JNLS**\n Journal Entry (Stock)\n- **OPASN**\n Option Assignment\n- **OPCA**\n Option Corporate Action\n- **OPCSH**\n Option cash deliverable for non-standard contracts\n- **OPEXC**\n Option Exercise\n- **OPEXP**\n Option Expiration\n- **OPTRD**\n Option Trade\n- **MA**\n Merger/Acquisition\n- **PTC**\n Pass Thru Change\n- **REO**\n Reorganization\n- **REORG**\n Worthless removal CA\n- **SPIN**\n Stock Spinoff\n- **SPLIT**\n Stock Split\n- **FOPT**\n Free of Payment Transfers\n- **OCT**\n On Chain Transactions (blockchain deposits/withdrawals)", + "enum": [ + "FILL", + "ACATC", + "ACATS", + "CGD", + "CIL", + "CSD", + "CSW", + "DIV", + "DIVCGL", + "DIVCGS", + "DIVNRA", + "DIVROC", + "DIVTXEX", + "FEE", + "INT", + "JNLC", + "JNLS", + "MA", + "OPASN", + "OPCA", + "OPCSH", + "OPEXC", + "OPEXP", + "OPTRD", + "PTC", + "REO", + "REORG", + "SPIN", + "SPLIT", + "FOPT", + "OCT" + ], + "title": "ActivityType", + "type": "string" + }, + "ActivityV2DetailNTA": { + "oneOf": [ + { + "$ref": "#/components/schemas/DIVSPDActivityV2" + }, + { + "$ref": "#/components/schemas/CDIVActivityV2" + }, + { + "$ref": "#/components/schemas/SDIVActivityV2" + }, + { + "$ref": "#/components/schemas/CGDActivityV2" + }, + { + "$ref": "#/components/schemas/ForwardSplitActivityV2" + }, + { + "$ref": "#/components/schemas/ReverseSplitActivityV2" + }, + { + "$ref": "#/components/schemas/UnitSplitActivityV2" + }, + { + "$ref": "#/components/schemas/SpinoffActivityV2" + }, + { + "$ref": "#/components/schemas/MAActivityV2" + }, + { + "$ref": "#/components/schemas/NCActivityV2" + }, + { + "$ref": "#/components/schemas/FixedIncomeRedemptionActivityV2" + }, + { + "$ref": "#/components/schemas/FixedIncomeInterestActivityV2" + }, + { + "$ref": "#/components/schemas/REOActivityV2" + }, + { + "$ref": "#/components/schemas/RightsDistributionActivityV2" + }, + { + "$ref": "#/components/schemas/RightsSubscriptionElectionActivityV2" + }, + { + "$ref": "#/components/schemas/TenderOfferActivityV2" + }, + { + "$ref": "#/components/schemas/ExchangeOfferActivityV2" + }, + { + "$ref": "#/components/schemas/WarrantExerciseElectionActivityV2" + }, + { + "$ref": "#/components/schemas/WRMActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaCDIVActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaSDIVActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaMAActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaNCActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaSPINActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaFSPLITActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaRSPLITActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaUSPLITActivityV2" + }, + { + "$ref": "#/components/schemas/OPASNActivityV2" + }, + { + "$ref": "#/components/schemas/OPEXCActivityV2" + }, + { + "$ref": "#/components/schemas/OPEXPActivityV2" + }, + { + "$ref": "#/components/schemas/OPTRDActivityV2" + }, + { + "$ref": "#/components/schemas/OPCSHActivityV2" + }, + { + "$ref": "#/components/schemas/AcatsActivityV2" + }, + { + "$ref": "#/components/schemas/AcatcActivityV2" + }, + { + "$ref": "#/components/schemas/FOPTActivityV2" + }, + { + "$ref": "#/components/schemas/DIVNRAActivityV2" + }, + { + "$ref": "#/components/schemas/DIVWHActivityV2" + }, + { + "$ref": "#/components/schemas/JNLSActivityV2" + }, + { + "$ref": "#/components/schemas/JNLCActivityV2" + }, + { + "$ref": "#/components/schemas/CSWActivityV2" + }, + { + "$ref": "#/components/schemas/FEEActivityV2" + }, + { + "$ref": "#/components/schemas/MEMActivityV2" + }, + { + "$ref": "#/components/schemas/OCTActivityV2" + } + ], + "type": "object" + }, + "ActivityV2DetailTRD": { + "description": "Activity details for a fill or partial_fill event", + "properties": { + "asset_id": { + "description": "Asset ID (For options this represents the option contract ID)", + "format": "uuid", + "type": "string" + }, + "client_order_id": { + "description": "Order ID provided by the customer", + "type": "string" + }, + "commission": { + "description": "Commission to collect from the account holder", + "format": "decimal", + "type": "string" + }, + "cum_qty": { + "description": "Total filled quantity on the order", + "format": "decimal", + "type": "string" + }, + "cusip": { + "description": "CUSIP of the security involved with the activity", + "type": "string" + }, + "execution_type": { + "description": "The execution type", + "enum": [ + "fill", + "trade_correct", + "trade_bust" + ], + "type": "string" + }, + "leaves_qty": { + "description": "Unfilled quantity on the order, when order is filled value could be 0", + "format": "decimal", + "type": "string" + }, + "order_id": { + "description": "Order ID generated by Alpaca", + "format": "uuid", + "type": "string" + }, + "order_status": { + "description": "Identifies the current status of the order", + "type": "string" + }, + "side": { + "description": "Represents what side of the transaction an order was on", + "enum": [ + "buy", + "sell" + ], + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "order_id", + "side", + "symbol", + "asset_id", + "leaves_qty", + "cum_qty", + "order_status", + "execution_type" + ], + "type": "object" + }, + "AdminActionBelongsTo": { + "description": "Represents structure of an Identifier for all AdminAction type", + "properties": { + "id_reference": { + "type": "string" + }, + "kind": { + "$ref": "#/components/schemas/AdminActionBelongsToKind" + } + }, + "title": "AdminActionBelongsTo", + "type": "object" + }, + "AdminActionBelongsToKind": { + "enum": [ + "account", + "owner", + "correspondent" + ] + }, + "AdminActionCategory": { + "description": "Category of the Admin Action", + "enum": [ + "accounts", + "order", + "other" + ] + }, + "AdminActionCreatedBy": { + "description": "Represents structure of an Creator's Identifier for all AdminAction type\n", + "properties": { + "id_reference": { + "type": "string" + }, + "kind": { + "$ref": "#/components/schemas/AdminActionCreatedByKind" + } + }, + "title": "AdminActionCreatedBy", + "type": "object" + }, + "AdminActionCreatedByKind": { + "enum": [ + "admin" + ] + }, + "AdminActionEventGeneral": { + "description": "Represents general fields for all AdminAction type", + "properties": { + "at": { + "description": "Timestamp of event", + "format": "date-time", + "type": "string" + }, + "belongs_to": { + "$ref": "#/components/schemas/AdminActionBelongsTo" + }, + "category": { + "$ref": "#/components/schemas/AdminActionCategory" + }, + "correspondent": { + "description": "Related correspondent", + "type": "string" + }, + "created_by": { + "$ref": "#/components/schemas/AdminActionCreatedBy" + }, + "event_id": { + "description": "Lexically sortable, monotonically increasing character array", + "format": "ulid", + "type": "string" + }, + "note": { + "description": "Free text form description of the admin action", + "type": "string" + }, + "replaces_event_id": { + "description": "Id of the replaced event (optional)", + "format": "ulid", + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/AdminActionType" + }, + "visibility": { + "$ref": "#/components/schemas/AdminActionVisibility" + } + }, + "required": [ + "event_id", + "at", + "belongs_to", + "created_by", + "type", + "category", + "visibility", + "note", + "correspondent" + ], + "title": "AdminActionEvent", + "type": "object" + }, + "AdminActionLegacyNote": { + "allOf": [ + { + "$ref": "#/components/schemas/AdminActionEventGeneral" + }, + { + "properties": { + "context": { + "description": "Variable schema type which depends on the type", + "type": "object" + } + }, + "required": [ + "context" + ], + "title": "AdminActionContextLegacyNote", + "type": "object" + } + ], + "description": "Represents structure of a LegacyNote type AdminAction", + "examples": [ + { + "at": "2023-03-06T16:38:01Z", + "belongs_to": { + "kind": "account", + "value": "0bbf1dd7-4235-4eca-8b1a-0db63572c735" + }, + "category": "other", + "context": {}, + "correspondent": "LPCA", + "created_by": { + "kind": "admin", + "value": "19455a3c-595f-457f-97b3-64a2b5aeae96" + }, + "event_id": "01GTVS4FVS2KJDTPYH2WM6NAXF", + "note": "Performed action: Positions split AMZN (long): 1.011266402\n", + "type": "legacy_note_admin_event", + "visibility": "internal" + } + ] + }, + "AdminActionLiquidation": { + "allOf": [ + { + "$ref": "#/components/schemas/AdminActionEventGeneral" + }, + { + "properties": { + "context": { + "description": "Variable schema type which depends on the type", + "properties": { + "available_qty": { + "format": "decimal", + "type": "string" + }, + "error": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "requested_qty": { + "format": "decimal", + "type": "string" + }, + "symbol": { + "type": "string" + } + }, + "type": "object" + } + }, + "required": [ + "context" + ], + "title": "AdminActionContextLiquidation", + "type": "object" + } + ], + "description": "Represents structure of a Liquidation type AdminAction", + "examples": [ + { + "at": "2023-03-06T16:38:01Z", + "belongs_to": { + "kind": "account", + "value": "0bbf1dd7-4235-4eca-8b1a-0db63572c735" + }, + "category": "accounts", + "context": { + "available_qty": "0.0001", + "error": "", + "reason": "Liquidation due to real time risk", + "requested_qty": "0.0001", + "symbol": "TSLA" + }, + "correspondent": "LPCA", + "created_by": { + "kind": "admin", + "value": "19455a3c-595f-457f-97b3-64a2b5aeae96" + }, + "event_id": "01GTVS4FVS2KJDTPYH2WM6NAXF", + "note": "Performed action: Position liquidated: Asset: TSLA, Quantity: 0.0001, Reason: Liquidation due to real time risk\n", + "type": "liquidation_admin_event", + "visibility": "external" + } + ] + }, + "AdminActionTransactionCancel": { + "allOf": [ + { + "$ref": "#/components/schemas/AdminActionEventGeneral" + }, + { + "properties": { + "context": { + "description": "Variable schema type which depends on the type", + "properties": { + "entry_type": { + "type": "string" + }, + "external_id": { + "type": "string" + }, + "transaction_id": { + "format": "uuid", + "type": "string" + } + }, + "type": "object" + } + }, + "required": [ + "context" + ], + "title": "AdminActionContextTransactionCancel", + "type": "object" + } + ], + "description": "Represents structure of a TransactionCancel type AdminAction", + "examples": [ + { + "at": "2023-03-06T16:38:01Z", + "belongs_to": { + "kind": "account", + "value": "0bbf1dd7-4235-4eca-8b1a-0db63572c735" + }, + "category": "accounts", + "context": { + "entry_type": "JNLC", + "external_id": "d5eede2c-1c08-45df-9800-87ad5eefc11f", + "transaction_id": "fdf18af2-142b-409e-8aad-d1731e276af0" + }, + "correspondent": "LPCA", + "created_by": { + "kind": "admin", + "value": "19455a3c-595f-457f-97b3-64a2b5aeae96" + }, + "event_id": "01GTVS4FVS2KJDTPYH2WM6NAXF", + "note": "\"Transaction fdf18af2-142b-409e-8aad-d1731e276af0 cancelled for LPCA-12345678\n", + "type": "transaction_cancel_admin_event", + "visibility": "external" + } + ] + }, + "AdminActionType": { + "description": "Type of the Admin Action", + "enum": [ + "liquidation_admin_event", + "legacy_note_admin_event", + "transaction_cancel_admin_event" + ] + }, + "AdminActionVisibility": { + "description": "Visibility of the Admin Action", + "enum": [ + "internal", + "external", + "correspondent_only" + ] + }, + "AdminConfigurations": { + "description": "These configurations show account properties that are overriden either by Alpaca Broker Operations or an automated process.\n\nThese values cannot be modified by the Broker Partners.\n\nThis schema represents the current, effective value of each configuration (e.g. as returned by the get trading account endpoint). For the shape of the payloads broadcast by the **events** streaming API when these values change, see [AdminConfigurationsEvent](#/components/schemas/AdminConfigurationsEvent).", + "properties": { + "acct_daily_transfer_limit": { + "description": "Override the correspondent level daily transfer limits", + "format": "decimal", + "type": "string" + }, + "allow_instant_ach": { + "description": "If true, the account is allowed to perform instant ACH", + "type": "boolean" + }, + "disable_algodash_access": { + "description": "If true, the account is allowed to access algo dash", + "type": "boolean" + }, + "disable_api_key": { + "description": "If true, the account's API key will be disabled", + "type": "boolean" + }, + "disable_crypto": { + "description": "If true, the account is not allowed to trade cryptos", + "type": "boolean" + }, + "disable_day_trading": { + "description": "If true, the account is not allowed to day trade (e.g. buy and sell the same security on the same day)", + "type": "boolean" + }, + "disable_fractional": { + "description": "If true, the account cannot create orders for fractional share positions", + "type": "boolean" + }, + "disable_shorting": { + "description": "If true the account is not allowed to create short position orders", + "type": "boolean" + }, + "incoming_transfers_blocked": { + "description": "If true, incoming transfers to this account are rejected", + "type": "boolean" + }, + "max_margin_multiplier": { + "description": "The max margin multiplier set by admin for this account. Can be \"1\", \"2\", or \"4\".", + "type": "string" + }, + "max_options_trading_level": { + "description": "The max options trading level set by admin for this account.\n0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.\n", + "enum": [ + 0, + 1, + 2, + 3 + ], + "type": "integer" + }, + "outgoing_transfers_blocked": { + "description": "If true, outgoing transfers from this account are rejected", + "type": "boolean" + }, + "restrict_to_liquidation_reasons": { + "$ref": "#/components/schemas/RestrictToLiquidationReasons" + } + }, + "title": "AdminConfigurations", + "type": "object" + }, + "AdminConfigurationsEvent": { + "description": "Represents a change to admin configurations, as broadcast over the **events** streaming API. Only fields whose value changed are included; unrelated update events will not include a flag that did not change.\n\nDepending on the type of the Admin Configuration, the sent event will behave differently. For bool flags we are only sending the new value.\n\nFor example, the following payload means that the disable_shorting flag was set to true:\n\n```\n{\n \"disable_shorting\": true\n}\n```\n\nFor other data types, we are embedding the old and new values into the payload. For example changing the max_margin_multiplier from 4 to 1 will yield this payload:\n\n```\n{\n \"max_margin_multiplier\": {\n \"from\": 4,\n \"to\": 1\n }\n}\n```\n\nIntroducing an override value from the default will yield a null value as `from`. For example restricting the max_margin_multiplier to 1 from default will yield the following payload:\n\n```\n{\n \"max_margin_multiplier\": {\n \"from\": null,\n \"to\": 1\n }\n}\n```", + "properties": { + "acct_daily_transfer_limit": { + "description": "The correspondent level daily transfer limit override was changed", + "properties": { + "from": { + "description": "Old value of the daily transfer limit", + "type": "string" + }, + "to": { + "description": "New value of the daily transfer limit", + "type": "string" + } + }, + "type": "object" + }, + "allow_instant_ach": { + "description": "If true, the account is allowed to perform instant ACH", + "type": "boolean" + }, + "disable_algodash_access": { + "description": "If true, the account is allowed to access algo dash", + "type": "boolean" + }, + "disable_api_key": { + "description": "If true, the account's API key will be disabled", + "type": "boolean" + }, + "disable_crypto": { + "description": "If true, the account is not allowed to trade cryptos", + "type": "boolean" + }, + "disable_day_trading": { + "description": "If true, the account is not allowed to day trade (e.g. buy and sell the same security on the same day)", + "type": "boolean" + }, + "disable_fractional": { + "description": "If true, the account cannot create orders for fractional share positions", + "type": "boolean" + }, + "disable_shorting": { + "description": "If true the account is not allowed to create short position orders", + "type": "boolean" + }, + "incoming_transfers_blocked": { + "description": "If true, incoming transfers to this account are rejected", + "type": "boolean" + }, + "max_margin_multiplier": { + "description": "Max margin multiplier was changed by admin to this value", + "properties": { + "from": { + "description": "Old value of margin multiplier", + "type": "string" + }, + "to": { + "description": "New value of margin multiplier", + "type": "string" + } + }, + "type": "object" + }, + "max_options_trading_level": { + "description": "Max options trading level was changed by admin to this value. It can be 0, 1, 2, or 3.", + "properties": { + "from": { + "description": "Old value of max options trading level", + "type": "string" + }, + "to": { + "description": "New value of max options trading level", + "type": "string" + } + }, + "type": "object" + }, + "outgoing_transfers_blocked": { + "description": "If true, outgoing transfers from this account are rejected", + "type": "boolean" + }, + "restrict_to_liquidation_reasons": { + "$ref": "#/components/schemas/RestrictToLiquidationReasons" + } + }, + "title": "AdminConfigurationsEvent", + "type": "object" + }, + "AdvancedInstructions": { + "description": "Advanced instructions for Direct Market Access (DMA) routing. When `algorithm` is `DMA`,\nthe order is routed directly to the exchange specified in `destination`. Note that this feature is only\navailable to partners/correspondents who have been enabled for DMA.", + "examples": [ + { + "algorithm": "DMA", + "destination": "IEX", + "display_qty": "100" + } + ], + "properties": { + "algorithm": { + "description": "The advanced routing algorithm to use for the order. Only `DMA` (Direct Market Access) is supported.", + "enum": [ + "DMA" + ], + "example": "DMA", + "type": "string" + }, + "destination": { + "description": "Target exchange for order execution. Required when `algorithm` is `DMA`.", + "enum": [ + "IEX", + "MEMX" + ], + "example": "IEX", + "type": "string" + }, + "display_qty": { + "description": "Maximum shares displayed on the exchange at any time. Must be in round lot increments.", + "example": "100", + "format": "decimal", + "type": "string" + } + }, + "title": "AdvancedInstructions", + "type": "object" + }, + "AggregatePositionResponse": { + "examples": [ + { + "asset_type": "us_equity", + "closing_price": "148.4700", + "cusip": "037833100", + "long_market_value": "148.4700", + "long_qty": "1", + "num_accounts": 1, + "short_market_value": "0", + "short_qty": "0", + "symbol": "AAPL" + } + ], + "properties": { + "asset_type": { + "$ref": "#/components/schemas/AssetClass" + }, + "closing_price": { + "description": "EOD asset price per share at session close", + "format": "decimal", + "type": "string" + }, + "cusip": { + "description": "Cusip (9 digits, can start with 0's)", + "format": "decimal", + "type": "string" + }, + "long_market_value": { + "description": "Aggregate notional dollar amount of the partner's long positions", + "format": "decimal", + "type": "string" + }, + "long_qty": { + "description": "Aggregate number of shares that the partner is long", + "format": "decimal", + "type": "string" + }, + "num_accounts": { + "description": "Number of accounts that have a position in this asset (either long or short)", + "format": "decimal", + "type": "integer" + }, + "short_market_value": { + "description": "Aggregate notional dollar amount of the partner's short positions", + "format": "decimal", + "type": "string" + }, + "short_qty": { + "description": "Aggregate number of shares that the partner is short", + "format": "decimal", + "type": "string" + }, + "symbol": { + "description": "Symbol of asset", + "type": "string" + } + }, + "title": "", + "type": "object" + }, + "Agreement": { + "properties": { + "agreement": { + "$ref": "#/components/schemas/AgreementType" + }, + "ip_address": { + "description": "The ip_address the signed agreements were sent from by the user.", + "example": "185.13.21.99", + "format": "ipv4", + "type": "string" + }, + "revision": { + "description": "The agreement revision.\nThe format is XX.YYYY.MM where XX is an incrementing revision number, YYYY is the year and MM is the month.\nIf the revision is not specified in a POST or PATCH request, the active revision will be used, which will align with the [Alpaca Documents Library](https://alpaca.markets/disclosures).\n", + "type": "string" + }, + "signed_at": { + "description": "The timestamp the agreement was signed.", + "example": "2019-09-11T18:09:33Z", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "agreement", + "signed_at", + "ip_address" + ], + "type": "object" + }, + "AgreementType": { + "description": "- margin_agreement: Alpaca Margin Agreement\n- account_agreement: Alpaca Account Agreement\n- customer_agreement: Alpaca Customer Agreement\n- crypto_agreement: Alpaca Crypto agreement\n- options_agreement: Alpaca Option agreement\n- custodial_customer_agreement: Alpaca Custodial Customer agreement\n", + "enum": [ + "margin_agreement", + "account_agreement", + "customer_agreement", + "crypto_agreement", + "options_agreement" + ], + "example": "customer_agreement", + "title": "AgreementType", + "type": "string" + }, + "Announcement": { + "description": "The announcements endpoint contains public information on previous and upcoming dividends, mergers, spinoffs, and stock splits.\n\nAnnouncement data is made available through the API as soon as it is ingested by Alpaca, which is typically the following trading day after the declaration date. This provides insight into future account stock position and cash balance changes that will take effect on an announcement's payable date. Additionally, viewing previous announcement details can improve bookkeeping and reconciling previous account cash and position changes.", + "examples": [ + { + "ca_sub_type": "cash", + "ca_type": "dividend", + "cash": "0", + "corporate_action_id": "78467X109_AA22", + "declaration_date": "2021-12-19", + "ex_date": "2022-01-21", + "id": "bebc5ece-34be-47e9-b944-687e69a102be", + "initiating_original_cusip": "252787106", + "initiating_symbol": "DIA", + "new_rate": "1", + "old_rate": "1", + "payable_date": "2022-02-14", + "record_date": "2022-01-24", + "target_original_cusip": "252787106", + "target_symbol": "DIA" + } + ], + "properties": { + "ca_sub_type": { + "$ref": "#/components/schemas/AnnouncementCASubType" + }, + "ca_type": { + "$ref": "#/components/schemas/AnnouncementCAType" + }, + "cash": { + "description": "The amount of cash to be paid per share held by an account on the record date.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "corporate_action_id": { + "description": "ID that remains consistent across all announcements for the same corporate action. Unlike 'id', this can be used to connect multiple announcements to see how the terms have changed throughout the lifecycle of the corporate action event.", + "minLength": 1, + "type": "string" + }, + "declaration_date": { + "description": "Date the corporate action or subsequent terms update was announced.", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The first date that purchasing a security will not result in a corporate action entitlement.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "id": { + "description": "ID that is specific to a single announcement.", + "minLength": 1, + "type": "string" + }, + "initiating_original_cusip": { + "description": "CUSIP of the company initiating the announcement.", + "minLength": 1, + "type": "string" + }, + "initiating_symbol": { + "description": "Symbol of the company initiating the announcement.", + "minLength": 1, + "type": "string" + }, + "new_rate": { + "description": "The numerator to determine any quantity change ratios in positions.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "old_rate": { + "description": "The denominator to determine any quantity change ratios in positions.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "payable_date": { + "description": "The date the announcement will take effect. On this date, account stock and cash balances are expected to be processed accordingly.", + "minLength": 1, + "type": "string" + }, + "record_date": { + "description": "The date an account must hold a settled position in the security in order to receive the corporate action entitlement.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "target_original_cusip": { + "description": "CUSIP of the child company involved in the announcement.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "target_symbol": { + "description": "Symbol of the child company involved in the announcement.", + "minLength": 1, + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "id", + "corporate_action_id", + "ca_type", + "ca_sub_type", + "initiating_symbol", + "initiating_original_cusip", + "target_symbol", + "target_original_cusip", + "declaration_date", + "ex_date", + "record_date", + "payable_date", + "cash", + "old_rate", + "new_rate" + ], + "title": "Announcement", + "type": "object" + }, + "AnnouncementCASubType": { + "description": "Announcements have both a type and a subtype to categorize them. This model represents the lowever level abstract \"sub types\" of Announcement. Please see the AnnouncementCAType model for higher level descriptions of the possible types\n\nPossible values are:\n\n- from the `dividend` type:\n - **cash**\n\n A cash payment based on the number of shares the account holds on the record date.\n - **stock**\n\n A stock payment based on the number of shares the account holds on the record date.\n\n- from the `merger` type:\n - **merger_update**\n\n An update to the terms of an upcoming merger. This can happen any number of times before the merger is completed and can be tracked by using the id parameter.\n\n - **merger_completion**\n\n A final update in the terms of the merger in which the intiating_symbol will acquire the target_symbol. Any previous terms updates for this announcement will have the same id value.\n\n- from the `split` type:\n - **stock_split**\n\n An increase in the number of shares outstanding with a decrease in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the split\n - **until_split**\n\n An increase in the number of shares outstanding with a decrease in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the split.\n - **reverse_split**\n\n A decrease in the number of shares outstanding with an increase in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the spli\n - **recapitalization**\n\n A stock recapitalization, typically used by a company to adjust debt and equity ratios.\n\n- from the `spinoff` type:\n - **spinoff**\n\n A disbursement of a newly tradable security when the intiating_symbol creates the target_symbol.", + "enum": [ + "cash", + "stock", + "merger_update", + "merger_completion", + "stock_split", + "until_split", + "reverse_split", + "recapitalization", + "spinoff" + ], + "title": "", + "type": "string" + }, + "AnnouncementCAType": { + "description": "Announcements have both a type and a subtype to categorize them. This model represents the higher level abstract \"types\" of Announcement. Please see the AnnouncementCASubType model for finer grain descriptions of the subtypes\n\nPossible values are:\n- dividend\n can have `cash` and `stock` subtypes\n- merger\n has `merger_update` and `merger_completion` sub types\n- split\n has `stock_split`, `until_split`, `reverse_split`, and `recapitalization` sub types\n- spinoff\n currently has only the `spinoff` subtype and thus is just this higher level category for now. A disbursement of a newly tradable security when the intiating_symbol creates the target_symbol.", + "enum": [ + "dividend", + "merger", + "split", + "spinoff" + ], + "example": "dividend", + "title": "", + "type": "string" + }, + "Asset": { + "description": "Assets are sorted by asset class, exchange and symbol. Some assets are not tradable with Alpaca. These assets will be marked with the flag tradable=false", + "properties": { + "attributes": { + "description": "Unique characteristics of the asset. Supported values:\n- `ptp_no_exception`: Asset is a Publicly Traded Partnership (PTP) without a qualified notice; non-U.S. customers may incur 10% withholding on gross proceeds as per IRS guidance, and are blocked from being purchased by default.\n- `ptp_with_exception`: Users can open positions in these PTPs without general restrictions.\n- `ipo`: Accepting limit orders only before the stock begins trading on the secondary market.\n- `has_options`: The underlying equity has listed options available on the platform. Note: if the equity had inactive/expired contracts in the past, this will still show up.\n- `options_late_close`: Indicates the underlying asset's options contracts close at 4:15pm ET instead of the standard 4:00pm ET.\n- `fractional_eh_enabled`: Indicates the asset accepts fractional orders during extended hours sessions (pre-market, post-market, and overnight if enabled).\n- `overnight_tradable`: Asset is eligible for overnight (24x5) trading in supported venues on the platform.\n- `overnight_halted`: Asset is eligible for overnight trading but is currently halted/blocked for overnight sessions due to risk, corporate action, compliance, or venue constraints.", + "example": [ + "ptp_no_exception", + "ipo" + ], + "items": { + "enum": [ + "ptp_no_exception", + "ptp_with_exception", + "ipo", + "has_options", + "options_late_close", + "fractional_eh_enabled", + "overnight_tradable", + "overnight_halted" + ], + "type": "string" + }, + "type": "array" + }, + "borrow_status": { + "description": "Borrow status for US equity assets. This field is omitted for non-US-equity assets.", + "enum": [ + "easy_to_borrow", + "hard_to_borrow" + ], + "example": "easy_to_borrow", + "type": "string" + }, + "class": { + "$ref": "#/components/schemas/AssetClass" + }, + "exchange": { + "$ref": "#/components/schemas/Exchange" + }, + "fractionable": { + "description": "Asset is fractionable or not", + "example": true, + "type": "boolean" + }, + "id": { + "description": "Asset ID", + "example": "904837e3-3b76-47ec-b432-046db621571b", + "format": "uuid", + "type": "string" + }, + "maintenance_margin_requirement": { + "deprecated": true, + "description": "**deprecated**: Please use margin_requirement_long or margin_requirement_short instead. Note that these fields are of type string.\nShows the margin requirement percentage for the asset (equities only).\n", + "type": "number" + }, + "margin_requirement_long": { + "description": "The margin requirement percentage for the asset's long positions (equities only), encoded as a decimal string.", + "example": "100", + "format": "decimal", + "type": "string" + }, + "margin_requirement_short": { + "description": "The margin requirement percentage for the asset's short positions (equities only), encoded as a decimal string.", + "example": "30", + "format": "decimal", + "type": "string" + }, + "marginable": { + "description": "Asset is marginable or not", + "example": true, + "type": "boolean" + }, + "min_order_size": { + "description": "Minimum order size. Field available for crypto only.", + "type": "string" + }, + "min_trade_increment": { + "description": "Amount a trade quantity can be incremented by. Field available for crypto only.", + "type": "string" + }, + "name": { + "description": "The official name of the asset", + "example": "Apple Inc. Common Stock", + "type": "string" + }, + "price_increment": { + "description": "Amount the price can be incremented by. Field available for crypto only.", + "type": "string" + }, + "shortable": { + "description": "Asset is shortable or not", + "example": true, + "type": "boolean" + }, + "status": { + "description": "active or inactive", + "enum": [ + "active", + "inactive" + ], + "example": "active", + "type": "string" + }, + "symbol": { + "description": "The symbol of the asset", + "example": "AAPL", + "type": "string" + }, + "tradable": { + "description": "Asset is tradable on Alpaca or not", + "example": true, + "type": "boolean" + } + }, + "required": [ + "id", + "class", + "exchange", + "symbol", + "name", + "status", + "tradable", + "marginable", + "shortable", + "fractionable", + "margin_requirement_long", + "margin_requirement_short" + ], + "title": "Asset", + "type": "object" + }, + "AssetClass": { + "description": "This represents the category to which the asset belongs to. It serves to identify the nature of the financial instrument, with options including \"us_equity\" for U.S. equities, \"us_option\" for U.S. options, \"crypto\" for cryptocurrencies, and \"ipo\" for IPO indications of interest. This `asset_class: ipo` value is distinct from the assets API `attributes: [\"ipo\"]` flag.", + "enum": [ + "us_equity", + "us_option", + "crypto", + "ipo" + ], + "type": "string" + }, + "AssetEntryRequirements": { + "description": "Defines the necessary conditions that must be met to initiate a position for a specific asset", + "properties": { + "regt_long": { + "description": "The percentage of the asset's market value required as Reg T (2x) buying power to open a long position", + "example": "0.5", + "format": "decimal", + "type": "string" + }, + "regt_short": { + "description": "The percentage of the asset's market value required as Reg T (2x) buying power to open a short position", + "example": "0.5", + "format": "decimal", + "type": "string" + }, + "symbol": { + "description": "The symbol (or asset id) of the requested asset", + "example": "AAPL", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "title": "AssetEntryRequirements", + "type": "object" + }, + "AuthorizeOAuthTokenResponse": { + "description": "", + "examples": [ + { + "client_id": "7a3c52a910e1dc2abbb14da2b6b8e711", + "code": "912b5502-c983-40f7-a01d-6a66f13a754d", + "redirect_uri": "http://localhost", + "scope": "" + } + ], + "properties": { + "client_id": { + "description": "OAuth `client_id`", + "minLength": 1, + "type": "string" + }, + "code": { + "description": "OAuth code to exchange with token", + "minLength": 1, + "type": "string" + }, + "redirect_uri": { + "description": "Redirect URI of OAuth flow", + "minLength": 1, + "type": "string" + }, + "scope": { + "description": "Granted scopes", + "type": "string" + } + }, + "required": [ + "code", + "client_id", + "redirect_uri", + "scope" + ], + "type": "object" + }, + "Bank": { + "examples": [ + { + "account_id": "56712986-9ff7-4d8f-8e52-077e099e533e", + "account_number": "123456789abc", + "bank_code": "123456789", + "bank_code_type": "ABA", + "city": "", + "country": "", + "created_at": "2022-02-11T21:35:19.268681613Z", + "id": "8475c676-68e3-4cfc-a683-9ca2f47a6172", + "name": "Bank XYZ", + "postal_code": "", + "state_province": "", + "status": "QUEUED", + "street_address": "", + "updated_at": "2022-02-11T21:35:19.268681613Z" + } + ], + "properties": { + "account_id": { + "format": "uuid", + "type": "string" + }, + "account_number": { + "type": "string" + }, + "bank_code": { + "description": "9-Digit ABA RTN (Routing Number) or BIC", + "type": "string" + }, + "bank_code_type": { + "description": "ABA (Domestic) or BIC (International)", + "enum": [ + "ABA", + "BIC" + ], + "type": "string" + }, + "city": { + "description": "Only for international banks", + "type": "string" + }, + "country": { + "description": "Only for international banks", + "type": "string" + }, + "created_at": { + "description": "Format: 2020-01-01T01:01:01Z", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "extra_fields": { + "$ref": "#/components/schemas/BankAdditionalFields" + }, + "id": { + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": "string" + }, + "name": { + "description": "Name of recipient bank", + "type": "string" + }, + "postal_code": { + "description": "Only for international banks", + "type": "string" + }, + "state_province": { + "description": "Only for international banks", + "type": "string" + }, + "status": { + "description": "QUEUED, SENT_TO_CLEARING, APPROVED, REJECTED, CANCELED", + "enum": [ + "QUEUED", + "SENT_TO_CLEARING", + "APPROVED", + "REJECTED", + "CANCELED" + ], + "type": "string" + }, + "street_address": { + "description": "Only for international banks", + "type": "string" + }, + "updated_at": { + "description": "Format: 2020-01-01T01:01:01Z", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "created_at", + "updated_at", + "name", + "bank_code", + "bank_code_type", + "account_number" + ], + "type": "object" + }, + "BankAdditionalFields": { + "description": "Additional wire instructions used to explicitly specify intermediary (correspondent) banks for international wire transfers. If omitted, intermediary banks may be automatically selected by downstream institutions, which can result in delays or additional charges.\n", + "properties": { + "intermediary_bank1_bic": { + "description": "The primary intermediary (correspondent) bank to be used when routing the international wire transfer to the beneficiary bank.", + "type": "string" + }, + "intermediary_bank2_bic": { + "description": "An additional intermediary bank to be used if the wire transfer requires multiple correspondent banks before reaching the beneficiary bank.", + "type": "string" + }, + "intermediary_bank3_bic": { + "description": "A tertiary intermediary bank used in complex international wire routes that require three correspondent banks prior to reaching the beneficiary bank.", + "type": "string" + } + }, + "type": "object" + }, + "BatchCreateFundingWalletRequest": { + "properties": { + "account_ids": { + "description": "list of UUID account ids which will have funding wallets created", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": "object" + }, + "BatchCreateFundingWalletResponse": { + "properties": { + "funding_wallets": { + "items": { + "$ref": "#/components/schemas/FundingWallet" + }, + "type": "array" + } + }, + "type": "object" + }, + "BatchJournalRequest": { + "description": "Journals API allows you to move cash or securities from one account to another.\n\nThis model represents the fields you can specify when creating a request of many Journals out of one account to many others at once.", + "properties": { + "correspondent": { + "description": "The 4-character correspondent code", + "example": "LPCA", + "type": "string" + }, + "entries": { + "description": "An array of objects describing which accounts you want to move funds into and how much to move into each account", + "items": { + "properties": { + "amount": { + "description": "Journal amount in USD", + "type": [ + "string", + "null" + ] + }, + "currency": { + "description": "Currency code in ISO format", + "type": [ + "string", + "null" + ] + }, + "description": { + "description": "Journal entry description, gets returned in the response", + "type": "string" + }, + "qty": { + "type": [ + "string", + "null" + ] + }, + "symbol": { + "type": "string" + }, + "to_account": { + "description": "The ID of the account that you want to journal funds into", + "format": "uuid", + "type": "string" + }, + "transmitter_account_number": { + "description": "Only valid for JNLC journals. Null for JNLS.max 255 characters", + "type": "string" + }, + "transmitter_address": { + "description": "Only valid for JNLC journals. Null for JNLS.max 255 characters", + "type": "string" + }, + "transmitter_financial_institution": { + "description": "Only valid for JNLC journals. Null for JNLS.max 255 characters", + "type": "string" + }, + "transmitter_name": { + "description": "Only valid for JNLC journals. Null for JNLS. Max 255 characters.", + "type": "string" + }, + "transmitter_timestamp": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "to_account", + "amount" + ], + "type": "object" + }, + "minItems": 1, + "type": "array" + }, + "entry_type": { + "description": "Only supports `JNLC` for now", + "enum": [ + "JNLC" + ], + "type": "string" + }, + "from_account": { + "description": "The account id that is the originator of the funds being moved. Most likely is your Sweep Firm Account", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "entry_type", + "from_account", + "entries" + ], + "title": "BatchJournalRequest", + "type": "object" + }, + "BatchJournalResponse": { + "description": "A forward batch journal result selected by `entry_type`, with an optional non-empty failure message.", + "discriminator": { + "mapping": { + "JNLC": "#/components/schemas/BatchJournalResponseJNLC", + "JNLS": "#/components/schemas/BatchJournalResponseJNLS" + }, + "propertyName": "entry_type" + }, + "examples": [ + { + "currency": "USD", + "description": "", + "entry_type": "JNLC", + "from_account": "8f8c8cee-2591-4f83-be12-82c659b5e748", + "id": "56f106e5-25a4-4eee-96fa-25bb05dc86bc", + "net_amount": "1000", + "price": null, + "qty": null, + "settle_date": null, + "status": "pending", + "symbol": null, + "system_date": null, + "to_account": "399f85f1-cbbd-4eaa-a934-70027fb5c1de" + }, + { + "currency": "USD", + "description": "this is a test journal", + "entry_type": "JNLS", + "from_account": "8f4f3d11-4483-4199-840f-6c5fe0b7ca24", + "id": "f45f67e8-d1fc-4136-aa4f-cf4460aecdfc", + "net_amount": null, + "price": "128.23", + "qty": "0.5", + "settle_date": "2020-12-24", + "status": "executed", + "symbol": "AAPL", + "system_date": "2020-12-24", + "to_account": "a7a7e666-6f2a-433c-8c33-17b66b8941fa" + }, + { + "currency": "USD", + "description": "", + "entry_type": "JNLC", + "error_message": "The destination account is not eligible to receive this journal.", + "from_account": "8f8c8cee-2591-4f83-be12-82c659b5e748", + "id": "c79bcd51-4bea-4d1d-9b3c-f37f5035b8f7", + "net_amount": "250", + "price": null, + "qty": null, + "settle_date": null, + "status": "refused", + "symbol": null, + "system_date": null, + "to_account": "d5f7dbea-cb40-4ea6-a56d-e30d572ee84f" + } + ], + "oneOf": [ + { + "$ref": "#/components/schemas/BatchJournalResponseJNLC" + }, + { + "$ref": "#/components/schemas/BatchJournalResponseJNLS" + } + ], + "title": "BatchJournalResponse" + }, + "BatchJournalResponseJNLC": { + "allOf": [ + { + "$ref": "#/components/schemas/JNLC" + }, + { + "properties": { + "error_message": { + "description": "Description of why this journal transaction failed. Omitted for successful results.", + "minLength": 1, + "type": "string" + } + }, + "type": "object" + } + ], + "description": "A cash journal result returned by the forward batch endpoint.", + "examples": [ + { + "currency": "USD", + "description": "", + "entry_type": "JNLC", + "from_account": "8f8c8cee-2591-4f83-be12-82c659b5e748", + "id": "56f106e5-25a4-4eee-96fa-25bb05dc86bc", + "net_amount": "1000", + "price": null, + "qty": null, + "settle_date": null, + "status": "pending", + "symbol": null, + "system_date": null, + "to_account": "399f85f1-cbbd-4eaa-a934-70027fb5c1de" + }, + { + "currency": "USD", + "description": "", + "entry_type": "JNLC", + "error_message": "The destination account is not eligible to receive this journal.", + "from_account": "8f8c8cee-2591-4f83-be12-82c659b5e748", + "id": "c79bcd51-4bea-4d1d-9b3c-f37f5035b8f7", + "net_amount": "250", + "price": null, + "qty": null, + "settle_date": null, + "status": "refused", + "symbol": null, + "system_date": null, + "to_account": "d5f7dbea-cb40-4ea6-a56d-e30d572ee84f" + } + ], + "title": "BatchJournalResponseJNLC" + }, + "BatchJournalResponseJNLS": { + "allOf": [ + { + "$ref": "#/components/schemas/JNLS" + }, + { + "properties": { + "error_message": { + "description": "Description of why this journal transaction failed. Omitted for successful results.", + "minLength": 1, + "type": "string" + } + }, + "type": "object" + } + ], + "description": "A securities journal result that preserves discriminator-complete batch response modeling, although current public batch requests support JNLC only.", + "examples": [ + { + "currency": "USD", + "description": "this is a test journal", + "entry_type": "JNLS", + "from_account": "8f4f3d11-4483-4199-840f-6c5fe0b7ca24", + "id": "f45f67e8-d1fc-4136-aa4f-cf4460aecdfc", + "net_amount": null, + "price": "128.23", + "qty": "0.5", + "settle_date": "2020-12-24", + "status": "executed", + "symbol": "AAPL", + "system_date": "2020-12-24", + "to_account": "a7a7e666-6f2a-433c-8c33-17b66b8941fa" + } + ], + "title": "BatchJournalResponseJNLS" + }, + "Beneficiary": { + "description": "Beneficiary of an account", + "example": { + "date_of_birth": "1970-01-01", + "family_name": "Doe", + "given_name": "Jane", + "middle_name": "P", + "relationship": "spouse", + "share_pct": "100", + "tax_id": "xxx-xx-xxxx", + "tax_id_type": "USA_SSN", + "type": "primary" + }, + "properties": { + "date_of_birth": { + "example": "1970-01-01", + "type": "string" + }, + "family_name": { + "example": "Doe", + "type": "string" + }, + "given_name": { + "example": "Jane", + "type": "string" + }, + "middle_name": { + "example": "P", + "type": "string" + }, + "relationship": { + "example": "spouse", + "type": "string" + }, + "share_pct": { + "example": "100", + "type": "string" + }, + "tax_id": { + "example": "xxx-xx-xxxx", + "type": "string" + }, + "tax_id_type": { + "example": "USA_SSN", + "type": "string" + }, + "type": { + "example": "primary", + "type": "string" + } + }, + "required": [ + "given_name", + "middle_name", + "family_name", + "date_of_birth", + "tax_id", + "tax_id_type", + "relationship", + "type", + "share_pct" + ], + "type": "object" + }, + "CDIVActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonCDIVActivityV2" + }, + { + "properties": { + "cash_payout": { + "description": "Total cash amount paid", + "type": "string" + }, + "entitled_qty": { + "description": "Quantity of shares entitled to receive the dividend or return of capital", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "cash_payout" + ], + "type": "object" + } + ], + "description": "Cash-dividend related details. Used for both Cash Dividend and Return of Capital.", + "type": "object" + }, + "CGDActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "cash_payout": { + "description": "Cash amount paid for this leg", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "entitled_qty": { + "description": "Quantity of shares entitled to receive the capital gains distribution", + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "long_term_rate": { + "description": "Long-term capital gains distribution rate per share, when applicable", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "Distribution rate per share for this leg (LTCG or STCG)", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "short_term_rate": { + "description": "Short-term capital gains distribution rate per share, when applicable", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "cash_payout", + "symbol", + "cusip", + "rate" + ], + "type": "object" + } + ], + "description": "Capital gains distribution. Used for both Long-Term (LTCG) and Short-Term (STCG) sub-types. Each activity represents a single leg; `long_term_rate` and/or `short_term_rate` are populated based on the source event, and `rate` matches the leg's own rate.", + "type": "object" + }, + "CIPDocument": { + "description": "Represents results of checking a document for CIPInfo\n", + "examples": [ + { + "created_at": "2021-06-10T15:37:03Z", + "id": "55B9931A-3BE6-4BC0-9BDD-0B954E4A4632", + "image_integrity": "clear", + "result": "clear", + "status": "complete" + } + ], + "properties": { + "age_validation": { + "$ref": "#/components/schemas/CIPResult" + }, + "comprised_document": { + "$ref": "#/components/schemas/CIPResult" + }, + "created_at": { + "description": "Datetime for when this check was done", + "format": "date-time", + "type": "string" + }, + "data_comparison": { + "$ref": "#/components/schemas/CIPResult" + }, + "data_comparison_breakdown": { + "description": "json object representing the results of the various sub-checks\n done when calculating the result on `data_comparison`. Example: {\"date_of_birth\": \"clear\",\n \"date_of_expiry\": \"clear\" \"document_numbers\": \"clear\", \"document_type\": \"clear\", \"first_name\": \"clear\",\n \"gender\": \"clear\", \"issuing_country\": \"clear\", \"last_name\": \"clear\"}", + "type": "string" + }, + "date_of_birth": { + "description": "Datetime for when this check was done", + "format": "date", + "type": "string" + }, + "date_of_expiry": { + "description": "Datetime for when this check was done", + "format": "date", + "type": "string" + }, + "document_numbers": { + "description": "Number of the document that was checked", + "items": { + "type": "string" + }, + "type": "array" + }, + "document_type": { + "description": "Type of the document that was checked", + "type": "string" + }, + "first_name": { + "description": "First name extracted from the document", + "type": "string" + }, + "gender": { + "description": "Gender info extracted from the document", + "type": "string" + }, + "id": { + "description": "Your internal ID of check", + "type": "string" + }, + "image_integrity": { + "$ref": "#/components/schemas/CIPResult" + }, + "image_integrity_breakdown": { + "description": "json object representing the results of the various sub-checks done\n when calculating the result on `image_integrity`. Example: example: {\"colour_picture\": \"clear\",\n \"conclusive_document_quality\": \"clear\", \"image_quality\": \"clear\", \"supported_document\": \"clear\"}", + "type": "string" + }, + "issuing_country": { + "description": "Country for which issued the document", + "type": "string" + }, + "last_name": { + "description": "Last name extracted from the document", + "type": "string" + }, + "nationality": { + "description": "Nationality extracted from the document", + "type": "string" + }, + "police_record": { + "$ref": "#/components/schemas/CIPStatus" + }, + "result": { + "$ref": "#/components/schemas/CIPResult" + }, + "status": { + "$ref": "#/components/schemas/CIPStatus" + }, + "visual_authenticity": { + "description": "json object representing the various sub-checks done when determining\n whether visual (non-textual) elements are correct given the document type. Example: {\n \"digital_tampering\": \"clear\", \"face_detection\": \"clear\", \"fonts\": \"clear\", \"original_document_present\":\n \"clear\", \"picture_face_integrity\": \"clear\", \"security_features\": \"clear\", \"template\": \"clear\"}", + "type": "string" + } + }, + "required": [ + "id" + ], + "type": "object" + }, + "CIPIdentity": { + "examples": [ + { + "address": "clear", + "created_at": "2021-06-10T15:37:03Z", + "date_of_birth": "clear", + "id": "28E1CCE8-1B1A-4472-9AD4-C6C5B7C3A6AF", + "result": "clear", + "sources": "clear", + "status": "complete" + } + ], + "properties": { + "address": { + "$ref": "#/components/schemas/CIPResult" + }, + "address_breakdown": { + "description": "a json object representing the breakdown of the `address` field. For example:\n {\"credit_agencies\": {\"result\": \"clear\",\"properties\":{\"number_of_matches\":\"1\"}}", + "type": "string" + }, + "created_at": { + "description": "datetime when identity check happened", + "type": "string" + }, + "date_of_birth": { + "$ref": "#/components/schemas/CIPResult" + }, + "date_of_birth_breakdown": { + "description": "a json object representing the breakdown of the `date_of_birth` field.\n For example: example: {\"credit_agencies\":{\"result\": \"clear\",\"properties\": {\"number_of_matches\": \"1\"}}", + "type": "string" + }, + "id": { + "description": "Your internal ID of check", + "type": "string" + }, + "matched_address": { + "$ref": "#/components/schemas/CIPResult" + }, + "matched_addresses": { + "description": "datetime when identity check happened", + "type": "string" + }, + "result": { + "$ref": "#/components/schemas/CIPResult" + }, + "sources": { + "$ref": "#/components/schemas/CIPResult" + }, + "sources_breakdown": { + "description": "a json object representing the breakdown of `sources` field. For example:\n {\"total_sources\": {\"result\": \"clear\",\"properties\": {\"total_number_of_sources\": \"3\"}}}", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/CIPStatus" + }, + "tax_id": { + "$ref": "#/components/schemas/CIPResult" + }, + "tax_id_breakdown": { + "description": "a json object representing the breakdown of the `tax_id` field", + "type": "string" + } + }, + "required": [ + "id" + ], + "type": "object" + }, + "CIPInfo": { + "description": "Customer Identification Program (CIP) information for an account applicant.", + "properties": { + "account_id": { + "description": "UUID of the Account instance this CIPInfo is for", + "format": "uuid", + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "document": { + "$ref": "#/components/schemas/CIPDocument" + }, + "id": { + "description": "ID of this CIPInfo", + "format": "uuid", + "type": "string" + }, + "identity": { + "$ref": "#/components/schemas/CIPIdentity" + }, + "kyc": { + "$ref": "#/components/schemas/CIPKYC" + }, + "photo": { + "$ref": "#/components/schemas/CIPPhoto" + }, + "provider_name": { + "description": "List of KYC providers this information came from", + "items": { + "$ref": "#/components/schemas/CIPProvider" + }, + "type": "array" + }, + "updated_at": { + "format": "date-time", + "type": "string" + }, + "watchlist": { + "$ref": "#/components/schemas/CIPWatchlist" + } + }, + "title": "CIPInfo", + "type": "object" + }, + "CIPKYC": { + "description": "Represents Know Your Customer (KYC) info for a CIPInfo", + "examples": [ + { + "address": "42 Faux St", + "applicant_name": "John Doe", + "approval_status": "approved", + "approved_at": "2021-06-10T15:38:03Z", + "approved_by": "Jane Doe", + "check_completed_at": "2021-06-10T15:37:03Z", + "check_initiated_at": "2021-06-10T15:37:03Z", + "country_of_residency": "USA", + "date_of_birth": "1970-12-01", + "email_address": "johndoe@example.com", + "id": "CBDAD1C4-1047-450E-BAE5-B6C406F509B4", + "id_number": "jd0000123456789", + "ip_address": "127.0.0.1", + "kyc_completed_at": "2021-06-10T15:37:03Z", + "nationality": "American", + "postal_code": "94401", + "risk_level": "LOW" + } + ], + "properties": { + "address": { + "description": "Concatenated street address, city, state and country of applicant", + "type": "string" + }, + "applicant_name": { + "description": "Given and family name of applicant", + "type": "string" + }, + "approval_status": { + "description": "Approval status of KYC check", + "enum": [ + "approved", + "rejected" + ], + "example": "approved", + "type": "string" + }, + "approved_at": { + "description": "Reason for approving this KYC check", + "format": "date-time", + "type": "string" + }, + "approved_by": { + "description": "Identifier of who approved KYC check", + "type": "string" + }, + "approved_reason": { + "description": "Datetime that this KYC check was approved", + "type": "string" + }, + "check_completed_at": { + "description": "completion datetime of KYC check", + "format": "date-time", + "type": "string" + }, + "check_initiated_at": { + "description": "start datetime of KYC check", + "format": "date-time", + "type": "string" + }, + "country_of_residency": { + "description": "country for `address` field", + "type": "string" + }, + "date_of_birth": { + "description": "DOB of applicant", + "format": "date", + "type": "string" + }, + "email_address": { + "description": "email address of applicant", + "type": "string" + }, + "id": { + "description": "Your internal ID of check", + "format": "uuid", + "type": "string" + }, + "ip_address": { + "description": "IP address of applicant at time of KYC check", + "type": "string" + }, + "kyc_completed_at": { + "description": "Datetime that KYC check was completed at", + "format": "date-time", + "type": "string" + }, + "nationality": { + "description": "nationality of applicant", + "type": "string" + }, + "postal_code": { + "description": "postal code for `address` field", + "type": "string" + }, + "risk_categories": { + "description": "The list of risk categories returned by the KYC provider or assessed", + "items": { + "type": "string" + }, + "type": "array" + }, + "risk_level": { + "description": "Overall risk level returned by KYC provider or assessed", + "type": "string" + }, + "risk_score": { + "description": "Overall risk score returned by KYC provider or assessed", + "type": "integer" + } + }, + "required": [ + "id" + ], + "title": "CIPKYCInfo", + "type": "object" + }, + "CIPPhoto": { + "description": "Represents the results of checking a Photo for CIPInfo", + "examples": [ + { + "created_at": "2021-06-10T15:37:03Z", + "face_comparison": "clear", + "id": "0DD13020-F0FD-4B5A-B58F-BC1885E90A6D", + "result": "clear", + "status": "complete" + } + ], + "properties": { + "created_at": { + "description": "datetime of when the check happened", + "type": "string" + }, + "face_comparison": { + "$ref": "#/components/schemas/CIPResult" + }, + "face_comparison_breakdown": { + "description": "a json object representing the breakdown of sub-checks done in\n `face_comparison`. Example: {\"face_match\":{\"result\": \"clear\",\"properties\":{\"score\": \"80\"}}}", + "type": "string" + }, + "id": { + "description": "Your internal ID of the check", + "type": "string" + }, + "image_integrity": { + "$ref": "#/components/schemas/CIPResult" + }, + "image_integrity_breakdown": { + "description": "a json object representing the breakdown of sub-checks done in\n `image_integrity`. Example {\"face_detected\":{\"result\": \"clear\"},\"source_integrity\": {\"result\": \"clear\"}}", + "type": "string" + }, + "result": { + "$ref": "#/components/schemas/CIPResult" + }, + "status": { + "description": "Overall status of the check. Either `complete` or `withdrawn`.", + "enum": [ + "complete", + "withdrawn" + ], + "type": "string" + }, + "visual_authenticity": { + "$ref": "#/components/schemas/CIPResult" + }, + "visual_authenticity_breakdown": { + "description": "a json object representing the breakdown of sub-checks don in\n `visual_authenticity`. Example {\"spoofing_detection\": {\"result\": \"clear\",\"properties\": {\"score\": \"26\"}}}}", + "type": "string" + } + }, + "required": [ + "id" + ], + "type": "object" + }, + "CIPProvider": { + "description": "\"alloy\" - ALLOY\n\"trulioo\" - TRULIOO\n\"onfido\" - ONFIDO\n\"veriff\" - VERIFF\n\"jumio\" - JUMIO\n\"getmati\" - GETMATI", + "title": "CIPProvider", + "type": "string" + }, + "CIPResult": { + "description": "The result of the check. Either `clear` or `consider`.", + "title": "CIPResult", + "type": "string" + }, + "CIPStatus": { + "description": "An enum representing the status of the CIPInfo\n\n\"complete\"\n\n\"withdrawn\"", + "title": "CIPStatus", + "type": "string" + }, + "CIPWatchlist": { + "description": "Represents the result of checking to see if the applicant is in any watchlists for a CIPInfo", + "examples": [ + { + "adverse_media": "clear", + "created_at": "2021-06-10T15:37:03Z", + "id": "7572B870-EB4C-46A2-8B88-509194CCEE7E", + "monitored_lists": "clear", + "politically_exposed_person": "clear", + "result": "clear", + "sanction": "clear", + "status": "complete" + } + ], + "properties": { + "adverse_media": { + "$ref": "#/components/schemas/CIPResult" + }, + "created_at": { + "description": "datetime when check happened", + "type": "string" + }, + "id": { + "description": "Your internal ID of check", + "type": "string" + }, + "monitored_lists": { + "$ref": "#/components/schemas/CIPResult" + }, + "politically_exposed_person": { + "$ref": "#/components/schemas/CIPResult" + }, + "records": { + "description": "a json object. Example [{\"text\": \"Record info\"}]", + "type": "string" + }, + "result": { + "$ref": "#/components/schemas/CIPResult" + }, + "sanction": { + "$ref": "#/components/schemas/CIPResult" + }, + "status": { + "$ref": "#/components/schemas/CIPStatus" + } + }, + "required": [ + "id" + ], + "type": "object" + }, + "CSWActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "bank_transaction_id": { + "description": "The bank transaction's ID", + "format": "uuid", + "type": "string" + } + }, + "type": "object" + } + ], + "description": "Cash withdrawal", + "type": "object" + }, + "CommissionType": { + "default": "notional", + "description": "An enum to select how to interpret the value provided in the commission field.\n\n- notional:\nCharge commission on a per order basis. (When the `commission_type` field is omitted from the order request, this is used as the default).\n\n- qty:\nCharge commission on a per qty/contract basis, pro rated.\n\n- bps:\nThe percent commission you want to charge the end user on the order (expressed in bps). Alpaca will convert the order to a notional amount for purposes of calculating commission.\nCommission value in bps can have up to two decimal places.", + "enum": [ + "notional", + "qty", + "bps" + ], + "example": "qty", + "title": "CommissionType", + "type": "string" + }, + "CommonAcatActivityV2": { + "properties": { + "external_id": { + "description": "The ID that DTCC assigned to this transfer", + "type": "string" + }, + "hold_date": { + "description": "Hold date when the transfers settle", + "format": "date", + "minLength": 1, + "type": "string" + }, + "request_id": { + "description": "The ID for original ACATS request", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "external_id", + "request_id" + ], + "type": "object" + }, + "CommonCDIVActivityV2": { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "due_bill_off_date": { + "description": "When due bills stop applying for this event", + "format": "date", + "minLength": 1, + "type": "string" + }, + "due_bill_on_date": { + "description": "When due bills begin to apply for this event", + "format": "date", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "foreign": { + "description": "Indicates if related to a non-US security. Serialized as the JSON strings `\"true\"` or `\"false\"`, not a JSON boolean.", + "enum": [ + "true", + "false" + ], + "example": "false", + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "Dividend rate per share", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "special": { + "description": "Indicates if this is a special dividend. Serialized as the JSON strings `\"true\"` or `\"false\"`, not a JSON boolean.", + "enum": [ + "true", + "false" + ], + "example": "false", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "rate", + "foreign", + "special" + ], + "type": "object" + }, + "CommonCaActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "ca_id": { + "description": "The unique identifier for this corporate action", + "format": "uuid", + "type": "string" + }, + "position_date": { + "description": "The position_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "reorg_id": { + "description": "The reorg identifier, if present in the source corporate action definition", + "type": "string" + } + }, + "required": [ + "position_date" + ], + "type": "object" + } + ], + "type": "object" + }, + "CommonFixedIncomeInterestActivityV2": { + "description": "Fixed income interest fields (INT/FI). Variants from the same activity type:\n\n- Coupon: `interest_type` is `coupon`. Includes `rate` (no `price` / `accrued_interest_rate`). No `order_id`.\n- Accrued interest on call: `interest_type` is `accrued`. Includes `price` and `accrued_interest_rate` (no `rate`). No `order_id`.\n- Trade accrued: `interest_type` is `accrued`. Includes `order_id` so the interest NTA can be linked to the fill. `parent_id` is set when a parent trade `ref_id` is available.", + "properties": { + "accrued_interest_rate": { + "description": "Accrued interest rate (present for accrued-interest-on-call variants)", + "format": "decimal", + "type": "string" + }, + "cash_payout": { + "description": "The cash payout for this interest activity", + "format": "decimal", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "entitled_qty": { + "description": "The entitled quantity (principal / face amount)", + "example": "1000", + "type": "string" + }, + "interest_type": { + "$ref": "#/components/schemas/FixedIncomeInterestType" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "order_id": { + "description": "The order that generated this accrued interest. Present for trade-accrued INT/FI.", + "example": "257bf308-a6b7-4777-8cf6-00dc441dc4d3", + "format": "uuid", + "type": "string" + }, + "parent_id": { + "description": "The ref_id of the parent trade this interest is attached to. Present for trade-accrued INT/FI when a parent trade `ref_id` is available.", + "example": "46aecae1-4629-4bcf-b441-0d8c847a1787", + "format": "uuid", + "type": "string" + }, + "payment_date": { + "description": "The payment date", + "format": "date", + "type": "string" + }, + "price": { + "description": "Call price used for accrued-interest-on-call variants", + "format": "decimal", + "type": "string" + }, + "rate": { + "description": "Coupon rate amount (present for regular coupon payments)", + "format": "decimal", + "type": "string" + }, + "record_date": { + "description": "The record date", + "format": "date", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "cash_payout", + "cusip", + "interest_type" + ], + "type": "object" + }, + "CommonJournalActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "journal_id": { + "description": "The journal's ID", + "format": "uuid", + "type": "string" + } + }, + "type": "object" + } + ], + "description": "Shared fields for journal non-trade activity records.", + "type": "object" + }, + "CommonMAActivityV2": { + "properties": { + "acquiree_cusip": { + "description": "CUSIP of the acquiree", + "type": "string" + }, + "acquiree_isin": { + "description": "ISIN of the acquiree", + "type": "string" + }, + "acquiree_rate": { + "description": "Rate of the acquiree", + "type": "string" + }, + "acquiree_symbol": { + "description": "Symbol of the acquiree", + "type": "string" + }, + "acquirer_cusip": { + "description": "CUSIP of the acquirer", + "type": "string" + }, + "acquirer_isin": { + "description": "ISIN of the acquirer", + "type": "string" + }, + "acquirer_rate": { + "description": "Rate of the acquirer", + "type": "string" + }, + "acquirer_symbol": { + "description": "Symbol of the acquirer", + "type": "string" + }, + "effective_date": { + "description": "When the merger/acquisition becomes effective", + "format": "date", + "minLength": 1, + "type": "string" + }, + "payable_date": { + "description": "The payable date", + "format": "date", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "acquiree_cusip", + "acquiree_symbol", + "effective_date", + "payable_date" + ], + "type": "object" + }, + "CommonNCActivityV2": { + "properties": { + "new_cusip": { + "description": "New CUSIP for the name change", + "type": "string" + }, + "new_symbol": { + "description": "New symbol for the name change", + "type": "string" + }, + "old_cusip": { + "description": "Old CUSIP for the name change", + "type": "string" + }, + "old_symbol": { + "description": "Old symbol for the name change", + "type": "string" + } + }, + "required": [ + "old_cusip", + "old_symbol", + "new_cusip", + "new_symbol" + ], + "type": "object" + }, + "CommonNTAActivityV2": { + "description": "Shared fields for non-trade (NTA) activity records.", + "properties": { + "group_id": { + "description": "Optional group ID which can help grouping together related activities", + "format": "uuid", + "type": "string" + }, + "system_date": { + "description": "The date when the activity was booked", + "format": "date", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "system_date" + ], + "type": "object" + }, + "CommonOPCAActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "new_contract_symbol": { + "description": "The new contract symbol", + "type": "string" + }, + "new_qty": { + "description": "used when the old contract's quantity is not equal to the new contract's quantity. Mutually exclusive with 'qty'.", + "type": "string" + }, + "old_contract_symbol": { + "description": "The old contract symbol", + "type": "string" + }, + "old_qty": { + "description": "used when the old contract's quantity is not equal to the new contract's quantity. Mutually exclusive with 'qty'.", + "type": "string" + }, + "qty": { + "description": "used when the old contract's quantity is equal to the new contract's quantity. Mutually exclusive with 'old_qty' and 'new_qty'", + "type": "string" + } + }, + "required": [ + "old_contract_symbol", + "new_contract_symbol" + ], + "type": "object" + } + ], + "type": "object" + }, + "CommonOptionsActivityV2": { + "allOf": [ + { + "description": "Shared fields for option-related non-trade activity records.", + "properties": { + "contract_symbol": { + "description": "The contract symbol of the security involved with the activity", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "group_id" + ], + "type": "object" + }, + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + } + ] + }, + "CommonREOActivityV2": { + "description": "Reorganization (REO) activity sub-types:\n- **REOS**: Stock only (1 or more stock legs)\n- **REOC**: Cash only (one cash leg)\n- **REOSC**: Stock and cash", + "properties": { + "cash_payout": { + "description": "Cash payout amount", + "format": "decimal", + "type": "string" + }, + "cash_rate": { + "description": "Cash rate per share", + "format": "decimal", + "type": "string" + }, + "cusip": { + "description": "CUSIP received on this stock leg", + "type": "string" + }, + "effective_date": { + "description": "Effective date of the reorganization", + "format": "date", + "type": "string" + }, + "isin": { + "description": "ISIN received on this stock leg", + "type": "string" + }, + "new_rate": { + "description": "New ratio for this stock leg", + "format": "decimal", + "type": "string" + }, + "payable_date": { + "description": "Payable date of the reorganization", + "format": "date", + "type": "string" + }, + "qty": { + "description": "Quantity received on this stock leg", + "format": "decimal", + "type": "string" + }, + "removed_qty": { + "description": "Positive quantity removed from the source position", + "format": "decimal", + "type": "string" + }, + "source_cusip": { + "description": "CUSIP of the source security", + "type": "string" + }, + "source_isin": { + "description": "ISIN of the source security", + "type": "string" + }, + "source_qty": { + "description": "Source position quantity", + "format": "decimal", + "type": "string" + }, + "source_rate": { + "description": "Source ratio for this stock leg", + "format": "decimal", + "type": "string" + }, + "source_symbol": { + "description": "Symbol of the source security", + "example": "CEPT", + "type": "string" + }, + "symbol": { + "description": "Symbol received on this stock leg", + "example": "SECZ", + "type": "string" + } + }, + "required": [ + "source_symbol", + "source_cusip", + "payable_date" + ], + "type": "object" + }, + "CommonSDIVActivityV2": { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "Dividend rate per share", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "rate" + ], + "type": "object" + }, + "CommonSpinoffActivityV2": { + "properties": { + "due_bill_redemption_date": { + "description": "When due bills related to the spinoff are redeemed", + "format": "date", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_cusip": { + "description": "CUSIP of the new security", + "type": "string" + }, + "new_isin": { + "description": "ISIN of the new security", + "type": "string" + }, + "new_price": { + "description": "Market price of new shares after the spinoff", + "type": "string" + }, + "new_rate": { + "description": "Ratio of new shares received", + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "source_cusip": { + "description": "CUSIP of the parent security", + "type": "string" + }, + "source_isin": { + "description": "ISIN of the parent security", + "type": "string" + }, + "source_price": { + "description": "Market price of parent shares before the spinoff", + "type": "string" + }, + "source_rate": { + "description": "Ratio of parent shares", + "type": "string" + }, + "source_symbol": { + "description": "Symbol of the parent security", + "type": "string" + } + }, + "required": [ + "source_cusip", + "source_symbol", + "source_rate", + "source_price", + "new_cusip", + "new_symbol", + "new_rate", + "new_price" + ], + "type": "object" + }, + "CommonSplitActivityV2": { + "properties": { + "new_cusip": { + "description": "CUSIP of the new security after the split", + "type": "string" + }, + "new_isin": { + "description": "ISIN of the new security after the split", + "type": "string" + }, + "new_rate": { + "description": "Ratio of new shares received", + "type": "string" + }, + "old_cusip": { + "description": "CUSIP of the old security before the split", + "type": "string" + }, + "old_isin": { + "description": "ISIN of the old security before the split", + "type": "string" + }, + "old_rate": { + "description": "Ratio of old shares exchanged", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "old_cusip", + "new_cusip", + "old_rate", + "new_rate" + ], + "type": "object" + }, + "CommonSplitStockActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSplitActivityV2" + }, + { + "properties": { + "new_qty": { + "description": "The new quantity after the split", + "type": "string" + }, + "old_qty": { + "description": "The old quantity before the split", + "type": "string" + } + }, + "required": [ + "old_qty", + "new_qty" + ], + "type": "object" + } + ], + "type": "object" + }, + "CommonVOFSubtypeActivityV2": { + "properties": { + "new_cusip": { + "description": "CUSIP of the new security", + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security", + "type": "string" + }, + "source_cusip": { + "description": "CUSIP of the parent security", + "type": "string" + }, + "source_symbol": { + "description": "Symbol of the parent security", + "type": "string" + } + }, + "required": [ + "source_cusip", + "source_symbol" + ], + "type": "object" + }, + "Contact": { + "description": "Contact is the model for the account owner contact information.\n", + "properties": { + "city": { + "example": "San Mateo", + "type": "string" + }, + "country": { + "description": "country code in ISO 3166-1 alpha-3 format, representing the country the person/entity resides in.", + "example": "USA", + "type": "string" + }, + "email_address": { + "example": "john.doe@example.com", + "format": "email", + "type": "string" + }, + "phone_number": { + "description": "Phone number should include the country code, format: \"+15555555555\"", + "example": "+15556667788", + "type": [ + "string", + "null" + ] + }, + "postal_code": { + "example": "94401", + "type": "string" + }, + "state": { + "description": "Required if the country or country_of_tax_residence (in the identity model below) is 'USA'.", + "example": "CA", + "type": "string" + }, + "street_address": { + "description": "The user's street address. If multiple lines in address, pass in as additional array elements. Maximum of 3 objects in array", + "items": { + "$ref": "#/components/schemas/StreetAddress" + }, + "type": "array" + }, + "unit": { + "description": "The specific apartment number if applicable", + "type": "string" + } + }, + "required": [ + "email_address", + "street_address", + "city" + ], + "type": "object" + }, + "CorrespondentLimit": { + "properties": { + "amount_available": { + "format": "decimal", + "type": "string" + }, + "amount_in_use": { + "format": "decimal", + "type": "string" + }, + "amount_limit": { + "format": "decimal", + "type": "string" + } + }, + "type": "object" + }, + "CountryInfo": { + "description": "Represents the info for a country.", + "properties": { + "crypto_risk_rating": { + "description": "crypto risk rating of the country", + "enum": [ + "low", + "medium", + "high", + "restricted", + "prohibited" + ], + "type": "string" + }, + "crypto_supported_states": { + "description": "states where Alpaca supports crypto trading", + "items": { + "description": "the state code defined by ISO 3166-2", + "type": "string" + }, + "type": "array" + }, + "full_name": { + "description": "The full name of the country definded by ISO 3166-1", + "example": "Åland Islands", + "minLength": 1, + "type": "string" + }, + "securities_risk_rating": { + "description": "the securities risk rating of the country", + "enum": [ + "low", + "medium", + "high", + "restricted", + "prohibited" + ], + "type": "string" + } + }, + "required": [ + "full_name", + "securities_risk_rating", + "crypto_risk_rating" + ], + "title": "CountryInfo", + "type": "object" + }, + "CountryInfos": { + "additionalProperties": { + "$ref": "#/components/schemas/CountryInfo" + }, + "description": "Represents the info for countries as a map where the keys are the ISO 3166 country codes.", + "title": "CountryInfos", + "type": "object" + }, + "CreateACHRelationshipRequest": { + "description": "Represents the fields used in creation of a new ACHRelationship.\n\nYou can create an ACHRelationship by passing the required fields here or if you have an account with Plaid you can use our integration with Plaid to create a relationship.\n\nPlease see the documentation [here](https://alpaca.markets/docs/api-references/broker-api/funding/ach/#plaid-integration-for-bank-transfers) for more info on using Plaid with Alpaca", + "properties": { + "account_owner_name": { + "minLength": 1, + "type": "string" + }, + "bank_account_number": { + "description": "In sandbox, this still must be a valid format", + "minLength": 1, + "type": "string" + }, + "bank_account_type": { + "description": "Must be `CHECKING` or `SAVINGS`", + "enum": [ + "CHECKING", + "SAVINGS" + ], + "minLength": 1, + "type": "string" + }, + "bank_routing_number": { + "description": "In sandbox, this still must be a valid format", + "minLength": 1, + "type": "string" + }, + "instant": { + "type": "boolean" + }, + "nickname": { + "minLength": 1, + "type": "string" + }, + "processor_token": { + "description": "If using Plaid, you can specify a Plaid processor token here ", + "type": "string" + } + }, + "required": [ + "account_owner_name", + "bank_account_type", + "bank_account_number", + "bank_routing_number" + ], + "title": "CreateACHRelationshipRequest", + "type": "object" + }, + "CreateBankRequest": { + "description": "Represents the possible fields to send when creating a new associated Bank resource for an account", + "properties": { + "account_number": { + "type": "string" + }, + "bank_code": { + "description": "9-Digit ABA RTN (Routing Number) or BIC", + "type": "string" + }, + "bank_code_type": { + "description": "ABA (Domestic) or BIC (International)", + "enum": [ + "ABA", + "BIC" + ], + "type": "string" + }, + "city": { + "description": "Only for international banks, ie if bank_code_type = BIC", + "type": "string" + }, + "country": { + "description": "Only for international banks, ie if bank_code_type = BIC", + "type": "string" + }, + "extra_fields": { + "$ref": "#/components/schemas/BankAdditionalFields" + }, + "name": { + "description": "Name of recipient bank", + "type": "string" + }, + "postal_code": { + "description": "Only for international banks, ie if bank_code_type = BIC. Minimum of 3 characters", + "type": "string" + }, + "state_province": { + "description": "Only for international banks, ie if bank_code_type = BIC", + "type": "string" + }, + "street_address": { + "description": "Only for international banks, ie if bank_code_type = BIC", + "type": "string" + } + }, + "required": [ + "name", + "bank_code", + "bank_code_type", + "account_number" + ], + "title": "CreateBankRequest", + "type": "object" + }, + "CreateCryptoTransferRequest": { + "properties": { + "address": { + "description": "The destination wallet address", + "type": "string" + }, + "amount": { + "description": "The amount, denoted in the specified asset, to be withdrawn from the user's wallet", + "type": "string" + }, + "asset": { + "type": "string" + }, + "chain": { + "description": "Optional chain identifier. The blockchain network used for the withdrawal.", + "enum": [ + "SOL", + "ETH", + "BTC", + "XRP", + "ARB" + ], + "type": "string" + } + }, + "required": [ + "amount", + "address", + "asset" + ], + "title": "CreateCryptoTransferRequest", + "type": "object" + }, + "CreateFundingWalletWithdrawalRequest": { + "properties": { + "desired_currency": { + "type": "string" + }, + "payment_type": { + "$ref": "#/components/schemas/FundingDetailPaymentType" + }, + "usd_amount": { + "format": "decimal", + "type": "string" + } + }, + "type": "object" + }, + "CreateIFTransferRequest": { + "description": "Request to create a new instant funding transfer\n", + "properties": { + "account_no": { + "type": "string" + }, + "amount": { + "format": "decimal", + "type": "string" + }, + "source_account_no": { + "type": "string" + } + }, + "required": [ + "account_no", + "source_account_no", + "amount" + ], + "type": "object" + }, + "CreateJITSettlementRequest": { + "description": "Request to create a new settlement. All transfers included must use the same source account, and the total amount received must be in the same currency as the base currency of the source account.\n", + "properties": { + "accounts": { + "items": { + "$ref": "#/components/schemas/SettlementAccount" + }, + "type": "array" + }, + "additional_info": { + "description": "Additional remittance information. Include if the funding source may require additional information to associate to the source account or settlement.\n", + "type": "string" + }, + "asset_class": { + "$ref": "#/components/schemas/JITAssetClass" + }, + "currency": { + "description": "The currency of the settlement. All accounts identified should have this base currency.\n", + "type": "string" + } + }, + "required": [ + "currency", + "asset_class", + "accounts" + ], + "type": "object" + }, + "CreateJournalRequest": { + "description": "Journals API allows you to move cash or securities from one account to another.\n\nThis model represents the fields you can specify when creating a Journal\n\nFixture Rules\n\n- No Fixtures\n - anything below limit is executed immediately\n - anything above limit is pending until executed at EOD,\n- With Fixtures\n - any status = rejected will be rejected EOD\n - any status = pending will be pending forever", + "examples": [ + { + "amount": "51", + "description": "test text /fixtures/status=rejected/fixtures/", + "entry_type": "JNLC", + "from_account": "c94bu7rn-4483-4199-840f-6c5fe0b7ca24", + "to_account": "fn68sbrk-6f2a-433c-8c33-17b66b8941fa" + } + ], + "properties": { + "amount": { + "description": "Required if `entry_type` = `JNLC`", + "type": "string" + }, + "currency": { + "type": "string" + }, + "description": { + "description": "Max 1024 characters. Can include fixtures for amounts that are above the transaction limit", + "maxLength": 1024, + "type": "string" + }, + "entry_type": { + "$ref": "#/components/schemas/JournalEntryType" + }, + "from_account": { + "description": "The account_id you wish to journal from", + "format": "uuid", + "minLength": 1, + "type": "string" + }, + "qty": { + "description": "Required if `entry_type` = `JNLS`", + "type": "string" + }, + "symbol": { + "description": "Required if `entry_type` = `JNLS`", + "type": "string" + }, + "to_account": { + "description": "The account_id you wish to journal to", + "format": "uuid", + "minLength": 1, + "type": "string" + }, + "transmitter_account_number": { + "description": "Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "maxLength": 255, + "type": "string" + }, + "transmitter_address": { + "description": "Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "maxLength": 255, + "type": "string" + }, + "transmitter_financial_institution": { + "description": "Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "maxLength": 255, + "type": "string" + }, + "transmitter_name": { + "description": "Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "maxLength": 255, + "type": "string" + }, + "transmitter_timestamp": { + "description": "RFC 3339 format. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "to_account", + "from_account", + "entry_type" + ], + "type": "object" + }, + "CreateOrderRequest": { + "properties": { + "advanced_instructions": { + "$ref": "#/components/schemas/AdvancedInstructions" + }, + "client_order_id": { + "description": "A unique identifier for the order. Automatically generated if not sent. (<= 128 characters)", + "example": "eb9e2aaa-f71a-4f51-b5b4-52a6c565dad4", + "maxLength": 128, + "type": "string" + }, + "commission": { + "description": "The commission you want to collect from the user.", + "example": "1.0", + "format": "decimal", + "type": "string" + }, + "commission_bps": { + "deprecated": true, + "description": "**deprecated**: Please use the commission_type = bps instead and set the desired bps value in the `commission` field.\nThe percent commission you want to charge the end user on the order (expressed in bps). Alpaca will convert the order to a notional amount for purposes of calculating commission.\n", + "example": "10", + "format": "decimal", + "type": "string" + }, + "commission_type": { + "$ref": "#/components/schemas/CommissionType" + }, + "extended_hours": { + "description": "Defaults to false. If true, order will be eligible for execution in the pre-market, after-hours, and overnight sessions. Only works with type `limit` and time_in_force set to either `day` or `gtc`.", + "example": false, + "type": "boolean" + }, + "instructions": { + "type": "string" + }, + "legs": { + "description": "list of order legs (<= 4)", + "items": { + "$ref": "#/components/schemas/MLegOrderLeg" + }, + "maxItems": 4, + "type": "array" + }, + "limit_price": { + "description": "Required if type is `limit` or `stop_limit`.\n- In case of `mleg`, the limit_price parameter is expressed with the following notation:\n - A positive value indicates a debit, representing a cost or payment to be made.\n - A negative value signifies a credit, reflecting an amount to be received.\n- In case of Fied Income, the price is expressed in percentage of par value (face value).\nPrice is always clean price, meaning it does not include accrued interest.", + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "notional": { + "description": "Dollar amount to trade. Cannot work with qty. Only market and limit orders supported with time_in_force = day; Only limit orders for extended hours.", + "example": "3", + "format": "decimal", + "type": "string" + }, + "order_class": { + "$ref": "#/components/schemas/OrderClass" + }, + "position_intent": { + "$ref": "#/components/schemas/PositionIntent" + }, + "qty": { + "description": "- For equities, the number of shares to trade. Can be fractionable for only market and day order types.\n- Required for `mleg` order class, represents the number of units to trade of this strategy.\n- For Fixed Income securities, qty represents the order size in par value (face value).\nFor example, to place an order for 1 bond with a face value of $1,000, provide a qty of 1000.\n", + "example": "4.124", + "format": "decimal", + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "source": { + "type": "string" + }, + "stop_loss": { + "description": "Takes in a string/number values for stop_price and limit_price", + "properties": { + "limit_price": { + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "stop_price": { + "example": "3.14", + "format": "decimal", + "type": "string" + } + }, + "type": "object" + }, + "stop_price": { + "description": "Required if type is stop or stop_limit", + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "subtag": { + "type": "string" + }, + "swap_fee_bps": { + "format": "decimal", + "type": "string" + }, + "symbol": { + "description": "Symbol or asset ID to identify the asset to trade. Required for all order classes except for `mleg`.", + "example": "AAPL", + "type": "string" + }, + "take_profit": { + "description": "Takes in a string/number value for limit_price", + "properties": { + "limit_price": { + "example": "3.14", + "format": "decimal", + "type": "string" + } + }, + "type": "object" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "trail_percent": { + "description": "If type is trailing_stop, then one of trail_price or trail_percent is required", + "example": "5.0", + "format": "decimal", + "type": "string" + }, + "trail_price": { + "description": "If type is trailing_stop, then one of trail_price or trail_percent is required", + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/OrderType" + } + }, + "required": [ + "type", + "time_in_force" + ], + "type": "object" + }, + "CreateSettlementRequest": { + "description": "Request to create a new settlement. All transfers included must use the same source account, and the total amount received must be in the same currency as the base currency of the source account as well as the transmitter information.\n", + "properties": { + "additional_info": { + "description": "Additional remittance information. Include if the funding source may require additional information to associate to the source account or settlement.\n", + "type": "string" + }, + "transfers": { + "items": { + "$ref": "#/components/schemas/SettlementTransfer" + }, + "type": "array" + } + }, + "required": [ + "transfers" + ], + "type": "object" + }, + "CreateTransferRequest": { + "description": "[See main docs here](https://alpaca.markets/docs/api-references/broker-api/funding/transfers/#creating-a-transfer-entity)", + "properties": { + "additional_information": { + "description": "Additional details for when type = `wire`", + "type": [ + "string", + "null" + ] + }, + "amount": { + "description": "Must be > 0.00", + "format": "decimal", + "type": "string" + }, + "bank_id": { + "description": "Required if type = `wire`\n\nThe bank_relationship created for the account_id [here](https://alpaca.markets/docs/api-references/broker-api/funding/bank/#creating-a-new-bank-relationship)", + "format": "uuid", + "type": "string" + }, + "direction": { + "$ref": "#/components/schemas/TransferDirection" + }, + "fee_payment_method": { + "$ref": "#/components/schemas/FeePaymentMethod" + }, + "ira": { + "$ref": "#/components/schemas/TransferIRA" + }, + "relationship_id": { + "description": "Required if type = `ach`\n\nThe ach_relationship created for the account_id [here](https://alpaca.markets/docs/api-references/broker-api/funding/ach/#creating-an-ach-relationship)", + "format": "uuid", + "type": "string" + }, + "transfer_type": { + "$ref": "#/components/schemas/TransferType" + } + }, + "required": [ + "transfer_type", + "amount", + "direction" + ], + "title": "CreateTransferRequest", + "type": "object" + }, + "CreateWatchlistRequest": { + "description": "This model represents the fields you can specify when Creating or Updating/Replacing a Watchlist", + "properties": { + "name": { + "description": "The watchlist name", + "type": "string" + }, + "symbols": { + "description": "The new list of symbol names to watch", + "items": { + "example": "[\"AAPL\", \"TSLA\"]", + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "name", + "symbols" + ], + "title": "CreateWatchlistRequest", + "type": "object" + }, + "CryptoTransfer": { + "description": "Transfers allow you to transfer assets into your end customer's account (deposits) or out (withdrawal).", + "properties": { + "amount": { + "description": "Amount of transfer denominated in the underlying crypto asset", + "type": "string" + }, + "asset": { + "description": "Symbol of crypto asset for given transfer (e.g. BTC)", + "type": "string" + }, + "chain": { + "description": "Underlying network for given transfer", + "type": "string" + }, + "created_at": { + "description": "Timestamp when transfer was created", + "format": "date-time", + "type": "string" + }, + "direction": { + "$ref": "#/components/schemas/TransferDirection" + }, + "fees": { + "type": "string" + }, + "from_address": { + "description": "Originating address of the transfer", + "type": "string" + }, + "id": { + "description": "The crypto transfer ID", + "format": "uuid", + "type": "string" + }, + "network_fee": { + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/CryptoTransferStatus" + }, + "to_address": { + "description": "Destination address of the transfer", + "type": "string" + }, + "tx_hash": { + "description": "On-chain transaction hash (e.g. 0xabc...xyz)", + "type": "string" + }, + "usd_value": { + "description": "Equivalent USD value at time of transfer", + "type": "string" + } + }, + "type": "object" + }, + "CryptoTransferStatus": { + "enum": [ + "PROCESSING", + "FAILED", + "COMPLETE" + ], + "example": "PROCESSING", + "type": "string" + }, + "CryptoWallet": { + "properties": { + "address": { + "type": "string" + }, + "chain": { + "type": "string" + }, + "created_at": { + "description": "Timestamp (RFC3339) of account creation.", + "format": "date-time", + "type": "string" + } + }, + "type": "object" + }, + "Currency": { + "description": "\"USD\" // US Dollar\n\"JPY\" // Japanese Yen\n\"EUR\" // Euro\n\"CAD\" // Canadian Dollar\n\"GBP\" // British Pound Sterling\n\"CHF\" // Swiss Franc\n\"TRY\" // Turkish Lira\n\"AUD\" // Australian Dollar\n\"CZK\" // Czech Koruna\n\"SEK\" // Swedish Krona\n\"DKK\" // Danish Krone\n\"SGD\" // Singapore Dollar\n\"HKD\" // Hong Kong Dollar\n\"HUF\" // Hungarian Forint\n\"NZD\" // New Zealand Dollar\n\"NOK\" // Norwegian Krone\n\"PLN\" // Poland Złoty", + "title": "Currency", + "type": "string" + }, + "CustodialAccountMinorIdentity": { + "description": "Represents Identity information for a minor that an account of type \"custodial\" is for", + "properties": { + "country_of_birth": { + "type": "string" + }, + "country_of_citizenship": { + "type": "string" + }, + "country_of_tax_residence": { + "type": "string" + }, + "date_of_birth": { + "format": "date", + "type": "string" + }, + "email": { + "format": "email", + "type": "string" + }, + "family_name": { + "type": "string" + }, + "given_name": { + "type": "string" + }, + "state": { + "type": "string" + }, + "tax_id": { + "type": "string" + }, + "tax_id_type": { + "$ref": "#/components/schemas/TaxIdType" + } + }, + "required": [ + "given_name", + "family_name", + "date_of_birth", + "tax_id_type", + "country_of_tax_residence", + "state", + "email" + ], + "type": "object" + }, + "CustodialAccountType": { + "description": "Represents the type of custodial account based on the state where the beneficiary resides.\nThis value is returned only when the `country_of_tax_residence` is `USA`. For other countries, this property is not included in the response.\n\n**Possible Return Values**\n\n`CustodianTypeUTMA` - Indicates that the custodial account is governed by the Uniform Transfers to Minors Act.\n`CustodianTypeUGMA` - Indicates that the custodial account is governed by the Uniform Gifts to Minors Act.", + "title": "CustodialAccountType", + "type": "string" + }, + "DIVNRAActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "parent_id": { + "description": "The ref_id of the parent dividend", + "format": "uuid", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + }, + "tax_country": { + "description": "Tax country used as the primary jurisdiction when determining withholding treatment for the dividend. Other factors may affect the final withholding rate.\nThe value is an [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html) country code.\n", + "example": "THA", + "type": "string" + }, + "tax_rate": { + "description": "The tax withholding rate applied to the dividend, represented as a value between 0 and 1", + "example": "0.15", + "format": "decimal", + "type": "string" + } + }, + "required": [ + "cusip", + "symbol", + "parent_id" + ], + "type": "object" + } + ], + "description": "Dividend withholding for non resident aliens", + "type": "object" + }, + "DIVSPDActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "cash_payout": { + "description": "Total cash amount paid", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "due_bill_off_date": { + "description": "When due bills stop applying for this event", + "format": "date", + "minLength": 1, + "type": "string" + }, + "due_bill_on_date": { + "description": "When due bills begin to apply for this event", + "format": "date", + "minLength": 1, + "type": "string" + }, + "entitled_qty": { + "description": "Quantity of shares entitled to receive cash in lieu", + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "foreign": { + "description": "Indicates if related to a non-US security. Serialized as the JSON strings `\"true\"` or `\"false\"`, not a JSON boolean.", + "enum": [ + "true", + "false" + ], + "example": "false", + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "Cash payout per share", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "special": { + "description": "Indicates if this is a special dividend. Serialized as the JSON strings `\"true\"` or `\"false\"`, not a JSON boolean.", + "enum": [ + "true", + "false" + ], + "example": "false", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "cash_payout", + "symbol", + "cusip", + "rate", + "foreign", + "special" + ], + "type": "object" + } + ], + "description": "Substitute payment in lieu of dividend", + "type": "object" + }, + "DIVWHActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "parent_id": { + "description": "The ref_id of the parent dividend", + "format": "uuid", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "cusip", + "symbol", + "parent_id" + ], + "type": "object" + } + ], + "description": "Dividend tax withholding (e.g. foreign withholding on global securities)", + "type": "object" + }, + "DailyCashInterest": { + "properties": { + "account_accrued_interest": { + "example": "1.2152", + "format": "decimal", + "type": "string" + }, + "account_id": { + "example": "02e5c5ba-36d2-467a-8699-81dc24271291", + "format": "uuid", + "type": "string" + }, + "account_rate_bps": { + "example": 423, + "type": "integer" + }, + "apr_tier_id": { + "example": "13d149c8-d620-43e0-978b-88af8abb2ef1", + "format": "uuid", + "type": "string" + }, + "apr_tier_name": { + "example": "gold", + "type": "string" + }, + "cash_balance": { + "example": "10485.76", + "format": "decimal", + "type": "string" + }, + "correspondent_fee": { + "example": "0.0718", + "format": "decimal", + "type": "string" + }, + "correspondent_rate_bps": { + "example": 25, + "type": "integer" + }, + "currency": { + "example": "USD", + "type": "string" + }, + "date": { + "example": "2024-09-27", + "format": "date", + "type": "string" + } + }, + "type": "object" + }, + "DailyTradingLimit": { + "description": "Correspondent-level daily net buying limit and the real-time amount currently consuming it.", + "properties": { + "cash_held": { + "description": "Cash reserved for open cash-secured put positions. Only present in the response when the correspondent has at least one open cash-secured put; the field is omitted from the response otherwise (including for options-enabled correspondents with no open cash-secured puts).", + "example": "20000", + "format": "decimal", + "type": "string" + }, + "correspondent": { + "description": "The correspondent code the limits apply to.", + "example": "EXMP", + "type": "string" + }, + "daily_net_limit": { + "description": "The daily net buying limit for the correspondent; further buying is halted once the in_use_limit limit reaches this value.", + "example": "1000000", + "format": "decimal", + "type": "string" + }, + "executed_buys": { + "description": "Cumulative cash value of executed buy activity contributing to the in-use limit since the last reset.", + "example": "55", + "format": "decimal", + "type": "string" + }, + "executed_sells": { + "description": "Cumulative cash value of executed sell activity offsetting the in-use limit since the last reset.", + "example": "0", + "format": "decimal", + "type": "string" + }, + "in_use_limit": { + "description": "Real-time net amount currently consuming the daily limit. Equal to `executed_buys` − `executed_sells` + `open_buys` − `open_sells` (+ `cash_held` when a cash-secured put is open). Resets at the start of the next trading day at 8.00 PM ET.", + "example": "55", + "format": "decimal", + "type": "string" + }, + "open_buys": { + "description": "Reserved cash value of currently open buy orders (limit price for limit orders, notional or estimated mid for market orders) contributing to the in-use limit.", + "example": "0", + "format": "decimal", + "type": "string" + }, + "open_sells": { + "description": "Reserved cash value of currently open sell orders offsetting the in-use limit.", + "example": "0", + "format": "decimal", + "type": "string" + } + }, + "title": "DailyTradingLimit", + "type": "object" + }, + "DemoFundingTransfer": { + "properties": { + "amount": { + "format": "decimal", + "type": "string" + }, + "currency": { + "type": "string" + }, + "receiver_account_number": { + "type": "string" + }, + "receiver_routing_code": { + "type": "string" + } + }, + "type": "object" + }, + "DisclosureContextAnnotation": { + "properties": { + "company_city": { + "description": "Required for FINRA affiliations and controlled firms.", + "type": "string" + }, + "company_compliance_email": { + "description": "Required for FINRA affiliations and controlled firms.", + "type": "string" + }, + "company_country": { + "description": "Required for FINRA affiliations and controlled firms.", + "type": "string" + }, + "company_name": { + "description": "Required for FINRA affiliations and controlled firms.", + "type": "string" + }, + "company_state": { + "description": "Required if and only if `company_country` is `USA`.", + "type": "string" + }, + "company_street_address": { + "description": "Required for FINRA affiliations and controlled firms.", + "type": "string" + }, + "context_type": { + "description": "Specifies the type of disclosure annotation. Valid types are FINRA affiliations, for users affiliated with or employed by a FINRA member firm, a Stock Exchange Member, FINRA, Registered Investment Advisor, or a Municipal Securities Broker/Dealer; Company control relationships, for senior executives, and 10% or greater shareholders, of a publicly traded company; and immediate family members of politically exposed individuals.", + "enum": [ + "CONTROLLED_FIRM", + "IMMEDIATE_FAMILY_EXPOSED", + "AFFILIATE_FIRM" + ], + "type": "string" + }, + "family_name": { + "description": "Required for immediate family members of politically exposed persons.", + "type": "string" + }, + "given_name": { + "description": "Required for immediate family members of politically exposed persons.", + "type": "string" + } + }, + "required": [ + "context_type" + ], + "title": "DisclosureContextAnnotation", + "type": "object" + }, + "Disclosures": { + "description": "Disclosures fields denote if the account owner falls under\neach category defined by FINRA rule. The client has to ask\nquestions for the end user and the values should reflect\ntheir answers.\nIf one of the answers is true (yes), the account goes into\nACTION_REQUIRED status.\n", + "example": { + "immediate_family_exposed": false, + "is_affiliated_exchange_or_finra": false, + "is_control_person": false, + "is_politically_exposed": false + }, + "properties": { + "context": { + "description": "Array of annotations describing the rationale for marking `is_control_person`, `is_affiliated_exchange_or_finra`, and/or `immediate_family_exposed` as true", + "items": { + "$ref": "#/components/schemas/DisclosureContextAnnotation" + }, + "type": [ + "array", + "null" + ] + }, + "employer_address": { + "description": "The employer's address if the user is employed.", + "type": "string" + }, + "employer_name": { + "description": "The name of the employer if the user is employed.", + "type": "string" + }, + "employment_position": { + "description": "The user's position if they are employed.", + "type": "string" + }, + "employment_sector": { + "description": "The industry sector of employment.\nIf the `employment_status` is `unemployed` or `student`, set this property to `not_employed`.\nIf the `employment_status` is `retired`, set this to `self_employed`.\n", + "enum": [ + "agriculture", + "business_management", + "computers_and_it", + "construction", + "education", + "finance", + "government", + "healthcare", + "hospitality", + "manufacturing", + "marketing", + "media", + "other", + "science", + "self_employed", + "transportation", + "not_employed" + ], + "type": "string" + }, + "employment_status": { + "description": "One of the following: `employed`, `unemployed`, `retired`, or `student`.", + "enum": [ + "unemployed", + "employed", + "student", + "retired" + ], + "type": "string" + }, + "immediate_family_exposed": { + "description": "If your user's immediate family member (sibling, husband/wife, child, parent) is either politically exposed or holds a control position.", + "type": "boolean" + }, + "is_affiliated_exchange_or_finra": { + "description": "Whether user is affiliated with any exchanges or FINRA.", + "type": "boolean" + }, + "is_control_person": { + "description": "Whether user holds a controlling position in a publicly traded company, member of the board of directors or has policy making abilities in a publicly traded company.", + "type": "boolean" + }, + "is_politically_exposed": { + "description": "Whether the user is politically exposed.", + "type": "boolean" + } + }, + "required": [ + "is_control_person", + "is_affiliated_exchange_or_finra", + "is_politically_exposed", + "immediate_family_exposed" + ], + "type": "object" + }, + "DoNotExerciseRequest": { + "description": "Request to submit a do-not-exercise (DNE) instruction for an option contract for an account.\nThe request body is empty. A successful request will mark the entire position as do not exercise.", + "title": "DoNotExerciseRequest", + "type": "object" + }, + "DoNotExerciseResponse": { + "description": "Response to a do-not-exercise request.\nA 200 response indicates that the entire position is set as do not exercise.\nThe response body is empty.", + "title": "DoNotExerciseResponse", + "type": "object" + }, + "EnabledAssetClass": { + "description": "An asset class that can be enabled on a brokerage account, i.e. a value that may appear in an account's `enabled_assets`. This differs from `AssetClass` (which also covers order and asset metadata) by excluding `ipo`, which is not an enable-able asset.", + "enum": [ + "us_equity", + "us_option", + "crypto" + ], + "type": "string" + }, + "EoDCashInterestReportResponse": { + "properties": { + "interest": { + "items": { + "$ref": "#/components/schemas/DailyCashInterest" + }, + "type": "array" + }, + "next_page_token": { + "example": "293639be-8807-423f-b00d-68c781e8bb56", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "Error": { + "properties": { + "code": { + "type": "number" + }, + "message": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ], + "title": "Error", + "type": "object" + }, + "Exchange": { + "description": "Represents the exchange where an asset is traded.\n\nFor Stocks:\n- AMEX\n- ARCA\n- BATS\n- NYSE\n- NASDAQ\n- NYSEARCA\n- OTC\n\nFor Crypto:\n- CRYPTO", + "enum": [ + "AMEX", + "ARCA", + "BATS", + "NYSE", + "NASDAQ", + "NYSEARCA", + "OTC" + ], + "example": "NASDAQ", + "title": "Exchange", + "type": "string" + }, + "ExchangeOfferActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonVOFSubtypeActivityV2" + } + ], + "type": "object" + }, + "ExerciseRequest": { + "description": "Request to exercise an option contract for an account.\nThis can be omitted or left empty, but it also allows for optionally charging a commission for exercising or\nspecifying a specific quantity of contracts to exercise (rather than the full quantity of contracts held).", + "properties": { + "commission": { + "description": "The commission you want to collect from the user. (notional amount)", + "example": "0.25", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "The number of contracts to exercise. If not provided, all contracts will be exercised.", + "example": "1", + "format": "decimal", + "type": "string" + } + }, + "title": "ExerciseRequest", + "type": "object" + }, + "ExerciseResponse": { + "description": "Response to an exercise request.\nThis will return the total quantity of contracts exercised as well as the quantity of remaining contracts.", + "properties": { + "qty_exercised": { + "description": "The total quantity of contracts exercised.", + "format": "decimal", + "type": "string" + }, + "qty_remaining": { + "description": "The total quantity of contracts remaining after the exercise.", + "format": "decimal", + "type": "string" + } + }, + "title": "ExerciseResponse", + "type": "object" + }, + "FEEActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "parent_id": { + "description": "The parent transaction's ID", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "parent_id" + ], + "type": "object" + } + ], + "description": "Fee", + "type": "object" + }, + "FOPTActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "contra": { + "description": "Contra for the transfer", + "type": "string" + }, + "external_id": { + "description": "External ID of the transfer", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "external_id", + "contra", + "symbol" + ], + "type": "object" + } + ], + "description": "Free-of-payment (FOP) transfers", + "type": "object" + }, + "FPSLAnalyticsLoansResponse": { + "description": "Aggregated FPSL interest and loan-activity counts for one account over a date range.\n", + "properties": { + "account_number": { + "description": "Account's number at Alpaca", + "example": "286873545", + "type": "string" + }, + "in_progress_lending_activities": { + "description": "The number of FPSL lending activities currently in progress for the account.", + "example": 2, + "format": "int64", + "type": "integer" + }, + "interest": { + "$ref": "#/components/schemas/FPSLInterest" + }, + "total_lending_activities": { + "description": "The total number of FPSL lending activities for the account within the specified date range.", + "example": 7, + "format": "int64", + "type": "integer" + } + }, + "required": [ + "account_number", + "total_lending_activities", + "in_progress_lending_activities" + ], + "type": "object" + }, + "FPSLError": { + "description": "FPSL API error response", + "properties": { + "message": { + "example": "Internal Server Error", + "type": "string" + } + }, + "type": "object" + }, + "FPSLInterest": { + "description": "The interest's details.\nPlease note that the object might not be set if interest has not yet been calculated for the loan.\nAdditionally, interest details may be adjusted retroactively at any time until interests are finalized for the month.\nThe loan's changed `updated_at` field can indicate such an adjustment.\n", + "properties": { + "customer": { + "description": "The interest accrued by the customer for this loan.", + "example": 1.23, + "format": "double", + "type": "number" + }, + "partner": { + "description": "The interest accrued by the partner for this loan.", + "example": 1.65, + "format": "double", + "type": "number" + } + }, + "required": [ + "customer", + "partner" + ], + "type": "object" + }, + "FPSLLoan": { + "description": "A loan of a security by an account on a date.", + "properties": { + "account_id": { + "description": "Account's ID at Alpaca", + "example": "06d83e79-5bea-4ce9-a362-a25251a700ec", + "type": "string" + }, + "account_number": { + "description": "Account's number at Alpaca", + "example": "286873545", + "type": "string" + }, + "collateral": { + "description": "The collateral posted for the loan.", + "example": 1161.015, + "format": "double", + "type": "number" + }, + "correspondent": { + "description": "Account's correspondent", + "example": "LPCA", + "type": "string" + }, + "date": { + "example": "2006-01-02", + "format": "date", + "type": "string" + }, + "interest": { + "$ref": "#/components/schemas/FPSLInterest" + }, + "market_value": { + "description": "The total market value of the shares on loan.", + "example": 1138.25, + "format": "double", + "type": "number" + }, + "quantity": { + "description": "The number of shares in the loan. This may be less than the total number of eligible shares held by the account.", + "example": 5, + "format": "int64", + "type": "integer" + }, + "symbol": { + "description": "Stock/Ticker symbol of a stock or security", + "example": "AAPL", + "type": "string" + }, + "updated_at": { + "description": "Timestamp of the last update to this loan in RFC-3339 format with microsecond precision with timezone.\nAn updated value may indicate adjusted interest values.\n", + "example": "2025-03-21T15:54:19.857034+01:00", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "date", + "account_id", + "account_number", + "correspondent", + "symbol", + "quantity", + "market_value", + "collateral" + ], + "type": "object" + }, + "FPSLTier": { + "properties": { + "created_at": { + "description": "The timestamp the FPSL tier was created, in RFC 3339 format.", + "example": "2024-09-16T20:06:32.207729Z", + "format": "date-time", + "type": "string" + }, + "customer_split": { + "description": "Percentage of the customer split represented as a value between 0 and 1.00. Max 2 decimal places are allowed.", + "example": 0.25, + "type": "number" + }, + "id": { + "description": "The unique identifier of the FPSL tier", + "example": "150df7eb-31e7-46b3-8848-a54ca21ff3bc", + "format": "uuid", + "type": "string" + }, + "market": { + "description": "The market of the FPSL tier", + "example": "US", + "type": "string" + }, + "partner_split": { + "description": "Percentage of the partner split represented as a value between 0 and 1.00. Max 2 decimal places are allowed.", + "example": 0.3, + "type": "number" + }, + "tier_name": { + "description": "The name of the FPSL tier", + "example": "gold", + "type": "string" + }, + "updated_at": { + "description": "The timestamp of the last update to the FPSL tier, in RFC 3339 format.", + "example": "2024-09-16T20:06:32.207729Z", + "format": "date-time", + "type": "string" + } + }, + "type": "object" + }, + "FeePaymentMethod": { + "description": "Only outgoing wire fees are currently supported for automated processing.\n\n\n**user**\tThe end user will pay any applicable fees\n**invoice**\tAny applicable fees will be billed to the client in the following monthly invoice", + "title": "FeePaymentMethod", + "type": "string" + }, + "FeePaymentType": { + "description": "Status:\n * `invoice`\n", + "enum": [ + "invoice" + ], + "type": "string" + }, + "FeeType": { + "description": "Status:\n * `withdrawal_fee`: Withdrawal fee\n * `fx_fee`: FX Fee\n * `network_fee`\n * `deposit_fee`\n * `ach_return_fee`\n * `parnter_fee`\n * `alpaca_fee`\n", + "enum": [ + "withdrawal_fee", + "fx_fee", + "network_fee", + "deposit_fee", + "ach_return_fee", + "parnter_fee", + "alpaca_fee" + ], + "type": "string" + }, + "FixedIncomeInterestActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonFixedIncomeInterestActivityV2" + } + ], + "description": "Fixed income interest (INT/FI)", + "type": "object" + }, + "FixedIncomeInterestType": { + "description": "Distinguishes coupon payments from accrued interest on INT/FI activities.", + "enum": [ + "coupon", + "accrued" + ], + "example": "accrued", + "title": "FixedIncomeInterestType", + "type": "string" + }, + "FixedIncomeRedemptionActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "ca_id": { + "description": "The unique identifier for this corporate action", + "type": "string" + }, + "cash_payout": { + "description": "The cash payout", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "payment_date": { + "description": "The payment date", + "format": "date", + "minLength": 1, + "type": "string" + }, + "qty": { + "description": "Quantity for the redemption", + "type": "string" + } + }, + "required": [ + "ca_id", + "payment_date", + "cusip", + "qty", + "cash_payout" + ], + "type": "object" + } + ], + "description": "Redemption", + "type": "object" + }, + "ForwardSplitActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonSplitStockActivityV2" + }, + { + "properties": { + "due_bill_redemption_date": { + "description": "When due bills related to the split are redeemed", + "format": "date", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security being split", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Forward stock split", + "type": "object" + }, + "FundingDetail": { + "description": "Gets funding details that can be used to settle and collect funds in each available currency.\n", + "properties": { + "account_holder_name": { + "type": "string" + }, + "account_number": { + "type": "string" + }, + "account_number_type": { + "type": "string" + }, + "bank_address": { + "type": "string" + }, + "bank_country": { + "type": "string" + }, + "bank_name": { + "type": "string" + }, + "currency": { + "type": "string" + }, + "payment_type": { + "$ref": "#/components/schemas/FundingDetailPaymentType" + }, + "routing_code": { + "type": "string" + }, + "routing_code_type": { + "$ref": "#/components/schemas/FundingDetailRoutingCodeType" + } + }, + "type": "object" + }, + "FundingDetailPaymentType": { + "description": "Status:\n * `swift_wire`: SWIFT wire\n * `local_rails`: Local scheme\n", + "enum": [ + "swift_wire", + "local_rails" + ], + "type": "string" + }, + "FundingDetailRoutingCodeType": { + "description": "Status:\n * `BIC`: bic_swift\n * `ACH`: ach_routing_code\n * `ABA`: aba\n * `ROUTING`: routing_code\n * `SORT_CODE`: sort_code\n", + "enum": [ + "BIC", + "ACH_ROUTING", + "ABA", + "ROUTING", + "SORT_CODE" + ], + "type": "string" + }, + "FundingWallet": { + "properties": { + "account_id": { + "format": "uuid", + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/FundingWalletStatus" + } + }, + "required": [ + "account_id", + "status", + "created_at" + ], + "type": "object" + }, + "FundingWalletRecipientBank": { + "properties": { + "account_number": { + "description": "Bank account number.", + "type": "string" + }, + "bic_swift": { + "description": "BIC/SWIFT code", + "type": "string" + }, + "city": { + "description": "City", + "type": "string" + }, + "company_name": { + "type": "string" + }, + "country": { + "description": "Two-letter ISO country code.", + "type": "string" + }, + "created_at": { + "description": "Date the beneficiary record was created.", + "format": "date-time", + "type": "string" + }, + "currency": { + "description": "Currency in which money is held in the beneficiary's bank account. Three-digit currency code.", + "type": "string" + }, + "first_name": { + "type": "string" + }, + "iban": { + "description": "IBAN code", + "type": "string" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "last_name": { + "type": "string" + }, + "payment_types": { + "items": { + "$ref": "#/components/schemas/FundingDetailPaymentType" + }, + "type": "array" + }, + "postal_code": { + "description": "Postal code", + "type": "string" + }, + "routing_code": { + "description": "Value for \"routing_code_type\".", + "type": "string" + }, + "routing_code_type": { + "description": "Local payment routing system.", + "type": "string" + }, + "state_or_province": { + "description": "State or province.", + "type": "string" + }, + "street_address": { + "type": "string" + }, + "updated_at": { + "description": "Date the beneficiary record was last updated.", + "format": "date-time", + "type": "string" + } + }, + "type": "object" + }, + "FundingWalletStatus": { + "description": "Status:\n * `active`: The funding wallet is ready\n * `pending`: The funding wallet is being processed\n * `disabled`: The funding wallet is disabled\n", + "enum": [ + "active", + "pending", + "disabled" + ], + "type": "string" + }, + "FundingWalletTransfer": { + "properties": { + "account_id": { + "format": "uuid", + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "direction": { + "$ref": "#/components/schemas/FundingWalletTransferDirection" + }, + "fees": { + "items": { + "$ref": "#/components/schemas/TransferFee" + }, + "type": "array" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "original_amount": { + "deprecated": true, + "description": "Deprecated. Prefer `total_amount` for the actual amount debited from the account. The amount you should expect to receive, calculated as requested amount - fees.", + "format": "decimal", + "type": "string", + "x-deprecation": { + "reason": "Use total_amount for the actual amount debited from the account.", + "since": "2026-09-22", + "sunset": "2026-12-21" + } + }, + "original_currency": { + "description": "The currency of the withdrawn amount, 3-letter ISO code", + "type": "string" + }, + "payment_type": { + "$ref": "#/components/schemas/FundingDetailPaymentType" + }, + "requested_amount": { + "description": "The amount requested when the transfer was created.", + "format": "decimal", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/FundingWalletTransferStatus" + }, + "total_amount": { + "description": "The total amount moved for the transfer. For outgoing transfers with fees added on top, this is the requested amount plus fees (the total debited from the account). For fee-inclusive outgoing withdrawals, fees are taken out of the requested amount, so this equals requested_amount. For incoming transfers, this is the requested amount credited to the account.", + "format": "decimal", + "type": "string" + }, + "updated_at": { + "format": "date-time", + "type": "string" + }, + "usd": { + "$ref": "#/components/schemas/Usd" + } + }, + "type": "object" + }, + "FundingWalletTransferDirection": { + "description": "Status:\n * `incoming`: incoming amount\n * `outgoing`: outgoing amount\n", + "enum": [ + "incoming", + "outgoing" + ], + "type": "string" + }, + "FundingWalletTransferStatus": { + "description": "Status:\n * `PENDING`: Created and waiting to be processed\n * `CANCELED`: Canceled\n * `FAILED`: Failed mostly due to technical reasons\n * `COMPLETE`: Transfer has settled\n", + "enum": [ + "PENDING", + "CANCELED", + "EXECUTED", + "FAILED", + "COMPLETE" + ], + "type": "string" + }, + "IFFee": { + "properties": { + "amount": { + "format": "decimal", + "type": "string" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/IFFeeType" + } + }, + "required": [ + "id", + "amount", + "type" + ], + "type": "object" + }, + "IFFeeType": { + "description": "Status:\n * `partner`: The fee on a transfer that was allocated to the partner\n * `alpaca`: The fee on a transfer that was allocated to Alpaca\n", + "enum": [ + "partner", + "alpaca" + ], + "type": "string" + }, + "IPOEvent": { + "description": "Represents an IPO offering lifecycle event delivered over the IPO events streaming API (`/v2/events/ipos`).\n\nIPO events come in six `verb` types:\n- **`Offering`** - initial publication of an offering. The `payload` carries `name`, `available_to_order`, `ticker_symbol`, `min_price`, `max_price` (and optional `source`).\n- **`OfferingUpdate`** - update to a previously published offering. The `payload` shape is identical to `Offering`.\n- **`Prospectus`** - prospectus document is now available. The `payload` carries `prospectus_url` and `subject`.\n- **`SixtyMinMail`** - 60-minute pricing window has opened, no new orders accepted. The `payload` carries `sixty_minute_expiration_time` and `subject`.\n- **`Allocation`** - final allocation result for a specific account. The `payload` carries `cusip_id`, `final_price`, `allocated_shares`, `allocated_amount`, `subject`. **This is the only verb that is account-scoped**: `account_id` and `correspondent` are populated.\n- **`OfferingCancellation`** - offering was cancelled. **No `payload` is present.**\n\nSee the example payloads below for a concrete example per verb.\n", + "examples": [ + { + "at": "2026-03-20T12:24:58.807230Z", + "event_id": "01J9RPMV5TKB8WX3M4F1KZ7QH2", + "offering_reference": "FI111225", + "payload": { + "available_to_order": "Available", + "max_price": "42", + "min_price": "42", + "name": "Example Corp", + "source": "example source", + "ticker_symbol": "EXMP" + }, + "received_at": "2026-03-20T12:24:58.500000Z", + "verb": "Offering" + }, + { + "at": "2026-03-20T15:42:11.118274Z", + "event_id": "01J9RQ5HNZQK7M3RDVJ8XBPCT1", + "offering_reference": "FI111225", + "payload": { + "available_to_order": "Available", + "max_price": "44", + "min_price": "40", + "name": "Example Corp", + "source": "example source", + "ticker_symbol": "EXMP" + }, + "received_at": "2026-03-20T15:42:10.892140Z", + "verb": "OfferingUpdate" + }, + { + "at": "2026-03-19T23:26:46.853262Z", + "event_id": "01J9RSGD8JR2A4K7MZNTPVQ5XW", + "offering_reference": "FI111225", + "payload": { + "prospectus_url": "https://example.com/prospectus/example-corp.pdf", + "subject": "IPO Prospectus: Example Corp" + }, + "received_at": "2026-03-19T23:26:46.612880Z", + "verb": "Prospectus" + }, + { + "at": "2026-03-19T22:50:11.729329Z", + "event_id": "01J9RT9P3WYH8KCJM2LFQX5ZRD", + "offering_reference": "FI111225", + "payload": { + "sixty_minute_expiration_time": "2026-03-19T23:50:11.729329Z", + "subject": "IPO 60 Minute Mail: Example Corp" + }, + "received_at": "2026-03-19T22:50:11.512640Z", + "verb": "SixtyMinMail" + }, + { + "account_id": "6221407b-32b2-3e6b-a7fe-cd79e1b68ba3", + "at": "2026-03-20T00:15:42.318901Z", + "correspondent": "COR1", + "event_id": "01J9RTPZGHKVB8M3X4F5J7LCQ9", + "offering_reference": "FI111225", + "payload": { + "allocated_amount": "1764", + "allocated_shares": "42", + "cusip_id": "123456789", + "final_price": "42", + "subject": "IPO Allocation: Example Corp" + }, + "received_at": "2026-03-20T00:15:42.103572Z", + "verb": "Allocation" + }, + { + "at": "2026-03-20T12:24:52.325158Z", + "event_id": "01J9RVB6Y4ZK8M3N7QD2WX1RFP", + "offering_reference": "FI111225", + "received_at": "2026-03-20T12:24:52.110430Z", + "verb": "OfferingCancellation" + } + ], + "properties": { + "account_id": { + "description": "The account this event applies to. Only populated for `Allocation` events; omitted for system-wide verbs (`Offering`, `OfferingUpdate`, `Prospectus`, `SixtyMinMail`, `OfferingCancellation`).\n", + "format": "uuid", + "type": "string" + }, + "at": { + "description": "Timestamp the event was emitted by the streaming service.", + "format": "date-time", + "type": "string" + }, + "correspondent": { + "description": "The correspondent that owns the account. Only populated for `Allocation` events.\n", + "example": "COR1", + "type": "string" + }, + "event_id": { + "description": "Lexically sortable, monotonically increasing identifier for this event. Use this value with `since_id`/`until_id` to resume the stream from a known point.", + "format": "ulid", + "type": "string" + }, + "offering_reference": { + "description": "The IPO offering this event refers to. Use this value with `GET /v1/ipos/{offering_reference}` to fetch the full offering metadata.\n", + "example": "FI111225", + "type": "string" + }, + "payload": { + "description": "Verb-specific payload. The shape varies by `verb` - see schema description and `components/examples` for the structure of each. **Omitted entirely for `OfferingCancellation`.**\n", + "type": "object" + }, + "received_at": { + "description": "Timestamp the upstream event was first received by Alpaca's IPO ingestion pipeline (before fanout).", + "format": "date-time", + "type": "string" + }, + "verb": { + "description": "The IPO event type. Determines the shape of `payload`.", + "enum": [ + "Allocation", + "Offering", + "OfferingUpdate", + "Prospectus", + "SixtyMinMail", + "OfferingCancellation" + ], + "type": "string" + } + }, + "required": [ + "event_id", + "at", + "verb", + "offering_reference", + "received_at" + ], + "title": "IPOEvent", + "type": "object" + }, + "IPOOffering": { + "description": "An IPO (Initial Public Offering) offering exposed via the IPO discovery REST API. Returned by `GET /v1/ipos` and `GET /v1/ipos/{offering_reference}`.\n\nMost IPO lifecycle changes (new offerings, prospectus availability, 60-minute mail, allocations, cancellations) are pushed in real time over the [IPO Events Stream](#operation/subscribeToIPOEventsSSE).\n", + "properties": { + "anticipated_shares": { + "description": "Anticipated total share count for the offering, when known.", + "format": "int64", + "type": "integer" + }, + "availability": { + "description": "Whether the offering is currently accepting orders.\n- `available` - accepting new orders.\n- `not_available` - not yet open for orders.\n- `closed` - no longer accepting orders.\n\nNote: the IPO Events Stream uses a different casing for the analogous `payload.available_to_order` field on `Offering`/`OfferingUpdate` events (`Available`, `NotAvailable`, `Closed`).\n", + "enum": [ + "available", + "not_available", + "closed" + ], + "example": "available", + "type": "string" + }, + "cusip_id": { + "description": "CUSIP identifier of the offering.", + "example": "123456789", + "type": "string" + }, + "description": { + "description": "A longer human-readable description of the offering, when available.", + "type": "string" + }, + "ipo_reference": { + "description": "The unique offering identifier used across the IPO Events Stream and `/v1/ipos/{offering_reference}`. Note that this value is also used as the path parameter, where it is named `offering_reference`.\n", + "example": "FI111225", + "type": "string" + }, + "logo_small": { + "description": "URL to a small logo asset for the issuer.", + "type": "string" + }, + "max_price": { + "description": "Upper bound of the indicated price range.", + "example": "42", + "format": "decimal", + "type": "string" + }, + "max_ticket_size": { + "description": "Maximum allowed order amount.", + "type": "string" + }, + "min_price": { + "description": "Lower bound of the indicated price range.", + "example": "42", + "format": "decimal", + "type": "string" + }, + "min_ticket_size": { + "description": "Minimum allowed order amount.", + "type": "string" + }, + "name": { + "description": "The official name of the offering.", + "example": "Example Corp", + "type": "string" + }, + "no_new_orders": { + "description": "When `true`, the offering is in its 60-minute pricing window and is not accepting new orders. This mirrors the `SixtyMinMail` event on the IPO Events Stream.\n", + "example": false, + "type": "boolean" + }, + "offering_type": { + "description": "The type of offering. Currently always `IPO`.", + "example": "IPO", + "type": "string" + }, + "prospectus_url": { + "description": "URL to the prospectus document. Mirrors the `prospectus_url` payload of the corresponding `Prospectus` event on the IPO Events Stream.\n", + "type": "string" + }, + "settlement_date": { + "description": "Anticipated settlement date.", + "format": "date", + "type": "string" + }, + "ticker_symbol": { + "description": "The ticker symbol that will be used once the security begins trading on the secondary market.", + "example": "EXMP", + "type": "string" + }, + "trade_date": { + "description": "Anticipated first trading date on the secondary market.", + "format": "date", + "type": "string" + }, + "underwriters": { + "description": "List of underwriter names participating in the offering.", + "items": { + "type": "string" + }, + "type": "array" + }, + "unit_step_size": { + "description": "The minimum increment in which order quantities can be specified.", + "type": "string" + } + }, + "required": [ + "name", + "ipo_reference", + "offering_type", + "availability", + "max_price", + "min_price", + "no_new_orders" + ], + "title": "IPOOffering", + "type": "object" + }, + "IPOOfferingListResponse": { + "description": "Wrapper response returned by `GET /v1/ipos`.", + "properties": { + "data": { + "description": "The page of IPO offerings matching the query.", + "items": { + "$ref": "#/components/schemas/IPOOffering" + }, + "type": "array" + }, + "next_page_token": { + "description": "Opaque cursor for the next page of results. When `null`, there are no further pages. Pass this value back as the `page_token` query parameter to fetch the next page.\n", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "data", + "next_page_token" + ], + "title": "IPOOfferingListResponse", + "type": "object" + }, + "IPOOfferingResponse": { + "description": "Wrapper response returned by `GET /v1/ipos/{offering_reference}`.", + "properties": { + "data": { + "$ref": "#/components/schemas/IPOOffering" + } + }, + "required": [ + "data" + ], + "title": "IPOOfferingResponse", + "type": "object" + }, + "Identity": { + "description": "Identity is the model to provide account owner's identity information.\n", + "example": { + "country_of_birth": "AUS", + "country_of_citizenship": "AUS", + "country_of_tax_residence": "USA", + "date_of_birth": "1990-01-01", + "family_name": "Doe", + "funding_source": [ + "employment_income" + ], + "given_name": "John", + "tax_id": "666-55-4321", + "tax_id_type": "USA_SSN" + }, + "properties": { + "annual_income_max": { + "description": "The upper bound of the user's annual income.", + "example": "100000", + "format": "decimal", + "type": "string" + }, + "annual_income_min": { + "description": "The lower bound of the user's annual income.", + "example": "50000", + "format": "decimal", + "type": "string" + }, + "country_of_birth": { + "description": "[ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html).\n", + "example": "USA", + "type": "string" + }, + "country_of_citizenship": { + "description": "[ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html).\n", + "example": "USA", + "type": "string" + }, + "country_of_tax_residence": { + "description": "[ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html).\n", + "example": "USA", + "type": "string" + }, + "date_of_birth": { + "description": "The date of birth in \"YYYY-MM-DD\" format.", + "example": "1990-01-01", + "format": "date", + "type": "string" + }, + "date_of_departure_from_usa": { + "description": "Required if `visa_type` = B1 or B2", + "format": "date", + "type": "string" + }, + "family_name": { + "description": "The last name (surname) of the user.", + "example": "Doe", + "type": "string" + }, + "funding_source": { + "description": "Can be one or more of the following: `employment_income`, `investments`, `inheritance`, `business_income`, `savings`, `family`.", + "items": { + "enum": [ + "employment_income", + "investments", + "inheritance", + "business_income", + "savings", + "family" + ], + "type": "string" + }, + "type": "array" + }, + "given_name": { + "description": "The first/given name of the user.", + "example": "John", + "type": "string" + }, + "investment_experience_with_options": { + "description": "The user's level of expertise and familiarity with investing in Options.\n", + "enum": [ + "none", + "1_to_5_years", + "over_5_years" + ], + "type": "string" + }, + "investment_experience_with_stocks": { + "description": "The user's level of expertise and familiarity with investing in US Equities.\n", + "enum": [ + "none", + "1_to_5_years", + "over_5_years" + ], + "type": "string" + }, + "investment_objective": { + "deprecated": true, + "description": "The user's investment objective. This field is deprecated. Please use the top level `investment_objective` field.\n", + "enum": [ + "generate_income", + "preserve_wealth", + "market_speculation", + "growth", + "balance_preserve_wealth_with_growth" + ], + "type": "string" + }, + "investment_time_horizon": { + "deprecated": true, + "description": "The expected period of time the user plan to invest to achieve his/her financial goal(s). This field is deprecated. Please use the top level `investment_time_horizon` field.\n", + "enum": [ + "less_than_1_year", + "1_to_2_years", + "3_to_5_years", + "6_to_10_years", + "more_than_10_years" + ], + "type": "string" + }, + "liquid_net_worth_max": { + "description": "The upper bound of the user's liquid net worth.", + "example": "500000", + "format": "decimal", + "type": "string" + }, + "liquid_net_worth_min": { + "description": "The lower bound of the user's liquid net worth.", + "example": "100000", + "format": "decimal", + "type": "string" + }, + "liquidity_needs": { + "deprecated": true, + "description": "The user's ability to quickly and easily convert all or part of their investments in this account to cash without significant loss in value. This field is deprecated. Please use the top level `liquidity_needs` field.\n", + "enum": [ + "very_important", + "important", + "somewhat_important", + "does_not_matter" + ], + "type": "string" + }, + "marital_status": { + "description": "The marital status of the user.\n", + "enum": [ + "SINGLE", + "MARRIED", + "DIVORCED", + "WIDOWED" + ], + "type": "string" + }, + "middle_name": { + "description": "The middle name of the user.", + "type": "string" + }, + "number_of_dependents": { + "description": "The number of dependents the user has.\n", + "type": "integer" + }, + "permanent_resident": { + "description": "Only used to collect permanent residence status in the USA.", + "type": "boolean" + }, + "risk_tolerance": { + "deprecated": true, + "description": "The user's investment risk tolerance. This field is deprecated. Please use the top level `risk_tolerance` field.\n", + "enum": [ + "conservative", + "moderate", + "significant_risk" + ], + "type": "string" + }, + "tax_id": { + "description": "If this is provided, `tax_id_type` is required.", + "example": "666-55-4321", + "type": "string" + }, + "tax_id_type": { + "description": "Required on write when `tax_id` is set. May be `null` on read when unset or for sparse identity on OmniSub / omnibus-non-disclosed accounts.", + "oneOf": [ + { + "$ref": "#/components/schemas/TaxIdType" + }, + { + "type": "null" + } + ] + }, + "total_net_worth_max": { + "description": "The upper bound of the user's total net worth.", + "example": "1000000", + "format": "decimal", + "type": "string" + }, + "total_net_worth_min": { + "description": "The lower bound of the user's total net worth.", + "example": "100000", + "format": "decimal", + "type": "string" + }, + "visa_expiration_date": { + "description": "Required if `visa_type` is set.", + "format": "date", + "type": "string" + }, + "visa_type": { + "description": "Only used to collect visa types for users residing in the USA.", + "type": "string" + } + }, + "required": [ + "given_name", + "family_name", + "date_of_birth", + "country_of_tax_residence", + "funding_source" + ], + "type": "object" + }, + "InstantFunding": { + "properties": { + "account_no": { + "type": "string" + }, + "amount": { + "format": "decimal", + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "deadline": { + "format": "date", + "type": "string" + }, + "fees": { + "items": { + "$ref": "#/components/schemas/IFFee" + }, + "type": "array" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "interests": { + "items": { + "$ref": "#/components/schemas/Interest" + }, + "type": "array" + }, + "remaining_payable": { + "format": "decimal", + "type": "string" + }, + "source_account_no": { + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/InstantFundingStatus" + }, + "system_date": { + "format": "date", + "type": "string" + }, + "total_interest": { + "format": "decimal", + "type": "string" + } + }, + "required": [ + "id", + "amount", + "account_no", + "source_account_no", + "status", + "system_date", + "deadline", + "created_at", + "total_interest", + "remaining_payable", + "interests", + "fees" + ], + "type": "object" + }, + "InstantFundingStatus": { + "description": "Status:\n * `PENDING`: Created and waiting to be processed\n * `CANCELED`: Canceled\n * `EXECUTED`: All fees (including Partner fee) are transacted\n * `FAILED`: Failed mostly due to technical reasons\n * `COMPLETED`: All transactions are settled\n", + "enum": [ + "PENDING", + "CANCELED", + "EXECUTED", + "FAILED", + "COMPLETED" + ], + "type": "string" + }, + "Interest": { + "properties": { + "amount": { + "format": "decimal", + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "date": { + "format": "date", + "type": "string" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "reconciled_at": { + "format": "date-time", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/InstantFundingStatus" + } + }, + "required": [ + "id", + "date", + "amount", + "status", + "created_at", + "reconciled_at" + ], + "type": "object" + }, + "IssueOAuthTokenResponse": { + "description": "", + "examples": [ + { + "access_token": "87586f14-c3f4-4912-b107-f75bc17ff87a", + "scope": "general", + "token_type": "Bearer" + } + ], + "properties": { + "access_token": { + "description": "OAuth token", + "type": "string" + }, + "scope": { + "description": "Token's scope", + "type": "string" + }, + "token_type": { + "description": "Always `Bearer`", + "enum": [ + "Bearer" + ], + "example": "Bearer", + "type": "string" + } + }, + "required": [ + "access_token", + "token_type", + "scope" + ], + "type": "object" + }, + "JITAssetClass": { + "description": "Values:\n * `crypto`: Used to identify a crypto only account\n * `us_equity`: Used to identify an account that trades US equities, or both crypto and\n US equities.\n", + "enum": [ + "crypto", + "us_equity" + ], + "type": "string" + }, + "JITLedgerAccount": { + "examples": [ + { + "created_at": "1653532627", + "id": "2896b9e2-3198-44cd-a08e-4cc4079aee33", + "ledger_name": "Securities JIT IN", + "status": "active" + } + ], + "properties": { + "created_at": { + "description": "Creation time in UNIX format", + "type": "string" + }, + "id": { + "description": "The ledger ID", + "type": "string" + }, + "ledger_name": { + "description": "The ledger name", + "type": "string" + }, + "status": { + "type": "string" + } + }, + "title": "JITLedgerAccount", + "type": "object" + }, + "JITReport": { + "description": "JIT Securities reports are made available through the API and can be accessed within the hour after 11:30 PM EST on the trade date (T+0). The reports communicate transaction-level details as well as overall settlement amounts, transfer direction, and payment timing.", + "properties": { + "detail": { + "description": "Contains all activities that impact cash throughout the trading session including executed trades, trading fees, and corporate actions that involve cash allocations.\n\ncontent-type = application/csv", + "type": "string" + }, + "net_payment": { + "description": "Highlights the net amount due to Alpaca by settlement or to the partner on the date of settlement in a formalized invoice format.\n\ncontent-type = application/pdf", + "type": "string" + }, + "net_payment_final": { + "description": "Includes additional information to account for T+0 and T+1 settling activity to clarify settlement journaling reconciliation. This report is generated after trading session close on T+1.\n\ncontent-type = application/pdf", + "type": "string" + }, + "net_summary": { + "description": "Consists of three columns and a single row, which lists the net money movement to or from Alpaca for T0, T1, and T2.\n\ncontent-type = application/csv", + "type": "string" + }, + "obligation": { + "description": "Lists of all open obligations towards the partner that are to be settled.\n\ncontent-type = application/csv", + "type": "string" + } + }, + "title": "JITReport", + "type": "object" + }, + "JITReportDownloadURL": { + "properties": { + "expires_at": { + "description": "Timestamp when the signed URL expires.", + "format": "date-time", + "type": "string" + }, + "filename": { + "description": "Name of the generated report file.", + "type": "string" + }, + "url": { + "description": "Temporary signed URL used to download the report.", + "format": "uri", + "type": "string" + } + }, + "required": [ + "url", + "filename", + "expires_at" + ], + "type": "object" + }, + "JNLC": { + "allOf": [ + { + "$ref": "#/components/schemas/JournalBase" + }, + { + "properties": { + "entry_type": { + "description": "Cash journal discriminator value.", + "enum": [ + "JNLC" + ], + "type": "string" + }, + "transmitter_account_number": { + "description": "Optional for JNLC journals. Maximum 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "maxLength": 255, + "type": "string" + }, + "transmitter_address": { + "description": "Optional for JNLC journals. Maximum 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "maxLength": 255, + "type": "string" + }, + "transmitter_financial_institution": { + "description": "Optional for JNLC journals. Maximum 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "maxLength": 255, + "type": "string" + }, + "transmitter_name": { + "description": "Optional for JNLC journals. Maximum 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "maxLength": 255, + "type": "string" + }, + "transmitter_timestamp": { + "description": "Optional for JNLC journals. RFC 3339 format. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "entry_type" + ], + "type": "object" + } + ], + "description": "A cash journal response with all shared Journal fields.", + "examples": [ + { + "currency": "USD", + "description": "", + "entry_type": "JNLC", + "from_account": "8f8c8cee-2591-4f83-be12-82c659b5e748", + "id": "56f106e5-25a4-4eee-96fa-25bb05dc86bc", + "net_amount": "1000", + "price": null, + "qty": null, + "settle_date": null, + "status": "pending", + "symbol": null, + "system_date": null, + "to_account": "399f85f1-cbbd-4eaa-a934-70027fb5c1de" + } + ], + "title": "JNLC" + }, + "JNLCActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonJournalActivityV2" + }, + { + "type": "object" + } + ], + "description": "Journal entry (cash)", + "type": "object" + }, + "JNLS": { + "allOf": [ + { + "$ref": "#/components/schemas/JournalBase" + }, + { + "properties": { + "entry_type": { + "description": "Securities journal discriminator value.", + "enum": [ + "JNLS" + ], + "type": "string" + } + }, + "required": [ + "entry_type" + ], + "type": "object" + } + ], + "description": "A securities journal response with all shared Journal fields.", + "examples": [ + { + "currency": "USD", + "description": "this is a test journal", + "entry_type": "JNLS", + "from_account": "8f4f3d11-4483-4199-840f-6c5fe0b7ca24", + "id": "f45f67e8-d1fc-4136-aa4f-cf4460aecdfc", + "net_amount": null, + "price": "128.23", + "qty": "0.5", + "settle_date": "2020-12-24", + "status": "executed", + "symbol": "AAPL", + "system_date": "2020-12-24", + "to_account": "a7a7e666-6f2a-433c-8c33-17b66b8941fa" + } + ], + "title": "JNLS" + }, + "JNLSActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonJournalActivityV2" + }, + { + "properties": { + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Journal entry (stock)", + "type": "object" + }, + "Journal": { + "description": "Represents a cash or securities transfer between accounts, selected by `entry_type`.", + "discriminator": { + "mapping": { + "JNLC": "#/components/schemas/JNLC", + "JNLS": "#/components/schemas/JNLS" + }, + "propertyName": "entry_type" + }, + "examples": [ + { + "currency": "USD", + "description": "", + "entry_type": "JNLC", + "from_account": "8f8c8cee-2591-4f83-be12-82c659b5e748", + "id": "56f106e5-25a4-4eee-96fa-25bb05dc86bc", + "net_amount": "1000", + "price": null, + "qty": null, + "settle_date": null, + "status": "pending", + "symbol": null, + "system_date": null, + "to_account": "399f85f1-cbbd-4eaa-a934-70027fb5c1de" + }, + { + "currency": "USD", + "description": "this is a test journal", + "entry_type": "JNLS", + "from_account": "8f4f3d11-4483-4199-840f-6c5fe0b7ca24", + "id": "f45f67e8-d1fc-4136-aa4f-cf4460aecdfc", + "net_amount": null, + "price": "128.23", + "qty": "0.5", + "settle_date": "2020-12-24", + "status": "executed", + "symbol": "AAPL", + "system_date": "2020-12-24", + "to_account": "a7a7e666-6f2a-433c-8c33-17b66b8941fa" + } + ], + "oneOf": [ + { + "$ref": "#/components/schemas/JNLC" + }, + { + "$ref": "#/components/schemas/JNLS" + } + ], + "title": "Journal" + }, + "JournalBase": { + "description": "Shared response fields returned for cash and securities journals.", + "properties": { + "created_at": { + "description": "The creation time when supplied by the endpoint.", + "format": "date-time", + "type": "string" + }, + "currency": { + "description": "Currency denomination of the journal.", + "type": "string" + }, + "description": { + "description": "The journal description.", + "type": "string" + }, + "from_account": { + "description": "The account ID that initiated the journal.", + "format": "uuid", + "type": "string" + }, + "id": { + "description": "The journal ID.", + "format": "uuid", + "type": "string" + }, + "net_amount": { + "description": "The cash amount, or null when not applicable.", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "price": { + "description": "The journaled security price, or null when not applicable.", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "qty": { + "description": "The journaled security quantity, or null when not applicable.", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "settle_date": { + "description": "The settlement date, or null until one is assigned.", + "format": "date", + "type": [ + "string", + "null" + ] + }, + "status": { + "$ref": "#/components/schemas/JournalStatus" + }, + "symbol": { + "description": "The journaled security symbol, or null for a cash journal.", + "type": [ + "string", + "null" + ] + }, + "system_date": { + "description": "The booking-system date, or null until one is assigned.", + "format": "date", + "type": [ + "string", + "null" + ] + }, + "to_account": { + "description": "The account ID that received the journal.", + "format": "uuid", + "type": "string" + }, + "transmitter_info": { + "$ref": "#/components/schemas/TransmitterInfo" + } + }, + "required": [ + "id", + "from_account", + "to_account", + "symbol", + "qty", + "price", + "status", + "settle_date", + "system_date", + "net_amount", + "description", + "currency" + ], + "title": "JournalBase", + "type": "object" + }, + "JournalEntryType": { + "description": "This enum represents the various kinds of Journal alpaca supports.\n\nCurrent values are:\n\n- **JNLC**\n\n Journal Cash between accounts\n\n- **JNLS**\n\n Journal Securities between accounts", + "enum": [ + "JNLC", + "JNLS" + ], + "title": "", + "type": "string" + }, + "JournalStatus": { + "description": "Represents the status that a Journal instance can be in.\n\n**Current Values**\n\nqueued\tJournal in queue to be processed. Journal is not processed yet.\n\nsent_to_clearing\tJournal sent to be processed by Alpaca's booking system. The journal is not processed yet.\n\npending\t Journal pending to be processed as it requires manual approval from Alpaca operations (for example due to hitting JNLC daily limits).\n\nexecuted\tJournal executed and balances updated for both sides of \nthe journal transaction. This is not a final status, journals can be reversed if there is an error.\n\nactivity_created\tNon-trade activity has been created for journal (JNLC v2-only).\n\nrejected\tJournal rejected. Please try again.\n\ncanceled\tJournal canceled. This is a **FINAL** status.\n\nrefused\tJournal refused. Please try again.\n\ndeleted\tJournal deleted. This is a **FINAL** status.\n\ncorrect\tJournal is corrected. Previously executed journal is cancelled and a new journal is corrected amount is created. This is a **FINAL** status.", + "enum": [ + "pending", + "canceled", + "executed", + "activity_created", + "queued", + "rejected", + "deleted", + "refused", + "sent_to_clearing", + "correct" + ], + "type": "string" + }, + "JournalStatusEvent": { + "description": "Represents a change in a Journal's status, sent over the events streaming api.\n", + "examples": [ + { + "at": "2021-05-07T10:28:23.163857Z", + "entry_type": "JNLC", + "event_id": 1406, + "event_ulid": "01F535Y1FVY8WZHE763HCNS8SZ", + "journal_id": "2f144d2a-91e6-46ff-8e37-959a701cc58d", + "status_from": "", + "status_to": "queued" + } + ], + "properties": { + "at": { + "description": "Timestamp of event", + "format": "date-time", + "minLength": 1, + "type": "string" + }, + "entry_type": { + "$ref": "#/components/schemas/JournalEntryType" + }, + "event_id": { + "description": "Monotonically increasing 64-bit integer not available to new partners, and for backward compatibility purposes only; use `event_ulid` as the stable identifier where possible\n", + "type": "integer" + }, + "event_ulid": { + "description": "lexically sortable, monotonically increasing character array", + "format": "ulid", + "type": "string" + }, + "journal_id": { + "description": "The UUID of the related Journal", + "format": "uuid", + "type": "string" + }, + "status_from": { + "$ref": "#/components/schemas/JournalStatusFrom" + }, + "status_to": { + "$ref": "#/components/schemas/JournalStatus" + } + }, + "required": [ + "at", + "entry_type", + "event_ulid", + "journal_id", + "status_from", + "status_to" + ], + "title": "JournalStatusEvent", + "type": "object" + }, + "JournalStatusEventV2": { + "description": "Represents a change in a Journal's status, sent over the events streaming api.\n", + "examples": [ + { + "at": "2021-05-07T10:28:23.163857Z", + "description": "Journal of cash between accounts", + "entry_type": "JNLC", + "event_id": "01F535Y1FVY8WZHE763HCNS8SZ", + "journal_id": "2f144d2a-91e6-46ff-8e37-959a701cc58d", + "status_from": "", + "status_to": "queued" + }, + { + "at": "2021-05-07T10:28:23.163857Z", + "description": "Journal of cash between accounts", + "entry_type": "JNLC", + "event_id": "01F535Y1FVY8WZHE763HCNS8SZ", + "idempotency_key": "72bdf18f-7410-43ec-b4e8-b6e41c5c0160", + "idempotency_key_type": "single", + "journal_id": "2f144d2a-91e6-46ff-8e37-959a701cc58d", + "status_from": "queued", + "status_to": "executed" + } + ], + "properties": { + "at": { + "description": "Timestamp of event", + "format": "date-time", + "minLength": 1, + "type": "string" + }, + "batch_error_message": { + "description": "If journal submitted in batch (that is, idempotency_key_type is batch), this is the error message of the batch journal execution.", + "type": "string" + }, + "description": { + "description": "The description of the journal event when submitted", + "example": "Journal of cash between accounts", + "type": "string" + }, + "entry_type": { + "$ref": "#/components/schemas/JournalEntryType" + }, + "event_id": { + "description": "lexically sortable, monotonically increasing character array", + "format": "ulid", + "type": "string" + }, + "idempotency_key": { + "description": "The idempotency key of the journal event", + "format": "uuid", + "type": "string" + }, + "idempotency_key_type": { + "description": "The type of idempotency key", + "enum": [ + "single", + "batch" + ], + "type": "string" + }, + "journal_id": { + "description": "The UUID of the related Journal", + "format": "uuid", + "type": "string" + }, + "status_from": { + "$ref": "#/components/schemas/JournalStatusFrom" + }, + "status_to": { + "$ref": "#/components/schemas/JournalStatus" + } + }, + "required": [ + "at", + "entry_type", + "event_id", + "journal_id", + "status_from", + "status_to" + ], + "title": "JournalStatusEvent", + "type": "object" + }, + "JournalStatusFrom": { + "description": "Previous journal status in stream status-change events. Empty string is used for the initial status-change event when there is no previous status.", + "oneOf": [ + { + "$ref": "#/components/schemas/JournalStatus" + }, + { + "enum": [ + "" + ], + "type": "string" + } + ] + }, + "KYCResultType": { + "description": "A KYC reason identifier used as a property name in `KYCResultTypeSet`. The set is extensible, so integrations must tolerate and preserve unrecognized values.", + "examples": [ + "IDENTITY_VERIFICATION", + "compromised_document" + ], + "title": "KYCResultType", + "type": "string" + }, + "KYCResultTypeSet": { + "additionalProperties": { + "maxProperties": 0, + "type": "object" + }, + "description": "A nullable set of KYC reason identifiers represented as property names with empty object values. See `KYCResults` for documented identifiers and interpretation guidance.", + "examples": [ + null, + {}, + { + "IDENTITY_VERIFICATION": {}, + "WATCHLIST_HIT": {} + } + ], + "propertyNames": { + "$ref": "#/components/schemas/KYCResultType" + }, + "title": "KYCResultTypeSet", + "type": [ + "object", + "null" + ] + }, + "KYCResults": { + "description": "Holds information about the result of KYC.\n\n`accept`, `indeterminate`, and `reject` are nullable sets represented as objects. Each property name is a KYC reason identifier, and every property value is always an empty object (`{}`) carrying no nested data. For example:\n\n```json\n{\n \"IDENTITY_VERIFICATION\": {},\n \"WATCHLIST_HIT\": {}\n}\n```\n\nInterpret each reason together with its enclosing result category and `additional_information`.\n\nDocumented reason identifiers:\n- `IDENTITY_VERIFICATION`: A government-issued identity document is required to verify the account owner's identity.\n- `TAX_IDENTIFICATION`: A tax identification document is required to verify the account owner's tax identification number.\n- `ADDRESS_VERIFICATION`: Additional documentation, such as a government-issued ID or statement, may be required to verify the account owner's residential address.\n- `DATE_OF_BIRTH`: A government-issued identity document is required to verify the account owner's date of birth.\n- `SELFIE_VERIFICATION`: A live selfie of the account owner is required to verify identity.\n- `PEP`: The account owner disclosed politically exposed person status, and additional information may be required.\n- `FAMILY_MEMBER_PEP`: The account owner disclosed that an immediate family member is politically exposed, and additional information may be required.\n- `CONTROL_PERSON`: Additional company information may be required because the account owner disclosed a control position.\n- `AFFILIATED`: Additional firm information may be required because the account owner disclosed an affiliation with FINRA or an exchange.\n- `VISA_TYPE_OTHER`: The account owner's visa type and expiration date may be required because the submitted visa type was \"other.\"\n- `W8BEN_CORRECTION`: A new W-8BEN with corrected identifying information is required.\n- `COUNTRY_NOT_SUPPORTED`: The account owner's country of tax residence or legal residence is not supported for this account.\n- `WATCHLIST_HIT`: Watchlist screening returned a result that requires further review; no action is needed from the account owner unless separately requested.\n- `OTHER`: See `additional_information` for a custom message describing what is required from the account owner.\n- `OTHER_PARTNER`: See `additional_information` for a custom message intended for the Broker API partner.\n- `CITIZENSHIP_COUNTRY_NOT_SUPPORTED`: The account owner's country of citizenship is not supported for this account.\n- `DIFFERING_COUNTRY`: A submitted identity document was issued by a country different from the account owner's country of tax residence.\n- `WL_PEP_SCREENING`: Watchlist screening returned a result related to possible political exposure.\n- `WL_LEGAL_REGULATORY_WARNING`: Watchlist screening returned a legal or regulatory warning result.\n- `UNDER_MINIMUM_AGE`: The account owner does not meet the minimum age requirement for this account.\n- `PEP_FOREIGN`: The account owner disclosed foreign politically exposed person status, and additional information may be required.\n- `FAMILY_MEMBER_PEP_FOREIGN`: The account owner disclosed that an immediate family member has foreign politically exposed person status, and additional information may be required.\n- `DISCRETIONARY`: The account is designated for discretionary trading by a registered investment adviser and requires review.\n- `HIO`: Additional information and a declaration form may be required because the account owner disclosed being the head of an international organization.\n- `INTERNAL_CHECK`: A non-specific account-opening check contributed to the KYC outcome; no more specific reason is available.\n- `compromised_document`: The identity document check indicated that the document may be compromised.\n- `data_comparison`: Data extracted from the identity document did not pass comparison checks and requires review.\n- `image_integrity`: A document or selfie image did not pass image-integrity checks and requires review.\n\nThe set of reason identifiers is extensible, so integrations must tolerate and preserve unrecognized values.\n", + "properties": { + "accept": { + "$ref": "#/components/schemas/KYCResultTypeSet" + }, + "additional_information": { + "description": "Used to display a custom message.", + "type": "string" + }, + "indeterminate": { + "$ref": "#/components/schemas/KYCResultTypeSet" + }, + "reject": { + "$ref": "#/components/schemas/KYCResultTypeSet" + }, + "summary": { + "description": "Either `pass` or `fail`. Used to indicate if KYC has completed and passed or not. This field is used for internal purposes only.", + "type": "string" + } + }, + "type": [ + "object", + "null" + ] + }, + "ListAPRTiersResponse": { + "description": "Response to a successful request for a list of APR tiers.\n", + "properties": { + "apr_tiers": { + "description": "All configured APR tiers available for assignment to accounts", + "items": { + "$ref": "#/components/schemas/APRTier" + }, + "type": "array" + } + }, + "type": "object" + }, + "ListFPSLLoansResponse": { + "description": "Response to a successful request for a list of FPSL loans.\n", + "properties": { + "loans": { + "description": "All FPSL loans matching the filter criteria", + "items": { + "$ref": "#/components/schemas/FPSLLoan" + }, + "type": "array" + }, + "next_page_token": { + "description": "The token to use to retrieve the next page of results. If `null`, there are no more pages.\n", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "loans", + "next_page_token" + ], + "type": "object" + }, + "ListFundingDetails": { + "properties": { + "funding_details": { + "items": { + "$ref": "#/components/schemas/FundingDetail" + }, + "type": "array" + } + }, + "type": "object" + }, + "ListSortBy": { + "enum": [ + "created_at", + "amount", + "deadline" + ], + "type": "string" + }, + "ListTransfersResponse": { + "properties": { + "transfers": { + "items": { + "$ref": "#/components/schemas/FundingWalletTransfer" + }, + "type": "array" + } + }, + "type": "object" + }, + "MAActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonMAActivityV2" + }, + { + "properties": { + "acquiree_qty": { + "description": "Quantity of the acquiree", + "type": "string" + }, + "acquirer_qty": { + "description": "Quantity of the acquirer", + "type": "string" + }, + "cash_payout": { + "description": "The cash payout", + "type": "string" + }, + "cash_rate": { + "description": "The cash rate", + "type": "string" + } + }, + "required": [ + "acquiree_qty" + ], + "type": "object" + } + ], + "description": "Merger and acquisition", + "type": "object" + }, + "MEMActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "transfer_id": { + "description": "The transfer's ID", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "transfer_id" + ], + "type": "object" + } + ], + "description": "Instant funding memopost", + "type": "object" + }, + "MLegOrderLeg": { + "description": "Represents an individual leg of a multileg options order.", + "properties": { + "position_intent": { + "$ref": "#/components/schemas/PositionIntent" + }, + "ratio_qty": { + "description": "proportional quantity of this leg in relation to the overall multileg order qty", + "example": "1", + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "symbol": { + "description": "symbol or asset ID to identify the asset to trade", + "type": "string" + } + }, + "required": [ + "symbol", + "ratio_qty" + ], + "title": "MLegOrderLeg", + "type": "object" + }, + "NCActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonNCActivityV2" + }, + { + "properties": { + "position_qty": { + "description": "The position quantity", + "type": "string" + } + }, + "required": [ + "position_qty" + ], + "type": "object" + } + ], + "description": "Name change", + "type": "object" + }, + "NextPageToken": { + "description": "Use this token in your next API call to paginate through the dataset and retrieve the next page of results. A null token indicates there are no more data to fetch.\n", + "example": "MTAwMA==", + "type": [ + "string", + "null" + ] + }, + "NonTradeActivity": { + "properties": { + "activity_sub_type": { + "$ref": "#/components/schemas/ActivitySubType" + }, + "created_at": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "example": "2021-05-10T14:01:04.650275Z", + "format": "date-time", + "type": "string" + }, + "currency": { + "description": "Currency denomination of the activity. USD by default.", + "type": "string" + }, + "cusip": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "example": "037833100", + "type": "string" + }, + "date": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "example": "2021-05-21", + "format": "date", + "type": "string" + }, + "description": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "example": "Example description", + "type": "string" + }, + "group_id": { + "description": "ID used to link activities who share a sibling relationship", + "example": "13d96cf3-1cbe-4632-b2f2-86a9df5a3b9d", + "format": "uuid", + "type": "string" + }, + "net_amount": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "example": "1234", + "format": "decimal", + "type": "string" + }, + "per_share_amount": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "example": "0.38921", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "example": "0.38921", + "format": "decimal", + "type": "string" + }, + "status": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "enum": [ + "executed", + "correct", + "canceled" + ], + "example": "executed", + "type": "string" + }, + "symbol": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "example": "AAPL", + "type": "string" + }, + "transfer_id": { + "description": "The transfer ID of the associated deposit or withdrawal. Populated for `OCT` (On Chain Transactions) activities.", + "example": "bacddbc5-1a45-4a54-8f6d-c3f2f9d2e2a1", + "format": "uuid", + "type": "string" + } + }, + "title": "NonTradeActivity", + "type": "object" + }, + "NonTradeActivityEvent": { + "description": "Represents a non-trade activity SSE event", + "examples": [ + { + "account_id": "8e00606a-c9ac-409a-ba45-f55e8f77984a", + "at": "2024-11-26T15:25:17.803914Z", + "description": "", + "entry_type": "JNLC", + "event_ulid": "01JDMH7BKCCB4XY5F11HN63NZX", + "id": "afb78fa2-7e4c-4e0a-bca2-2e0d26a87f88", + "net_amount": 10, + "qty": 0, + "settle_date": "2024-11-26", + "status": "executed", + "symbol": "", + "system_date": "2024-11-26" + }, + { + "account_id": "11629972-5fd6-4e14-ad9e-0f0cabd2777f", + "at": "2024-11-12T01:15:53.132425Z", + "description": "TAF fee for proceed of 0.010052895 shares (1 trades) on 2024-11-11 by 613651765", + "entry_sub_type": "TAF", + "entry_type": "FEE", + "event_ulid": "01JCEZ1ZDCE44GFX6WZ75N4199", + "id": "d96cea8a-6a77-46cd-bb7b-df6d74442653", + "net_amount": -0.01, + "qty": 0, + "settle_date": "2024-11-12", + "status": "executed", + "symbol": "", + "system_date": "2024-11-11" + } + ], + "properties": { + "account_id": { + "description": "Account UUID", + "format": "uuid", + "type": "string" + }, + "at": { + "description": "Timestamp of when the event was emitted", + "format": "date-time", + "type": "string" + }, + "cusip": { + "description": "CUSIP the event is associated with, not present when no CUSIP is applicable", + "example": "037833100", + "type": "string" + }, + "description": { + "description": "Additional information about the event, empty string if not applicable", + "example": "Example description", + "type": "string" + }, + "entry_type": { + "description": "Type of entry for e.g JNLC, FEE, INT, DIVNRA etc", + "example": "JNLC", + "type": "string" + }, + "event_id": { + "description": "Monotonically increasing 64bit integer", + "type": "integer" + }, + "event_ulid": { + "description": "lexically sortable, monotonically increasing character array", + "format": "ulid", + "type": "string" + }, + "id": { + "description": "Record UUID", + "format": "uuid", + "type": "string" + }, + "net_amount": { + "description": "Net amount if applicable, 0 otherwise", + "example": 1, + "format": "decimal", + "type": "number" + }, + "per_share_amount": { + "description": "Per share amount if applicable", + "example": 0.3, + "format": "decimal", + "type": "number" + }, + "price": { + "description": "Price if applicable.", + "example": "0.38921", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "Quantity of the stock affected. 0 for cash events", + "format": "decimal", + "type": "number" + }, + "settle_date": { + "description": "Date of settlement if applicable", + "format": "date", + "type": "string" + }, + "status": { + "description": "Status of the event. `pending` is an internal/preprocessing status for journal-type NTAs and is only emitted when the subscriber opts in with `include_preprocessing=true`.\n", + "enum": [ + "executed", + "correct", + "canceled", + "pending" + ], + "example": "executed", + "type": "string" + }, + "symbol": { + "description": "Symbol the event is associated with, empty string when no symbol is applicable", + "example": "AAPL", + "type": "string" + }, + "system_date": { + "description": "Date of the event recorded in the system", + "format": "date", + "type": "string" + } + }, + "required": [ + "account_id", + "at", + "id", + "event_ulid", + "system_date", + "settle_date", + "net_amount", + "entry_type", + "description" + ], + "title": "NonTradeActivityEvent", + "type": "object" + }, + "OAuthTokenRequest": { + "description": "This model is used for both the Issue and Authorize OAuth token routes", + "example": { + "account_id": "0d18ae51-3c94-4511-b209-101e1666416b", + "client_id": "7a3c52a910e1dc2abbb14da2b6b8e711", + "client_secret": "bbb14da2b6b8e7117a3c52a910e1dc2a", + "redirect_uri": "http://localhost", + "scope": "general" + }, + "properties": { + "account_id": { + "description": "end-user account ID", + "format": "uuid", + "type": "string" + }, + "client_id": { + "description": "OAuth client ID", + "type": "string" + }, + "client_secret": { + "description": "OAuth client secret", + "type": "string" + }, + "redirect_uri": { + "description": "redirect URI for the OAuth flow", + "type": "string" + }, + "scope": { + "description": "scopes requested by the OAuth flow", + "type": "string" + } + }, + "required": [ + "client_id", + "client_secret", + "redirect_uri", + "scope", + "account_id" + ], + "title": "OAuthTokenRequest", + "type": "object" + }, + "OCTActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "symbol": { + "description": "The symbol of the asset involved with the on chain transaction", + "type": "string" + }, + "transfer_id": { + "description": "The transfer ID of the associated deposit or withdrawal", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "transfer_id", + "symbol" + ], + "type": "object" + } + ], + "description": "On chain transaction (blockchain deposit/withdrawal)", + "type": "object" + }, + "OPASNActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Option assignment", + "type": "object" + }, + "OPCSHActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Option cash deliverable for non-standard contracts", + "type": "object" + }, + "OPEXCActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Option exercise", + "type": "object" + }, + "OPEXPActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Option expiry", + "type": "object" + }, + "OPTRDActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Trading activity that is paired with the assignment/exercise", + "type": "object" + }, + "OathClientResponse": { + "example": { + "client_id": "7a3c52a910e1dc2abbb14da2b6b8e711", + "description": "Sample description", + "live_trading_approved": true, + "name": "TradingApp", + "privacy_policy": "", + "redirect_uri": [ + "http://localhost" + ], + "status": "ACTIVE", + "terms_of_use": "", + "url": "http://test.com" + }, + "examples": [ + { + "client_id": "7a3c52a910e1dc2abbb14da2b6b8e711", + "description": "Sample description", + "live_trading_approved": true, + "name": "TradingApp", + "privacy_policy": "", + "redirect_uri": [ + "http://localhost" + ], + "status": "ACTIVE", + "terms_of_use": "", + "url": "http://test.com" + } + ], + "properties": { + "client_id": { + "description": "OAuth client id", + "type": "string" + }, + "description": { + "type": "string" + }, + "live_trading_approved": { + "example": true, + "type": "boolean" + }, + "name": { + "description": "Broker name (your name)", + "type": "string" + }, + "privacy_policy": { + "description": "URL of Privacy Policy", + "type": "string" + }, + "redirect_uri": { + "items": { + "type": "string" + }, + "type": "array" + }, + "status": { + "description": "ACTIVE or DISABLED", + "enum": [ + "ACTIVE", + "DISABLED" + ], + "example": "ACTIVE", + "type": "string" + }, + "terms_of_use": { + "description": "URL of Terms of Use", + "type": "string" + }, + "url": { + "type": "string" + } + }, + "title": "OathClientResponse", + "type": "object" + }, + "OnfidoSDKOutcome": { + "description": "\"NOT_STARTED\"\tThe user has not started the SDK flow yet. outcome is set to this default value upon token generation\n\"USER_EXITED\"\tThe user exited the SDK flow\n\"SDK_ERROR\"\tAn error occurred in the SDK flow\n\"USER_COMPLETED\"\tThe user completed the SDK flow", + "title": "OnfidoSDKOutcome", + "type": "string" + }, + "OpcaCDIVActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonCDIVActivityV2" + } + ], + "description": "Options corporate action of cash dividend or return of capital", + "type": "object" + }, + "OpcaFSPLITActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSplitActivityV2" + }, + { + "properties": { + "due_bill_redemption_date": { + "description": "When due bills related to the split are redeemed", + "format": "date", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Options corporate action of forward-splits", + "type": "object" + }, + "OpcaMAActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonMAActivityV2" + } + ], + "description": "Options corporate action of Mergers & Acquisitions", + "type": "object" + }, + "OpcaNCActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonNCActivityV2" + } + ], + "description": "Options corporate action of name changes", + "type": "object" + }, + "OpcaRSPLITActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSplitActivityV2" + }, + { + "properties": { + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security after the split", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Options corporate action of reverse-splits", + "type": "object" + }, + "OpcaSDIVActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSDIVActivityV2" + } + ], + "description": "Options corporate action of stock dividend", + "type": "object" + }, + "OpcaSPINActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSpinoffActivityV2" + } + ], + "description": "Options corporate action of spin-offs", + "type": "object" + }, + "OpcaUSPLITActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSplitActivityV2" + }, + { + "properties": { + "alternate_cusip": { + "description": "CUSIP for the alternate security after the split", + "type": "string" + }, + "alternate_rate": { + "description": "Ratio of alternate shares received", + "type": "string" + }, + "alternate_symbol": { + "description": "Symbol for the alternate security after the split", + "type": "string" + }, + "effective_date": { + "description": "When the unit split becomes effective", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security after the unit split", + "type": "string" + }, + "old_symbol": { + "description": "The old symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "old_symbol", + "new_symbol", + "alternate_cusip", + "alternate_symbol", + "alternate_rate", + "effective_date" + ], + "type": "object" + } + ], + "description": "Options corporate action of unit-splits", + "type": "object" + }, + "OptionContract": { + "properties": { + "close_price": { + "description": "The close price of the option contract.", + "example": "148.38", + "type": "string" + }, + "close_price_date": { + "description": "The date of the close price data.", + "example": "2023-12-11", + "format": "date", + "type": "string" + }, + "deliverables": { + "description": "Represents the deliverables tied to the option contract. While standard contracts entail a single deliverable, non-standard ones can encompass multiple deliverables, each potentially customized with distinct parameters.\nThis array is included in the list contracts response only if the query parameter show_deliverables=true is provided.\n", + "items": { + "$ref": "#/components/schemas/OptionDeliverable" + }, + "type": "array" + }, + "expiration_date": { + "description": "The expiration date of the option contract.", + "example": "2025-06-20", + "format": "date", + "type": "string" + }, + "id": { + "description": "The unique identifier of the option contract.", + "example": "98359ef7-5124-49f3-85ea-5cf02df6defa", + "type": "string" + }, + "multiplier": { + "description": "The multiplier of the option contract is crucial for calculating both the trade premium and the extended strike price. In standard contracts, the multiplier is always set to 100.\nFor instance, if a contract is traded at $1.50 and the multiplier is 100, the total amount debited when buying the contract would be $150.00.\nSimilarly, when exercising a call contract, the total cost will be equal to the strike price times the multiplier.", + "example": "100", + "type": "string" + }, + "name": { + "description": "The name of the option contract.", + "example": "AAPL Jun 20 2025 100 Call", + "type": "string" + }, + "open_interest": { + "description": "The open interest of the option contract.", + "example": "237", + "type": "string" + }, + "open_interest_date": { + "description": "The date of the open interest data.", + "example": "2023-12-11", + "format": "date", + "type": "string" + }, + "ppind": { + "description": "The ppind (Penny Program Indicator) field indicates whether an option contract is eligible for penny price increments,\nwith `true` meaning it is part of the Penny Program and `false` meaning it is not.", + "example": true, + "type": "boolean" + }, + "root_symbol": { + "description": "The root symbol of the option contract.", + "example": "AAPL", + "type": "string" + }, + "size": { + "description": "Represents the number of underlying shares to be delivered in case the contract is exercised/assigned. For standard contracts, this is always 100.\nThis field should **not** be used as a multiplier, specially for non-standard contracts.", + "example": "100", + "type": "string" + }, + "status": { + "description": "The status of the option contract.", + "enum": [ + "active", + "inactive" + ], + "example": "active", + "type": "string" + }, + "strike_price": { + "description": "The strike price of the option contract.", + "example": "100", + "type": "string" + }, + "style": { + "description": "The style of the option contract.", + "enum": [ + "american", + "european" + ], + "example": "american", + "type": "string" + }, + "symbol": { + "description": "The symbol representing the option contract.", + "example": "AAPL250620C00100000", + "type": "string" + }, + "tradable": { + "description": "Indicates whether the option contract is tradable.", + "example": true, + "type": "boolean" + }, + "type": { + "description": "The type of the option contract.", + "enum": [ + "call", + "put" + ], + "example": "call", + "type": "string" + }, + "underlying_asset_id": { + "description": "The unique identifier of the underlying asset.", + "example": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "type": "string" + }, + "underlying_symbol": { + "description": "The underlying symbol of the option contract.", + "example": "AAPL", + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "name", + "status", + "tradable", + "expiration_date", + "underlying_symbol", + "underlying_asset_id", + "type", + "style", + "strike_price", + "multiplier", + "size", + "ppind" + ], + "type": "object" + }, + "OptionDeliverable": { + "properties": { + "allocation_percentage": { + "description": "Cost allocation percentage of the deliverable.\nThis is used to determine the cost basis of the equity shares received from the exercise, specially for non-standard contracts with multiple deliverables.\n", + "example": "100", + "type": "string" + }, + "amount": { + "description": "The deliverable amount. For cash deliverables, this is the cash amount.\nFor standard contract, this is always 100.\nThis field can be null in case the deliverable settlement is delayed and the amount is yet to be determined.\n", + "example": "100", + "type": "string" + }, + "asset_id": { + "description": "Unique identifier of the deliverable asset. For standard contracts, this is equivalent to underlying_asset_id of the contracts.\nThis field is not returned for cash deliverables.\n", + "example": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "type": "string" + }, + "delayed_settlement": { + "description": "If true, the settlement of the deliverable will be delayed.\nFor instance, in the event of a contract with a delayed deliverable being exercised, both the availability of the deliverable and its settlement may be postponed beyond the typical timeframe.\n", + "example": false, + "type": "boolean" + }, + "settlement_method": { + "description": "Indicates the settlement method that will be used:\n- **BTOB**: Broker to Broker\n- **CADF**: Cash Difference\n- **CAFX**: Cash Fixed\n- **CCC**: Correspondent Clearing Corp\n", + "enum": [ + "BTOB", + "CADF", + "CAFX", + "CCC" + ], + "example": "CCC", + "type": "string" + }, + "settlement_type": { + "description": "Indicates when the deliverable will be settled if the contract is exercised/assigned.\n", + "enum": [ + "T+0", + "T+1", + "T+2", + "T+3", + "T+4", + "T+5" + ], + "example": "T+2", + "type": "string" + }, + "symbol": { + "description": "Symbol of the deliverable. For standard contracts, this is equivalent to the underlying symbol of the contract.\n", + "example": "AAPL", + "type": "string" + }, + "type": { + "description": "Type of deliverable, indicating whether it's cash or equity. For standard contracts, it is always \"equity\".\n", + "enum": [ + "cash", + "equity" + ], + "example": "equity", + "type": "string" + } + }, + "required": [ + "type", + "symbol", + "amount", + "allocation_percentage", + "settlement_type", + "settlement_method", + "delayed_settlement" + ], + "type": "object" + }, + "OptionsApprovalEvent": { + "description": "This property is included when the account's approved options level changes.\n", + "properties": { + "approved_level_from": { + "description": "The approved options level before the change", + "type": "integer" + }, + "approved_level_to": { + "description": "The approved options level after the change", + "type": "integer" + } + }, + "type": "object" + }, + "OptionsApprovalRequest": { + "properties": { + "level": { + "description": "The desired option trading level. 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.", + "enum": [ + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + } + }, + "type": "object" + }, + "OptionsApprovalResponse": { + "properties": { + "account_id": { + "description": "The account ID.", + "example": "c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4", + "format": "uuid", + "type": "string" + }, + "approved_level": { + "description": "The option trading level approved for this request. Only present once the request has completed processiing.\nNote that a subsequent request may be approved for a different level.\n0=Disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.\"\n", + "enum": [ + 0, + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + }, + "created_at": { + "description": "The time when the request was submitted.", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "The request ID.", + "example": "88b5f678-fef5-447b-af15-f21e367e6d8c", + "format": "uuid", + "type": "string" + }, + "requested_level": { + "description": "The request option trading level. 0=Disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.", + "enum": [ + 0, + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + }, + "requester": { + "description": "The requester of the options approval request.", + "enum": [ + "CORRESPONDENT", + "ALPACA_ADMIN" + ], + "example": "CORRESPONDENT", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/OptionsApprovalStatus" + }, + "updated_at": { + "description": "The time when the request was last updated.", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + }, + "type": "object" + }, + "OptionsApprovalStatus": { + "description": "The request status.\n- PENDING: The request is under review.\n- APPROVED: The request has been successfully approved, the account is now able to trade options.\n- LOWER_LEVEL_APPROVED: The request has been approved for a level lower than the requested one.\n- REJECTED: The request has been rejected.\n", + "enum": [ + "PENDING", + "APPROVED", + "LOWER_LEVEL_APPROVED", + "REJECTED" + ], + "example": "PENDING", + "type": "string" + }, + "OptionsApprovalsList": { + "description": "A list of options approval requests.", + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/NextPageToken" + }, + "options_approvals": { + "description": "An array of options approval requests.", + "items": { + "$ref": "#/components/schemas/OptionsApprovalResponse" + }, + "type": "array" + } + }, + "type": "object" + }, + "Order": { + "properties": { + "asset_class": { + "$ref": "#/components/schemas/AssetClass" + }, + "asset_id": { + "description": "The asset ID (For options this represents the option contract ID)", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": "string" + }, + "cancel_requested_at": { + "description": "Time when cancellation or bust was requested (if applicable)", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "canceled_at": { + "description": "Can be null", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "client_order_id": { + "description": "Client unique order ID", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "maxLength": 128, + "type": "string" + }, + "commission": { + "description": "The dollar value commission for this order.", + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "commission_bps": { + "deprecated": true, + "description": "**deprecated**: Please use the commission_type = bps instead and set the desired bps value in the `commission` field.\nThe percent commission you want to charge the end user on the order (expressed in bps). Alpaca will convert the order to a notional amount for purposes of calculating commission.\n", + "example": "10", + "format": "decimal", + "type": "string" + }, + "commission_type": { + "$ref": "#/components/schemas/CommissionType" + }, + "created_at": { + "description": "Time when order was entered", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "expired_at": { + "description": "Can be null", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "extended_hours": { + "example": true, + "type": "boolean" + }, + "failed_at": { + "description": "Can be null", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "filled_at": { + "description": "Time the order was filled. Can be null if not filled", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "filled_avg_price": { + "description": "Filled average price. Can be 0 until order is processed in case order is passed outside of market hours", + "example": "4.2", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "filled_qty": { + "description": "Filled quantity", + "example": "4.2", + "format": "decimal", + "type": "string" + }, + "hwm": { + "description": "The highest (lowest) market price seen since the trailing stop order was submitted.", + "example": "3.14", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "id": { + "description": "Order ID generated by Alpaca", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": "string" + }, + "legs": { + "description": "When querying non-simple order_class orders in a nested style, an array of Order entities associated with this order. Otherwise, null.", + "items": { + "$ref": "#/components/schemas/OrderLeg" + }, + "type": [ + "array", + "null" + ] + }, + "limit_price": { + "description": "Limit price", + "example": "3.14", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "notional": { + "description": "Ordered notional amount. If entered, qty will be null. Can take up to 2 decimal points.", + "example": "4.2", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "order_class": { + "$ref": "#/components/schemas/OrderClass" + }, + "order_type": { + "$ref": "#/components/schemas/OrderType" + }, + "position_intent": { + "$ref": "#/components/schemas/PositionIntent" + }, + "qty": { + "description": "Ordered quantity. If entered, notional will be null. Can take up to 2 decimal points.", + "example": "4.2", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "replaced_at": { + "description": "Can be null", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "replaced_by": { + "description": "The order ID that this order was replaced by. (Can be null)", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "replaces": { + "description": "The order ID that this order replaces. (Can be null)", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "status": { + "$ref": "#/components/schemas/OrderStatus" + }, + "stop_price": { + "description": "Stop price", + "example": "3.14", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "submitted_at": { + "description": "Time the order was submitted for execution or, if not yet submitted the created_at time. Because orders are submitted for execution asynchronous to database updates, at times this may be after the created_at time.", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "swap_fee_bps": { + "description": "Fee in basis points on top swap rate charged by the correspondent on every order", + "type": "string" + }, + "swap_rate": { + "description": "Swap rate is the exchange rate (without mark-up) used to convert the price into local currency or crypto asset", + "type": "string" + }, + "symbol": { + "description": "The asset symbol", + "example": "AALP", + "type": "string" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "trail_percent": { + "description": "The percent value away from the high water mark for trailing stop orders.", + "example": "5.0", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "trail_price": { + "description": "The dollar value away from the high water mark for trailing stop orders.", + "example": "3.14", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "type": { + "$ref": "#/components/schemas/OrderType" + }, + "updated_at": { + "description": "Time of most recent change to the order", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "usd": { + "description": "Nested object to encompass the USD equivalent fields for the local currency fields", + "type": "object" + } + }, + "required": [ + "id", + "symbol" + ], + "type": "object" + }, + "OrderClass": { + "description": "The order classes supported by Alpaca vary based on the order's security type. The following provides a comprehensive breakdown of the supported order classes for each category:\n - Equity trading: simple (or \"\"), oco, oto, bracket.\n - Options trading:\n - simple (or \"\")\n - mleg (required for multi-leg complex option strategies)\n - Crypto trading: simple (or \"\").", + "enum": [ + "simple", + "bracket", + "oco", + "oto", + "mleg", + "" + ], + "example": "", + "type": "string" + }, + "OrderClosedResponse": { + "description": "Represents the result of asking the api to cancel an Order.\n", + "properties": { + "body": { + "$ref": "#/components/schemas/Order" + }, + "id": { + "description": "UUID of the order that was canceled", + "format": "uuid", + "type": "string" + }, + "status": { + "description": "Http status code for the attempt to close this Order", + "type": "integer" + } + }, + "required": [ + "id", + "status" + ], + "title": "OrderClosedResponse", + "type": "object" + }, + "OrderLeg": { + "properties": { + "asset_class": { + "$ref": "#/components/schemas/AssetClass" + }, + "asset_id": { + "description": "The asset ID (For options this represents the option contract ID)", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": "string" + }, + "canceled_at": { + "description": "Can be null", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "client_order_id": { + "description": "Client unique order ID", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "maxLength": 128, + "type": "string" + }, + "commission": { + "description": "The dollar value commission you want to charge the end user.", + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "commission_bps": { + "deprecated": true, + "description": "**deprecated**: Please use the commission_type = bps instead and set the desired bps value in the `commission` field.\nThe percent commission you want to charge the end user on the order (expressed in bps). Alpaca will convert the order to a notional amount for purposes of calculating commission.\n", + "example": "10", + "format": "decimal", + "type": "string" + }, + "commission_type": { + "$ref": "#/components/schemas/CommissionType" + }, + "created_at": { + "description": "Time when order was entered", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "expired_at": { + "description": "Can be null", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "extended_hours": { + "example": true, + "type": "boolean" + }, + "failed_at": { + "description": "Can be null", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "filled_at": { + "description": "Time the order was filled. Can be null if not filled", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "filled_avg_price": { + "description": "Filled average price. Can be 0 until order is processed in case order is passed outside of market hours", + "example": "4.2", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "filled_qty": { + "description": "Filled quantity", + "example": "4.2", + "format": "decimal", + "type": "string" + }, + "hwm": { + "description": "The highest (lowest) market price seen since the trailing stop order was submitted.", + "example": "3.14", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "id": { + "description": "Order ID generated by Alpaca", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": "string" + }, + "legs": { + "description": "Always null for an order leg; legs are not nested beyond one level. An empty array is accepted for generated-client compatibility.", + "example": null, + "items": { + "type": "object" + }, + "maxItems": 0, + "type": [ + "array", + "null" + ] + }, + "limit_price": { + "description": "Limit price", + "example": "3.14", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "notional": { + "description": "Ordered notional amount. If entered, qty will be null. Can take up to 2 decimal points.", + "example": "4.2", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "order_class": { + "$ref": "#/components/schemas/OrderClass" + }, + "order_type": { + "$ref": "#/components/schemas/OrderType" + }, + "position_intent": { + "$ref": "#/components/schemas/PositionIntent" + }, + "qty": { + "description": "Ordered quantity. If entered, notional will be null. Can take up to 2 decimal points.", + "example": "4.2", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "replaced_at": { + "description": "Can be null", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "replaced_by": { + "description": "The order ID that this order was replaced by. (Can be null)", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "replaces": { + "description": "The order ID that this order replaces. (Can be null)", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "status": { + "$ref": "#/components/schemas/OrderStatus" + }, + "stop_price": { + "description": "Stop price", + "example": "3.14", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "submitted_at": { + "description": "Time the order was submitted for execution or, if not yet submitted the created_at time. Because orders are submitted for execution asynchronous to database updates, at times this may be after the created_at time.", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "swap_fee_bps": { + "description": "Fee in basis points on top swap rate charged by the correspondent on every order", + "type": "string" + }, + "swap_rate": { + "description": "Swap rate is the exchange rate (without mark-up) used to convert the price into local currency or crypto asset", + "type": "string" + }, + "symbol": { + "description": "The asset symbol", + "example": "AALP", + "type": "string" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "trail_percent": { + "description": "The percent value away from the high water mark for trailing stop orders.", + "example": "5.0", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "trail_price": { + "description": "The dollar value away from the high water mark for trailing stop orders.", + "example": "3.14", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "type": { + "$ref": "#/components/schemas/OrderType" + }, + "updated_at": { + "description": "Time of most recent change to the order", + "example": "2021-03-16T18:38:01.942282Z", + "format": "date-time", + "type": "string" + }, + "usd": { + "description": "Nested object to encompass the USD equivalent fields for the local currency fields", + "type": "object" + } + }, + "required": [ + "id", + "symbol" + ], + "type": "object" + }, + "OrderSide": { + "description": "Represents what side of the transaction an order was on. Required for all order classes except for `mleg`.", + "enum": [ + "buy", + "sell", + "buy_minus", + "sell_plus", + "sell_short", + "sell_short_exempt", + "undisclosed", + "cross", + "cross_short" + ], + "example": "buy", + "type": "string" + }, + "OrderStatus": { + "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", + "type": "string" + }, + "OrderType": { + "description": "The order types supported by Alpaca vary based on the order's security type. The following provides a comprehensive breakdown of the supported order types for each category:\n - Equity trading: market, limit, stop, stop_limit, trailing_stop.\n - Options trading: market, limit, stop, stop_limit.\n - Options Multileg trading: market, limit.\n - Crypto trading: market, limit, stop_limit.", + "enum": [ + "market", + "limit", + "stop", + "stop_limit", + "trailing_stop" + ], + "example": "market", + "title": "OrderType", + "type": "string" + }, + "OvercontributedIRAAccount": { + "properties": { + "account_id": { + "description": "The account id", + "type": "string" + }, + "tax_year": { + "description": "The tax year", + "type": "number" + }, + "total_contribution_amount": { + "description": "The total conntribution amount", + "type": "number" + } + }, + "type": "object" + }, + "OwnerDocument": { + "description": "A document associated with an owner of the account", + "example": { + "created_at": "2019-09-30T23:55:31.185998Z", + "document_sub_type": "passport", + "document_type": "identity_verification", + "id": "0d18ae51-3c94-4511-b209-101e1666416b", + "mime_type": "image/jpeg" + }, + "properties": { + "created_at": { + "format": "date-time", + "type": "string" + }, + "document_sub_type": { + "description": "The sub-type of the document. This is a free-form property.", + "type": "string" + }, + "document_type": { + "$ref": "#/components/schemas/OwnerDocumentType" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "mime_type": { + "type": "string" + } + }, + "required": [ + "id", + "document_type", + "created_at" + ], + "type": "object" + }, + "OwnerDocumentType": { + "description": "The type of the owner document", + "enum": [ + "account_approval_letter", + "address_verification", + "cip_result", + "company_formation", + "date_of_birth_verification", + "entity_operating_document", + "entity_registration", + "hio_declaration_form", + "identity_verification", + "limited_trading_authorization", + "pep_declaration_form", + "tax_id_verification", + "w8ben", + "w9" + ], + "example": "identity_verification", + "type": "string" + }, + "OwnerDocumentUploadRequest": { + "description": "The request to upload a document for an owner of the account", + "example": { + "content": "/9j/Cg==", + "document_sub_type": "passport", + "document_type": "identity_verification", + "mime_type": "image/jpeg" + }, + "examples": [ + { + "content": "/9j/Cg==", + "document_sub_type": "passport", + "document_type": "identity_verification", + "mime_type": "image/jpeg" + } + ], + "properties": { + "content": { + "contentEncoding": "base64", + "description": "The base64 string encoding of the document contents. This property is required unless content_data is provided.", + "example": "/9j/Cg==", + "type": "string" + }, + "content_data": { + "$ref": "#/components/schemas/W8benDocument" + }, + "document_sub_type": { + "description": "The specific type of document, e.g. passport. This is a free-form property.", + "example": "passport", + "type": "string" + }, + "document_type": { + "$ref": "#/components/schemas/OwnerDocumentType" + }, + "mime_type": { + "description": "This field is required if content is specified. ENUM: application/pdf, image/png, or image/jpeg. If document_type is w8ben then application/json is also accepted", + "example": "image/jpeg", + "type": "string" + } + }, + "required": [ + "document_type", + "content" + ], + "title": "OwnerDocumentUploadRequest", + "type": "object" + }, + "Portfolio": { + "properties": { + "cooldown_days": { + "description": "Count of calendar days following a rebalance before a subscription is eligible to trigger another rebalance", + "type": "integer" + }, + "created_at": { + "description": "Portfolio creation timestamp", + "type": "string" + }, + "description": { + "description": "Text to describe portfolio", + "type": "string" + }, + "id": { + "description": "Portfolio ID", + "type": "string" + }, + "name": { + "description": "Name of portfolio", + "type": "string" + }, + "rebalancing_conditions": { + "description": "Rebalancing conditions for portfolio", + "type": "string" + }, + "status": { + "description": "Current status of portfolio", + "enum": [ + "active", + "inactive", + "needs_adjustment" + ], + "type": "string" + }, + "updated_at": { + "description": "Portfolio updated timestamp", + "type": "string" + }, + "weights": { + "description": "Weight configuration to portfolio. Sum of \"percent\" values in the weights array must be 100.00", + "items": { + "$ref": "#/components/schemas/PortfolioWeights" + }, + "type": "array" + } + }, + "required": [ + "cooldown_days" + ], + "title": "Portfolio", + "type": "object" + }, + "PortfolioHistory": { + "description": "Timeseries data for equity and profit loss information of the account.", + "properties": { + "base_value": { + "description": "basis in dollar of the profit loss calculation", + "type": [ + "number", + "null" + ] + }, + "base_value_asof": { + "description": "If included, then it indicates that the base_value is the account's closing\nequity value at this trading date.\n\nIf not specified, then the baseline calculation is done against the earliest returned data item. This could happen for\naccounts without prior closing balances (e.g. new account) or for queries with 1D timeframes, where the first data point\nis used as a reference point.\n", + "example": "2023-10-20", + "format": "date", + "type": "string" + }, + "cashflow": { + "additionalProperties": { + "items": { + "type": "number" + }, + "type": "array" + }, + "description": "accumulated value in dollar amount as of the end of each time window", + "type": "object" + }, + "equity": { + "description": "equity value of the account in dollar amount as of the end of each time window", + "items": { + "type": [ + "number", + "null" + ] + }, + "type": "array" + }, + "profit_loss": { + "description": "profit/loss in dollar from the base value", + "items": { + "type": [ + "number", + "null" + ] + }, + "type": "array" + }, + "profit_loss_pct": { + "description": "profit/loss in percentage from the base value", + "example": [ + 0.001, + 0.002 + ], + "items": { + "type": [ + "number", + "null" + ] + }, + "type": "array" + }, + "timeframe": { + "description": "time window size of each data element", + "example": "15Min", + "type": "string" + }, + "timestamp": { + "description": "Time of each data element, left-labeled (the beginning of time window).\n\nThe values returned are in [UNIX epoch format](https://en.wikipedia.org/wiki/Unix_time).\n", + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "required": [ + "timestamp", + "equity", + "profit_loss", + "profit_loss_pct", + "base_value", + "timeframe" + ], + "title": "PortfolioHistory", + "type": "object" + }, + "PortfolioRun": { + "properties": { + "account_id": { + "description": "Account ID for given run", + "type": "string" + }, + "canceled_at": { + "description": "RFC3339 format", + "type": "string" + }, + "completed_at": { + "description": "RFC3339 format", + "type": "string" + }, + "failed_orders": { + "description": "Array of failed orders for this run", + "items": { + "$ref": "#/components/schemas/Order" + }, + "type": "array" + }, + "id": { + "description": "Run ID", + "type": "string" + }, + "initiated_from": { + "description": "system or api", + "enum": [ + "system", + "api" + ], + "type": "string" + }, + "orders": { + "description": "Array of executed orders for this run", + "items": { + "$ref": "#/components/schemas/Order" + }, + "type": "array" + }, + "portfolio_id": { + "description": "Portfolio ID for given run", + "type": "string" + }, + "reason": { + "description": "Explainer text in case of failed runs", + "type": "string" + }, + "skipped_orders": { + "description": "Array of skipped order for this run", + "items": { + "$ref": "#/components/schemas/SkippedOrder" + }, + "type": "array" + }, + "status": { + "$ref": "#/components/schemas/PortfolioRunStatus" + }, + "type": { + "description": "full_rebalance or invest_cash", + "enum": [ + "full_rebalance", + "invest_cash" + ], + "type": "string" + }, + "updated_at": { + "description": "RFC3339 format", + "type": "string" + }, + "weights": { + "description": "Considered weighting for this run", + "items": { + "$ref": "#/components/schemas/PortfolioWeights" + }, + "type": "array" + } + }, + "title": "PortfolioRun", + "type": "object" + }, + "PortfolioRunStatus": { + "description": "| Status | Final | Represented State | Notes |\n|:------------------:|:-----:|:--------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------:|\n| QUEUED | No | The run has been queued, waiting for our system to process it. | Runs only executed when the US market is open and there's at least 15 minutes before the market closes. |\n| IN_PROGRESS | No | Portfolio adjustment is in progress. | |\n| CANCELED | Yes | Portfolio run canceled, before being picked up by Alpaca's background processing | |\n| CANCELED_MID_RUN | Yes | Portfolio run canceled while executing. | The portfolio's state is in between the pre-run and post-run state, manual remediation or job re-run is recommended. |\n| ERROR | Yes | There was an error while rebalancing the portfolio. | The portfolio's state is in between the pre-run and post-run state, manual remediation or job re-run is recommended. |\n| TIMEOUT | Yes | A timeout occurred while rebalancing the portfolio. | The portfolio's state is in between the pre-run and post-run state, manual remediation or job re-run is recommended. |\n| COMPLETED_ADJUSTED | Yes | The portfolio has been adjusted | The adjustments have been prepared, but the run details haven't yet updated with the list of resulting orders |\n| COMPLETED_SUCCESS | Yes | The portfolio has been adjusted, run status updated | |", + "enum": [ + "QUEUED", + "IN_PROGRESS", + "CANCELED", + "CANCELED_MID_RUN", + "ERROR", + "TIMEOUT", + "COMPLETED_ADJUSTED", + "COMPLETED_SUCCESS" + ], + "title": "PortfolioRunStatus", + "type": "string" + }, + "PortfolioSubscription": { + "properties": { + "account_id": { + "description": "Account ID subscribing to portfolio", + "type": "string" + }, + "created_at": { + "description": "Subscription creation timestamp", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "Subscription ID", + "type": "string" + }, + "last_rebalanced_at": { + "description": "Last rebalancing event for this subscription. Can be null.", + "type": "string" + }, + "portfolio_id": { + "description": "Portfolio ID for subscription", + "type": "string" + } + }, + "title": "PortfolioSubscription", + "type": "object" + }, + "PortfolioWeightRequest": { + "oneOf": [ + { + "properties": { + "type": { + "enum": [ + "cash" + ] + } + } + }, + { + "properties": { + "symbol": { + "type": "string" + }, + "type": { + "enum": [ + "asset" + ] + } + }, + "required": [ + "symbol" + ] + } + ], + "properties": { + "percent": { + "description": "Percentage allocated to this weight. Values must be greater than zero, and all supplied weights must total exactly 100.", + "type": [ + "string", + "number" + ] + }, + "symbol": { + "description": "Asset symbol. Required and non-null when `type` is `asset`.", + "type": [ + "string", + "null" + ] + }, + "type": { + "description": "Type of weight entry in a portfolio.", + "enum": [ + "cash", + "asset" + ], + "type": "string" + } + }, + "required": [ + "type", + "percent" + ], + "title": "PortfolioWeightRequest", + "type": "object" + }, + "PortfolioWeights": { + "properties": { + "percent": { + "description": "Percentage allocated to this weight as a decimal string.", + "type": "string" + }, + "symbol": { + "description": "Asset symbol. `null` for cash weights. Always present.", + "type": [ + "string", + "null" + ] + }, + "type": { + "description": "Type of weight entry in a portfolio.", + "enum": [ + "cash", + "asset" + ], + "type": "string" + } + }, + "required": [ + "type", + "symbol", + "percent" + ], + "title": "PortfolioWeights", + "type": "object" + }, + "Position": { + "examples": [ + { + "asset_class": "us_equity", + "asset_id": "93f58d0b-6c53-432d-b8ce-2bad264dbd94", + "asset_marginable": false, + "avg_entry_price": "172.08", + "change_today": "0.0189483657034581", + "cost_basis": "688.32", + "current_price": "172.08", + "exchange": "NASDAQ", + "lastday_price": "168.88", + "market_value": "688.32", + "qty": "4", + "qty_available": "4", + "side": "long", + "symbol": "AAPL", + "unrealized_intraday_pl": "0", + "unrealized_intraday_plpc": "0", + "unrealized_pl": "0", + "unrealized_plpc": "0" + } + ], + "properties": { + "asset_class": { + "$ref": "#/components/schemas/AssetClass" + }, + "asset_id": { + "description": "Asset ID (For options this represents the option contract ID)", + "example": "904837e3-3b76-47ec-b432-046db621571b", + "format": "uuid", + "type": "string" + }, + "asset_marginable": { + "description": "Indicates if this asset is marginable", + "type": "boolean" + }, + "avg_entry_price": { + "description": "Average entry price of the position", + "example": "100.0", + "type": "string" + }, + "avg_entry_swap_rate": { + "description": "The average swap rate of the position. This is only returned for LCT accounts.", + "example": "1.40", + "format": "decimal", + "type": "string" + }, + "change_today": { + "description": "Percent change from last day price (by a factor of 1)", + "example": "0.0084", + "format": "decimal", + "type": "string" + }, + "cost_basis": { + "description": "Total cost basis", + "example": "500.0", + "format": "decimal", + "type": "string" + }, + "current_price": { + "description": "Current asset price per share", + "example": "120.0", + "format": "decimal", + "type": "string" + }, + "exchange": { + "description": "Exchange name of the asset", + "example": "NASDAQ", + "type": "string" + }, + "lastday_price": { + "description": "Last day's asset price per share based on the closing value of the last trading day", + "example": "119.0", + "format": "decimal", + "type": "string" + }, + "market_value": { + "description": "Total market value of the position", + "example": "600.0", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "The number of shares", + "example": "5", + "type": "string" + }, + "qty_available": { + "description": "Total number of shares available minus open orders / locked for options covered call", + "example": "5", + "type": "string" + }, + "side": { + "enum": [ + "long", + "short" + ], + "example": "long", + "type": "string" + }, + "swap_rate": { + "description": "The latest swap rate. This is only returned for LCT accounts.", + "example": "1.50", + "format": "decimal", + "type": "string" + }, + "symbol": { + "description": "Asset symbol", + "example": "AAPL", + "type": "string" + }, + "unrealized_intraday_pl": { + "description": "Unrealized profit/loss for the day", + "example": "10.0", + "format": "decimal", + "type": "string" + }, + "unrealized_intraday_plpc": { + "description": "Unrealized interday profit/loss percent (by a factor of 1)", + "example": "0.0084", + "format": "decimal", + "type": "string" + }, + "unrealized_pl": { + "description": "Unrealized profit/loss", + "example": "100.0", + "format": "decimal", + "type": "string" + }, + "unrealized_plpc": { + "description": "Unrealized profit/loss percent (by a factor of 1)", + "example": "0.20", + "format": "decimal", + "type": "string" + }, + "usd": { + "$ref": "#/components/schemas/USDPosition" + } + }, + "required": [ + "asset_id", + "symbol", + "exchange", + "asset_class", + "avg_entry_price", + "qty", + "qty_available", + "side", + "market_value", + "cost_basis", + "unrealized_pl", + "unrealized_plpc", + "unrealized_intraday_pl", + "unrealized_intraday_plpc", + "current_price", + "lastday_price", + "change_today" + ], + "type": "object" + }, + "PositionClosedResponse": { + "description": "Represents the result of asking the api to close a position.\n\n`body` is the Order used to close out the position.", + "examples": [ + { + "body": { + "asset_class": "us_equity", + "asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "canceled_at": null, + "client_order_id": "52f8574c-96d5-49b6-94c1-2570a268434e", + "commision": "1.0", + "created_at": "2022-02-04T16:53:29.53427917Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "f7f25e89-939a-4587-aaf6-414a6b3c341d", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "", + "order_type": "market", + "qty": "2", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "sell", + "status": "accepted", + "stop_price": null, + "submitted_at": "2022-02-04T16:53:29.533738219Z", + "symbol": "AAPL", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "market", + "updated_at": "2022-02-04T16:53:29.53427917Z" + }, + "status": 200, + "symbol": "AAPL" + } + ], + "properties": { + "body": { + "$ref": "#/components/schemas/Order" + }, + "status": { + "description": "Http status code for the attempt to close this position", + "type": "integer" + }, + "symbol": { + "description": "Symbol name of the asset", + "type": "string" + } + }, + "required": [ + "symbol", + "status" + ], + "title": "PositionClosedResponse", + "type": "object" + }, + "PositionIntent": { + "description": "Represents the desired position strategy.", + "enum": [ + "buy_to_open", + "buy_to_close", + "sell_to_open", + "sell_to_close" + ], + "example": "buy_to_open", + "title": "PositionIntent", + "type": "string" + }, + "REOActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonREOActivityV2" + } + ], + "description": "Reorganization (REO)", + "type": "object" + }, + "RebalancingConditions": { + "properties": { + "day": { + "description": "Used to specify the rebalancing day for conditions of type = calendar. Only permitted and required for type = calendar. In scenarios when the specified day aligns to a non-trading day, the rebalance will be triggered on the preceding trading day. For type= annually, the value must be passed in MM-DD format. If 02-29 is specified and the current year is not a leap year, the rebalance will occur on the trading day preceding 2/29. For type= quarterly and monthly the value must be an integer between 1 and 31 inclusive. This represents the day of month. For quarterly, rebalancing will trigger on this day in January, March, June, and December. If the specified day is non-existent for the month then the rebalancing will trigger on the preceding trading day. For type = weekly, permitted values are Monday, Tuesday, Wednesday, Thursday, Friday.", + "type": "string" + }, + "percent": { + "description": "Must be a positive value, up to two decimal places. Only permitted and required for type = drift_band. This is the max allowable drift percent from any target weight (+/-)", + "type": "string" + }, + "sub_type": { + "description": "For type = drift_band: absolute or relative. For type = calendar: weekly,monthly, quarterly or annually. For type = on_portfolio_update: there is no subtype", + "type": "string" + }, + "type": { + "description": "Possible values of drift_band, calendar or on_portfolio_update", + "type": "string" + } + }, + "title": "RebalancingConditions", + "type": "object" + }, + "ReportsResponse": { + "properties": { + "account_no": { + "type": "string" + }, + "deadline": { + "format": "date", + "type": "string" + }, + "instant_funding_transfers": { + "items": { + "$ref": "#/components/schemas/InstantFunding" + }, + "type": "array" + }, + "system_date": { + "format": "date", + "type": "string" + }, + "total_amount_owed": { + "format": "decimal", + "type": "string" + }, + "total_interest_penalty": { + "format": "decimal", + "type": "string" + } + }, + "required": [ + "system_date", + "account_no", + "total_amount_owed", + "total_interest_penalty", + "deadline" + ], + "type": "object" + }, + "RestrictToLiquidationReasons": { + "description": "Reasons why the liquidation only flag was set", + "properties": { + "ach_return": { + "description": "Set when an incoming ACH transfer gets rejected", + "type": "boolean" + }, + "position_to_equity_ratio": { + "description": "Set when the position to equity ration exceeds the maximum limit", + "type": "boolean" + }, + "unspecified": { + "description": "Default value for unknown reason", + "type": "boolean" + } + }, + "title": "RestrictToLiquidationReasons", + "type": "object" + }, + "ReverseBatchJournalRequest": { + "examples": [ + { + "entries": [ + { + "amount": "10", + "from_account": "8e00606a-c9ac-409a-ba45-f55e8f77984a" + }, + { + "amount": "100", + "from_account": "b9b19618-22dd-4e80-8432-fc9e1ba0b27d" + }, + { + "amount": "100", + "from_account": "c96a5e16-7fca-425a-b67b-0814d064bfc0" + } + ], + "entry_type": "JNLC", + "to_account": "8f8c8cee-2591-4f83-be12-82c659b5e748" + } + ], + "properties": { + "entries": { + "items": { + "properties": { + "amount": { + "description": "Journal amount in USD", + "type": "string" + }, + "description": { + "description": "Journal description, gets returned in the response", + "type": "string" + }, + "from_account": { + "description": "The ID of the from_account that you want to journal from", + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "entry_type": { + "description": "Only supports `JNLC` for now", + "enum": [ + "JNLC" + ], + "type": "string" + }, + "to_account": { + "description": "The destination of funds. Most likely is your Sweep Firm Account", + "type": "string" + } + }, + "type": "object" + }, + "ReverseSplitActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonSplitStockActivityV2" + }, + { + "properties": { + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security after the split", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Reverse stock split", + "type": "object" + }, + "RightsDistributionActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "expiration_date": { + "description": "The expiration date for the rights distribution", + "format": "date", + "type": "string" + }, + "new_cusip": { + "description": "The new CUSIP", + "type": "string" + }, + "new_qty": { + "description": "The new quantity", + "type": "string" + }, + "new_symbol": { + "description": "The new symbol", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "The rate for the rights distribution", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "source_cusip": { + "description": "The source CUSIP", + "type": "string" + }, + "source_qty": { + "description": "The source quantity", + "type": "string" + }, + "source_symbol": { + "description": "The source symbol", + "type": "string" + } + }, + "required": [ + "source_cusip", + "source_symbol", + "source_qty", + "new_cusip", + "new_symbol", + "new_qty", + "rate" + ], + "type": "object" + } + ], + "description": "Rights distribution", + "type": "object" + }, + "RightsSubscriptionElectionActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonVOFSubtypeActivityV2" + } + ], + "type": "object" + }, + "SDIVActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSDIVActivityV2" + }, + { + "properties": { + "entitled_qty": { + "description": "Quantity of shares entitled to receive the dividend", + "type": "string" + }, + "new_qty": { + "description": "The total number of shares after the dividend", + "type": "string" + }, + "paid_qty": { + "description": "The paid quantity", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "paid_qty", + "new_qty" + ], + "type": "object" + } + ], + "description": "Stock dividend", + "type": "object" + }, + "SearchVASPsResponse": { + "description": "Paginated VASP directory search results.", + "properties": { + "page": { + "example": 1, + "type": "integer" + }, + "pages": { + "example": 1, + "type": "integer" + }, + "total": { + "description": "Total count of matching records.", + "example": 1, + "type": "integer" + }, + "vasps": { + "example": [ + { + "id": "vasp-1", + "name": "Example Exchange" + } + ], + "items": { + "$ref": "#/components/schemas/VASP" + }, + "type": "array" + } + }, + "type": "object" + }, + "SettlementAccount": { + "properties": { + "account_number": { + "description": "The account number of the client account to settle\n", + "type": "string" + }, + "amount": { + "format": "decimal", + "type": "string" + }, + "transmitter_info": { + "$ref": "#/components/schemas/TransmitterInfo" + } + }, + "required": [ + "account_number", + "amount", + "transmitter_info" + ], + "type": "object" + }, + "SettlementResponse": { + "description": "A settlement response, either from creation or retrieval\n", + "properties": { + "additional_info": { + "type": "string" + }, + "asset_class": { + "$ref": "#/components/schemas/JITAssetClass" + }, + "completed_at": { + "format": "date-time", + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "currency": { + "description": "The currency of the settlement. Only applicable to JIT settlements.\n", + "type": "string" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "interest_amount": { + "description": "The total interest amount accrued on the transfers included in this settlement. Only applicable for instant funding settlements.\n", + "format": "decimal", + "type": "string" + }, + "reason": { + "description": "The reason for failure, if applicable\n", + "type": "string" + }, + "source_account_number": { + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/SettlementStatus" + }, + "total_amount": { + "format": "decimal", + "type": "string" + }, + "updated_at": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "total_amount", + "status", + "created_at", + "updated_at" + ], + "type": "object" + }, + "SettlementStatus": { + "description": "Values:\n * `PENDING`: Created and waiting to be processed\n * `AWAITING_ADDITIONAL_FUNDS`: Waiting for additional funds to be deposited\n * `COMPLETED`: All transactions are reconciled\n * `FAILED`: Attempt to process this settlement has failed. If this is observed\n additional remittance information may be required, or one of the transfers being settled\n accrued additional interest since the settlement was created.\n", + "enum": [ + "PENDING", + "AWAITING_ADDITIONAL_FUNDS", + "COMPLETED", + "FAILED" + ], + "type": "string" + }, + "SettlementTransfer": { + "properties": { + "instant_transfer_id": { + "format": "uuid", + "type": "string" + }, + "transmitter_info": { + "$ref": "#/components/schemas/TransmitterInfo" + } + }, + "required": [ + "instant_transfer_id", + "transmitter_info" + ], + "type": "object" + }, + "SettlementsResponse": { + "description": "Response to a successful settlements request\n", + "properties": { + "settlements": { + "items": { + "$ref": "#/components/schemas/SettlementResponse" + }, + "type": "array" + } + }, + "required": [ + "settlements" + ], + "type": "object" + }, + "SkippedOrder": { + "description": "Skipped orders model contains information for such orders that the rebalancing engine didn't send to our order system due to some validation issues.", + "properties": { + "currency": { + "description": "Currency of the order", + "type": "string" + }, + "notional": { + "description": "Notional value of the order", + "type": "string" + }, + "reason": { + "description": "Reason for the order being skipped", + "type": "string" + }, + "reason_details": { + "description": "Formatted error message with the cause of the skip", + "type": "string" + }, + "side": { + "description": "Side of the order (buy, sell, sell_short)", + "type": "string" + }, + "symbol": { + "description": "Symbol for which the adjustment was skipped", + "type": "string" + } + }, + "required": [ + "symbol", + "reason", + "reason_details" + ], + "title": "SkippedOrder", + "type": "object" + }, + "SortOrder": { + "enum": [ + "ASC", + "DESC" + ], + "type": "string" + }, + "SpinoffActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSpinoffActivityV2" + }, + { + "properties": { + "new_qty": { + "description": "The new quantity", + "type": "string" + }, + "source_qty": { + "description": "The source quantity", + "type": "string" + } + }, + "required": [ + "source_qty", + "new_qty" + ], + "type": "object" + } + ], + "description": "Spinoff", + "type": "object" + }, + "StatusFundingEvent": { + "description": "Represents a change in a Funding entity's status, sent over the events streaming api. Currently, the suppported entities are: bank relationships, bank wires, transfers and funding wallets.", + "examples": [ + { + "account_id": "8e00606a-c9ac-409a-ba45-f55e8f77984a", + "at": "2025-04-11T19:52:24.066998Z", + "correspondent": "LPCA", + "entity_id": "c4ed4206-697b-4859-ab71-b9de6649859d", + "entity_type": "BankRelationship", + "event_id": "01F7VQQ782DM57SJNWAYMD14J9", + "status_to": "QUEUED" + }, + { + "account_id": "8e00606a-c9ac-409a-ba45-f55e8f77984a", + "at": "2025-04-11T19:52:24.066998Z", + "correspondent": "LPCA", + "entity_id": "c4ed4206-697b-4859-ab71-b9de6649859d", + "entity_type": "BankRelationship", + "event_id": "01F7VQQ782DM57SJNWAYMD14J9", + "reason": "bank account owner name does not match brokerage account name", + "status_from": "QUEUED", + "status_to": "REJECTED" + } + ], + "properties": { + "account_id": { + "description": "Account UUID", + "format": "uuid", + "minLength": 1, + "type": "string" + }, + "at": { + "description": "Timestamp of when the transfer status changed", + "minLength": 1, + "type": "string" + }, + "correspondent": { + "description": "Correspondent's code", + "format": "ABCD", + "maxLength": 4, + "minLength": 1, + "type": "string" + }, + "entity_id": { + "description": "Entity's UUID", + "format": "uuid", + "minLength": 1, + "type": "string" + }, + "entity_type": { + "description": "Valid values are BankRelationship, WireBank, Transfer and FundingWallet.", + "format": "uuid", + "minLength": 1, + "type": "string" + }, + "event_id": { + "description": "lexically sortable, monotonically increasing character array", + "format": "ulid", + "minLength": 1, + "type": "string" + }, + "reason": { + "description": "Used when an a bank relationship is rejected, a wire bank is canceled, etc.", + "type": "string" + }, + "status_from": { + "description": "Valid values are based on entity type:\n- BankRelationship:\n - QUEUED\n - CANCEL_REQUESTED\n - CANCEL_SENT\n - CANCEL_FAILED\n - PENDING\n - SENT_TO_CLEARING\n - APPROVED\n - CANCELED\n - REJECTED\n- WireBank:\n - QUEUED\n - SENT_TO_CLEARING\n - APPROVED\n - CANCELED\n - REJECTED\n- Transfer:\n - QUEUED\n - APPROVAL_PENDING\n - CANCELED\n - EXPIRED\n - APPROVED\n - REJECTED\n - SENT_TO_CLEARING\n - COMPLETE\n - RETURNED\n- FundingWallet:\n - active\n - pending\n", + "type": "string" + }, + "status_to": { + "description": "Valid values are based on entity type:\n- BankRelationship:\n - QUEUED\n - CANCEL_REQUESTED\n - CANCEL_SENT\n - CANCEL_FAILED\n - PENDING\n - SENT_TO_CLEARING\n - APPROVED\n - CANCELED\n - REJECTED\n- WireBank:\n - QUEUED\n - SENT_TO_CLEARING\n - APPROVED\n - CANCELED\n - REJECTED\n- Transfer:\n - QUEUED\n - APPROVAL_PENDING\n - CANCELED\n - EXPIRED\n - APPROVED\n - REJECTED\n - SENT_TO_CLEARING\n - COMPLETE\n - RETURNED\n- FundingWallet:\n - active\n - pending\n", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "event_id", + "at", + "account_id", + "correspondent", + "entity_id", + "entity_type", + "status_to" + ], + "title": "StatusFundingEvent", + "type": "object" + }, + "StreetAddress": { + "example": "20 N San Mateo Dr", + "type": "string" + }, + "SystemEventV2": { + "description": "Represents that system event had occurred and sent over the events streaming api.\n", + "examples": [ + { + "at": "2026-01-05T10:28:23.163857Z", + "description": "End-of-day balances are now available.", + "event_id": "01F535Y1FVY8WZHE763HCNS8SZ", + "system_date": "2026-01-05", + "type": "eod_balances_ready" + } + ], + "properties": { + "at": { + "description": "Timestamp of the event", + "format": "date-time", + "type": "string" + }, + "description": { + "description": "The human readable description of the system event", + "type": "string" + }, + "event_id": { + "description": "lexically sortable, monotonically increasing character array", + "format": "ulid", + "type": "string" + }, + "system_date": { + "description": "the system date to which this system event belongs to", + "format": "date", + "type": "string" + }, + "type": { + "description": "the machine readable type of the system event", + "enum": [ + "eod_balances_ready", + "eod_positions_ready" + ], + "type": "string" + } + }, + "required": [ + "at", + "event_id", + "type", + "system_date", + "description" + ], + "title": "SystemEvent", + "type": "object" + }, + "TaxIdType": { + "description": "An Enum of the various kinds of Tax ID formats Alpaca supports.\n\nPossible Values are:\n\n\n- **USA_SSN**\nUSA Social Security Number\n\n- **USA_ITIN**\nUSA Individual Taxpayer Identification Number\n\n- **ARG_AR_CUIT**\nArgentina CUIT\n\n- **AUS_TFN**\nAustralian Tax File Number\n\n- **AUS_ABN**\nAustralian Business Number\n\n- **BOL_NIT**\nBolivia NIT\n\n- **BRA_CPF**\nBrazil CPF\n\n- **CHL_RUT**\nChile RUT\n\n- **COL_NIT**\nColombia NIT\n\n- **CRI_NITE**\nCosta Rica NITE\n\n- **DEU_TAX_ID**\nGermany Tax ID (Identifikationsnummer)\n\n- **DOM_RNC**\nDominican Republic RNC\n\n- **ECU_RUC**\nEcuador RUC\n\n- **FRA_SPI**\nFrance SPI (Reference Tax Number)\n\n- **GBR_UTR**\nUK UTR (Unique Taxpayer Reference)\n\n- **GBR_NINO**\nUK NINO (National Insurance Number)\n\n- **GTM_NIT**\nGuatemala NIT\n\n- **HND_RTN**\nHonduras RTN\n\n- **HUN_TIN**\nHungary TIN Number\n\n- **IDN_KTP**\nIndonesia KTP\n\n- **IND_PAN**\nIndia PAN Number\n\n- **ISR_TAX_ID**\nIsrael Tax ID (Teudat Zehut)\n\n- **ITA_TAX_ID**\nItaly Tax ID (Codice Fiscale)\n\n- **JPN_TAX_ID**\nJapan Tax ID (Koijin Bango)\n\n- **MEX_RFC**\nMexico RFC\n\n- **NIC_RUC**\nNicaragua RUC\n\n- **NLD_TIN**\nNetherlands TIN Number\n\n- **PAN_RUC**\nPanama RUC\n\n- **PER_RUC**\nPeru RUC\n\n- **PRY_RUC**\nParaguay RUC\n\n- **SGP_NRIC**\nSingapore NRIC\n\n- **SGP_FIN**\nSingapore FIN\n\n- **SGP_ASGD**\nSingapore ASGD\n\n- **SGP_ITR**\nSingapore ITR\n\n- **SLV_NIT**\nEl Salvador NIT\n\n- **SWE_TAX_ID**\nSweden Tax ID (Personnummer)\n\n- **URY_RUT**\nUruguay RUT\n\n- **VEN_RIF**\nVenezuela RIF\n\n- **NATIONAL_ID**\nNational ID number, if a tax ID number is not available\n\n- **PASSPORT**\nPassport number, if a tax ID number is not available\n\n- **PERMANENT_RESIDENT**\nPermanent resident number, if a tax ID number is not available\n\n- **DRIVER_LICENSE**\nDriver's license number, if a tax ID number is not available\n\n- **OTHER_GOV_ID**\nOther government issued identifier, if a tax ID number is not available\n\n- **NOT_SPECIFIED**\nOther Tax IDs", + "enum": [ + "USA_SSN", + "USA_ITIN", + "ARG_AG_CUIT", + "AUS_TFN", + "AUS_ABN", + "BOL_NIT", + "BRA_CPF", + "CHL_RUT", + "COL_NIT", + "CRI_NITE", + "DEU_TAX_ID", + "DOM_RNC", + "ECU_RUC", + "FRA_SPI", + "GBR_UTR", + "GBR_NINO", + "GTM_NIT", + "HND_RTN", + "HUN_TIN", + "IDN_KTP", + "IND_PAN", + "ISR_TAX_ID", + "ITA_TAX_ID", + "JPN_TAX_ID", + "MEX_RFC", + "NIC_RUC", + "NLD_TIN", + "PAN_RUC", + "PER_RUC", + "PRY_RUC", + "SGP_NRIC", + "SGP_FIN", + "SGP_ASGD", + "SGP_ITR", + "SLV_NIT", + "SWE_TAX_ID", + "URY_RUT", + "VEN_RIF", + "NATIONAL_ID", + "PASSPORT", + "PERMANENT_RESIDENT", + "DRIVER_LICENSE", + "OTHER_GOV_ID", + "NOT_SPECIFIED" + ], + "example": "USA_SSN", + "title": "TaxIdType", + "type": "string" + }, + "TenderOfferActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonVOFSubtypeActivityV2" + } + ], + "type": "object" + }, + "TimeInForce": { + "description": "The Time-In-Force values supported by Alpaca vary based on the order's security type. Here is a breakdown of the supported TIFs for each specific security type:\n- Equity trading: day, gtc, opg, cls, ioc, fok.\n- Options trading: day, gtc.\n- Crypto trading: gtc, ioc.\n\nBelow are the descriptions of each TIF:\n- day:\n A day order is eligible for execution only on the day it is live. By default, the order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled after the closing auction, it is automatically canceled. If submitted after the close, it is queued and submitted the following trading day. However, if marked as eligible for extended hours, the order can also execute during supported extended hours.\n\n- gtc:\n The order is good until canceled. Non-marketable GTC limit orders are subject to price adjustments to offset corporate actions affecting the issue. We do not currently support Do Not Reduce (DNR) orders to opt out of such price adjustments.\n\n- opg:\n Use this TIF with a market/limit order type to submit \"market on open\" (MOO) and \"limit on open\" (LOO) orders. This order is eligible to execute only in the market opening auction. Any unfilled orders after the open will be cancelled. OPG orders submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted after 7:00pm will be queued and routed to the following day's opening auction. On open/on close orders are routed to the primary exchange. Such orders do not necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange's auction rules.\n\n- cls:\n Use this TIF with a market/limit order type to submit \"market on close\" (MOC) and \"limit on close\" (LOC) orders. This order is eligible to execute only in the market closing auction. Any unfilled orders after the close will be cancelled. CLS orders submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted after 7:00pm will be queued and routed to the following day's closing auction.\n\n- ioc:\n An Immediate Or Cancel (IOC) order requires all or part of the order to be executed immediately. Any unfilled portion of the order is canceled. Most market makers who receive IOC orders will attempt to fill the order on a principal basis only, and cancel any unfilled balance. On occasion, this can result in the entire order being cancelled if the market maker does not have any existing inventory of the security in question.\n\n- fok:\n A Fill or Kill (FOK) order is only executed if the entire order quantity can be filled, otherwise the order is canceled.", + "enum": [ + "day", + "gtc", + "opg", + "cls", + "ioc", + "fok" + ], + "example": "gtc", + "title": "TimeInForce", + "type": "string" + }, + "TokenizationIssuer": { + "description": "The tokenized asset's issuer", + "enum": [ + "binance", + "coinbase", + "ondo", + "st0x", + "xstocks" + ], + "example": "xstocks", + "title": "TokenizationIssuer", + "type": "string" + }, + "TokenizationMintCallback": { + "properties": { + "client_account_id": { + "description": "Alpaca account ID (UUID) of the Authorized Participant. Exactly one of `client_external_account_id` or `client_account_id` must be provided, matching the identifier used on the original mint request. The deprecated `client_id` field is still accepted as an alias for `client_external_account_id` during the deprecation window.", + "format": "uuid", + "type": "string" + }, + "client_external_account_id": { + "description": "Customer's client identifier on the issuer's platform. Exactly one of `client_external_account_id` or `client_account_id` must be provided, matching the identifier used on the original mint request. The deprecated `client_id` field is still accepted as an alias for `client_external_account_id` during the deprecation window.", + "type": "string" + }, + "client_id": { + "deprecated": true, + "description": "Customer's client identifier on the issuer's platform. Use `client_external_account_id` instead.", + "type": "string", + "x-deprecation": { + "reason": "Use client_external_account_id instead.", + "since": "2026-07-15", + "sunset": "2026-10-15" + } + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "tokenization_request_id": { + "description": "Unique identifier of the tokenization request", + "format": "uuid", + "type": "string" + }, + "tx_hash": { + "description": "Transaction hash of the completed request on the blockchain", + "type": "string" + }, + "wallet_address": { + "description": "The wallet address to receive the tokenized asset", + "type": "string" + } + }, + "required": [ + "tokenization_request_id", + "tx_hash" + ], + "title": "TokenizationMintCallback", + "type": "object" + }, + "TokenizationMintRequest": { + "properties": { + "issuer": { + "$ref": "#/components/schemas/TokenizationIssuer" + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "qty": { + "description": "The underlying quantity to convert into the tokenized asset. It can be fractional.", + "type": "string" + }, + "underlying_symbol": { + "description": "The underlying asset symbol", + "type": "string" + }, + "wallet_address": { + "description": "The wallet address to receive the tokenized asset", + "type": "string" + } + }, + "required": [ + "underlying_symbol", + "qty", + "issuer", + "network", + "wallet_address" + ], + "title": "TokenizationMintRequest", + "type": "object" + }, + "TokenizationMintResponse": { + "properties": { + "created_at": { + "format": "date-time", + "type": "string" + }, + "issuer": { + "$ref": "#/components/schemas/TokenizationIssuer" + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "qty": { + "description": "The quantity to convert for this tokenization request. It can be fractional.", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/TokenizationRequestStatus" + }, + "token_symbol": { + "description": "The tokenized asset symbol", + "type": "string" + }, + "tokenization_request_id": { + "description": "Unique identifier of the tokenization request set by Alpaca", + "type": "string" + }, + "underlying_symbol": { + "description": "The underlying asset symbol", + "type": "string" + } + }, + "required": [ + "tokenization_request_id", + "status", + "underlying_symbol", + "token_symbol", + "qty", + "created_at", + "issuer", + "network" + ], + "title": "TokenizationMintResponse", + "type": "object" + }, + "TokenizationNetwork": { + "description": "The token's blockchain network", + "enum": [ + "arbitrum", + "base", + "binance", + "cronos", + "ethereum", + "hypercore", + "hyperevm", + "mantle", + "robinhood", + "solana", + "ton", + "tron" + ], + "example": "solana", + "title": "TokenizationNetwork", + "type": "string" + }, + "TokenizationRedeemRequest": { + "properties": { + "client_account_id": { + "description": "Alpaca account ID (UUID) of the Authorized Participant. Exactly one of `client_external_account_id` or `client_account_id` must be provided to identify the Authorized Participant whose account will receive the underlying asset. The deprecated `client_id` field is still accepted as an alias for `client_external_account_id` during the deprecation window.", + "format": "uuid", + "type": "string" + }, + "client_external_account_id": { + "description": "Customer's client identifier on the issuer's platform. Exactly one of `client_external_account_id` or `client_account_id` must be provided to identify the Authorized Participant whose account will receive the underlying asset. The deprecated `client_id` field is still accepted as an alias for `client_external_account_id` during the deprecation window.", + "type": "string" + }, + "client_id": { + "deprecated": true, + "description": "Customer's client identifier on the issuer's platform. Use `client_external_account_id` instead.", + "type": "string", + "x-deprecation": { + "reason": "Use client_external_account_id instead.", + "since": "2026-07-15", + "sunset": "2026-10-15" + } + }, + "issuer_request_id": { + "description": "Unique identifier of the redemption request set by the issuer", + "type": "string" + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "qty": { + "description": "The quantity to convert into the underlying asset. It can be fractional.", + "type": "string" + }, + "token_symbol": { + "description": "The tokenized asset symbol", + "type": "string" + }, + "tx_hash": { + "description": "Transaction hash of the completed request on the blockchain", + "type": "string" + }, + "underlying_symbol": { + "description": "The underlying asset symbol", + "type": "string" + }, + "wallet_address": { + "description": "The address where the redeemed tokens were originally held", + "type": "string" + } + }, + "required": [ + "issuer_request_id", + "underlying_symbol", + "token_symbol", + "qty", + "network", + "wallet_address", + "tx_hash" + ], + "title": "TokenizationRedeemRequest", + "type": "object" + }, + "TokenizationRedeemResponse": { + "properties": { + "created_at": { + "format": "date-time", + "type": "string" + }, + "issuer": { + "$ref": "#/components/schemas/TokenizationIssuer" + }, + "issuer_request_id": { + "description": "Unique identifier of the redemption request set by the issuer", + "type": "string" + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "qty": { + "description": "The quantity to convert into the underlying asset. It can be fractional.", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/TokenizationRequestStatus" + }, + "token_symbol": { + "description": "The tokenized asset symbol", + "type": "string" + }, + "tokenization_request_id": { + "description": "Unique identifier of the tokenization request set by Alpaca", + "type": "string" + }, + "tx_hash": { + "description": "Transaction hash of the completed request on the blockchain", + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/TokenizationRequestType" + }, + "underlying_symbol": { + "description": "The underlying asset symbol", + "type": "string" + }, + "wallet_address": { + "description": "The address where the redeemed tokens were originally held", + "type": "string" + } + }, + "required": [ + "tokenization_request_id", + "issuer_request_id", + "created_at", + "type", + "status", + "underlying_symbol", + "token_symbol", + "qty", + "issuer", + "network", + "wallet_address", + "tx_hash" + ], + "title": "TokenizationRedeemResponse", + "type": "object" + }, + "TokenizationRequest": { + "properties": { + "account": { + "deprecated": true, + "description": "Alpaca account ID associated with this tokenization request. Use `client_account_id` instead.", + "type": "string", + "x-deprecation": { + "reason": "Use client_account_id instead.", + "since": "2026-07-15", + "sunset": "2026-10-15" + } + }, + "client_account_id": { + "description": "Alpaca account UUID of the Authorized Participant associated with this tokenization request", + "format": "uuid", + "type": "string" + }, + "client_external_account_id": { + "description": "Issuer-side account identifier of the Authorized Participant associated with this tokenization request", + "type": "string" + }, + "client_request_id": { + "description": "Authorized Participant-supplied label associated with this tokenization request", + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "fees": { + "description": "Fees charged for this tokenization request", + "type": [ + "string", + "null" + ] + }, + "issuer": { + "$ref": "#/components/schemas/TokenizationIssuer" + }, + "issuer_account": { + "deprecated": true, + "description": "Issuer's account ID associated with this tokenization request. Use `client_external_account_id` instead.", + "type": "string", + "x-deprecation": { + "reason": "Use client_external_account_id instead.", + "since": "2026-07-15", + "sunset": "2026-10-15" + } + }, + "issuer_request_id": { + "description": "Unique identifier of the tokenization request set by the issuer", + "type": [ + "string", + "null" + ] + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "qty": { + "description": "The quantity to convert for this tokenization request. It can be fractional.", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/TokenizationRequestStatus" + }, + "token_symbol": { + "description": "The tokenized asset symbol", + "type": "string" + }, + "tokenization_request_id": { + "description": "Unique identifier of the tokenization request set by Alpaca", + "type": "string" + }, + "tx_hash": { + "description": "Transaction hash of the completed request on the blockchain", + "type": [ + "string", + "null" + ] + }, + "type": { + "$ref": "#/components/schemas/TokenizationRequestType" + }, + "underlying_symbol": { + "description": "The underlying asset symbol", + "type": "string" + }, + "updated_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "wallet_address": { + "description": "The wallet address associated with this tokenization request", + "type": "string" + } + }, + "required": [ + "tokenization_request_id", + "created_at", + "type", + "status", + "underlying_symbol", + "token_symbol", + "qty", + "issuer", + "network", + "wallet_address" + ], + "title": "TokenizationRequest", + "type": "object" + }, + "TokenizationRequestStatus": { + "description": "Status of the tokenization request", + "enum": [ + "pending", + "rejected", + "completed" + ], + "example": "completed", + "title": "TokenizationRequestStatus", + "type": "string" + }, + "TokenizationRequestType": { + "description": "Tokenization request type", + "enum": [ + "mint", + "redeem" + ], + "example": "mint", + "title": "TokenizationRequestType", + "type": "string" + }, + "TradeAccount": { + "description": "This is an extended version of the Account model found [in the trading api](https://alpaca.markets/docs/api-references/trading-api/account/#account-entity).\n\nExtra data has been added that would be useful for brokers.", + "examples": [ + { + "account_blocked": false, + "account_number": "927584925", + "accrued_fees": "0", + "admin_configurations": {}, + "balance_asof": "2021-04-01", + "buying_power": "103556.8572572922", + "cash": "24861.91", + "cash_transferable": "24861.91", + "cash_withdrawable": "17861.91", + "clearing_broker": "VELOX", + "created_at": "2021-03-01T13:28:49.270232Z", + "crypto_status": "ACTIVE", + "currency": "USD", + "effective_buying_power": "103556.8572572922", + "equity": "28059.3882330664", + "id": "c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4", + "initial_margin": "1598.7391165332", + "intraday_adjustments": "0", + "last_buying_power": "104433.9158860662", + "last_cash": "23861.91", + "last_equity": "26977.323677655", + "last_initial_margin": "1557.7068388275", + "last_long_market_value": "3115.413677655", + "last_maintenance_margin": "934.6241032965", + "last_options_buying_power": "25419.62", + "last_regt_buying_power": "50839.233677655", + "last_short_market_value": "0", + "long_market_value": "3197.4782330664", + "maintenance_margin": "959.24346991992", + "multiplier": "2", + "non_marginable_buying_power": "24861.91", + "options_approved_level": 0, + "options_buying_power": "26460.65", + "options_trading_level": 0, + "pending_reg_taf_fees": "0", + "pending_transfer_out": "0", + "portfolio_value": "28059.3882330664", + "position_market_value": "3197.4782330664", + "previous_close": "2021-04-01T19:00:00-04:00", + "regt_buying_power": "52921.2982330664", + "short_market_value": "0", + "shorting_enabled": true, + "sma": "26758.0590204615", + "status": "ACTIVE", + "trade_suspended_by_user": false, + "trading_blocked": false, + "transfers_blocked": false + }, + { + "account_blocked": false, + "account_number": "601612064", + "accrued_fees": "0", + "admin_configurations": {}, + "balance_asof": "2022-02-08", + "buying_power": "83567.42", + "cash": "83567.42", + "cash_transferable": "41783.71", + "cash_withdrawable": "0", + "clearing_broker": "VELOX", + "created_at": "2022-01-21T21:25:26.713802Z", + "crypto_status": "PAPER_ONLY", + "currency": "USD", + "effective_buying_power": "83567.42", + "equity": "83567.42", + "id": "56712986-9ff7-4d8f-8e52-077e099e533e", + "initial_margin": "0", + "intraday_adjustments": "0", + "last_buying_power": "41783.71", + "last_cash": "41783.71", + "last_equity": "41783.71", + "last_initial_margin": "0", + "last_long_market_value": "0", + "last_maintenance_margin": "0", + "last_options_buying_power": "41783.71", + "last_regt_buying_power": "41783.71", + "last_short_market_value": "0", + "long_market_value": "0", + "maintenance_margin": "0", + "multiplier": "1", + "non_marginable_buying_power": "41783.71", + "options_approved_level": 2, + "options_buying_power": "83567.42", + "options_trading_level": 1, + "pending_reg_taf_fees": "0.01", + "pending_transfer_in": "0", + "pending_transfer_out": "0", + "portfolio_value": "83567.42", + "position_market_value": "0", + "previous_close": "2022-02-08T19:00:00-05:00", + "regt_buying_power": "83567.42", + "short_market_value": "0", + "shorting_enabled": false, + "sma": "0", + "status": "ACTIVE", + "trade_suspended_by_user": false, + "trading_blocked": false, + "transfers_blocked": false + } + ], + "properties": { + "account_blocked": { + "description": "If true, the account activity by user is prohibited.", + "example": false, + "type": "boolean" + }, + "account_number": { + "description": "The account number", + "example": "927584925", + "type": [ + "string", + "null" + ] + }, + "accrued_fees": { + "description": "Accrued fees", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "admin_configurations": { + "$ref": "#/components/schemas/AdminConfigurations" + }, + "balance_asof": { + "description": "The date of the snapshot for `last_*` fields", + "example": "2021-04-01", + "type": "string" + }, + "buying_power": { + "description": "Current available cash buying power. If multiplier = 2 then buying_power = max(equity-initial_margin(0) * 2). If multiplier = 1 then buying_power = cash.", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "cash": { + "description": "Cash balance", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "cash_transferable": { + "description": "Cash available for transfer (JNLC)", + "example": "12345.6789", + "type": "string" + }, + "cash_withdrawable": { + "description": "Cash available for withdrawal", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "clearing_broker": { + "description": "Clearing broker", + "example": "Velox", + "type": "string" + }, + "created_at": { + "description": "Timestamp this account was created at", + "example": "2021-03-01T13:28:49.270232Z", + "type": "string" + }, + "crypto_status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "currency": { + "description": "Always USD", + "example": "USD", + "type": "string" + }, + "effective_buying_power": { + "description": "Effective buying power (duplicate of buying power)", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "equity": { + "description": "cash + long_market_value + short_market_value", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "id": { + "description": "The account ID", + "example": "c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4", + "format": "uuid", + "type": "string" + }, + "initial_margin": { + "description": "Reg T initial margin requirement (continuously updated value)", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "intraday_adjustments": { + "description": "The intraday adjustment by non_trade_activities such as fund deposit/withdraw.\n", + "example": "0", + "type": "string" + }, + "last_buying_power": { + "description": "Value of buying_power as of previous trading day at 16:00:00 ET", + "example": "12345.6789", + "type": "string" + }, + "last_cash": { + "description": "Value of all cash as of previous trading day at 16:00:00 ET", + "example": "12345.6789", + "type": "string" + }, + "last_equity": { + "description": "Equity as of previous trading day at 16:00:00 ET", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "last_initial_margin": { + "description": "Value of Reg T margin as of previous trading day at 16:00:00 ET", + "example": "12345.6789", + "type": "string" + }, + "last_long_market_value": { + "description": "Value of all long positions as of previous trading day at 16:00:00 ET", + "example": "12345.6789", + "type": "string" + }, + "last_maintenance_margin": { + "description": "Maintenance margin requirement on the previous trading day", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "last_options_buying_power": { + "description": "Value of option buying power as of previous trading day at 16:00:00 ET", + "example": "12345.6789", + "type": "string" + }, + "last_regt_buying_power": { + "description": "Value of Reg T buying power as of previous trading day at 16:00:00 ET", + "example": "12345.6789", + "type": "string" + }, + "last_short_market_value": { + "description": "Value of all short positions as of previous trading day at 16:00:00 ET", + "example": "0", + "type": "string" + }, + "long_market_value": { + "description": "Real-time MtM value of all long positions held in the account", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "maintenance_margin": { + "description": "Maintenance margin requirement (continuously updated value)", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "memoposts": { + "description": "Outstanding memopost value", + "example": "100", + "type": "string" + }, + "multiplier": { + "description": "\"1\", \"2\", \"3\", or \"4\"", + "example": "2", + "format": "decimal", + "type": "string" + }, + "non_marginable_buying_power": { + "description": "Non-marginable buying power (currently used for only crypto trading)", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "options_approved_level": { + "description": "The options trading level that was approved for this account.\n0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.\n", + "enum": [ + 0, + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + }, + "options_buying_power": { + "description": "Your buying power for options trading", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "options_trading_level": { + "description": "The effective options trading level of the account.\nThis is the minimum between account options_approved_level and account configurations max_options_trading_level.\n0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.\n", + "enum": [ + 0, + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + }, + "pending_reg_taf_fees": { + "description": "Pending regulatory fees for the account.", + "example": "0.01", + "type": "string" + }, + "pending_transfer_out": { + "description": "Cash pending transfer out", + "example": "12345.6789", + "type": "string" + }, + "portfolio_value": { + "description": "Total value of cash + holding positions. (This field is deprecated. It is equivalent to the equity field.)", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "position_market_value": { + "description": "Real-time MtM value of all the positions held in the account", + "example": "0", + "format": "decimal", + "type": "string" + }, + "previous_close": { + "description": "Previous sessions close time", + "example": "2021-04-01T19:00:00-04:00", + "type": "string" + }, + "regt_buying_power": { + "description": "User's buying power under Regulation T (excess equity - (equity - margin value) - * margin multiplier)", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "short_market_value": { + "description": "Real-time MtM value of all short positions held in the account", + "example": "0", + "format": "decimal", + "type": "string" + }, + "shorting_enabled": { + "description": "Flag to denote whether or not the account is permitted to short", + "example": false, + "type": "boolean" + }, + "sma": { + "description": "Value of Special Memorandum Account (will be used at a later date to provide additional buying_power)", + "example": "12345.6789", + "format": "decimal", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "trade_suspended_by_user": { + "description": "If true, the account is not allowed to place orders.", + "example": false, + "type": "boolean" + }, + "trading_blocked": { + "description": "If true, the account is not allowed to place orders.", + "example": false, + "type": "boolean" + }, + "transfers_blocked": { + "description": "If true, the account is not allowed to request money transfers.", + "example": false, + "type": "boolean" + }, + "user_configurations": { + "anyOf": [ + { + "$ref": "#/components/schemas/AccountConfigurations" + }, + { + "type": "null" + } + ], + "description": "Custom user-level configuration overrides for this account.\n\nThis field is always present in the response, but its value will be `null` until user-level configurations have been explicitly set for the account." + } + }, + "required": [ + "id", + "admin_configurations", + "account_number", + "status", + "crypto_status", + "currency", + "buying_power", + "regt_buying_power", + "effective_buying_power", + "non_marginable_buying_power", + "accrued_fees", + "portfolio_value", + "trading_blocked", + "transfers_blocked", + "account_blocked", + "created_at", + "trade_suspended_by_user", + "multiplier", + "shorting_enabled", + "equity", + "last_equity", + "long_market_value", + "short_market_value", + "position_market_value", + "initial_margin", + "maintenance_margin", + "last_maintenance_margin", + "sma", + "balance_asof", + "cash" + ], + "type": "object" + }, + "TradeActivity": { + "properties": { + "cum_qty": { + "description": "Valid only for trading activity types. Null for non-trading activites.", + "example": "0.9723", + "format": "decimal", + "type": "string" + }, + "leaves_qty": { + "description": "Valid only for trading activity types. Null for non-trading activites.", + "example": "0.5123", + "format": "decimal", + "type": "string" + }, + "order_id": { + "description": "Valid only for trading activity types. Null for non-trading activites.", + "example": "fe060a1b-5b45-4eba-ba46-c3a3345d8255", + "format": "uuid", + "type": "string" + }, + "order_status": { + "$ref": "#/components/schemas/OrderStatus" + }, + "price": { + "description": "Valid only for trading activity types. Null for non-trading activites.", + "example": "3.1415", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "Valid only for trading activity types. Null for non-trading activites.", + "example": "0.38921", + "format": "decimal", + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "symbol": { + "description": "Valid only for trading activity types. Null for non-trading activites.", + "example": "AAPL", + "type": "string" + }, + "transaction_time": { + "description": "Valid only for trading activity types. Null for non-trading activites.", + "example": "2021-05-10T14:01:04.650275Z", + "format": "date-time", + "type": "string" + }, + "type": { + "description": "Valid only for trading activity types. Null for non-trading activites.", + "enum": [ + "fill", + "partial_fill" + ], + "example": "fill", + "type": "string" + } + }, + "title": "TradeActivity", + "type": "object" + }, + "TradeUpdateEventType": { + "description": "**Common events**\n\nThese are the events that are the expected results of actions you may have taken by sending API requests.\n\nThe meaning of the `timestamp` field changes for each type; the meanings have been specified here for which types the\ntimestamp field will be present.\n\n- `accepted`: Sent when an order is received and accepted by Alpaca.\n- `new`: Sent when an order has been routed to exchanges for execution.\n- `fill`: Sent when your order has been completely filled.\n - `timestamp`: The time at which the order was filled.\n- `partial_fill`: Sent when a number of shares less than the total remaining quantity on your order has been filled.\n - `timestamp`: The time at which the shares were filled.\n- `canceled`: Sent when the order transitions to the `canceled` state. This can be triggered by a user-submitted cancel request, by Alpaca as part of automated processing (e.g. corporate-action sweeps, aged-GTC expiration, overnight-session lifecycle), or by an upstream execution venue. When Alpaca populates a machine-readable cause, it is exposed on the top-level `reason` field — see the `reason` property on `TradeUpdateEventV2` for known values (e.g. `CORPORATE_ACTION`).\n - `timestamp`: The time at which the order was canceled.\n- `expired`: Sent when an order has reached the end of its lifespan, as determined by the order's time in force value.\n - `timestamp`: The time at which the order expired.\n- `done_for_day`: Sent when the order is done executing for the day, and will not receive further updates until the next trading day.\n- `replaced`: Sent when your requested replacement of an order is processed.\n - `timestamp`: The time at which the order was replaced.\n\n**Rarer events**\n\nThese are events that may rarely be sent due to unexpected circumstances on the exchanges. It is unlikely you will need to design your code around them, but you may still wish to account for the possibility that they will occur.\n\n- `rejected`: Sent when your order has been rejected.\n - `timestamp`: The time at which the rejection occurred.\n- `pending_new`: Sent when the order has been received by Alpaca and routed to the exchanges, but has not yet been accepted for execution.\n- `stopped`: Sent when your order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred.\n- `pending_cancel`: Sent when the order is awaiting cancellation. Most cancellations will occur without the order entering this state.\n- `pending_replace`: Sent when the order is awaiting replacement.\n- `calculated`: Sent when the order has been completed for the day - it is either `filled` or `done_for_day` - but remaining settlement calculations are still pending.\n- `suspended`: Sent when the order has been suspended and is not eligible for trading.\n- `order_replace_rejected`: Sent when the order replace has been rejected.\n- `order_cancel_rejected`: Sent when the order cancel has been rejected.\n- `trade_bust`: Sent when a previously reported execution has been canceled (\"busted\") by the upstream exchange.\n- `trade_correct`: Sent when a previously reported trade has been corrected. For example, the exchange may have updated the price, quantity, or another execution parameter after the trade was initially reported.\n- `restated`: Sent when the order is manually modified.\n", + "enum": [ + "new", + "fill", + "partial_fill", + "canceled", + "expired", + "done_for_day", + "replaced", + "rejected", + "pending_new", + "accepted", + "stopped", + "pending_cancel", + "pending_replace", + "calculated", + "suspended", + "order_replace_rejected", + "order_cancel_rejected", + "trade_bust", + "trade_correct" + ], + "type": "string" + }, + "TradeUpdateEventV2": { + "description": "Represents an update to an order/trade, sent over the events streaming api.", + "properties": { + "account_id": { + "description": "Account UUID", + "format": "uuid", + "minLength": 1, + "type": "string" + }, + "at": { + "description": "Timestamp of event", + "format": "date-time", + "minLength": 1, + "type": "string" + }, + "event": { + "$ref": "#/components/schemas/TradeUpdateEventType" + }, + "event_id": { + "description": "lexically sortable, monotonically increasing character array", + "format": "ulid", + "type": "string" + }, + "execution_id": { + "description": "Corresponding execution of an order. If an order gets filled over two executions (a partial_fill for example), you will receive two events with different IDs.\nNot present for `MultilegOptions`\n", + "format": "uui", + "type": "string" + }, + "legs": { + "description": "Only present when event is for `MultilegOptions`. Represents filled qty/price of legs.\n", + "items": { + "$ref": "#/components/schemas/TradeUpdateEventV2Leg" + }, + "type": "array" + }, + "order": { + "$ref": "#/components/schemas/Order" + }, + "position_qty": { + "description": "Only present when event is either `fill` or `partial_fill` other than `MultilegOptions`. The size of your total position, after this fill event, in shares. Positive for long positions, negative for short positions.\n", + "type": "string" + }, + "position_qtys": { + "description": "Only present when event is either `fill` or `partial_fill` for `MultilegOptions`. The size of your total position, after this fill event, in shares. Positive for long positions, negative for short positions.\n", + "type": "string" + }, + "previous_execution_id": { + "description": "ID of the original execution that was busted or corrected (present only in trade_bust and trade_correct events).", + "format": "uuid", + "type": "string" + }, + "price": { + "description": "Only present when event is either `fill` or `partial_fill`. The average price per share at which the order was filled.", + "type": "string" + }, + "qty": { + "description": "Only present when event is either `fill`, `partial_fill`, `trade_bust` and `trade_correct`. The amount of shares this Trade order was for.
For `trade_bust` events, the qty field may be negative, representing a reversal of the original quantity.", + "type": "string" + }, + "reason": { + "description": "Machine-readable code that explains **why** the event occurred. Only present when a reason applies; omitted from routine lifecycle events such as `new`, `fill`, and `partial_fill`.\n\nKnown values:\n\n| Value | Event(s) | Meaning |\n| --- | --- | --- |\n| `CORPORATE_ACTION` | `canceled` | Alpaca canceled the order internally because the underlying is scheduled for a mandatory corporate action other than a cash dividend (e.g. reverse split, symbol/CUSIP change, merger, liquidation). Emitted by the overnight-session lifecycle and, where enabled by Alpaca, the daytime GTC corporate-action sweep. Not emitted when the cancel is routed to the upstream venue instead (e.g. day-session, `extended_hours=false`, agency- or mixed-capacity orders); those `canceled` events carry the venue's own text in `reason` if any. |\n| `TOO_LATE_TO_CANCEL` | `order_cancel_rejected`, `order_replace_rejected` | The cancel or replace request arrived after the order had already reached a terminal state (typically `filled`). |\n| `TRADE_BUST` | `trade_bust` | Alpaca operations replayed or synthesized a bust of a previously reported execution. Busts that originate from the upstream venue surface the venue's own text in `reason` (or omit it entirely), so consumers should not rely on `TRADE_BUST` alone to identify all busts — key on the `event` field (`trade_bust`) for that. |\n\nFree-form strings may also appear in `reason`. In particular, `canceled`, `trade_bust`, and `trade_correct` events originating from the upstream venue carry the venue's own text field (when the venue provides one) rather than an Alpaca-defined code. Consumers should tolerate unknown values and, where they need to distinguish cases, key on `event` first and use `reason` as a secondary hint.\n", + "example": "CORPORATE_ACTION", + "type": [ + "string", + "null" + ] + }, + "settle_date": { + "description": "Settlement date of the trade in format `YYYY-MM-DD` for `fill` and `partial_fill` events", + "example": "2026-03-03", + "format": "date", + "type": "string" + }, + "swap_rate": { + "description": "Only present for `local currency trading account` or `crypto asset trade` when event is either `fill` or `partial_fill`. The swap rate at which the current trade was filled.", + "type": "string" + }, + "timestamp": { + "description": "Has various different meanings depending on the value of `event`, please see the [Trading Events](https://alpaca.markets/docs/api-references/broker-api/events/#trade-events)\nEnum in the documentation or the TradeUpdateEventType model for more details on when it means different things.\n", + "format": "date-time", + "type": "string" + } + }, + "title": "TradeUpdateEvent", + "type": "object" + }, + "TradeUpdateEventV2Leg": { + "description": "Represents filled qty/price of legs.", + "properties": { + "execution_id": { + "description": "Corresponding execution of an order. If an order gets filled over two executions (a partial_fill for example), you will receive two events with different IDs.", + "format": "uuid", + "type": "string" + }, + "order_id": { + "description": "Order UUID", + "format": "uuid", + "minLength": 1, + "type": "string" + }, + "price": { + "description": "The average price per share for this event.", + "type": "string" + }, + "qty": { + "description": "The amount of shares filled for this event", + "type": "string" + }, + "symbol": { + "description": "Symbol of an asset", + "type": "string" + }, + "timestamp": { + "description": "Timestamp of this event leg\n", + "format": "date-time", + "type": "string" + } + }, + "title": "TradeUpdateEventV2Leg", + "type": "object" + }, + "Transaction": { + "examples": [ + { + "account_id": "06b9d76e-1733-460c-844e-48d1ae0f10c3", + "account_name": "Just In Time Receivable - JITS", + "account_no": "JTRJITS00", + "amount": "1", + "balance": "4186.36", + "contra_account_name": "Just In Time Interest Income", + "description": "debit balance = 4185.36, base_rate = 0.0375, spread = 0.05", + "entry_type": "JNLC", + "system_date": "2022-06-10" + } + ], + "properties": { + "account_id": { + "description": "The ledger ID", + "type": "string" + }, + "account_name": { + "description": "The ledger name", + "type": "string" + }, + "account_no": { + "description": "The ledger account number", + "type": "string" + }, + "amount": { + "description": "Total amount of the transaction", + "type": "string" + }, + "balance": { + "description": "Ending balance after thetransaction has been applied", + "type": "string" + }, + "contra_account_name": { + "description": "Contra account of transaction", + "type": "string" + }, + "description": { + "description": "Plain text overview of the transaction", + "type": "string" + }, + "entry_type": { + "description": "Type of transaction", + "type": "string" + }, + "system_date": { + "description": "Date of transaction", + "type": "string" + } + }, + "type": "object" + }, + "Transfer": { + "description": "Transfers allow you to transfer money/balance into your end customers' account (deposits) or out (withdrawal).\n\n[Main docs here](https://alpaca.markets/docs/api-references/broker-api/funding/transfers/#the-transfer-object)", + "examples": [ + { + "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65", + "additional_information": "string", + "amount": "string", + "bank_id": "f1ae96de-94c1-468e-93a3-6b7213930ca8", + "created_at": "2019-08-24T14:15:22Z", + "direction": "INCOMING", + "expires_at": "2019-08-24T14:15:22Z", + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "ira": { + "distribution_reason": "normal", + "fed_withholding_amount": "102.5", + "fed_withholding_pct": "10.25", + "state_withholding_amount": "97.5", + "state_withholding_pct": "9.75", + "tax_year": "2024" + }, + "reason": "string", + "relationship_id": "81412018-ffa2-43f9-a3eb-d39f1c5e0f87", + "status": "QUEUED", + "type": "ach", + "updated_at": "2019-08-24T14:15:22Z" + } + ], + "properties": { + "account_id": { + "description": "The account ID", + "format": "uuid", + "type": "string" + }, + "additional_information": { + "description": "Additional information. Only applies when type = \"wire\".", + "type": [ + "string", + "null" + ] + }, + "amount": { + "description": "Must be > 0.00", + "format": "decimal", + "type": "string" + }, + "bank_id": { + "description": "The ID of the Bank, only present if type = \"wire\"", + "format": "uuid", + "type": "string" + }, + "created_at": { + "description": "Timestamp when transfer was created", + "format": "date-time", + "type": "string" + }, + "direction": { + "$ref": "#/components/schemas/TransferDirection" + }, + "expires_at": { + "description": "Timestamp when transfer expires", + "format": "date-time", + "type": "string" + }, + "fee": { + "description": "Fee amount to be collected. Only applies when type = \"wire\".", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "fee_payment_method": { + "description": "Either \"user\" or \"invoice\". Only applies when type = \"wire\".", + "type": [ + "string", + "null" + ] + }, + "hold_until": { + "format": "date-time", + "type": "string" + }, + "id": { + "description": "The transfer ID", + "format": "uuid", + "type": "string" + }, + "instant_amount": { + "type": "string" + }, + "ira": { + "$ref": "#/components/schemas/TransferIRADetails" + }, + "reason": { + "description": "Cause of the status", + "type": [ + "string", + "null" + ] + }, + "relationship_id": { + "description": "The ACH relationship ID only present if type = \"ach\"", + "format": "uuid", + "type": "string" + }, + "requested_amount": { + "description": "Must be > 0.00. Only applies when type = \"wire\".", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "status": { + "$ref": "#/components/schemas/TransferStatus" + }, + "type": { + "$ref": "#/components/schemas/TransferType" + }, + "updated_at": { + "description": "Timestamp when transfer was updated", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "account_id", + "type", + "status", + "amount", + "direction", + "created_at" + ], + "title": "Transfer", + "type": "object" + }, + "TransferDirection": { + "description": "- **INCOMING**\nFunds incoming to user's account (deposit).\n- **OUTGOING**\nFunds outgoing from user's account (withdrawal).\n", + "enum": [ + "INCOMING", + "OUTGOING" + ], + "example": "INCOMING", + "type": "string" + }, + "TransferFee": { + "properties": { + "amount": { + "format": "decimal", + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/Currency" + }, + "payment_type": { + "$ref": "#/components/schemas/FeePaymentType" + }, + "type": { + "$ref": "#/components/schemas/FeeType" + } + }, + "required": [ + "type", + "amount", + "currency", + "payment_type" + ], + "type": "object" + }, + "TransferIRA": { + "description": "This field is used for IRA Account only", + "properties": { + "distribution_reason": { + "example": "normal", + "type": "string" + }, + "tax_withholding": { + "$ref": "#/components/schemas/TransferIRATaxWithholding" + }, + "tax_year": { + "example": "2024", + "type": "string" + } + }, + "type": "object" + }, + "TransferIRADetails": { + "properties": { + "distribution_reason": { + "example": "normal", + "type": "string" + }, + "fed_withholding_amount": { + "example": "102.5", + "type": "string" + }, + "fed_withholding_pct": { + "example": "10.25", + "type": "string" + }, + "state_withholding_amount": { + "example": "97.5", + "type": "string" + }, + "state_withholding_pct": { + "example": "9.75", + "type": "string" + }, + "tax_year": { + "example": "2024", + "type": "string" + } + }, + "type": "object" + }, + "TransferIRATaxWithholding": { + "properties": { + "fed_pct": { + "example": "10.25", + "type": "string" + }, + "state_pct": { + "example": "8.25", + "type": "string" + } + }, + "type": "object" + }, + "TransferStatus": { + "description": "- **QUEUED**\nTransfer is in queue to be processed.\n- **APPROVAL_PENDING**\nTransfer is pending approval.\n- **PENDING**\nTransfer is pending processing.\n- **SENT_TO_CLEARING**\nTransfer is being processed by the clearing firm.\n- **REJECTED**\nTransfer is rejected.\n- **CANCELED**\nClient initiated transfer cancellation.\n- **APPROVED**\nTransfer is approved.\n- **COMPLETE**\nTransfer is completed.\n- **RETURNED**\nThe bank issued an ACH return for the transfer.\n", + "enum": [ + "QUEUED", + "APPROVAL_PENDING", + "PENDING", + "SENT_TO_CLEARING", + "REJECTED", + "CANCELED", + "APPROVED", + "COMPLETE", + "RETURNED" + ], + "example": "QUEUED", + "type": "string" + }, + "TransferStatusEvent": { + "description": "Represents a change in a Transfer's status, sent over the events streaming api.", + "examples": [ + { + "account_id": "8e00606a-c9ac-409a-ba45-f55e8f77984a", + "at": "2021-06-10T19:52:24.066998Z", + "event_id": 15961, + "event_ulid": "01F7VQQ782DM57SJNWAYMD14J9", + "status_from": "QUEUED", + "status_to": "SENT_TO_CLEARING", + "transfer_id": "c4ed4206-697b-4859-ab71-b9de6649859d" + }, + { + "account_id": "8e00606a-c9ac-409a-ba45-f55e8f77984a", + "at": "2021-06-10T20:02:24.280178Z", + "event_id": 15962, + "event_ulid": "01F7VQQ782DM57SJNWAYMD14JA", + "status_from": "SENT_TO_CLEARING", + "status_to": "COMPLETE", + "transfer_id": "c4ed4206-697b-4859-ab71-b9de6649859d" + } + ], + "properties": { + "account_id": { + "description": "Account UUID", + "format": "uuid", + "minLength": 1, + "type": "string" + }, + "at": { + "description": "Timestamp of when the transfer status changed", + "format": "date-time", + "minLength": 1, + "type": "string" + }, + "event_id": { + "description": "Monotonically increasing 64-bit integer not available to new partners, and for backward compatibility purposes only; use `event_ulid` as the stable identifier where possible\n", + "type": "integer" + }, + "event_ulid": { + "description": "lexically sortable, monotonically increasing character array", + "format": "ulid", + "type": "string" + }, + "status_from": { + "$ref": "#/components/schemas/TransferStatusFrom" + }, + "status_to": { + "$ref": "#/components/schemas/TransferStatus" + }, + "transfer_id": { + "description": "Transfer UUID", + "format": "uuid", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "account_id", + "at", + "event_ulid", + "status_from", + "status_to", + "transfer_id" + ], + "title": "TransferStatusEvent", + "type": "object" + }, + "TransferStatusFrom": { + "description": "Previous transfer status in stream status-change events. Empty string is used for the initial status-change event when there is no previous status.", + "oneOf": [ + { + "$ref": "#/components/schemas/TransferStatus" + }, + { + "enum": [ + "" + ], + "type": "string" + } + ] + }, + "TransferType": { + "description": "- **ach**\nTransfer via ACH (US Only). Supports both `INCOMING` (deposit) and `OUTGOING` (withdrawal) directions.\n- **wire**\nTransfer via wire. `OUTGOING` (withdrawal) only.\n", + "enum": [ + "ach", + "wire" + ], + "example": "ach", + "title": "TransferType", + "type": "string" + }, + "TransmitterInfo": { + "description": "Information about the transmitter to satisfy travel rule requirements. Required if the requesting correspondent qualifies as a financial institution\n", + "properties": { + "originator_bank_account_number": { + "description": "Required if the requesting correspondent qualifies as a financial institution\n", + "type": "string" + }, + "originator_bank_name": { + "description": "Required if the requesting correspondent qualifies as a financial institution\n", + "type": "string" + }, + "originator_city": { + "type": "string" + }, + "originator_country": { + "description": "Required if the requesting correspondent qualifies as a financial institution\n", + "type": "string" + }, + "originator_full_name": { + "description": "Required if the requesting correspondent qualifies as a financial institution\n", + "type": "string" + }, + "originator_postal_code": { + "type": "string" + }, + "originator_state": { + "type": "string" + }, + "originator_street_address": { + "type": "string" + }, + "other_identifying_information": { + "description": "Used to facilitate transfer lookup in the event it is required. Recommended to be the originating bank's reference number for the transfer\n", + "type": "string" + } + }, + "type": "object" + }, + "TravelRuleErrorResponse": { + "description": "A wallet or travel rule validation error.", + "oneOf": [ + { + "$ref": "#/components/schemas/TravelRuleValidationError" + }, + { + "$ref": "#/components/schemas/WalletError" + } + ] + }, + "TravelRuleFieldOption": { + "description": "Allowed value for a travel rule field that accepts a fixed set of choices.", + "properties": { + "description": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "value", + "description" + ], + "type": "object" + }, + "TravelRuleInfo": { + "description": "Travel rule information pertaining to the wallet being whitelisted. Identify the destination by providing beneficiary_vasp_id, setting beneficiary_is_self_hosted to true, or providing beneficiary_manual_entry. Either beneficiary_entity_name (for legal entities) or beneficiary_given_name and beneficiary_family_name (for natural persons) must be provided.", + "properties": { + "beneficiary_country_of_residence": { + "description": "ISO 3166-1 country code for the beneficiary's country of residence.", + "example": "US", + "type": "string" + }, + "beneficiary_entity_name": { + "description": "The beneficiary's legal entity name (required for legal entities)", + "example": "Alpaca Crypto LLC", + "minLength": 1, + "type": "string" + }, + "beneficiary_family_name": { + "description": "The beneficiary's last name (required for natural persons)", + "example": "Doe", + "minLength": 1, + "type": "string" + }, + "beneficiary_geographic_address_building_number": { + "description": "Building number in the beneficiary's geographic address.", + "example": "1", + "type": "string" + }, + "beneficiary_geographic_address_country": { + "description": "ISO 3166-1 alpha-2 or alpha-3 country code in the beneficiary's geographic address.", + "example": "US", + "type": "string" + }, + "beneficiary_geographic_address_post_code": { + "description": "Postal code in the beneficiary's geographic address.", + "example": "10001", + "type": "string" + }, + "beneficiary_geographic_address_street_name": { + "description": "Street name in the beneficiary's geographic address.", + "example": "Main Street", + "type": "string" + }, + "beneficiary_geographic_address_town_name": { + "description": "Town or city in the beneficiary's geographic address.", + "example": "New York", + "type": "string" + }, + "beneficiary_given_name": { + "description": "The beneficiary's first name (required for natural persons)", + "example": "John", + "minLength": 1, + "type": "string" + }, + "beneficiary_is_self_hosted": { + "description": "Beneficiary is receiving funds to a self-hosted / non-custodial wallet", + "example": true, + "type": "boolean" + }, + "beneficiary_manual_entry": { + "$ref": "#/components/schemas/TravelRuleManualEntry" + }, + "beneficiary_vasp_id": { + "description": "The W3C Decentralized Identifier (DID) representing the beneficiary's VASP.", + "example": "did:ethr:0xf1c002f9e7ca88018d6dcf1e86403fb2f5f055f4", + "pattern": "^did:[a-zA-Z0-9]*:.*$", + "type": "string" + } + }, + "title": "TravelRuleInfo", + "type": "object" + }, + "TravelRuleManualEntry": { + "description": "Information about a beneficiary VASP that is not available in the VASP directory.", + "properties": { + "vasp_name": { + "description": "The name of the receiving exchange.", + "example": "Alpaca", + "type": "string" + }, + "vasp_website": { + "description": "The receiving exchange's website.", + "example": "https://alpaca.markets", + "format": "uri", + "type": "string" + } + }, + "required": [ + "vasp_name", + "vasp_website" + ], + "type": "object" + }, + "TravelRuleNextAction": { + "description": "Action the client must take to satisfy travel rule requirements.", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "required_fields": { + "items": { + "$ref": "#/components/schemas/TravelRuleRequiredField" + }, + "type": "array" + }, + "type": { + "enum": [ + "REQUIRED", + "ONE_OF" + ], + "type": "string" + } + }, + "required": [ + "name", + "description", + "type" + ], + "type": "object" + }, + "TravelRuleRequiredField": { + "description": "Request field required to complete a travel rule action.", + "properties": { + "description": { + "type": "string" + }, + "field": { + "type": "string" + }, + "options": { + "description": "List of valid choices for 'enum' types. Null for simple strings or booleans.", + "items": { + "$ref": "#/components/schemas/TravelRuleFieldOption" + }, + "type": [ + "array", + "null" + ] + }, + "value_type": { + "enum": [ + "string", + "bool" + ], + "type": "string" + } + }, + "required": [ + "field", + "value_type", + "description" + ], + "type": "object" + }, + "TravelRuleValidationError": { + "description": "Travel rule validation failure and the actions required to correct it.", + "properties": { + "error_code": { + "$ref": "#/components/schemas/TravelRuleValidationErrorCode" + }, + "message": { + "example": "Please provide the beneficiary's name. Select one of the following options.", + "type": "string" + }, + "next_actions": { + "description": "A list of actions to be taken to fulfill information requirements.", + "example": [ + { + "description": "Provide the recipient's first and last name.", + "name": "supply_beneficiaryName_naturalPerson", + "required_fields": [ + { + "description": "The recipient's first name.", + "field": "beneficiary_given_name", + "value_type": "string" + }, + { + "description": "The recipient's last name.", + "field": "beneficiary_family_name", + "value_type": "string" + } + ], + "type": "ONE_OF" + }, + { + "description": "Provide the entity's legal name.", + "name": "supply_beneficiaryName_legalEntity", + "required_fields": [ + { + "description": "The legal name of the receiving entity.", + "field": "beneficiary_entity_name", + "value_type": "string" + } + ], + "type": "ONE_OF" + } + ], + "items": { + "$ref": "#/components/schemas/TravelRuleNextAction" + }, + "type": "array" + } + }, + "required": [ + "error_code", + "message", + "next_actions" + ], + "type": "object" + }, + "TravelRuleValidationErrorCode": { + "description": "Machine-readable code identifying the travel rule validation failure.", + "enum": [ + "INVALID_DATA", + "UNKNOWN_VASP", + "ADDRESS_BELONGS_TO_VASP", + "TRAVEL_RULE_ACTION_REQUIRED", + "BENEFICIARY_NAME_REQUIRED" + ], + "example": "BENEFICIARY_NAME_REQUIRED", + "type": "string" + }, + "TrustedContact": { + "anyOf": [ + { + "required": [ + "email_address" + ] + }, + { + "required": [ + "phone_number" + ] + }, + { + "required": [ + "street_address" + ] + } + ], + "dependentRequired": { + "street_address": [ + "city", + "state", + "postal_code", + "country" + ] + }, + "description": "This model input is optional. However, the client should make a reasonable effort to obtain the trusted contact information. See [FINRA Notice 17-11](https://www.finra.org/sites/default/files/Regulatory-Notice-17-11.pdf) for more details.\n\nAt least one of the following is required:\n- `email_address`\n- `phone_number`\n- `street_address`\n", + "example": { + "email_address": "jane.doe@example.com", + "family_name": "Doe", + "given_name": "Jane" + }, + "properties": { + "city": { + "description": "Required if `street_address` is set.", + "type": "string" + }, + "country": { + "description": "The country in [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html) format. Required if `street_address` is set.", + "type": "string" + }, + "email_address": { + "description": "At least one of `email_address`, `phone_number`, or `street_address` is required.", + "example": "jane.doe@example.com", + "format": "email", + "type": "string" + }, + "family_name": { + "example": "Doe", + "type": "string" + }, + "given_name": { + "example": "Jane", + "type": "string" + }, + "phone_number": { + "description": "At least one of `email_address`, `phone_number`, or `street_address` is required.", + "type": "string" + }, + "postal_code": { + "description": "Required if `street_address` is set.", + "type": "string" + }, + "state": { + "description": "Required if `street_address` is set.", + "type": "string" + }, + "street_address": { + "description": "At least one of `email_address`, `phone_number`, or `street_address` is required.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "given_name", + "family_name" + ], + "type": "object" + }, + "USDAccountTradingLimit": { + "properties": { + "available": { + "description": "The remaining net buying limit that can be used for trading.", + "format": "decimal", + "type": "string" + }, + "daily_net_limit": { + "description": "The net buying limit that can be reached before further trading activity is restricted. Please reach out to learn more about how this limit is determined.", + "format": "decimal", + "type": "string" + }, + "held": { + "description": "The limit that is currently being held for open orders", + "format": "decimal", + "type": "string" + }, + "used": { + "description": "The real time net value of cash inflows (buy trades, etc.) with cash outflows (sell trades, etc). This will be dynamic throughout the day based on user activity, with executed orders being reset at the start of the next trading day.", + "format": "decimal", + "type": "string" + } + }, + "title": "USDAccountTradingLimit", + "type": "object" + }, + "USDPosition": { + "description": "Position values in USD. This is returned for LCT (non-USD) accounts only.", + "properties": { + "avg_entry_price": { + "description": "Average entry price of the position in USD", + "example": "71.43", + "format": "decimal", + "type": "string" + }, + "change_today": { + "description": "Percent change from last day price (by a factor of 1)", + "example": "0.67", + "format": "decimal", + "type": "string" + }, + "cost_basis": { + "description": "Total cost basis in USD", + "example": "333.33", + "format": "decimal", + "type": "string" + }, + "current_price": { + "description": "Current asset price per share in USD", + "example": "80.0", + "format": "decimal", + "type": "string" + }, + "lastday_price": { + "description": "Last day's asset price per share based on the closing value of the last trading day in USD", + "example": "79.33", + "format": "decimal", + "type": "string" + }, + "market_value": { + "description": "Total market value of the position in USD", + "example": "400.00", + "format": "decimal", + "type": "string" + }, + "unrealized_intraday_pl": { + "description": "Unrealized profit/loss in USD for the day", + "example": "6.67", + "format": "decimal", + "type": "string" + }, + "unrealized_intraday_plpc": { + "description": "Unrealized interday profit/loss percent (by a factor of 1)", + "example": "0.0084", + "format": "decimal", + "type": "string" + }, + "unrealized_pl": { + "description": "Unrealized profit/loss in USD", + "example": "66.67", + "format": "decimal", + "type": "string" + }, + "unrealized_plpc": { + "description": "Unrealized profit/loss percent (by a factor of 1)", + "example": "0.2", + "format": "decimal", + "type": "string" + } + }, + "title": "USDPosition", + "type": "object" + }, + "UnitSplitActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonSplitStockActivityV2" + }, + { + "properties": { + "alternate_cusip": { + "description": "CUSIP for the alternate security after the split", + "type": "string" + }, + "alternate_isin": { + "description": "ISIN for the alternate security after the split", + "type": "string" + }, + "alternate_qty": { + "description": "Quantity of alternate shares received", + "type": "string" + }, + "alternate_rate": { + "description": "Ratio of alternate shares received", + "type": "string" + }, + "alternate_symbol": { + "description": "Symbol for the alternate security after the split", + "type": "string" + }, + "effective_date": { + "description": "When the unit split becomes effective", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security after the split", + "type": "string" + }, + "old_symbol": { + "description": "Symbol of the old security before the split", + "type": "string" + } + }, + "required": [ + "old_symbol", + "new_symbol", + "alternate_cusip", + "alternate_symbol", + "alternate_rate", + "alternate_qty", + "effective_date" + ], + "type": "object" + } + ], + "description": "Unit split", + "type": "object" + }, + "UpdateOrderRequest": { + "description": "Represents the fields that are editable in an order replace/update call.\n\nNote: client_order_id is currently not editable on its own, one of the other fields must be changed at the same time to effectively replace the order.\n\nNote: `qty` and `notional` are mutually exclusive on a single replace request. `notional` is only valid for IPO indications of interest (`asset_class: \"ipo\"`); non-IPO notional orders cannot be replaced at all.", + "properties": { + "advanced_instructions": { + "$ref": "#/components/schemas/AdvancedInstructions" + }, + "client_order_id": { + "description": "A unique identifier for the new order. Automatically generated if not sent. (<= 128 characters)", + "example": "61e69015-8549-4bfd-b9c3-01e75843f47d", + "maxLength": 128, + "type": "string" + }, + "limit_price": { + "description": "Required if original order's `type` field was `limit` or `stop_limit`.\nIn case of `mleg`, the limit_price parameter is expressed with the following notation:\n- A positive value indicates a debit, representing a cost or payment to be made.\n- A negative value signifies a credit, reflecting an amount to be received.", + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "notional": { + "description": "New notional (dollar amount) for the order. Only valid for IPO indications of interest (`asset_class: \"ipo\"`); will be rejected for any other asset class.\nMutually exclusive with `qty` on the same replace request.", + "example": "750", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "You can only patch full shares for now.\n\nQty of equity fractional orders are not allowed to change. Non-IPO notional orders cannot be replaced at all - no fields (qty, limit_price, stop_price, etc.) can be modified; cancel and resubmit instead.\nIn case of multi-leg orders represents the number of units to trade of this strategy.", + "example": "4", + "format": "decimal", + "type": "string" + }, + "stop_price": { + "description": "Required if original order's `type` field was stop or stop_limit", + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "trail": { + "description": "The new value of the trail_price or trail_percent", + "example": "3.14", + "format": "decimal", + "type": "string" + } + }, + "title": "OrderUpdateRequest", + "type": "object" + }, + "UpdateWhitelistedAddressTravelRuleInfoRequest": { + "description": "Travel rule information to associate with a whitelisted address.", + "properties": { + "travel_rule_info": { + "$ref": "#/components/schemas/TravelRuleInfo" + } + }, + "required": [ + "travel_rule_info" + ], + "type": "object" + }, + "Usd": { + "properties": { + "amount": { + "format": "decimal", + "type": "string" + } + }, + "required": [ + "amount" + ], + "type": "object" + }, + "VASP": { + "description": "Virtual Asset Service Provider returned by the directory search.", + "properties": { + "address": { + "type": "string" + }, + "city": { + "type": "string" + }, + "country": { + "description": "ISO 3166-1 alpha-2 country code for the VASP.", + "example": "US", + "type": "string" + }, + "did": { + "description": "The W3C Decentralized Identifier (DID) representing the VASP.", + "example": "did:ethr:0xf1c002f9e7ca88018d6dcf1e86403fb2f5f055f4", + "pattern": "^did:[a-zA-Z0-9]*:.*$", + "type": "string" + }, + "emailDomain": { + "type": "string" + }, + "id": { + "description": "Opaque identifier for the VASP directory record.", + "example": "vasp-1", + "type": "string" + }, + "name": { + "type": "string" + }, + "postalCode": { + "type": "string" + }, + "state": { + "type": "string" + }, + "website": { + "format": "uri", + "type": "string" + } + }, + "required": [ + "id", + "name" + ], + "type": "object" + }, + "W8benDocument": { + "description": "Use this property (instead of the content property) to upload W-8 BEN data in JSON format.", + "examples": [ + { + "additional_conditions": "None", + "country_citizen": "Australia", + "date": "2021-06-14", + "date_of_birth": "1970-01-01", + "foreign_tax_id": "123 456 789", + "ftin_not_required": false, + "full_name": "John Doe", + "income_type": "interest", + "ip_address": "127.0.0.1", + "mailing_address_city_state": "Adelaide, South Australia", + "mailing_address_country": "Australia", + "mailing_address_street": "51 Main St", + "paragraph_number": "15", + "percent_rate_withholding": 5, + "permanent_address_city_state": "Adelaide, South Australia", + "permanent_address_country": "Australia", + "permanent_address_street": "20 Main St", + "reference_number": "abc123", + "residency": "Australia", + "revision": "10-2021", + "signer_full_name": "Mr. Signing User", + "tax_id_ssn": "123-00-456", + "timestamp": "2021-06-14T09:31:05Z" + } + ], + "properties": { + "additional_conditions": { + "description": "Any additional conditions to specify", + "type": "string" + }, + "country_citizen": { + "description": "The country that the applicant is a citizen of", + "type": "string" + }, + "date": { + "description": "date signed", + "format": "date", + "type": "string" + }, + "date_of_birth": { + "description": "date of birth of applicant", + "format": "date", + "type": "string" + }, + "foreign_tax_id": { + "description": "Applicant's tax id in their home country", + "type": "string" + }, + "ftin_not_required": { + "description": "Required if foreign_tax_id and tax_id_ssn are empty.", + "type": "boolean" + }, + "full_name": { + "description": "Full name of applicant", + "type": "string" + }, + "income_type": { + "description": "Income type of applicant", + "type": "string" + }, + "ip_address": { + "description": "IP address of applicant when signed", + "type": "string" + }, + "mailing_address_city_state": { + "description": "Mailing city/state of applicant", + "type": "string" + }, + "mailing_address_country": { + "description": "Mailing country for applicant", + "type": "string" + }, + "mailing_address_street": { + "description": "Mailing street address for applicant", + "type": "string" + }, + "paragraph_number": { + "type": "string" + }, + "percent_rate_withholding": { + "type": "integer" + }, + "permanent_address_city_state": { + "description": "Permanent city/state of applicant", + "type": "string" + }, + "permanent_address_country": { + "description": "Permanent country of residence of applicant", + "type": "string" + }, + "permanent_address_street": { + "description": "Permanent street address of applicant", + "type": "string" + }, + "reference_number": { + "type": "string" + }, + "residency": { + "description": "Country of residency of applicant", + "type": "string" + }, + "revision": { + "description": "Revision of the W8BEN form", + "type": "string" + }, + "signer_full_name": { + "description": "Full name of signing user", + "type": "string" + }, + "tax_id_ssn": { + "description": "TaxID/SSN of applicant", + "type": "string" + }, + "timestamp": { + "description": "Timestamp when form data was gathered", + "format": "time", + "type": "string" + } + }, + "required": [ + "country_citizen", + "date", + "date_of_birth", + "full_name", + "ip_address", + "permanent_address_city_state", + "permanent_address_country", + "permanent_address_street", + "revision", + "timestamp", + "signer_full_name" + ], + "type": "object" + }, + "WRMActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "removed_qty": { + "description": "The removed quantity", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "cusip", + "symbol", + "removed_qty" + ], + "type": "object" + } + ], + "description": "Worthless Removal", + "type": "object" + }, + "WalletError": { + "additionalProperties": false, + "description": "A wallet error response.", + "properties": { + "message": { + "example": "travel_rule_info is missing", + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "WarrantExerciseElectionActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonVOFSubtypeActivityV2" + } + ], + "type": "object" + }, + "Watchlist": { + "description": "Represents a set of securities observed by a user.", + "properties": { + "account_id": { + "description": "Unique identifier of the account that owns this watchlist.\n", + "format": "uuid", + "type": "string" + }, + "assets": { + "description": "The contents of the watchlist, in the order as registered", + "items": { + "$ref": "#/components/schemas/Asset" + }, + "type": "array" + }, + "created_at": { + "description": "When watchlist was created", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "Unique identifier of the watchlist itself.\n", + "format": "uuid", + "type": "string" + }, + "name": { + "description": "User friendly Name of watchlist", + "pattern": "^[a-zA-Z0-9]+$", + "type": "string" + }, + "updated_at": { + "description": "When watchlist was last updated", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "account_id", + "created_at", + "updated_at", + "name" + ], + "title": "Watchlist", + "type": "object" + }, + "WatchlistWithoutAsset": { + "description": "Represents a set of securities observed by a user.", + "properties": { + "account_id": { + "description": "Unique identifier of the account that owns this watchlist.\n", + "format": "uuid", + "type": "string" + }, + "created_at": { + "description": "When watchlist was created", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "Unique identifier of the watchlist itself.\n", + "format": "uuid", + "type": "string" + }, + "name": { + "description": "User friendly Name of watchlist", + "pattern": "^[a-zA-Z0-9]+$", + "type": "string" + }, + "updated_at": { + "description": "When watchlist was last updated", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "account_id", + "created_at", + "updated_at", + "name" + ], + "title": "Watchlist", + "type": "object" + }, + "WhitelistedAddress": { + "properties": { + "address": { + "description": "The whitelisted address", + "type": "string" + }, + "asset": { + "description": "Symbol of underlying asset for the whitelisted address", + "type": "string" + }, + "chain": { + "description": "Underlying network this address represents", + "type": "string" + }, + "created_at": { + "description": "Timestamp (RFC3339) of account creation.", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "Unique ID for whitelisted address", + "type": "string" + }, + "status": { + "description": "Status of whitelisted address which is either APPROVED or PENDING. Whitelisted addresses will be subjected to a 24 waiting period. After the waiting period is over the status will become APPROVED.", + "enum": [ + "APPROVED", + "PENDING" + ], + "type": "string" + }, + "travel_rule_info": { + "allOf": [ + { + "$ref": "#/components/schemas/TravelRuleInfo" + } + ], + "description": "Travel rule information associated with the whitelisted address." + } + }, + "type": "object" + }, + "bic": { + "description": "Business Identifier Code (BIC/SWIFT).", + "example": "IRVTUS3NXXX", + "maxLength": 11, + "minLength": 11, + "pattern": "^[A-Z0-9]{11}$", + "type": "string" + }, + "bond_status": { + "description": "Status of the bond.", + "enum": [ + "outstanding", + "matured", + "pre_issuance" + ], + "type": "string" + }, + "calendar_day": { + "description": "A calendar day.", + "properties": { + "core_end": { + "description": "The end time of the core market session.", + "example": "2025-01-02T16:00:00-05:00", + "format": "date-time", + "type": "string" + }, + "core_start": { + "description": "The start time of the core market session.", + "example": "2025-01-02T09:30:00-05:00", + "format": "date-time", + "type": "string" + }, + "date": { + "description": "The date of the calendar day.", + "example": "2025-01-02", + "format": "date", + "type": "string" + }, + "lunch_end": { + "description": "The end time of the lunch session.", + "format": "date-time", + "type": "string" + }, + "lunch_start": { + "description": "The start time of the lunch session.", + "format": "date-time", + "type": "string" + }, + "post_end": { + "description": "The end time of the after-hours session.", + "example": "2025-01-02T20:00:00-05:00", + "format": "date-time", + "type": "string" + }, + "post_start": { + "description": "The start time of the after-hours session.", + "example": "2025-01-02T16:00:00-05:00", + "format": "date-time", + "type": "string" + }, + "pre_end": { + "description": "The end time of the pre-market session.", + "example": "2025-01-02T09:30:00-05:00", + "format": "date-time", + "type": "string" + }, + "pre_start": { + "description": "The start time of the pre-market session.", + "example": "2025-01-02T04:00:00-05:00", + "format": "date-time", + "type": "string" + }, + "settlement_date": { + "description": "The settlement date.", + "example": "2025-01-03", + "format": "date", + "type": "string" + } + }, + "required": [ + "date", + "core_start", + "core_end" + ], + "type": "object" + }, + "call_type": { + "description": "The type of call on the bond refers to one of a variety of circumstances under which a callable bond may be called.", + "enum": [ + "ordinary", + "make_whole", + "regulatory", + "special" + ], + "type": "string" + }, + "clock": { + "properties": { + "is_market_day": { + "description": "Whether the clock is on a market day.", + "type": "boolean" + }, + "market": { + "$ref": "#/components/schemas/public_market" + }, + "next_market_close": { + "description": "Next market close timestamp", + "format": "date-time", + "type": "string" + }, + "next_market_open": { + "description": "Next market open timestamp", + "format": "date-time", + "type": "string" + }, + "phase": { + "$ref": "#/components/schemas/phase" + }, + "phase_until": { + "description": "The end of the current phase.", + "format": "date-time", + "type": "string" + }, + "timestamp": { + "description": "The time on the clock.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "market", + "timestamp", + "is_market_day", + "next_market_open", + "next_market_close", + "phase", + "phase_until" + ], + "type": "object" + }, + "clock_resp": { + "description": "Clock response.", + "properties": { + "clocks": { + "items": { + "$ref": "#/components/schemas/clock" + }, + "type": "array" + } + }, + "required": [ + "clocks" + ], + "type": "object" + }, + "coupon_frequency": { + "description": "How often the coupon is paid", + "enum": [ + "annual", + "semi_annual", + "quarterly", + "monthly", + "zero" + ], + "type": "string" + }, + "coupon_type": { + "description": "The type of the coupon rate", + "enum": [ + "fixed", + "floating", + "zero" + ], + "type": "string" + }, + "day_count": { + "description": "The day count convention used to calculate accrued interest.\n\n- `A/360`: calculates the daily interest using a 360-day year and then multiplies that by the actual number of days in each time period.\n- `A/365`: calculates the daily interest using a 365-day year and then multiplies that by the actual number of days in each time period.\n- `30/360`: calculates the daily interest using a 360-day year and then multiplies that by 30 (standardized month).\n- `30/365`: calculates the daily interest using a 365-day year and then multiplies that by 30 (standardized month).\n- `A/A`: calculates the daily interest using the actual number of days in the year and then multiplies that by the actual number of days in each time period.\n- `30E/360`: number of days equals to the actual number of days (for February). If the start date or the end date of the period is the 31st of a month, that date is set to the 30th. The number of days in a year is 360.\n- `B/252`: calculates the daily interest using a 252-business-day year and then multiplies that by the actual number of days in each time period.\n- `A/364`: calculates the daily interest using a 364-day year and then multiplies that by the actual number of days in each time period.\n", + "enum": [ + "A/360", + "A/365", + "30/360", + "30/365", + "A/A", + "30E/360", + "B/252", + "A/364" + ], + "type": "string" + }, + "legacy_calendar_day": { + "description": "A calendar day.", + "properties": { + "close": { + "description": "The time the market closes at on this date in HH:MM format.", + "example": "16:00", + "type": "string" + }, + "date": { + "description": "Date string in YYYY-MM-DD format.", + "example": "2025-01-02", + "format": "date", + "type": "string" + }, + "open": { + "description": "The time the market opens at on this date in HH:MM format.", + "example": "09:30", + "type": "string" + }, + "session_close": { + "description": "The time the session closes at on this date in HHMM format.", + "example": "2000", + "type": "string" + }, + "session_open": { + "description": "The time the session opens at on this date in HHMM format.", + "example": "0400", + "type": "string" + }, + "settlement_date": { + "description": "Date string in YYYY-MM-DD format. Representing the settlement date for the trade date.", + "example": "2025-01-03", + "format": "date", + "type": "string" + } + }, + "required": [ + "date", + "open", + "close", + "session_open", + "session_close", + "settlement_date" + ], + "type": "object" + }, + "legacy_clock": { + "example": { + "is_open": true, + "next_close": "2025-06-24T16:00:00-04:00", + "next_open": "2025-06-25T09:30:00-04:00", + "timestamp": "2025-06-24T14:15:22-04:00" + }, + "properties": { + "is_open": { + "description": "Whether or not the market is open.", + "type": "boolean" + }, + "next_close": { + "description": "Next market close timestamp.", + "format": "date-time", + "type": "string" + }, + "next_open": { + "description": "Next market open timestamp.", + "format": "date-time", + "type": "string" + }, + "timestamp": { + "description": "Current timestamp.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "timestamp", + "is_open", + "next_open", + "next_close" + ], + "title": "Clock", + "type": "object" + }, + "legacy_public_calendar_resp": { + "items": { + "$ref": "#/components/schemas/legacy_calendar_day" + }, + "type": "array" + }, + "market": { + "description": "The market identifier (MIC, BIC, or acronym).", + "enum": [ + "BMO", + "BNYM", + "BOATS", + "CEUX", + "CHIX", + "HKEX", + "IEX", + "IEXG", + "ISE", + "LSE", + "MTA", + "MTAA", + "NASDAQ", + "NYSE", + "OCEA", + "OPRA", + "OTC", + "OTCM", + "SIFMA", + "TADAWUL", + "XAMS", + "XBRU", + "XDUB", + "XETR", + "XETRA", + "XHKG", + "XLIS", + "XLON", + "XNAS", + "XNYS", + "XPAR", + "XSAU" + ], + "type": "string" + }, + "market_acronym": { + "description": "The acronym of the market.", + "example": "NYSE", + "type": "string" + }, + "market_name": { + "description": "The full name of the market.", + "example": "New York Stock Exchange", + "type": "string" + }, + "market_timezone": { + "description": "The timezone of the market.", + "example": "America/New_York", + "type": "string" + }, + "mic": { + "description": "Market identifier code (ISO 10383).", + "example": "XNYS", + "maxLength": 4, + "minLength": 4, + "pattern": "^[A-Z0-9]{4}$", + "type": "string" + }, + "phase": { + "enum": [ + "closed", + "pre", + "core", + "lunch", + "post" + ], + "type": "string" + }, + "public_calendar_resp": { + "description": "Calendar response.", + "properties": { + "calendar": { + "description": "The market calendar.", + "items": { + "$ref": "#/components/schemas/calendar_day" + }, + "type": "array" + }, + "market": { + "$ref": "#/components/schemas/public_market" + } + }, + "required": [ + "market", + "calendar" + ], + "type": "object" + }, + "public_market": { + "description": "A market.", + "properties": { + "acronym": { + "$ref": "#/components/schemas/market_acronym" + }, + "bic": { + "$ref": "#/components/schemas/bic" + }, + "mic": { + "$ref": "#/components/schemas/mic" + }, + "name": { + "$ref": "#/components/schemas/market_name" + }, + "timezone": { + "$ref": "#/components/schemas/market_timezone" + } + }, + "required": [ + "acronym", + "name", + "timezone" + ], + "type": "object" + }, + "sp_outlook": { + "description": "A Standard & Poor's rating outlook indicates S&P's view regarding the potential direction of a long-term credit rating over the intermediate term (2 years for investment grade, 1 year for speculative grade)", + "enum": [ + "positive", + "negative", + "developing", + "stable", + "not_rated", + "not_meaningful" + ], + "type": "string" + }, + "treasury_subtype": { + "description": "The subtype of the treasury.", + "enum": [ + "bond", + "bill", + "note", + "strips", + "tips", + "floating" + ], + "type": "string" + }, + "us_corporate": { + "description": "A US corporate", + "properties": { + "accrued_interest": { + "description": "The interest that has accumulated on a bond in dollars per bond between the last interest payment and the present date that has not yet been paid to the bondholder", + "format": "double", + "type": "number" + }, + "bond_status": { + "$ref": "#/components/schemas/bond_status" + }, + "call_type": { + "$ref": "#/components/schemas/call_type" + }, + "callable": { + "description": "Whether the bond is callable, meaning the issuer has the right, but not the obligation to redeem the bond - in other words, pay out the bondholder - before its maturity date at a set price (the call price)", + "type": "boolean" + }, + "close_price": { + "description": "The price of the last transaction of a security before the market closes for normal trading, shown as a percentage of par value", + "format": "double", + "type": "number" + }, + "close_price_date": { + "description": "The date of the close price", + "format": "date", + "type": "string" + }, + "close_yield_to_maturity": { + "description": "Yield to maturity of the treasury after the last close", + "format": "double", + "type": "number" + }, + "close_yield_to_worst": { + "description": "Yield to worst of the treasury after the last close", + "format": "double", + "type": "number" + }, + "convertible": { + "description": "A flag indicating whether the bond is convertible", + "type": "boolean" + }, + "country_domicile": { + "description": "The country where the corporate is domiciled in the 2-alpha country code format (e.g., US, CA)", + "type": "string" + }, + "coupon": { + "description": "The annual interest rate paid on the bond as a percentage of par value", + "format": "double", + "type": "number" + }, + "coupon_frequency": { + "$ref": "#/components/schemas/coupon_frequency" + }, + "coupon_type": { + "$ref": "#/components/schemas/coupon_type" + }, + "cusip": { + "description": "CUSIP is a nine-character alphanumeric code that uniquely identifies the security", + "maxLength": 9, + "minLength": 9, + "pattern": "^[A-Z0-9]{9}$", + "type": "string" + }, + "dated_date": { + "description": "The dated date marks the beginning of the period for which interest starts accruing on the bond", + "format": "date", + "type": "string" + }, + "day_count": { + "$ref": "#/components/schemas/day_count" + }, + "description": { + "description": "Description of the corporate bond", + "type": "string" + }, + "description_short": { + "description": "Short description of the corporate bond", + "type": "string" + }, + "first_coupon_date": { + "description": "The date of the first coupon payment", + "format": "date", + "type": "string" + }, + "fractionable": { + "description": "Whether the corporate can be traded in fractional amounts", + "type": "boolean" + }, + "isin": { + "description": "International Securities Identification Number", + "maxLength": 12, + "minLength": 12, + "pattern": "^[A-Z]{2}[A-Z0-9]{9}[0-9]$", + "type": "string" + }, + "issue_date": { + "description": "The date on which the bond was issued", + "format": "date", + "type": "string" + }, + "issue_minimum_denomination": { + "description": "The smallest unit of the bond that can be purchased at its initial offering", + "type": "number" + }, + "issue_price": { + "description": "The price at which the bond was originally issued as a percentage of par value", + "format": "double", + "type": "number" + }, + "issue_size": { + "description": "The total size amount of the bond issue in the issuing currency", + "type": "number" + }, + "issuer": { + "description": "The name of the issuer of the corporate bond", + "type": "string" + }, + "last_coupon_date": { + "description": "The date of the last coupon payment", + "format": "date", + "type": "string" + }, + "liquidity_institutional_aggregate": { + "description": "Score (from 1-5 or null if the bond is not priced/tradable) reflecting the historical depth of executable liquidity to buy or sell (no minimum trading sizes)", + "type": "number" + }, + "liquidity_institutional_buy": { + "description": "Score (from 1-5 or null if the bond is not priced/tradable) reflecting the historical depth of executable liquidity to buy (no minimum trading sizes)", + "type": "number" + }, + "liquidity_institutional_sell": { + "description": "Score (from 1-5 or null if the bond is not priced/tradable) reflecting the historical depth of executable liquidity to sell (no minimum trading sizes)", + "type": "number" + }, + "liquidity_micro_aggregate": { + "description": "Score (from 1-5 or null if the bond is not priced/tradable) reflecting the historical depth of executable liquidity to buy or sell with minimum trading sizes less than or equal to $1,000.00", + "type": "number" + }, + "liquidity_micro_buy": { + "description": "Score (from 1-5 if the bond is priced, or null if the bond is not tradable) reflecting the historical depth of executable liquidity to buy with minimum trading sizes less than or equal to $1,000.00", + "type": "number" + }, + "liquidity_micro_sell": { + "description": "Score (from 1-5 or null if the bond is not priced/tradable) reflecting the historical depth of executable liquidity to sell with minimum trading sizes less than or equal to $1,000.00", + "type": "number" + }, + "liquidity_retail_aggregate": { + "description": "Score (from 1-5 or null if the bond is not priced/tradable) reflecting the historical depth of executable liquidity to buy or sell with minimum trading sizes less than or equal to 10,000", + "type": "number" + }, + "liquidity_retail_buy": { + "description": "Score (from 1-5 or null if the bond is not priced/tradable) reflecting the historical depth of executable liquidity to buy with minimum trading sizes less than or equal to $10,000.00", + "type": "number" + }, + "liquidity_retail_sell": { + "description": "Score (from 1-5 or null if the bond is not priced/tradable) reflecting the historical depth of executable liquidity to sell with minimum trading sizes less than or equal to 10,000", + "type": "number" + }, + "marginable": { + "description": "Whether the corporate is marginable", + "type": "boolean" + }, + "maturity_date": { + "description": "The date on which the bond matures", + "format": "date", + "type": "string" + }, + "next_call_date": { + "description": "The date of the next possible call on the bond.", + "format": "date", + "type": "string" + }, + "next_call_price": { + "description": "The price at which a callable bond can be redeemed by the issuer on the next call date, as a percentage of par.", + "format": "double", + "type": "number" + }, + "next_coupon_date": { + "description": "The date of the next coupon payment", + "format": "date", + "type": "string" + }, + "par_value": { + "description": "The amount that the issuer of the bond will pay back to the bondholder upon maturity", + "type": "number" + }, + "perpetual": { + "description": "A flag representing whether a bond is perpetual", + "type": "boolean" + }, + "puttable": { + "description": "Whether the bond is puttable, meaning the bondholder has the right, but not the obligation to sell the bond back to the issuer at a set price (the put price) on specified dates before maturity", + "type": "boolean" + }, + "reg_s": { + "description": "Indicates whether the security falls under Regulation S, a rule that provides an exemption from the registration requirements for securities offerings made outside the United States", + "type": "boolean" + }, + "reissue_date": { + "description": "The date on which the corporate was reissued", + "format": "date", + "type": "string" + }, + "reissue_price": { + "description": "The price at which the corporate was reissued as a percentage of par value", + "format": "double", + "type": "number" + }, + "reissue_size": { + "description": "The total size amount of the corporate reissue in the issuing currency", + "type": "number" + }, + "sector": { + "description": "The sector of the corporate bond", + "type": "string" + }, + "seniority": { + "description": "The seniority of the corporate bond", + "type": "string" + }, + "sp_creditwatch": { + "description": "S&P's CreditWatch highlights S&P's opinion regarding the potential direction of a short-term or long-term rating", + "type": "string" + }, + "sp_creditwatch_date": { + "description": "The date of the most recent Standard & Poor's CreditWatch for the bond in YYYY-MM-DD format", + "format": "date", + "type": "string" + }, + "sp_outlook": { + "$ref": "#/components/schemas/sp_outlook" + }, + "sp_outlook_date": { + "description": "The date of the most recent Standard & Poor's outlook for the bond in YYYY-MM-DD format", + "format": "date", + "type": "string" + }, + "sp_rating": { + "description": "Standard & Poor's rating for the bond in the standard AAA - D format", + "type": "string" + }, + "sp_rating_date": { + "description": "The date in the timezone of the issuing country of the most recent Standard & Poor's rating for the bond in YYYY-MM-DD format", + "format": "date", + "type": "string" + }, + "ticker": { + "description": "The ticker symbol of the corporate", + "type": "string" + }, + "tradable": { + "description": "Whether the treasury is tradable", + "type": "boolean" + } + }, + "required": [ + "isin", + "cusip", + "bond_status", + "tradable", + "marginable", + "fractionable", + "issue_date", + "country_domicile", + "ticker", + "seniority", + "issuer", + "sector", + "description", + "description_short", + "coupon", + "coupon_type", + "coupon_frequency", + "perpetual", + "day_count", + "dated_date", + "issue_size", + "issue_price", + "issue_minimum_denomination", + "par_value", + "callable", + "puttable", + "convertible", + "reg_s" + ], + "type": "object" + }, + "us_corporates_resp": { + "properties": { + "us_corporates": { + "items": { + "$ref": "#/components/schemas/us_corporate" + }, + "type": "array" + } + }, + "required": [ + "us_corporates" + ], + "type": "object" + }, + "us_treasuries_resp": { + "properties": { + "us_treasuries": { + "items": { + "$ref": "#/components/schemas/us_treasury" + }, + "type": "array" + } + }, + "required": [ + "us_treasuries" + ], + "type": "object" + }, + "us_treasury": { + "description": "A US treasury", + "properties": { + "bond_status": { + "$ref": "#/components/schemas/bond_status" + }, + "close_price": { + "description": "The price of the last transaction of a security before the market closes for normal trading, shown as a percentage of par value", + "format": "double", + "type": "number" + }, + "close_price_date": { + "description": "The date of the close price", + "format": "date", + "type": "string" + }, + "close_yield_to_maturity": { + "description": "Yield to maturity of the treasury after the last close", + "format": "double", + "type": "number" + }, + "close_yield_to_worst": { + "description": "Yield to worst of the treasury after the last close", + "format": "double", + "type": "number" + }, + "coupon": { + "description": "The annual interest rate paid on the bond as a percentage of par value", + "format": "double", + "type": "number" + }, + "coupon_frequency": { + "$ref": "#/components/schemas/coupon_frequency" + }, + "coupon_type": { + "$ref": "#/components/schemas/coupon_type" + }, + "cusip": { + "description": "CUSIP is a nine-character alphanumeric code that uniquely identifies the security", + "maxLength": 9, + "minLength": 9, + "pattern": "^[A-Z0-9]{9}$", + "type": "string" + }, + "description": { + "description": "Description of the treasury", + "type": "string" + }, + "description_short": { + "description": "Short description of the treasury", + "type": "string" + }, + "first_coupon_date": { + "description": "The date of the first coupon payment", + "format": "date", + "type": "string" + }, + "fractionable": { + "description": "Whether the treasury can be traded in fractional amounts", + "type": "boolean" + }, + "isin": { + "description": "International Securities Identification Number", + "maxLength": 12, + "minLength": 12, + "pattern": "^[A-Z]{2}[A-Z0-9]{9}[0-9]$", + "type": "string" + }, + "issue_date": { + "description": "The date on which the bond was issued", + "format": "date", + "type": "string" + }, + "last_coupon_date": { + "description": "The date of the last coupon payment", + "format": "date", + "type": "string" + }, + "maturity_date": { + "description": "The date on which the bond matures", + "format": "date", + "type": "string" + }, + "next_coupon_date": { + "description": "The date of the next coupon payment", + "format": "date", + "type": "string" + }, + "subtype": { + "$ref": "#/components/schemas/treasury_subtype" + }, + "tradable": { + "description": "Whether the treasury is tradable", + "type": "boolean" + } + }, + "required": [ + "isin", + "cusip", + "bond_status", + "tradable", + "fractionable", + "subtype", + "issue_date", + "maturity_date", + "description", + "description_short", + "coupon", + "coupon_type", + "coupon_frequency" + ], + "type": "object" + } + }, + "securitySchemes": { + "BasicAuth": { + "scheme": "basic", + "type": "http" + } + } + }, + "info": { + "contact": { + "email": "support@alpaca.markets", + "name": "Alpaca Support", + "url": "https://alpaca.markets/support" + }, + "description": "Open brokerage accounts, enable stock, options and crypto trading. Manage the ongoing user experience and brokerage customer lifecycle with the Alpaca Broker API", + "termsOfService": "https://s3.amazonaws.com/files.alpaca.markets/disclosures/library/TermsAndConditions.pdf", + "title": "Broker API", + "version": "1.1.1" + }, + "openapi": "3.1.2", + "paths": { + "/v1beta/accounts/{account_id}/funding_wallet": { + "get": { + "description": "Returns the funding wallet for the specified account. Responds with 404 if the account has not been onboarded to funding wallets or a wallet has not been created.", + "operationId": "getFundingWallet", + "parameters": [ + { + "description": "UUID alpaca account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FundingWallet" + } + } + }, + "description": "funding wallet" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Retrieve funding wallet", + "tags": [ + "Funding Wallets" + ] + }, + "post": { + "description": "Creates a funding wallet for the specified account. The request is rejected if the account already has a funding wallet.", + "operationId": "createFundingWallet", + "parameters": [ + { + "description": "UUID alpaca account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FundingWallet" + } + } + }, + "description": "funding wallet" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Creates a funding wallet", + "tags": [ + "Funding Wallets" + ] + } + }, + "/v1beta/accounts/{account_id}/funding_wallet/funding_details": { + "get": { + "description": "Returns a list of funding details if it exists. Query parameters must be passed to create a new funding details object if none exist.", + "operationId": "listFundingDetails", + "parameters": [ + { + "description": "UUID alpaca account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The type of SSI to be returned, priority (SWIFT) or regular (local). A null value returns all payment types.", + "in": "query", + "name": "payment_type", + "required": false, + "schema": { + "$ref": "#/components/schemas/FundingDetailPaymentType" + } + }, + { + "description": "Should be provided in ISO 4217 standard", + "in": "query", + "name": "currency", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/ListFundingDetails" + } + } + } + }, + "description": "list of wallets" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Retrieve funding details", + "tags": [ + "Funding Wallets" + ] + } + }, + "/v1beta/accounts/{account_id}/funding_wallet/recipient_bank": { + "delete": { + "description": "deletes a recipient bank.", + "operationId": "deleteFundingWalletRecipientBank", + "parameters": [ + { + "description": "UUID alpaca account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "recipient bank" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Delete a recipient bank", + "tags": [ + "Funding Wallets" + ] + }, + "get": { + "description": "Returns the recipient bank registered against the specified account's funding wallet. Responds with 404 if no recipient bank has been registered for the account.", + "operationId": "getFundingWalletRecipientBank", + "parameters": [ + { + "description": "UUID alpaca account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "recipient bank" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Retrieve recipient bank", + "tags": [ + "Funding Wallets" + ] + }, + "post": { + "description": "Creates a new recipient bank. Returns the new recipient bank entity on success. entity.", + "operationId": "createFundingWalletRecipientBank", + "parameters": [ + { + "description": "UUID alpaca account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "account_number": { + "description": "Bank account number.", + "type": "string" + }, + "account_type": { + "description": "Bank account type.", + "enum": [ + "checking", + "savings" + ], + "type": "string" + }, + "bank_account_holder_name": { + "description": "Bank account holder's name.", + "type": "string" + }, + "bank_country": { + "description": "Two-letter code for the country in which the beneficiary's bank account is held.", + "type": "string" + }, + "bank_name": { + "type": "string" + }, + "bic_swift": { + "description": "BIC/SWIFT code", + "type": "string" + }, + "city": { + "description": "City", + "type": "string" + }, + "currency": { + "description": "Currency in which money is held in the beneficiary's bank account. ISO-3 currency code.", + "type": "string" + }, + "iban": { + "description": "IBAN code", + "type": "string" + }, + "postal_code": { + "description": "Postal code", + "type": "string" + }, + "routing_code": { + "description": "Routing code for routing_code_type. If supplied, routing_code_type should also be supplied.", + "type": "string" + }, + "routing_code_type": { + "description": "Local payment routing system. If supplied, routing_code should also be supplied.", + "enum": [ + "sort_code", + "aba", + "bsb_code", + "institution_no", + "bank_code", + "branch_code", + "clabe", + "cnaps", + "ifsc" + ], + "type": "string" + }, + "state_or_province": { + "description": "State or province.", + "type": "string" + }, + "street_address": { + "description": "First line of address.", + "type": "string" + } + }, + "required": [ + "bank_country", + "currency", + "bank_name", + "street_address", + "city", + "account_number" + ] + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FundingWalletRecipientBank" + } + } + }, + "description": "Success." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Create a recipient bank", + "tags": [ + "Funding Wallets" + ] + } + }, + "/v1beta/accounts/{account_id}/funding_wallet/transfers": { + "get": { + "description": "Returns all funding wallet transfers (deposits and withdrawals) associated with the specified account.", + "operationId": "getFundingWalletTransfers", + "parameters": [ + { + "description": "UUID alpaca account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListTransfersResponse" + } + } + }, + "description": "transfers" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Retrieve funding wallet transfers", + "tags": [ + "Funding Wallets" + ] + } + }, + "/v1beta/accounts/{account_id}/funding_wallet/transfers/{transfer_id}": { + "get": { + "description": "Returns a single funding wallet transfer for the specified account by `transfer_id`. Responds with 404 if no matching transfer exists for the account.", + "operationId": "getFundingWalletTransferByID", + "parameters": [ + { + "description": "Alpaca account UUID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "transfer UUID", + "in": "path", + "name": "transfer_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FundingWalletTransfer" + } + } + }, + "description": "transfer response if found" + }, + "404": { + "description": "error response if transfer is not found" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Retrieve funding wallet transfer by ID", + "tags": [ + "Funding Wallets" + ] + } + }, + "/v1beta/accounts/{account_id}/funding_wallet/withdrawal": { + "post": { + "description": "Creates a withdrawal", + "operationId": "createFundingWalletWithdrawal", + "parameters": [ + { + "description": "UUID alpaca account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateFundingWalletWithdrawalRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FundingWalletTransfer" + } + } + }, + "description": "Transfer" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Create a withdrawal", + "tags": [ + "Funding Wallets" + ] + } + }, + "/v1beta/accounts/funding_wallet": { + "post": { + "description": "Creates funding wallets for a list of accounts in a single request. Every `account_id` in the request must belong to your firm, and the request is rejected if a funding wallet already exists for any of the supplied accounts.", + "operationId": "batchCreateFundingWallets", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BatchCreateFundingWalletRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BatchCreateFundingWalletResponse" + } + } + }, + "description": "Funding wallets" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Batch create funding wallets", + "tags": [ + "Funding Wallets" + ] + } + }, + "/v1beta/demo/banking/funding": { + "post": { + "description": "Simulates an inbound deposit into an account's funding wallet for end-to-end testing of the deposit flow.\n\nThe transfer can only credit accounts that belong to your firm. Available in non-production (sandbox) environments only.", + "operationId": "demoDepositFunding", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DemoFundingTransfer" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DemoFundingTransfer" + } + } + }, + "description": "Demo deposit funding transfer" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Create sandbox deposit transfer", + "tags": [ + "Funding Wallets" + ] + } + }, + "/v1beta1/acats": { + "get": { + "description": "List all incoming and outgoing transfers, for all accounts. The list may include transfers not initiated using this API. The list is paginated: use the `page_token` query parameter with the value returned in the response to continue listing transfers.", + "operationId": "listACATSTransfers", + "parameters": [ + { + "description": "Filter by the account number associated with the transfer", + "in": "query", + "name": "account_number", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter by the type of the transfer", + "in": "query", + "name": "transfer_type", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsDtccTransferType" + } + }, + { + "description": "Filter by the direction of the transfer", + "in": "query", + "name": "transfer_direction", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsTransferDirection" + } + }, + { + "description": "Filter by the current status of the transfer", + "in": "query", + "name": "transfer_status", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsTransferStatus" + } + }, + { + "description": "Filter by the current DTCC status of the transfer", + "in": "query", + "name": "dtcc_status", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsDtccStatus" + } + }, + { + "description": "Filter by the contra broker number of the transfer", + "in": "query", + "name": "contra_broker_number", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "List transfers created at or after this RFC-3339 timestamp (e.g. `2026-01-01T00:00:00Z`).", + "in": "query", + "name": "since", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsTimestamp" + } + }, + { + "description": "List transfers created strictly before this RFC-3339 timestamp (exclusive -- e.g. `2026-01-01T00:00:00Z` excludes transfers created exactly at that instant).", + "in": "query", + "name": "until", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsTimestamp" + } + }, + { + "description": "Specify whether transfers should be sorted by creation time in ascending or descending order", + "in": "query", + "name": "sort_direction", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsSortDirection" + } + }, + { + "description": "Specify the field to sort by. Defaults to `created_at`.", + "in": "query", + "name": "sort_by", + "required": false, + "schema": { + "default": "created_at", + "enum": [ + "account_number", + "total_transfer_value", + "created_at", + "contra_account_number", + "contra_broker_number", + "external_transfer_id", + "settled_at", + "status", + "transfer_type", + "updated_at" + ], + "type": "string" + } + }, + { + "description": "Maximum number of transfers to return on one page", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "format": "int32", + "type": "integer" + } + }, + { + "description": "Page token for the next or previous page, used to continue listing transfers", + "in": "query", + "name": "page_token", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsPageToken" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsListTransfersResponse" + } + } + }, + "description": "OK" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Bad Request" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Forbidden" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "List transfers", + "tags": [ + "ACATS" + ] + } + }, + "/v1beta1/acats/{account_id}": { + "get": { + "description": "List all incoming and outgoing transfers where the account was one of the parties. The list may include transfers not initiated using this API. By default, the response includes all transfers for the account for backwards compatibility. To paginate results, provide the `limit` query parameter and use the `page_token` value returned in the response to continue listing transfers.", + "operationId": "listACATSTransfersByAccount", + "parameters": [ + { + "description": "Account ID associated with the ACATS transfer", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "Maximum number of transfers to return on one page", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "format": "int32", + "type": "integer" + } + }, + { + "description": "Page token for the next or previous page, used to continue listing transfers", + "in": "query", + "name": "page_token", + "required": false, + "schema": { + "$ref": "#/components/schemas/AcatsPageToken" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsListTransfersResponse" + } + } + }, + "description": "OK" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Forbidden" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "List transfers for an account", + "tags": [ + "ACATS" + ] + }, + "post": { + "description": "This endpoint allows you to create new incoming ACATS requests. We currently support full and partial transfer types, for US equities and cash. Note that after submitting a request, it might take some time for the transfer to show up on the other endpoints. Transfers are not immediately sent to DTCC, and will appear in the `PENDING` state initially.", + "operationId": "requestACATSTransfer", + "parameters": [ + { + "description": "Account ID associated with the ACATS transfer", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsInitiateTransferRequest" + } + } + }, + "description": "Details of the incoming ACATS transfer to initiate.", + "required": true + }, + "responses": { + "202": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsInitiateTransferResponse" + } + } + }, + "description": "Accepted" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Bad Request" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Forbidden" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Unprocessable Entity. Returned when:\n- the cleansed contra account number contains no digit at all;\n- `validate_account_number` is `true` and the contra account number matches none of the contra broker's enabled format rules;\n- the calling correspondent is pending migration, in which case the account is treated as being in distribution.\n" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "Initiate an incoming transfer", + "tags": [ + "ACATS" + ], + "x-readme": { + "code-samples": [ + { + "code": "curl --request POST \\\n --url https://broker-api.alpaca.markets/v1beta1/acats/{account_id} \\\n -u \"$BROKER_API_KEY:$BROKER_API_SECRET\" \\\n --header 'content-type: application/json' \\\n --data '{\n \"contra_account_details\": {\n \"broker_number\": \"0158\",\n \"account_number\": \"A00000123\",\n \"customer_name\": \"Jane Doe\",\n \"customer_tax_id\": \"123456789\"\n },\n \"transfer_details\": {\n \"type\": \"PARTIAL\",\n \"cash\": [\n { \"amount\": \"10000\", \"currency\": \"USD\" }\n ],\n \"securities\": {\n \"equities\": [\n { \"symbol\": \"AAPL\", \"qty\": \"2\", \"position\": \"LONG\" },\n { \"cusip\": \"123456789\", \"qty\": \"5\", \"position\": \"LONG\" },\n { \"symbol\": \"TSLA\", \"position\": \"SHORT\" }\n ]\n }\n },\n \"ip_address\": \"203.0.113.42\",\n \"signed_at\": \"2026-04-29T13:00:00Z\"\n }'", + "language": "shell", + "name": "Partial transfer (cash + equities)" + }, + { + "code": "curl --request POST \\\n --url https://broker-api.alpaca.markets/v1beta1/acats/{account_id} \\\n -u \"$BROKER_API_KEY:$BROKER_API_SECRET\" \\\n --header 'content-type: application/json' \\\n --data '{\n \"contra_account_details\": {\n \"broker_number\": \"0158\",\n \"account_number\": \"A00000123\",\n \"customer_name\": \"Jane Doe\",\n \"customer_tax_id\": \"123456789\"\n },\n \"transfer_details\": { \"type\": \"FULL\" },\n \"ip_address\": \"203.0.113.42\",\n \"signed_at\": \"2026-04-29T13:00:00Z\"\n }'", + "language": "shell", + "name": "Full transfer (entire account)" + } + ] + } + } + }, + "/v1beta1/acats/{account_id}/{acats_id}": { + "get": { + "description": "Includes the same information returned by the list transfers endpoints, but for just one transfer.", + "operationId": "getACATSTransfer", + "parameters": [ + { + "description": "Account ID associated with the ACATS transfer", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "The ID of the ACATS transfer", + "in": "path", + "name": "acats_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsTransfer" + } + } + }, + "description": "OK" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Not Found. No transfer with this `acats_id` exists for the given `account_id`." + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "Get transfer details", + "tags": [ + "ACATS" + ] + } + }, + "/v1beta1/acats/{account_id}/{acats_id}/assets": { + "get": { + "description": "Assets are only available for partial transfers and for transfers where the deliverer has already responded with the list of assets. The asset list may change as the transfer is updated by the deliverer, all the way up until the transfer settles.", + "operationId": "listACATSAssets", + "parameters": [ + { + "description": "Account ID associated with the ACATS transfer", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "The ID of the ACATS transfer", + "in": "path", + "name": "acats_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsListAssetsResponse" + } + } + }, + "description": "OK" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Forbidden" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Not Found. No transfer with this `acats_id` exists for the given `account_id`." + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "List assets for a transfer", + "tags": [ + "ACATS" + ] + } + }, + "/v1beta1/acats/contrabrokers": { + "get": { + "description": "This information is provided based on the latest ACATS Participant Master File, and contains the DTCC account numbers of valid contra brokers. Only participants that are either brokers or banks are returned. These numbers are the valid values for the `broker_number` property that is required for initiating transfers.", + "operationId": "listACATSContraBrokers", + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "brokers": [ + { + "name": "Example Brokerage Inc.", + "number": "0001", + "type": "BROKER" + }, + { + "name": "Example Bank, N.A.", + "number": "0002", + "type": "BANK" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/AcatsListContraBrokersResponse" + } + } + }, + "description": "OK" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Forbidden" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcatsError" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "List contra brokers", + "tags": [ + "ACATS" + ] + } + }, + "/v1beta1/logos/{symbol}": { + "get": { + "description": "Alpaca's Logo API serves uniform logo images for select stock and crypto symbols.\n\nNote: For Logo API pricing details, reach out to sales@alpaca.markets\n\nThe API response will return the raw image as a binary", + "operationId": "get-v1beta1-logos-symbol", + "parameters": [ + { + "description": "True by default, will return sample placeholder images with the first letter of the asset symbol. If false, 404 will be returned for symbols which do not contain an image.", + "in": "query", + "name": "placeholder", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The API response will return the raw image as a binary" + } + }, + "summary": "Get Logo", + "tags": [ + "Logos" + ] + }, + "parameters": [ + { + "description": "Stock or crypto symbol (e.g. AAPL, BTCUSD, etc.)", + "in": "path", + "name": "symbol", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/accounts": { + "get": { + "description": "Retrieves the first 1000 accounts that match the query parameters.\nSorting is based on creation time.\nThe created_after/created_before query parameters can be used to paginate the results.\nTo further limit the size of the response, the entities query parameter can be used to specify which properties are included in the response.\n", + "operationId": "getAllAccounts", + "parameters": [ + { + "description": "A space-delimited list of tokens. The response will contain accounts that match with all of the tokens (i.e. a logical AND). A match means the token is present in either the account's associated account number, phone number, name, or e-mail address (logical OR).", + "in": "query", + "name": "query", + "schema": { + "type": "string" + } + }, + { + "description": "Inclusive of timestamp. Example: 2019-10-12T07:20:50.52Z", + "in": "query", + "name": "created_after", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Inclusive of timestamp. Example: 2019-10-12T07:20:50.52Z", + "in": "query", + "name": "created_before", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "See the AccountStatus model for values", + "in": "query", + "name": "status", + "schema": { + "type": "string" + } + }, + { + "$ref": "#/components/parameters/Sort" + }, + { + "description": "Comma-delimited entity names to include in the response. If not specified, all entities are included.", + "in": "query", + "name": "entities", + "schema": { + "enum": [ + "agreements", + "contact", + "disclosures", + "documents", + "identity", + "trading_configurations", + "trusted_contact" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/AccountExtended" + }, + "type": "array" + } + } + }, + "description": "A list of accounts that match the query parameters.\n" + } + }, + "summary": "Get All Accounts", + "tags": [ + "Accounts" + ] + }, + "post": { + "description": "Create an account for a new or existing account holder. Required fields, eligibility, and initial status depend on the account type, enabled assets, and your correspondent configuration. Account status changes are available through the Account Status Events stream.\n\nTo create an account for an existing holder, provide `primary_account_holder_id` instead of inline holder information. Among the documented account types, existing holders are supported for trading and IRA accounts. Donor-advised accounts instead reference an existing legal entity with `entity_id`.\n", + "operationId": "createAccount", + "requestBody": { + "content": { + "application/json": { + "examples": { + "custodial-account": { + "summary": "Custodial account with guardian and minor information", + "value": { + "account_type": "custodial", + "agreements": [ + { + "agreement": "customer_agreement", + "ip_address": "185.13.21.99", + "signed_at": "2020-09-11T18:13:44Z" + } + ], + "contact": { + "city": "San Mateo", + "country": "USA", + "email_address": "john.doe@example.com", + "postal_code": "94401", + "state": "CA", + "street_address": [ + "123 Main Street" + ] + }, + "disclosures": { + "immediate_family_exposed": false, + "is_affiliated_exchange_or_finra": false, + "is_control_person": false, + "is_politically_exposed": false + }, + "enabled_assets": [ + "us_equity" + ], + "identity": { + "country_of_birth": "USA", + "country_of_citizenship": "USA", + "country_of_tax_residence": "USA", + "date_of_birth": "1990-01-01", + "family_name": "Doe", + "funding_source": [ + "employment_income" + ], + "given_name": "John", + "tax_id": "666-55-4321", + "tax_id_type": "USA_SSN" + }, + "minor_identity": { + "country_of_birth": "USA", + "country_of_citizenship": "USA", + "country_of_tax_residence": "USA", + "date_of_birth": "2012-04-05", + "email": "jamie.doe@example.com", + "family_name": "Doe", + "given_name": "Jamie", + "state": "CA", + "tax_id": "666-55-1234", + "tax_id_type": "USA_SSN" + } + } + }, + "donor-advised-account": { + "summary": "Donor-advised account for an existing legal entity", + "value": { + "account_type": "donor_advised", + "entity_id": "14fbfc51-3704-4c74-8984-8326c4117aee" + } + }, + "existing-holder-ira": { + "summary": "IRA account for an existing holder", + "value": { + "account_sub_type": "traditional", + "account_type": "ira", + "agreements": [ + { + "agreement": "customer_agreement", + "ip_address": "185.13.21.99", + "signed_at": "2020-09-11T18:13:44Z" + } + ], + "enabled_assets": [ + "us_equity" + ], + "primary_account_holder_id": "8b5b7e4c-9f2d-4f4a-9a7b-1b2c3d4e5f60" + } + }, + "trading-account": { + "summary": "Trading account with inline holder information", + "value": { + "agreements": [ + { + "agreement": "customer_agreement", + "ip_address": "185.13.21.99", + "signed_at": "2020-09-11T18:13:44Z" + } + ], + "contact": { + "city": "San Mateo", + "country": "USA", + "email_address": "john.doe@example.com", + "postal_code": "94401", + "state": "CA", + "street_address": [ + "123 Main Street" + ] + }, + "disclosures": { + "immediate_family_exposed": false, + "is_affiliated_exchange_or_finra": false, + "is_control_person": false, + "is_politically_exposed": false + }, + "enabled_assets": [ + "us_equity" + ], + "identity": { + "country_of_birth": "USA", + "country_of_citizenship": "USA", + "country_of_tax_residence": "USA", + "date_of_birth": "1990-01-01", + "family_name": "Doe", + "funding_source": [ + "employment_income" + ], + "given_name": "John", + "tax_id": "666-55-4321", + "tax_id_type": "USA_SSN" + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/AccountCreationRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Account" + } + } + }, + "description": "OK" + }, + "400": { + "content": { + "application/json": { + "examples": { + "malformed-request-body": { + "summary": "Malformed request body", + "value": { + "code": 40010000, + "message": "request body format is invalid: error decoding string '\"\"': can't convert \"\" to decimal" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request body is malformed or cannot be decoded." + }, + "409": { + "description": "There is already an existing account registered with the same email address." + }, + "422": { + "content": { + "application/json": { + "examples": { + "conflicting-holder-data": { + "summary": "Conflicting inline and referenced holder data", + "value": { + "code": 40010001, + "message": "cannot specify primary_account_holder_id together with identity or contact or disclosures or minor_identity" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request is well-formed but fails account-creation validation. This can include conflicting inline and referenced holder data, an unsupported account-type and holder combination, or an ineligible referenced party." + } + }, + "summary": "Create an Account", + "tags": [ + "Accounts" + ] + } + }, + "/v1/accounts/{account_id}": { + "get": { + "description": "You can query a specific account that you submitted to Alpaca by passing into the query the account_id associated with the account you're retrieving.\n", + "operationId": "getAccount", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountExtended" + } + } + }, + "description": "Will return an AccountExtended if an account with account_id exists, otherwise will throw an error." + } + }, + "summary": "Get An Account by ID", + "tags": [ + "Accounts" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "patch": { + "description": "This operation updates account information.\n\nIf all parameters are valid and updates have been made, it returns with status code 200. The response is the account model.", + "operationId": "patchAccount", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountUpdateRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountExtended" + } + } + }, + "description": "If all parameters are valid and updates have been made, it returns with status code 200. The response is the account model." + }, + "400": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "The post body is not well formed." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "cannot change primary account holder to: d4dbe130-839d-4e0a-8d2f-312a2011729c" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The requested update is forbidden. This includes attempting to change the immutable `primary_account_holder_id`." + }, + "422": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "The request body contains an attribute that is not permitted to be updated or you are attempting to set an invalid value." + } + }, + "summary": "Update an Account", + "tags": [ + "Accounts" + ] + } + }, + "/v1/accounts/{account_id}/ach_relationships": { + "get": { + "description": "Returns a list of ACH Relationships for an account", + "operationId": "getAccountACHRelationships", + "parameters": [ + { + "description": "Comma-separated status values", + "in": "query", + "name": "statuses", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/ACHRelationship" + }, + "type": "array" + } + } + }, + "description": "Success" + } + }, + "summary": "Retrieve ACH Relationships for an account", + "tags": [ + "Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "post": { + "description": "Create a new ACHRelationship for an account\n\nIf successful, will return 200 code with a newly created ACH Relationship entity.", + "operationId": "createACHRelationshipForAccount", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateACHRelationshipRequest" + } + } + }, + "description": "Create ACH Relationship ", + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ACHRelationship" + } + } + }, + "description": "returns the newly created ACH Relationship entity." + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "401": { + "$ref": "#/components/responses/NotAuthorized" + }, + "409": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account already has an active relationship." + } + }, + "summary": "Create an ACH Relationship", + "tags": [ + "Funding" + ] + } + }, + "/v1/accounts/{account_id}/ach_relationships/{ach_relationship_id}": { + "delete": { + "description": "Delete an existing ACH relationship for an account", + "operationId": "deleteACHRelationshipFromAccount", + "responses": { + "204": { + "description": "Success (No Content)" + }, + "400": { + "description": "the passed in account_id or relationship_id were invalid" + }, + "404": { + "description": "Relationship Not Found" + } + }, + "summary": "Delete an existing ACH relationship", + "tags": [ + "Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "ACH relationship identifier", + "in": "path", + "name": "ach_relationship_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ] + }, + "/v1/accounts/{account_id}/actions/close": { + "parameters": [ + { + "description": "The id of the account to be closed", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "post": { + "description": "This operation closes an active account. The underlying records and information of the account are not deleted by this operation.\n\n**Before closing an account, you are responsible for closing all the positions and withdrawing all the money associated with that account. Learn more in the Positions Documentation.**", + "operationId": "post-v1-accounts-account_id-actions-close", + "responses": { + "204": { + "description": "Success" + }, + "404": { + "description": "Account Not Found" + } + }, + "summary": "Close an Account", + "tags": [ + "Accounts" + ] + } + }, + "/v1/accounts/{account_id}/cip": { + "get": { + "description": "You can retrieve the CIP information you've submitted for a given account.", + "operationId": "get-v1-accounts-account_id-cip", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CIPInfo" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve CIP information", + "tags": [ + "KYC" + ] + }, + "parameters": [ + { + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "post": { + "description": "The customer identification program (CIP) API allows you to submit the CIP results received from your KYC provider.\n\nThe minimum requirements to open an individual financial account are delimited and you must verify the true identity of the account holder at account opening:\n\nName\nDate of birth\nAddress\nIdentification number (for a U.S. citizen, a taxpayer identification number)", + "operationId": "post-v1-accounts-account_id-cip", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CIPInfo" + } + } + } + }, + "responses": { + "200": { + "description": "OK" + } + }, + "summary": "Upload CIP information", + "tags": [ + "KYC" + ] + } + }, + "/v1/accounts/{account_id}/documents": { + "get": { + "description": "This endpoint allows you to query all the account document based on an account ID. You can filter by date, or type of document.\n\nThese account documents are tax statements, trade confirmations, etc, generated by the Alpaca system. They are distinct from the owner documents you upload and later access via the account object's documents property.", + "operationId": "getDocsForAccount", + "parameters": [ + { + "description": "optional date value to filter the list (inclusive).", + "in": "query", + "name": "start", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "optional date value to filter the list (inclusive).", + "in": "query", + "name": "end", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "$ref": "#/components/parameters/AccountDocumentType" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": {}, + "schema": { + "items": { + "$ref": "#/components/schemas/AccountDocument" + }, + "type": "array" + } + } + }, + "description": "OK" + }, + "404": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Not found" + } + }, + "summary": "Retrieve a List of Account Documents", + "tags": [ + "Documents" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ] + }, + "/v1/accounts/{account_id}/documents/{document_id}/download": { + "get": { + "description": "This endpoint downloads an account document based on the document ID. The document will be in PDF format.\n\nThe operation returns a pre-signed downloadable link as a redirect with HTTP status code 301 if one is found.\n\nYou can retrieve a JSON version of a monthly statement by passing in the header accept: application/json header.\n\nThese account documents are tax statements, trade confirmations, etc, generated by the Alpaca system. They are distinct from the owner documents you upload and later access via the account object's documents property.\n", + "operationId": "downloadDocFromAccount", + "responses": { + "301": { + "description": "Redirect to the pre-signed download link for the account document PDF file.\n" + }, + "404": { + "description": "The document is not found." + } + }, + "security": [ + { + "BasicAuth": [] + } + ], + "summary": "Download an Account Document", + "tags": [ + "Documents" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "$ref": "#/components/parameters/DocumentID" + } + ] + }, + "/v1/accounts/{account_id}/documents/upload": { + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "post": { + "description": "Upload documents for the primary account owner of an account.\n\nDocuments are binary objects whose contents are encoded in base64. Each encoded content size is limited to 10MB if you use Alpaca for KYCaaS. If you perform your own KYC there are no document size limitations.\n\nAs a convenience, documents of type w8ben may be uploaded as a JSON object using the content_data request property. The Alpaca system will then generate a formatted W-8 BEN document for subsequent downloads.\n\nNote that these owner documents are distinct from the account documents generated by Alpaca, such as tax statements and trade confirmations.", + "operationId": "uploadDocToAccount", + "requestBody": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/OwnerDocumentUploadRequest" + }, + "type": "array" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "Success (No Content)" + }, + "400": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Bad Request. The body in the request is not valid." + }, + "404": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Not Found. No account was found for this account_id" + } + }, + "summary": "Upload Owner Documents for an Existing Account", + "tags": [ + "Documents" + ] + } + }, + "/v1/accounts/{account_id}/documents/w8ben/{document_id}/download": { + "get": { + "description": "This endpoint allows you to download a W-8 BEN document for the primary owner of an account based on the document_id passed as a path parameter. The returned document is in PDF format.\n\nFor certain individuals, a W-8 BEN form should be submitted at onboarding. If the individual is not a registered U.S. taxpayer (not subject to a W-9), the W-8 BEN form may need to be submitted. The IRS explains which individuals this applies to and provides instructions on completing the form. Every three years, in addition to the calendar year it was signed, a new W-8 BEN form must be submitted.\n\nThe form can be submitted in JSON, JSONC, PNG, JPEG or PDF. If submitting it in JSON, please see the W-8 BEN completed with the corresponding field names for the API here.\n\nNote: The dates collected on the form are in a slightly different format than how they need to be submitted via Accounts API. It is requested by the user on the form in MM-DD-YYYY, but should be submitted as YYYY-MM-DD.", + "operationId": "get-v1-accounts-account_id-documents-w8ben-document_id-download", + "responses": { + "301": { + "description": "Redirects to a presigned download link for the document PDF." + }, + "404": { + "description": "Document Not Found" + } + }, + "summary": "Download the W8BEN document for the primary owner of an account", + "tags": [ + "Documents" + ] + }, + "parameters": [ + { + "description": "The id of the related account", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The id of the W8BEN to download", + "in": "path", + "name": "document_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/accounts/{account_id}/onfido/sdk": { + "parameters": [ + { + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "patch": { + "description": "This request allows you to send Alpaca the result of the Onfido SDK flow in your app. A notification of a successful outcome is required for Alpaca to continue the KYC process.", + "operationId": "patch-v1-accounts-account_id-onfido-sdk", + "requestBody": { + "content": { + "application/json": { + "examples": { + "Example 1": { + "value": { + "outcome": "USER_EXITED", + "reason": "User denied consent", + "token": "header.payload.signature" + } + } + }, + "schema": { + "properties": { + "outcome": { + "$ref": "#/components/schemas/OnfidoSDKOutcome" + }, + "reason": { + "description": "Any additional information related to the outcome", + "type": "string" + }, + "token": { + "description": "The SDK token associated with the SDK flow you are updating the outcome for", + "type": "string" + } + }, + "required": [ + "outcome", + "token" + ], + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "OK" + }, + "404": { + "description": "Account Not Found" + }, + "422": { + "description": "Invalid input value for outcome." + } + }, + "summary": "Update the Onfido SDK Outcome", + "tags": [ + "KYC" + ] + } + }, + "/v1/accounts/{account_id}/onfido/sdk/tokens": { + "get": { + "description": "Get an SDK token to activate the Onfido SDK flow within your app. You will have to keep track of the SDK token so you can pass it back when you upload the SDK outcome. We recommend storing the token in memory rather than persistent storage to reduce any unnecessary overhead in your app.", + "operationId": "get-v1-accounts-account_id-onfido-sdk-tokens", + "parameters": [ + { + "description": "The account ID", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "The referrer URL of your web app or the application ID of your mobile app. If not passed in, will default to the * wildcard", + "in": "query", + "name": "referrer", + "schema": { + "type": "string" + } + }, + { + "description": "Required if referrer provided. Enum values are either mobile or web", + "in": "query", + "name": "platform", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Example 1": { + "value": { + "token": "header.payload.signature" + } + } + }, + "schema": { + "properties": { + "token": { + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "OK" + }, + "422": { + "description": "Onfido applicant not yet created for account. If you haven't already contacted Alapca to enable Onfido, please do so." + } + }, + "summary": "Retrieve an Onfido SDK Token", + "tags": [ + "KYC" + ] + } + }, + "/v1/accounts/{account_id}/options/approval": { + "post": { + "description": "This endpoint requests options trading for an account.\nFollowing submission, an assigned administrator will review the request.\nUpon approval, the account's options_approved_level parameter will be modified, granting the account the ability to participate in options trading.\nNote: This endpoint is only available for partners who have been enabled for Options BETA.", + "operationId": "requestOptionsForAccount", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OptionsApprovalRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OptionsApprovalResponse" + } + } + }, + "description": "The request was submitted successfully." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request body is invalid." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Client does not exist, you do not have access to the client, or \"client_secret\" is incorrect.\n" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request body did not pass all validations." + } + }, + "summary": "Request options trading for an account (BETA)", + "tags": [ + "Accounts" + ] + } + }, + "/v1/accounts/{account_id}/recipient_banks": { + "get": { + "description": "Retrieves Bank Relationships for an account", + "operationId": "getRecipientBanks", + "parameters": [ + { + "in": "query", + "name": "status", + "schema": { + "enum": [ + "ACTIVE", + "INACTIVE" + ], + "example": "ACTIVE", + "type": "string" + } + }, + { + "in": "query", + "name": "bank_name", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Bank" + }, + "type": "array" + } + } + }, + "description": "An array of Bank relationships attached to this Account.\n\nAn empty array will be returned if no Bank relationships have been attached to this account" + }, + "400": { + "description": "Bad request. The body in the request is not valid." + } + }, + "summary": "Retrieve Bank Relationships for an Account", + "tags": [ + "Funding", + "Accounts" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "post": { + "description": "If successful, retrieves Bank Relationships for an account", + "operationId": "createRecipientBank", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateBankRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Bank" + } + } + }, + "description": "The created Bank relationship" + }, + "400": { + "description": "Bad Request" + }, + "409": { + "description": "A Bank relationship already exists for this account" + } + }, + "summary": "Create a Bank Relationship for an Account", + "tags": [ + "Funding", + "Accounts" + ] + } + }, + "/v1/accounts/{account_id}/recipient_banks/{bank_id}": { + "delete": { + "description": "If successful, deletes Bank Relationship for an account", + "operationId": "deleteRecipientBank", + "responses": { + "204": { + "description": "Success (No Content)" + }, + "400": { + "description": "Bad Request" + }, + "404": { + "description": "No Bank Relationship with the id specified by bank_id was found for this Account" + } + }, + "summary": "Delete a Bank Relationship for an Account", + "tags": [ + "Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "in": "path", + "name": "bank_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ] + }, + "/v1/accounts/{account_id}/tokenization/callback/mint": { + "post": { + "description": "This endpoint is used by the issuer to confirm the minting of tokenized assets previously requested by the Authorized Participant.", + "operationId": "postTokenizationCallbackMint", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenizationMintCallback" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenizationRequest" + } + } + }, + "description": "Successfully confirmed minting of a tokenized asset." + }, + "400": { + "content": { + "application/json": { + "example": { + "code": 40010000, + "message": "failed to decode request body" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Bad request (e.g. failed to decode request body)." + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "tokenization_request_id is required, tx_hash is required" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "One or more request parameters are missing or invalid." + } + }, + "summary": "Confirm Tokenized Asset Minted", + "tags": [ + "Tokenization" + ] + } + }, + "/v1/accounts/{account_id}/tokenization/callback/redeem": { + "post": { + "description": "This endpoint is used by the tokenized asset issuer to confirm the redemption of tokens previously held in the Authorized Participant's wallet. When the issuer invokes this endpoint, Alpaca will initiate a journal of the underlying asset into the Authorized Participant's account.\n\n**Idempotency**: When the `Idempotency-Key` header is supplied, this endpoint is\nidempotent. Multiple requests with the same key and identical request body will\ncreate only one redeem request. A subsequent request returns the previously created\nrequest with the same response (no duplicate is created). If the same key is used\nwith a different request body, the API returns `422 Unprocessable Entity`.\n\n**Recommended for production**: Always supply `Idempotency-Key` when requesting a\nredemption. This allows safe retries on timeouts, network errors, or 5xx responses\nwithout risking duplicate requests. Use a client-generated unique value (e.g. UUID).", + "operationId": "postTokenizationRedeem", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "$ref": "#/components/parameters/LegacyIdempotencyKey" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenizationRedeemRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenizationRedeemResponse" + } + } + }, + "description": "Successfully requested redemption of a tokenized asset." + }, + "400": { + "content": { + "application/json": { + "example": { + "code": 40010000, + "message": "failed to decode request body" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Bad request (e.g. malformed input, insufficient quantity, or account not authorized to redeem). Also returned when the `Idempotency-Key` header is malformed, or when replaying a request that was originally rejected." + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "issuer_request_id is required, tx_hash is required" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "One or more request parameters are missing or invalid, or the same `Idempotency-Key` was reused with a different request body." + } + }, + "summary": "Redeem a Tokenized Asset", + "tags": [ + "Tokenization" + ] + } + }, + "/v1/accounts/{account_id}/tokenization/mint": { + "post": { + "description": "This endpoint is used by an Authorized Participant to request the minting of a tokenized asset. Alpaca will initiate a journal of the underlying asset from the Authorized Participant's account to the issuer's account.\n\n**Idempotency**: When the `Idempotency-Key` header is supplied, this endpoint is\nidempotent. Multiple requests with the same key and identical request body will\ncreate only one mint request. A subsequent request returns the previously created\nrequest with the same response (no duplicate is created). If the same key is used\nwith a different request body, the API returns `422 Unprocessable Entity`.\n\n**Recommended for production**: Always supply `Idempotency-Key` when requesting a\nmint. This allows safe retries on timeouts, network errors, or 5xx responses\nwithout risking duplicate requests. Use a client-generated unique value (e.g. UUID).", + "operationId": "postTokenizationMintBroker", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "$ref": "#/components/parameters/LegacyIdempotencyKey" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenizationMintRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenizationMintResponse" + } + } + }, + "description": "Successfully requested minting of a tokenized asset." + }, + "400": { + "content": { + "application/json": { + "example": { + "code": 40010000, + "message": "failed to decode request body" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Bad request (e.g. malformed input, insufficient position, or account not authorized to mint). Also returned when the `Idempotency-Key` header is malformed, or when replaying a request that was originally rejected." + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "issuer is required, network is required" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "One or more request parameters are missing or invalid, or the same `Idempotency-Key` was reused with a different request body." + } + }, + "summary": "Mint a Tokenized Asset", + "tags": [ + "Tokenization" + ] + } + }, + "/v1/accounts/{account_id}/tokenization/requests": { + "get": { + "description": "Retrieve tokenization requests for the account. This endpoint may be used by the tokenized asset issuer or by an Authorized Participant (AP). The list can contain both mint and redeem requests.", + "operationId": "getTokenizationRequestsBroker", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "Tokenization request type to be queried", + "in": "query", + "name": "type", + "schema": { + "enum": [ + "mint", + "redeem" + ], + "type": "string" + } + }, + { + "description": "Tokenization request status to be queried", + "in": "query", + "name": "status", + "schema": { + "enum": [ + "pending", + "rejected", + "completed" + ], + "type": "string" + } + }, + { + "description": "Underlying symbol of the tokenization requests to be queried", + "in": "query", + "name": "underlying_symbol", + "schema": { + "type": "string" + } + }, + { + "description": "Issuer of the tokenization requests to be queried", + "in": "query", + "name": "issuer", + "schema": { + "$ref": "#/components/schemas/TokenizationIssuer" + } + }, + { + "description": "Network of the tokenization requests to be queried", + "in": "query", + "name": "network", + "schema": { + "$ref": "#/components/schemas/TokenizationNetwork" + } + }, + { + "description": "The response will include only requests created after this timestamp (exclusive)", + "in": "query", + "name": "after", + "schema": { + "example": "2025-09-30T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + }, + { + "description": "The response will include only requests created before this timestamp (exclusive)", + "in": "query", + "name": "before", + "schema": { + "example": "2025-09-30T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/TokenizationRequest" + }, + "type": "array" + } + } + }, + "description": "Successful response\n\nA list of tokenization requests" + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "failed to parse after" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "One or more request parameters are missing or invalid." + } + }, + "summary": "List Tokenization Requests", + "tags": [ + "Tokenization" + ] + } + }, + "/v1/accounts/{account_id}/tokenization/requests/{tokenization_request_id}": { + "get": { + "description": "Retrieve a single tokenization request by its `tokenization_request_id`. This endpoint may be used by the tokenized asset issuer or by an Authorized Participant (AP), and returns either a mint or a redeem request.", + "operationId": "getTokenizationRequestByIDBroker", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "Unique identifier of the tokenization request, as returned by the mint endpoint or the list-requests endpoint.", + "in": "path", + "name": "tokenization_request_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "created_at": "2025-11-04T18:38:01.942282Z", + "fees": "0.5", + "issuer": "xstocks", + "network": "solana", + "qty": "1.0", + "status": "completed", + "token_symbol": "TSLAx", + "tokenization_request_id": "5b1d6a3e-7f0a-4d2c-b8e1-9e6f1c0d2c4a", + "tx_hash": "5J7ZxK4QwR3vH2pY1aB6sN8cM9tD0fA2eXyVwUjL3kPqR4mZcF7nB1tA8sH6dG2pE", + "type": "mint", + "underlying_symbol": "TSLA", + "updated_at": "2025-11-04T18:38:42.117004Z", + "wallet_address": "5dXY1aH2tQpV3wXmJg6Z7c8B4nKvF9bA1pQrSt2uVwYxXz" + }, + "schema": { + "$ref": "#/components/schemas/TokenizationRequest" + } + } + }, + "description": "Successful response" + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "404": { + "content": { + "application/json": { + "example": { + "code": 40410000, + "message": "tokenization request not found" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "No tokenization request with the supplied `tokenization_request_id` exists for this account." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "tokenization_request_id is not a valid UUID" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The `tokenization_request_id` path parameter is not a valid UUID." + } + }, + "summary": "Get Tokenization Request by ID", + "tags": [ + "Tokenization" + ] + } + }, + "/v1/accounts/{account_id}/tokenization/requests:by_client_request_id": { + "get": { + "description": "Retrieve a single tokenization request by the Authorized Participant's `client_request_id`, the AP-supplied label originally passed on the mint request. Available to Authorized Participants and to issuers that are affiliated with the AP. Returns the matching mint request. If the AP has reused a `client_request_id` across multiple requests, the most recently created request is returned.", + "operationId": "getTokenizationRequestByClientRequestIDBroker", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "AP-supplied request identifier originally passed on the mint request, echoed back on the tokenization-request response.", + "in": "query", + "name": "client_request_id", + "required": true, + "schema": { + "example": "ap-request-2025-11-04-001", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "created_at": "2025-11-04T18:38:01.942282Z", + "fees": "0.5", + "issuer": "xstocks", + "network": "solana", + "qty": "1.0", + "status": "completed", + "token_symbol": "TSLAx", + "tokenization_request_id": "5b1d6a3e-7f0a-4d2c-b8e1-9e6f1c0d2c4a", + "tx_hash": "5J7ZxK4QwR3vH2pY1aB6sN8cM9tD0fA2eXyVwUjL3kPqR4mZcF7nB1tA8sH6dG2pE", + "type": "mint", + "underlying_symbol": "TSLA", + "updated_at": "2025-11-04T18:38:42.117004Z", + "wallet_address": "5dXY1aH2tQpV3wXmJg6Z7c8B4nKvF9bA1pQrSt2uVwYxXz" + }, + "schema": { + "$ref": "#/components/schemas/TokenizationRequest" + } + } + }, + "description": "Successful response" + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "404": { + "content": { + "application/json": { + "example": { + "code": 40410000, + "message": "tokenization request not found" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "No tokenization request with the supplied `client_request_id` exists for this account." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "client_request_id query parameter is required" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The `client_request_id` query parameter is missing." + } + }, + "summary": "Get Tokenization Request by `client_request_id`", + "tags": [ + "Tokenization" + ] + } + }, + "/v1/accounts/{account_id}/tokenization/requests:by_issuer_request_id": { + "get": { + "description": "Retrieve a single tokenization request by the `issuer_request_id`. Returns either a mint or a redeem request. Can be called by issuers only.", + "operationId": "getTokenizationRequestByIssuerRequestIDBroker", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "Issuer-assigned request identifier returned to the AP on the original mint or redeem response and visible to the issuer on rows it owns.", + "in": "query", + "name": "issuer_request_id", + "required": true, + "schema": { + "example": "ABCDEF123", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "created_at": "2025-11-04T18:38:01.942282Z", + "fees": "0.5", + "issuer": "xstocks", + "issuer_request_id": "issuer-req-12345", + "network": "solana", + "qty": "1.0", + "status": "completed", + "token_symbol": "TSLAx", + "tokenization_request_id": "5b1d6a3e-7f0a-4d2c-b8e1-9e6f1c0d2c4a", + "tx_hash": "5J7ZxK4QwR3vH2pY1aB6sN8cM9tD0fA2eXyVwUjL3kPqR4mZcF7nB1tA8sH6dG2pE", + "type": "mint", + "underlying_symbol": "TSLA", + "updated_at": "2025-11-04T18:38:42.117004Z", + "wallet_address": "5dXY1aH2tQpV3wXmJg6Z7c8B4nKvF9bA1pQrSt2uVwYxXz" + }, + "schema": { + "$ref": "#/components/schemas/TokenizationRequest" + } + } + }, + "description": "Successful response" + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "404": { + "content": { + "application/json": { + "example": { + "code": 40410000, + "message": "tokenization request not found" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "No tokenization request with the supplied `issuer_request_id` exists for this account, or the caller is not the tokenized asset issuer." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "issuer_request_id query parameter is required" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The `issuer_request_id` query parameter is missing." + } + }, + "summary": "Get Tokenization Request by `issuer_request_id`", + "tags": [ + "Tokenization" + ] + } + }, + "/v1/accounts/{account_id}/transfers": { + "get": { + "description": "You can query a list of transfers for an account.\n\n\nYou can filter requested transfers by values such as direction and status.\n\nReturns a list of transfer entities ordered by created_at\n", + "operationId": "getTransfersForAccount", + "parameters": [ + { + "description": "INCOMING or OUTGOING", + "in": "query", + "name": "direction", + "schema": { + "enum": [ + "INCOMING", + "OUTGOING" + ], + "type": "string" + } + }, + { + "in": "query", + "name": "limit", + "schema": { + "format": "int32", + "type": "integer" + } + }, + { + "in": "query", + "name": "offset", + "schema": { + "format": "int32", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "example-1": { + "value": [ + { + "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65", + "additional_information": "string", + "amount": "string", + "bank_id": "f1ae96de-94c1-468e-93a3-6b7213930ca8", + "created_at": "2019-08-24T14:15:22Z", + "direction": "INCOMING", + "expires_at": "2019-08-24T14:15:22Z", + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "ira": { + "distribution_reason": "normal", + "fed_withholding_amount": "102.5", + "fed_withholding_pct": "10.25", + "state_withholding_amount": "97.5", + "state_withholding_pct": "9.75", + "tax_year": "2024" + }, + "reason": "string", + "relationship_id": "81412018-ffa2-43f9-a3eb-d39f1c5e0f87", + "status": "QUEUED", + "type": "ach", + "updated_at": "2019-08-24T14:15:22Z" + } + ] + }, + "example-2": { + "value": [ + { + "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65", + "additional_information": "string", + "amount": "string", + "bank_id": "f1ae96de-94c1-468e-93a3-6b7213930ca8", + "created_at": "2019-08-24T14:15:22Z", + "direction": "INCOMING", + "expires_at": "2019-08-24T14:15:22Z", + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "ira": { + "distribution_reason": "normal", + "fed_withholding_amount": "102.5", + "fed_withholding_pct": "10.25", + "state_withholding_amount": "97.5", + "state_withholding_pct": "9.75", + "tax_year": "2024" + }, + "reason": "string", + "relationship_id": "81412018-ffa2-43f9-a3eb-d39f1c5e0f87", + "status": "QUEUED", + "type": "ach", + "updated_at": "2019-08-24T14:15:22Z" + } + ] + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/Transfer" + }, + "type": "array" + } + } + }, + "description": "Success." + } + }, + "summary": "Retrieve List of Transfers for an Account.", + "tags": [ + "Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "post": { + "description": "Create a new transfer to deposit money into or withdraw money from an account.\n\nTwo `transfer_type` values are accepted, and both are available in sandbox and production:\n\n- **`ach`** — supports both `INCOMING` (deposit) and `OUTGOING` (withdrawal) directions. A `relationship_id` from a previously created [ACH Relationship](https://docs.alpaca.markets/reference/createachrelationshipforaccount) is required.\n- **`wire`** — supports the `OUTGOING` (withdrawal) direction only. Incoming wires cannot be initiated through this endpoint; they are pushed in by the sending bank and recorded automatically. A `bank_id` from a previously created [Bank Relationship](https://docs.alpaca.markets/reference/createrecipientbank) is required, and the bank must be in `APPROVED` status before the transfer will progress past `QUEUED`.\n\nIn the sandbox environment, ACH deposits and withdrawals settle instantly against virtual funds. Outgoing wire withdrawals are accepted and simulated end-to-end — no funds are transmitted to a bank, but the transfer progresses to `COMPLETE` and the account is debited against virtual funds. Sandbox wire withdrawals are asynchronous (not instant) and auto-complete on weekdays only; transfers submitted on a weekend will not progress until Monday. For more on funding accounts in sandbox, see [this tutorial](https://alpaca.markets/learn/fund-broker-api/).", + "operationId": "createTransferForAccount", + "parameters": [ + { + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTransferRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Transfer" + } + } + }, + "description": "Successfully requested a transfer." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request body is malformed (e.g. invalid JSON)." + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account is not permitted to perform this transfer. Examples include:\n\n- `deposits are not permitted for this account` — the account's `depositable_status` is not `allowed` / `limited`.\n- `withdrawals are not permitted for this account` — the account's `withdrawable_status` is not `allowed` / `limited`.\n" + }, + "422": { + "content": { + "application/json": { + "examples": { + "wireIncomingRejected": { + "summary": "Wire transfer with direction = INCOMING", + "value": { + "code": 40010001, + "message": "cannot submit incoming wire transfer using this API" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request was rejected by validation. Common reasons include:\n\n- `cannot submit incoming wire transfer using this API` — sent `transfer_type: wire` with `direction: INCOMING`. Incoming wires cannot be initiated through this endpoint.\n- `invalid relationship_id` / `bank_id required for wire transfer` — missing the required relationship/bank identifier for the chosen `transfer_type`.\n- `bank_id should be empty for ach transfer` / `relationship_id should be empty for wire transfer` — provided the wrong identifier for the chosen `transfer_type`.\n- `only wire transfer type can provide additional information for the transfer` — `additional_information` was supplied on a non-wire request.\n- `amount must be greater than 0.00` / `deposit amount must be greater than or equal to ` / `withdrawal amount must be greater than ` — amount fails the minimum-amount checks.\n- `transfer_type must be either ach or wire` / `direction must be either incoming or outgoing` — invalid enum values.\n" + } + }, + "summary": "Request a New Transfer", + "tags": [ + "Funding", + "Accounts" + ] + } + }, + "/v1/accounts/{account_id}/transfers/{transfer_id}": { + "delete": { + "description": "Request to close a transfer", + "operationId": "deleteTransfer", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "Transfer identifier", + "in": "path", + "name": "transfer_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Success" + }, + "404": { + "description": "Transfer Not Found" + } + }, + "summary": "Request to Close a Transfer", + "tags": [ + "Funding" + ] + } + }, + "/v1/accounts/{account_id}/wallets": { + "get": { + "description": "Lists wallets for the account given in the path parameter. If an asset is specified and no wallet for the account and asset pair exists one will be created. If no asset is specified only existing wallets will be listed for the account. An account may have at most one wallet per asset.", + "operationId": "listCryptoFundingWallets", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CryptoWallet" + } + } + }, + "description": "A single wallet object if an asset is specified or an array of wallet objects if no asset is specified" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Retrieve Crypto Funding Wallets", + "tags": [ + "Crypto Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "in": "query", + "name": "asset", + "schema": { + "type": "string" + } + }, + { + "description": "Optional chain identifier. Use to request wallets for a specific chain when asset is a multi-chain crypto asset. If not specified, network is considered.", + "in": "query", + "name": "chain", + "schema": { + "enum": [ + "SOL", + "ETH", + "BTC", + "XRP", + "ARB" + ], + "type": "string" + } + }, + { + "description": "Deprecated. Use chain instead. Optional network identifier which is used to request wallets for a specific network when asset is a multi-chain crypto asset. When both 'chain' and 'network' are specified, 'chain' will take precedence and 'network' will be ignored. If 'chain' and 'network' are not specified, the default 'network' (ethereum) will be used.", + "in": "query", + "name": "network", + "schema": { + "deprecated": true, + "enum": [ + "ethereum", + "solana" + ], + "type": "string" + } + } + ] + }, + "/v1/accounts/{account_id}/wallets/transfers": { + "get": { + "description": "Returns an array of all transfers associated with the given account across all wallets.", + "operationId": "listCryptoFundingTransfers", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CryptoTransfer" + } + } + }, + "description": "An array of transfer objects" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Retrieve Crypto Funding Transfers", + "tags": [ + "Crypto Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "post": { + "description": "Creates a withdrawal request. Note that outgoing withdrawals must be sent to a whitelisted address and you must whitelist addresses at least 24 hours in advance. If you attempt to withdraw funds to a non-whitelisted address then the transfer will be rejected.", + "operationId": "createCryptoTransferForAccount", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCryptoTransferRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CryptoTransfer" + } + } + }, + "description": "Successfully requested a transfer." + }, + "400": { + "content": { + "application/json": { + "examples": { + "TravelRuleValidationError": { + "$ref": "#/components/examples/TravelRuleValidationError" + }, + "WalletError": { + "value": { + "message": "asset cannot be empty" + } + } + }, + "schema": { + "$ref": "#/components/schemas/TravelRuleErrorResponse" + } + } + }, + "description": "The request or travel rule information is invalid." + } + }, + "summary": "Request a New Withdrawal", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v1/accounts/{account_id}/wallets/transfers/{transfer_id}": { + "get": { + "description": "Returns a specific wallet transfer by passing into the query the transfer_id.", + "operationId": "getCryptoFundingTransfer", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CryptoTransfer" + } + } + }, + "description": "A single crypto transfer object" + } + }, + "summary": "Retrieve a Crypto Funding Transfer", + "tags": [ + "Crypto Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "The crypto transfer to retrieve", + "in": "path", + "name": "transfer_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/accounts/{account_id}/wallets/whitelists": { + "get": { + "description": "Returns the list of whitelisted withdrawal addresses for the specified account.", + "operationId": "listWhitelistedAddress", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WhitelistedAddress" + } + } + }, + "description": "An array of whitelisted objects" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "An array of whitelisted addresses", + "tags": [ + "Crypto Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "post": { + "description": "Submits a new whitelisted withdrawal address for the specified account. The chain is derived from the supplied asset symbol and address, and the same address cannot be whitelisted twice on the same chain.\n\nWhere travel rule reporting applies to the account, supply travel rule information for the destination wallet. Use the `Search VASPs` endpoint to find the VASP DID for the destination exchange. For a self-hosted wallet, set `beneficiary_is_self_hosted` to true. If the exchange is not in the directory, provide its information in `beneficiary_manual_entry`.\n\nNote that whitelisted addresses must wait at least 24 hours before they can be used as a withdrawal destination.", + "operationId": "createWhitelistedAddress", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "address": { + "description": "The address to be whitelisted", + "type": "string" + }, + "asset": { + "description": "Symbol of underlying asset for the whitelisted address", + "type": "string" + }, + "chain": { + "description": "Optional chain identifier. Use when the underlying asset for the whitelisted address is a multi-chain crypto asset.", + "enum": [ + "SOL", + "ETH", + "BTC", + "XRP", + "ARB" + ], + "type": "string" + }, + "travel_rule_info": { + "$ref": "#/components/schemas/TravelRuleInfo" + } + }, + "type": "object" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WhitelistedAddress" + } + } + }, + "description": "Successfully requested a whitelisted address" + }, + "400": { + "content": { + "application/json": { + "examples": { + "TravelRuleValidationError": { + "$ref": "#/components/examples/TravelRuleValidationError" + }, + "WalletError": { + "value": { + "message": "asset cannot be empty" + } + } + }, + "schema": { + "$ref": "#/components/schemas/TravelRuleErrorResponse" + } + } + }, + "description": "The request or travel rule information is invalid." + } + }, + "summary": "Request a new whitelisted address", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v1/accounts/{account_id}/wallets/whitelists/{whitelisted_address_id}": { + "delete": { + "description": "Deletes a whitelisted withdrawal address from the specified account by ID. Subsequent withdrawals targeting the deleted address will be rejected.", + "operationId": "deleteWhitelistedAddress", + "responses": { + "200": { + "description": "Successfully deleted a whitelisted address" + } + }, + "summary": "Delete a whitelisted address", + "tags": [ + "Crypto Funding" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "The whitelisted address to delete", + "in": "path", + "name": "whitelisted_address_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/accounts/{account_id}/wallets/whitelists/{whitelisted_address_id}/travel-rule-info": { + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "The whitelisted address update travel rule information for", + "in": "path", + "name": "whitelisted_address_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "patch": { + "description": "You are required to supply travel rule information for the crypto wallets you're withdrawing to.\n\nIt is preferred that you use the `Search VASPs` endpoint to find the VASP DID for the exchange you are withdrawing to,\notherwise, if it's a self-hosted wallet, please set `beneficiary_is_self_hosted` to true.\n\nIf the exchange cannot be found in our directory, please supply the information manually using the `beneficiary_manual_entry` object.", + "operationId": "updateWhitelistedAddressTravelRuleInfo", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateWhitelistedAddressTravelRuleInfoRequest" + } + } + }, + "description": "Travel rule information to associate with the whitelisted address.", + "required": true + }, + "responses": { + "200": { + "description": "Successfully updated travel rule information" + }, + "400": { + "content": { + "application/json": { + "examples": { + "TravelRuleValidationError": { + "$ref": "#/components/examples/TravelRuleValidationError" + }, + "WalletError": { + "value": { + "message": "travel_rule_info is missing" + } + } + }, + "schema": { + "$ref": "#/components/schemas/TravelRuleErrorResponse" + } + } + }, + "description": "The request or travel rule information is invalid." + } + }, + "summary": "Update travel rule information for a whitelisted wallet", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v1/accounts/activities": { + "get": { + "description": "Returns a list of activities\n\nNotes:\n* Pagination is handled using the `page_token` and `page_size` parameters.\n* `page_token` represents the ID of the last item on your current page of results.\n For example, if the ID of the last activity in your first response is `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you would pass that value as `page_token` to retrieve the next page of results.\n\n* If specified with a `direction` of `desc`, for example, the results will end before the activity with the specified ID.\n* If specified with a `direction` of `asc`, results will begin with the activity immediately after the one specified.\n* `page_size` is the maximum number of entries to return in the response.\n* If `date` is not specified, the default and maximum value is 100.\n* If `date` is specified, the default behavior is to return all results, and there is no maximum page size.", + "operationId": "getAccountActivities", + "parameters": [ + { + "description": "id of a single account to filter by", + "in": "query", + "name": "account_id", + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "A comma-separated list of activity types used to filter the results.", + "explode": false, + "in": "query", + "name": "activity_types", + "schema": { + "items": { + "$ref": "#/components/schemas/ActivityType" + }, + "type": "array" + }, + "style": "form" + }, + { + "description": "The activity category. Cannot be used with \"activity_types\" parameter.", + "in": "query", + "name": "category", + "schema": { + "enum": [ + "trade_activity", + "non_trade_activity" + ], + "type": "string" + } + }, + { + "description": "Filter activities associated with a specific order. Useful for retrieving the fills that make up a completely filled order.", + "in": "query", + "name": "order_id", + "schema": { + "example": "fe060a1b-5b45-4eba-ba46-c3a3345d8255", + "format": "uuid", + "type": "string" + } + }, + { + "description": "Filter activities by their creation date (created_at), not the activity's settlement date. For non-trade activities such as fees, the creation date is typically the day after the trade date (in UTC). Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "date", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Get activities created before this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Get activities created after this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "after", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "$ref": "#/components/parameters/Direction" + }, + { + "description": "The maximum number of entries to return in the response.", + "in": "query", + "name": "page_size", + "schema": { + "default": 100, + "maximum": 100, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Token used for pagination. Provide the ID of the last activity from the last page to retrieve the next set of results.", + "in": "query", + "name": "page_token", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Activity" + }, + "type": "array" + } + } + }, + "description": "Success" + } + }, + "summary": "Retrieve Account Activities", + "tags": [ + "Accounts" + ] + } + }, + "/v1/accounts/activities/{activity_type}": { + "get": { + "description": "Retrieves an array of Activity by type.\n\nIf {activity_type} is provided as part of the URL, category cannot be provided as query parameter. They are mutually exclusive.\n\nNotes:\n* Pagination is handled using the `page_token` and `page_size` parameters.\n* `page_token` represents the ID of the end of your current page of results.\n for example if in your first response the id of the last Activiy item returned in the array was `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you'd pass that value as `page_token` to get the next page of results\n\n* If specified with a `direction` of `desc`, for example, the results will end before the activity with the specified ID.\n* If specified with a `direction` of `asc`, results will begin with the activity immediately after the one specified.\n* `page_size` is the maximum number of entries to return in the response.\n* If `date` is not specified, the default and maximum value is 100.\n* If `date` is specified, the default behavior is to return all results, and there is no maximum page size.", + "operationId": "getAccountActivitiesByType", + "parameters": [ + { + "description": "id of a single account to filter by", + "in": "query", + "name": "account_id", + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "Filter activities associated with a specific order. Useful for retrieving the fills that make up a completely filled order.", + "in": "query", + "name": "order_id", + "schema": { + "example": "fe060a1b-5b45-4eba-ba46-c3a3345d8255", + "format": "uuid", + "type": "string" + } + }, + { + "description": "Filter activities by their creation date (created_at), not the activity's settlement date. For non-trade activities such as fees, the creation date is typically the day after the trade date (in UTC). Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "date", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Get activities created before this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Get activities created after this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "after", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "$ref": "#/components/parameters/Direction" + }, + { + "description": "The maximum number of entries to return in the response.", + "in": "query", + "name": "page_size", + "schema": { + "default": 100, + "maximum": 100, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Token used for pagination. Provide the ID of the last activity from the last page to retrieve the next set of results.", + "in": "query", + "name": "page_token", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Activity" + }, + "type": "array" + } + } + }, + "description": "Success" + } + }, + "summary": "Retrieve Account Activities of Specific Type", + "tags": [ + "Accounts" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/ActivityType" + } + ] + }, + "/v1/accounts/ira_excess_contributions": { + "get": { + "description": "Returns all overcontributed IRA accounts", + "operationId": "listIRAExcessContritbutions", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/OvercontributedIRAAccount" + }, + "type": "array" + } + } + }, + "description": "list of overcontributed IRA accounts" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Retrieve Excess Contributions", + "tags": [ + "IRA" + ] + } + }, + "/v1/accounts/options/approvals": { + "get": { + "description": "This endpoint retrieves options trading level approval requests. Query parameters can be specified to filter the results. If multiple query parameters are specified, the results will be filtered to include only those that match all of the specified parameters. Each query parameter can only be specified once.", + "operationId": "requestListOptionsApprovals", + "parameters": [ + { + "description": "Only return results for the specified account.", + "in": "query", + "name": "account_id", + "schema": { + "example": "c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4", + "format": "uuid", + "type": "string" + } + }, + { + "in": "query", + "name": "requested_level", + "schema": { + "description": "Only return requests with the specified requested level.\n0=Disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.\n", + "enum": [ + 0, + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + } + }, + { + "in": "query", + "name": "approved_level", + "schema": { + "description": "Only return requests with the specified approved level.\n0=Disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.\n", + "enum": [ + 0, + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + } + }, + { + "description": "Only return requests with the specified approval request status.", + "in": "query", + "name": "status", + "schema": { + "$ref": "#/components/schemas/OptionsApprovalStatus" + } + }, + { + "description": "The maximum number of results to return. The default (and maximum value) is 1000.", + "in": "query", + "name": "page_size", + "schema": { + "default": 1000, + "maximum": 1000, + "minimum": 1, + "type": "integer" + } + }, + { + "$ref": "#/components/parameters/PageToken" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OptionsApprovalsList" + } + } + }, + "description": "The request was submitted successfully." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request body is invalid." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Client does not exist, you do not have access to the client, or \"client_secret\" is incorrect.\n" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The correspondent entity does not have access to options approvals or the account does not exist.\n" + } + }, + "summary": "Retrieve options level approval requests (BETA)", + "tags": [ + "Accounts" + ] + } + }, + "/v1/accounts/positions": { + "get": { + "deprecated": true, + "description": "Retrieves a list of the account's open positions.\nThis endpoint is deprecated and will be removed in the future. Please use the [GET /v1/reporting/eod/positions endpoint](https://docs.alpaca.markets/reference/get-v1-reporting-eod-positions) instead.\n", + "operationId": "get-v1-accounts-positions", + "parameters": [ + { + "description": "The number of the page of the results to be fetched.", + "in": "query", + "name": "page", + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Example 1": { + "value": { + "as_of": "2022-08-04T16:00:00-04:00", + "positions": { + "000c8a47-7487-430b-94e1-e628a71cd123": [ + { + "asset_class": "us_equity", + "asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "asset_marginable": true, + "avg_entry_price": "172.34", + "change_today": "0", + "cost_basis": "13.63999992516", + "current_price": "166.13", + "exchange": "NASDAQ", + "lastday_price": "166.13", + "market_value": "13.14850404762", + "qty": "0.079145874", + "qty_available": "0.079145874", + "side": "long", + "symbol": "AAPL", + "unrealized_intraday_pl": "0", + "unrealized_intraday_plpc": "0", + "unrealized_pl": "-0.49149587754", + "unrealized_plpc": "-0.0360334223047464" + } + ] + } + } + } + }, + "schema": { + "properties": { + "as_of": { + "format": "date-time", + "type": "string" + }, + "positions": { + "type": "object" + } + }, + "type": "object" + } + } + }, + "description": "The response contains two fields:\n\nasof: the timestamp for which the positions are returned. It is always the last market close\n\npositions: an account-id to position list map, contains the requested page's accounts\nThe positions map is empty for the last page.\n\nNote: when fetching bulk positions, which can take multiple minutes depending on the number of accounts managed have, a market close can happen, and after that a new set of results might be returned. To make sure results are consistent, please always check that the as_of field didn't change during the whole fetching process." + } + }, + "summary": "Bulk Fetch All Accounts Positions", + "tags": [ + "Trading" + ] + } + }, + "/v1/assets": { + "get": { + "description": "Returns all assets", + "operationId": "getAssets", + "parameters": [ + { + "description": "Asset status to filter by, will default to `all`", + "in": "query", + "name": "status", + "schema": { + "default": "all", + "enum": [ + "active", + "inactive", + "all" + ], + "example": "all", + "type": "string" + } + }, + { + "description": "Asset class to filter by, `us_equity` or `crypto`. Defaults to `us_equity`", + "in": "query", + "name": "asset_class", + "schema": { + "default": "us_equity", + "enum": [ + "us_equity", + "crypto" + ], + "example": "us_equity", + "type": "string" + } + }, + { + "description": "Comma separated values to query for more than one attribute. Assets which have any of the given attributes will be included.\n\nSupported values:\n- `ptp_no_exception`: Asset is a Publicly Traded Partnership (PTP) without a qualified notice; non-U.S. customers may incur 10% withholding on gross proceeds as per IRS guidance, and are blocked from being purchased by default.\n- `ptp_with_exception`: Users can open positions in these PTPs without general restrictions.\n- `ipo`: Accepting limit orders only before the stock begins trading on the secondary market.\n- `has_options`: The underlying equity has listed options available on the platform. Note: if the equity had inactive/expired contracts in the past, this will still show up.\n- `options_late_close`: Indicates the underlying asset's options contracts close at 4:15pm ET instead of the standard 4:00pm ET.\n- `fractional_eh_enabled`: Indicates the asset accepts fractional orders during extended hours sessions (pre-market, post-market, and overnight if enabled).\n- `overnight_tradable`: Asset is eligible for overnight (24x5) trading in supported venues on the platform.\n- `overnight_halted`: Asset is eligible for overnight trading but is currently halted/blocked for overnight sessions due to risk, corporate action, compliance, or venue constraints.", + "explode": false, + "in": "query", + "name": "attributes", + "schema": { + "default": [], + "example": [ + "ptp_no_exception", + "ipo" + ], + "items": { + "enum": [ + "ptp_no_exception", + "ptp_with_exception", + "ipo", + "has_options", + "options_late_close", + "fractional_eh_enabled", + "overnight_tradable", + "overnight_halted" + ], + "type": "string" + }, + "type": "array" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Asset" + }, + "type": "array" + } + } + }, + "description": "An array of asset objects." + } + }, + "summary": "Retrieve All Assets", + "tags": [ + "Assets" + ] + } + }, + "/v1/assets/{symbol_or_asset_id}": { + "get": { + "description": "Returns the requested asset, if found", + "operationId": "getAssetBySymbolOrId", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Asset" + } + } + }, + "description": "Returns asset" + }, + "404": { + "description": "Asset not found" + } + }, + "summary": "Retrieve an Asset by ID", + "tags": [ + "Assets" + ] + }, + "parameters": [ + { + "description": "you can use either the asset's Id or the symbol to search", + "in": "path", + "name": "symbol_or_asset_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/assets/entry-requirements": { + "get": { + "description": "Returns all entry-requirements", + "operationId": "get-asset-entry-requirements", + "parameters": [ + { + "description": "Comma-separated symbols or asset ids. The symbols (or asset ids) for which asset entry requirements are to be requested. Maximum number of symbols allowed is 500.", + "example": "AAPL,SPY", + "in": "query", + "name": "symbols", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/AssetEntryRequirements" + }, + "type": "array" + } + } + }, + "description": "An array of asset entry requirement objects." + } + }, + "summary": "Retrieve Entry Requirements for requested assets", + "tags": [ + "Assets" + ] + } + }, + "/v1/assets/fixed_income/us_corporates": { + "get": { + "description": "Serves the list of US corporates available at Alpaca. The response is sorted by ISIN.", + "operationId": "UsCorporates", + "parameters": [ + { + "in": "query", + "name": "bond_status", + "schema": { + "$ref": "#/components/schemas/bond_status" + } + }, + { + "description": "A comma-separated list of ISINs with a limit of 1000.", + "example": "US912810UG12,US912797PM34", + "in": "query", + "name": "isins", + "schema": { + "type": "string" + } + }, + { + "description": "A comma-separated list of CUSIPs with a limit of 1000.", + "example": "912810UG1,912797PM3", + "in": "query", + "name": "cusips", + "schema": { + "type": "string" + } + }, + { + "description": "A comma-separated list of tickers with a limit of 1000.", + "example": "BAC,MSFT", + "in": "query", + "name": "tickers", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/us_corporates_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get US corporates", + "tags": [ + "Assets" + ] + } + }, + "/v1/assets/fixed_income/us_treasuries": { + "get": { + "description": "Serves the list of US treasuries available at Alpaca. The response is sorted by ISIN.", + "operationId": "UsTreasuries", + "parameters": [ + { + "in": "query", + "name": "subtype", + "schema": { + "$ref": "#/components/schemas/treasury_subtype" + } + }, + { + "in": "query", + "name": "bond_status", + "schema": { + "$ref": "#/components/schemas/bond_status" + } + }, + { + "description": "A comma-separated list of CUSIPs with a limit of 1000.", + "example": "912810UG1,912797PM3", + "in": "query", + "name": "cusips", + "schema": { + "type": "string" + } + }, + { + "description": "A comma-separated list of ISINs with a limit of 1000.", + "example": "US912810UG12,US912797PM34", + "in": "query", + "name": "isins", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/us_treasuries_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get US treasuries", + "tags": [ + "Assets" + ] + } + }, + "/v1/calendar": { + "get": { + "description": "The calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results. In addition to the dates, the response also contains the specific open and close times for the market days, taking into account early closures.\n", + "operationId": "LegacyCalendar", + "parameters": [ + { + "$ref": "#/components/parameters/legacy_start" + }, + { + "$ref": "#/components/parameters/legacy_end" + }, + { + "$ref": "#/components/parameters/legacy_date_type" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/legacy_public_calendar_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get US Market Calendar", + "tags": [ + "Calendar" + ] + } + }, + "/v1/cash_interest/apr_tiers": { + "get": { + "description": "List all available APR tiers. These tiers may be assigned to an account, and will be used to determine the interest rate paid on uninvested cash balances.", + "operationId": "get-v1-list-apr-tiers", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListAPRTiersResponse" + } + } + }, + "description": "Successful response, returns a list of APR tiers or none if no tiers are available." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Unauthorized. Please check your API key and try again." + }, + "429": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Too many requests. Please wait a moment and try again." + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "A server error occurred. Please contact Alpaca." + } + }, + "summary": "List APR Tiers", + "tags": [ + "Cash Interest" + ] + } + }, + "/v1/clock": { + "get": { + "description": "The clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close.\n", + "operationId": "LegacyClock", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/legacy_clock" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get US Market Clock", + "tags": [ + "Calendar" + ] + } + }, + "/v1/corporate_actions/announcements": { + "get": { + "deprecated": true, + "description": "This endpoint is deprecated, please use [the new corporate actions endpoint](https://docs.alpaca.markets/reference/corporateactions-1) instead.", + "operationId": "getCorporateAnnouncements", + "parameters": [ + { + "description": "A comma-delimited list of CorporateActionType values", + "in": "query", + "name": "ca_types", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The start (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days.", + "in": "query", + "name": "since", + "required": true, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "The end (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days.", + "in": "query", + "name": "until", + "required": true, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "The symbol of the company initiating the announcement.", + "in": "query", + "name": "symbol", + "schema": { + "type": "string" + } + }, + { + "description": "The CUSIP of the company initiating the announcement.", + "in": "query", + "name": "cusip", + "schema": { + "type": "string" + } + }, + { + "description": "An emum of possible ways to use the `since` and `until` parameters to search by.\n\nthe types are:\n\n- **declaration_date**: The date of the preliminary announcement details or the date that any subsequent term updates took place.\n- **ex_date**: The date on which any security purchasing activity will not result in a corporate action entitlement. Any selling activity that takes place on or after this date will result in a corporate action entitlement.\n- **record_date**: The date the company checks its records to determine who is shareholder in order to allocate entitlements.\n- **payable_date**: The date that the stock and cash positions will update according to the account positions as of the record date.", + "in": "query", + "name": "date_type", + "schema": { + "enum": [ + "declaration_date", + "ex_date", + "record_date", + "payable_date" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Announcement" + }, + "type": "array" + } + } + }, + "description": "OK" + }, + "400": { + "$ref": "#/components/responses/BadRequest" + } + }, + "summary": "Retrieve Announcements", + "tags": [ + "Corporate Actions" + ] + } + }, + "/v1/corporate_actions/announcements/{id}": { + "get": { + "deprecated": true, + "description": "This endpoint is deprecated, please use [the new corporate actions endpoint](https://docs.alpaca.markets/reference/corporateactions-1) instead.", + "operationId": "get-GET-v1-corporate_actions-announcements-id", + "responses": { + "200": { + "description": "An Announcement object." + }, + "400": { + "description": "The body in the request is not valid" + }, + "422": { + "description": "Invalid input value." + }, + "500": { + "description": "A server error occurred. Please contact Alpaca." + } + }, + "summary": "Retrieve a Specific Announcement", + "tags": [ + "Corporate Actions" + ] + }, + "parameters": [ + { + "description": "The id of the corporate action announcement to be returned.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/country-info": { + "get": { + "description": "The Country Info API serves country information for every supported countries including risk ratings and supported crypto states where applicable.", + "operationId": "queryCountryInfos", + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "countries": { + "summary": "Example response", + "value": { + "USA": { + "crypto_risk_rating": "medium", + "crypto_supported_states": [ + "CA", + "CT", + "GA", + "IA", + "ID", + "IL", + "IN", + "KS", + "KY", + "MA", + "MD", + "ME", + "MI", + "MS", + "MO", + "MT", + "NC", + "ND", + "NE", + "OH", + "RI", + "SD", + "UT", + "VT", + "WA" + ], + "full_name": "United States of America", + "securities_risk_rating": "medium" + }, + "ZAF": { + "crypto_risk_rating": "high", + "full_name": "South Africa", + "securities_risk_rating": "high" + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/CountryInfos" + } + } + }, + "description": "Returns the countries information as a map" + } + }, + "summary": "Retrieve countries information", + "tags": [ + "Country Info" + ] + } + }, + "/v1/events/accounts/status": { + "get": { + "description": "The accounts events API provides streaming of account changes as they occur, via SSE (server sent events). Past events can also be queried.\n\nEvents are generated for changes to the following account properties:\n- account_blocked\n- admin_configurations\n- cash_interest\n- crypto_status\n- kyc_results\n- options\n- status\n- trading_blocked\n\nOnly the changed properties are included in the event payload.\n\nQuery Parameter Rules:\n- `since_id` and `until_id` are deprecated and available only to select broker partners; use `since_ulid` and `until_ulid` instead\n- `since` is required if `until` specified\n- `since_id` is required if `until_id` specified\n- `since_ulid` is required if `until_ulid` specified\n- `since`, `since_id` and `since_ulid` can't be used at the same time\n\nBehavior:\nThis API supports querying a range of events, starting now or in the past. If the end of the range is in the future or not specified, the connection is kept open and future events are pushed.\n\nTo be specific:\n- if `since`, `since_id` or `since_ulid` is not specified, this will not return any historic data\n- if `until`, `until_id` or `until_ulid` is reached, the stream will end with a status of 200\n\n---\n\nNote for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correctly in OAS-3.\n", + "operationId": "suscribeToAccountStatusSSE", + "parameters": [ + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "deprecated": true, + "in": "query", + "name": "since_id", + "schema": { + "type": "integer" + }, + "x-deprecation": { + "reason": "Use since_ulid instead.", + "since": "2023-08-01", + "sunset": "2027-02-15" + } + }, + { + "deprecated": true, + "in": "query", + "name": "until_id", + "schema": { + "type": "integer" + }, + "x-deprecation": { + "reason": "Use until_ulid instead.", + "since": "2023-08-01", + "sunset": "2027-02-15" + } + }, + { + "in": "query", + "name": "since_ulid", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_ulid", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "id", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "examples": {}, + "schema": { + "items": { + "$ref": "#/components/schemas/AccountStatusEvent" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to Account Status Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v1/events/journals/status": { + "get": { + "description": "The Events API provides event push as well as historical queries via SSE (server sent events).\n\nYou can listen to journal status updates as they get processed by our backoffice.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery Params Rules:\n- `since_id` and `until_id` are deprecated and available only to select broker partners; use `since_ulid` and `until_ulid` instead\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since_ulid` required if `until_ulid` specified\n- `since`, `since_id` or `since_ulid` can't be used at the same time\nBehavior:\n- if `since`, `since_id` or `since_ulid` not specified this will not return any historic data\n- if `until`, `until_id` or `until_ulid` reached stream will end (status 200)\n\n---\n\nThere is no compatibility between /v1/events/journals/status and /v2/events/journals/status, the ids (ulid) are always different, and the number of events might also different\n\nPlease note that the new `/v2` endpoint, is the same as, and was originally available under `/v2beta1`.\nWe encourage all customers to adjust their codebase from that interim beta endpoint to the `/v2` stable endpoint.\nIn the near future we will setup permanent redirect from `/v2beta1` to `/v2` before we completely remove the beta endpoint.\n\n---\n\nNote for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correctly in OAS-3.\n", + "operationId": "subscribeToJournalStatusSSE", + "parameters": [ + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "deprecated": true, + "in": "query", + "name": "since_id", + "schema": { + "type": "integer" + }, + "x-deprecation": { + "reason": "Use since_ulid instead.", + "since": "2023-08-01", + "sunset": "2027-02-15" + } + }, + { + "deprecated": true, + "in": "query", + "name": "until_id", + "schema": { + "type": "integer" + }, + "x-deprecation": { + "reason": "Use until_ulid instead.", + "since": "2023-08-01", + "sunset": "2027-02-15" + } + }, + { + "in": "query", + "name": "since_ulid", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_ulid", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "id", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "items": { + "$ref": "#/components/schemas/JournalStatusEvent" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to Journal Events (SSE) (Legacy)", + "tags": [ + "Events" + ] + } + }, + "/v1/events/nta": { + "get": { + "description": "The Events API provides event push as well as historical queries via SSE (server sent events).\n\nYou can listen to non-trading activities updates as they get processed by our backoffice, for both end-user and firm accounts.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nYou can listen to when NTAs are pushed such as CSDs, JNLC (journals) or FEEs.\n\nQuery Params Rules:\n- `since_id` and `until_id` are deprecated and available only to select broker partners; use `since_ulid` and `until_ulid` instead\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since_ulid` required if `until_ulid` specified\n- `since`, `since_id` or `since_ulid` can't be used at the same time\nBehavior:\n- if `since`, `since_id` or `since_ulid` not specified this will not return any historic data\n- if `until`, `until_id` or `until_ulid` reached stream will end (status 200)'", + "operationId": "get-v1-events-nta", + "parameters": [ + { + "in": "query", + "name": "id", + "schema": { + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "deprecated": true, + "in": "query", + "name": "since_id", + "schema": { + "type": "integer" + }, + "x-deprecation": { + "reason": "Use since_ulid instead.", + "since": "2023-08-01", + "sunset": "2027-02-15" + } + }, + { + "deprecated": true, + "in": "query", + "name": "until_id", + "schema": { + "type": "integer" + }, + "x-deprecation": { + "reason": "Use until_ulid instead.", + "since": "2023-08-01", + "sunset": "2027-02-15" + } + }, + { + "in": "query", + "name": "since_ulid", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_ulid", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "include_preprocessing", + "schema": { + "type": "boolean" + } + }, + { + "description": "ID used to link activities who share a sibling relationship", + "in": "query", + "name": "group_id", + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "$ref": "#/components/schemas/NonTradeActivityEvent" + } + } + }, + "description": "OK" + } + }, + "summary": "Subscribe to Non-Trading Activities Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v1/events/transfers/status": { + "get": { + "deprecated": true, + "description": "**Deprecation notice**\n\nAs part of the deprecation process, the legacy transfer events API is now only available for existing broker-partners at `GET /v1/events/transfers/status` and for compatibility reasons.\n\nAll new broker partners will not have the option to use the legacy transfer events endpoint.\n\nThey should integrate with the new `/v2/events/funding/status` endpoint instead.\n\nAlso, all existing broker partners are now recommended to upgrade to the `/v2/events/funding/status` endpoint, which provides faster event delivery times.\n\n---\n\nThe Events API provides event push as well as historical queries via SSE (server sent events).\n\nYou can listen to transfer status updates as they get processed by our backoffice, for both end-user and firm accounts.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery Params Rules:\n- `since_id` and `until_id` are deprecated and available only to select broker partners; use `since_ulid` and `until_ulid` instead\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since_ulid` required if `until_ulid` specified\n- `since`, `since_id` or `since_ulid` can't be used at the same time\nBehavior:\n- if `since`, `since_id` or `since_ulid` not specified this will not return any historic data\n- if `until`, `until_id` or `until_ulid` reached stream will end (status 200)\n\n---\n\nNote for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correctly in OAS-3.", + "operationId": "subscribeToTransferStatusSSE", + "parameters": [ + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "deprecated": true, + "in": "query", + "name": "since_id", + "schema": { + "type": "integer" + }, + "x-deprecation": { + "reason": "Use since_ulid instead.", + "since": "2023-08-01", + "sunset": "2027-02-15" + } + }, + { + "deprecated": true, + "in": "query", + "name": "until_id", + "schema": { + "type": "integer" + }, + "x-deprecation": { + "reason": "Use until_ulid instead.", + "since": "2023-08-01", + "sunset": "2027-02-15" + } + }, + { + "in": "query", + "name": "since_ulid", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_ulid", + "schema": { + "format": "ulid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "items": { + "$ref": "#/components/schemas/TransferStatusEvent" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + }, + "410": { + "description": "Deprecated. The endpoint is not available for this partner." + } + }, + "summary": "Subscribe to Transfer Events (SSE) (Legacy)", + "tags": [ + "Events" + ] + } + }, + "/v1/fpsl/analytics/{account_id}/loans": { + "get": { + "description": "Returns aggregated FPSL interest and loan-activity counts for one account over a date range. Use this for \"earned so far this month\" customer UIs and for supervisory spot-checks against your internal accrual model.\n\nThe `{account_id}` path parameter accepts a account UUID (aggregation for that account).", + "operationId": "get-v1-fpsl-analytics-account-loans", + "parameters": [ + { + "description": "The account identifier (account UUID).", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "Filter loans after or on this start date (inclusive). Defaults to the first day of the current month, New York timezone.", + "in": "query", + "name": "start", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter loans before this end date (exclusive). Defaults to the day after the current date, New York timezone.", + "in": "query", + "name": "end", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLAnalyticsLoansResponse" + } + } + }, + "description": "Returns the aggregated FPSL loan analytics for the account." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLError" + } + } + }, + "description": "One of the request parameters is invalid. See the returned message for details." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLError" + } + } + }, + "description": "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key." + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLError" + } + } + }, + "description": "User has no access to a resource." + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLError" + } + } + }, + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on Slack or on the Community Forum." + } + }, + "summary": "Read FPSL Loans Analytics for an Account", + "tags": [ + "FPSL Program" + ] + } + }, + "/v1/fpsl/loans": { + "get": { + "description": "Returns a list of all FPSL loans that match the specified filter criteria, ordered in ascending order by `date`, `account_number`, and `symbol`. Each entry represents a loan of a `symbol` on a given `date`, made on behalf of the specified `account_number`.", + "operationId": "get-v1-list-fpsl-loans", + "parameters": [ + { + "description": "The account identifier", + "in": "query", + "name": "account_id", + "required": false, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "Filter loans after or on this start date.", + "in": "query", + "name": "start", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter loans before this end date.", + "in": "query", + "name": "end", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "The pagination token used to continue retrieving results. This value is returned in certain responses when additional data is available, typically due to a response size limit.", + "in": "query", + "name": "page_token", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "The maximum number of data points to return in the response page.", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "default": 1000, + "maximum": 10000, + "minimum": 1, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListFPSLLoansResponse" + } + } + }, + "description": "Returns a list of FPSL loans for the account, or an empty list if no loans are found." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLError" + } + } + }, + "description": "One of the request parameters is invalid. See the returned message for details." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLError" + } + } + }, + "description": "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key." + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLError" + } + } + }, + "description": "User has no access to a resource." + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FPSLError" + } + } + }, + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on Slack or on the Community Forum." + } + }, + "summary": "List FPSL Loans", + "tags": [ + "FPSL Program" + ] + } + }, + "/v1/fpsl/tiers": { + "get": { + "description": "List all available FPSL tiers. These tiers may be assigned to an account.", + "operationId": "get-v1-list-fpsl-tiers", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/FPSLTier" + }, + "type": "array" + } + } + }, + "description": "Successful response, returns a list of FPSL tiers or none if no tiers are available." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Unauthorized. Please check your API key and try again." + }, + "429": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Too many requests. Please wait a moment and try again." + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "A server error occurred. Please contact Alpaca." + } + }, + "summary": "List FPSL Tiers", + "tags": [ + "FPSL Program" + ] + } + }, + "/v1/instant_funding": { + "get": { + "description": "Returns a list of instant funding records based on the query parameters. The results are\npaginated, sorted, and filtered based on the parameters provided.", + "operationId": "get-v1-instant-funding-list", + "parameters": [ + { + "description": "sort results based on created_at, amount, and deadline", + "in": "query", + "name": "sort_by", + "required": false, + "schema": { + "$ref": "#/components/schemas/ListSortBy" + } + }, + { + "description": "Defines the ordering of sort_by query. Defaults to ASC when not specified.", + "in": "query", + "name": "sort_order", + "required": false, + "schema": { + "$ref": "#/components/schemas/SortOrder" + } + }, + { + "description": "defines the number of results that will be returned from the request", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "maximum": 100, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "defines the number of results that will be skipped before picking the results that will be returned", + "in": "query", + "name": "offset", + "required": false, + "schema": { + "minimum": 1, + "type": "integer" + } + }, + { + "description": "filter transfers based on system date", + "in": "query", + "name": "system_date", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "filter transfers based on settlement deadline", + "in": "query", + "name": "deadline", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "filter transfers based on status", + "in": "query", + "name": "status", + "required": false, + "schema": { + "$ref": "#/components/schemas/InstantFundingStatus" + } + }, + { + "description": "filter transfers based on the date of creation", + "in": "query", + "name": "before", + "required": false, + "schema": { + "format": "date-time", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/InstantFunding" + }, + "type": "array" + } + } + }, + "description": "list of transfers" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Get Instant Funding List", + "tags": [ + "Instant Funding" + ] + }, + "post": { + "description": "Creates an instant funding request. The request will be processed and the funds will be\nmade available to the account in the form of a Memopost non trade activity. Upon settlement\nthe Memoposted will be corrected to a CSD activity.\n\n**Idempotency**: When the `Idempotency-Key` header is supplied, this endpoint is\nidempotent. Multiple requests with the same key and identical request body will\ncreate only one transfer. A subsequent request returns the previously created\ntransfer with the same response (no duplicate is created). If the same key is used\nwith a different request body, the API returns `422 Unprocessable Entity`.\n\n**Recommended for production**: Always supply `Idempotency-Key` when creating\ntransfers. This allows safe retries on timeouts, network errors, or 5xx responses\nwithout risking duplicate transfers. Use a client-generated unique value (e.g. UUID).\n", + "operationId": "post-v1-instant-funding", + "parameters": [ + { + "$ref": "#/components/parameters/LegacyIdempotencyKey" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateIFTransferRequest" + } + } + }, + "description": "details of the instant funding request", + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InstantFunding" + } + } + }, + "description": "Instant transfer request created." + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Unprocessable Entity. Returned when an idempotency key is reused with a different request body." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Create an instant funding request", + "tags": [ + "Instant Funding" + ] + } + }, + "/v1/instant_funding/{instant_funding_id}": { + "delete": { + "description": "Cancels a single instant funding request based on the ID supplied if possible.", + "operationId": "delete-v1-instant-funding-single", + "parameters": [ + { + "description": "UUID ID of the instant funding transfer to cancel", + "in": "path", + "name": "instant_funding_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "Successful response." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Cancel an instant funding request", + "tags": [ + "Instant Funding" + ] + }, + "get": { + "description": "Returns an instant funding transfer based on the ID supplied.", + "operationId": "get-v1-instant-funding-single", + "parameters": [ + { + "description": "ID of the instant funding transfer", + "in": "path", + "name": "instant_funding_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InstantFunding" + } + } + }, + "description": "Successful response." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Get an instant funding request", + "tags": [ + "Instant Funding" + ] + } + }, + "/v1/instant_funding/limits": { + "get": { + "description": "Returns globally configured limits for the correspondent. These limits are used to determine\nthe maximum amount that can be extended to all accounts, and reaching this limit will result\nin further requests to create instant funding requests being rejected.", + "operationId": "get-v1-instant-funding-correspondent-limits", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CorrespondentLimit" + } + } + }, + "description": "correspondent instant funding limits" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Get instant funding limits", + "tags": [ + "Instant Funding" + ] + } + }, + "/v1/instant_funding/limits/accounts": { + "get": { + "description": "Returns the limits for individual partner accounts.", + "operationId": "get-v1-instant-funding-account-limits", + "parameters": [ + { + "description": "Filter limits based on comma-separated account numbers", + "explode": false, + "in": "query", + "name": "account_numbers", + "required": true, + "schema": { + "items": { + "type": "string" + }, + "type": "array" + }, + "style": "form" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/AccountLimit" + }, + "type": "array" + } + } + }, + "description": "invidual broker account limits" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Get instant funding account limits", + "tags": [ + "Instant Funding" + ] + } + }, + "/v1/instant_funding/reports": { + "get": { + "description": "Returns instant funding reports which are to be used for daily reconciliation reporting.", + "operationId": "get-v1-instant-funding-reports", + "parameters": [ + { + "description": "The report type to be returned; 'summary' or 'detail', defaults to 'summary'", + "in": "query", + "name": "report_type", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "The system date to be used for the report. If not provided then the last system date will be used.\n", + "in": "query", + "name": "system_date", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/ReportsResponse" + }, + "type": "array" + } + } + }, + "description": "Successful response." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Get instant funding report", + "tags": [ + "Instant Funding" + ] + } + }, + "/v1/instant_funding/settlements": { + "get": { + "description": "Returns all settlements filtered by status if provided.", + "operationId": "get-v1-instant-funding-settlements", + "parameters": [ + { + "description": "comma delimited list of statuses to use as a filter", + "in": "query", + "name": "statuses", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettlementsResponse" + } + } + }, + "description": "Successful response." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "List settlements", + "tags": [ + "Instant Funding" + ] + }, + "post": { + "description": "Creates a new settlement, which will trigger the reconciliation process for all included\ntransfers and their interests. There is a limit of 50,000 transfers per settlement. If more\nthan 50,000 transfers need to be settled, they should be batched in multiple settlements.", + "operationId": "post-v1-instant-funding-settlements", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateSettlementRequest" + } + } + }, + "description": "details of the settlement request", + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettlementResponse" + } + } + }, + "description": "Settlement created." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Create a new settlement", + "tags": [ + "Instant Funding" + ] + } + }, + "/v1/instant_funding/settlements/{settlement_id}": { + "get": { + "description": "Returns the settlement specified by the path parameter.", + "operationId": "get-v1-instant-funding-settlements-single", + "parameters": [ + { + "description": "ID of the settlement", + "in": "path", + "name": "settlement_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettlementResponse" + } + } + }, + "description": "Successful response." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Get a single settlement", + "tags": [ + "Instant Funding" + ] + } + }, + "/v1/ipos": { + "get": { + "description": "Returns a paginated list of IPO offerings currently known to Alpaca.\n\nUse this endpoint to power IPO discovery surfaces (e.g. an \"Upcoming IPOs\" list). Real-time lifecycle changes (availability, prospectus, 60-minute mail, allocations, cancellations) are pushed over the [IPO Events Stream](#operation/subscribeToIPOEventsSSE).\n", + "operationId": "listIPOOfferings", + "parameters": [ + { + "description": "Filter by offering availability.\n- `available` - accepting new orders.\n- `not_available` - not yet open for orders.\n- `closed` - no longer accepting orders.\n", + "in": "query", + "name": "availability", + "schema": { + "enum": [ + "available", + "not_available", + "closed" + ], + "type": "string" + } + }, + { + "description": "Filter by ticker symbol (case-insensitive exact match).", + "example": "EXMP", + "in": "query", + "name": "ticker", + "schema": { + "type": "string" + } + }, + { + "description": "Maximum number of offerings to return per page. Capped at `200`.", + "in": "query", + "name": "limit", + "schema": { + "default": 50, + "maximum": 200, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Opaque cursor returned in the previous response's `next_page_token` field. Pass it back to fetch the next page.", + "in": "query", + "name": "page_token", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "default": { + "$ref": "#/components/examples/IPOOfferingListExample" + } + }, + "schema": { + "$ref": "#/components/schemas/IPOOfferingListResponse" + } + } + }, + "description": "A page of IPO offerings." + } + }, + "summary": "List IPO Offerings", + "tags": [ + "IPO" + ] + } + }, + "/v1/ipos/{offering_reference}": { + "get": { + "description": "Returns a single IPO offering by `offering_reference`.\n\nThe `offering_reference` value matches the one delivered on the [IPO Events Stream](#operation/subscribeToIPOEventsSSE).\n", + "operationId": "getIPOOffering", + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "default": { + "$ref": "#/components/examples/IPOOfferingGetExample" + } + }, + "schema": { + "$ref": "#/components/schemas/IPOOfferingResponse" + } + } + }, + "description": "The requested IPO offering." + }, + "404": { + "description": "No IPO offering exists for the given `offering_reference`." + } + }, + "summary": "Retrieve an IPO Offering", + "tags": [ + "IPO" + ] + }, + "parameters": [ + { + "description": "The unique offering identifier (also referred to as `ipo_reference` in the response body).", + "example": "FI111225", + "in": "path", + "name": "offering_reference", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/jit/settlements": { + "get": { + "description": "Returns all JIT settlements filtered by status if provided.", + "operationId": "get-v1-jit-settlements", + "parameters": [ + { + "description": "comma delimited list of statuses to use as a filter", + "in": "query", + "name": "statuses", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettlementsResponse" + } + } + }, + "description": "Successful response." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "List all JIT Settlements", + "tags": [ + "Funding" + ] + }, + "post": { + "description": "Creates a new JIT settlement, which will trigger the reconciliation process for all included accounts. There is a limit of 150,000 accounts per settlement. If more than 150,000 accounts need to be settled, they should be batched in multiple settlements.\n", + "operationId": "post-v1-jit-settlements", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateJITSettlementRequest" + } + } + }, + "description": "details of the JIT settlement request", + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettlementResponse" + } + } + }, + "description": "Settlement created." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Create a new JIT settlement", + "tags": [ + "Funding" + ] + } + }, + "/v1/jit/settlements/{settlement_id}": { + "get": { + "description": "Returns the JIT settlement specified by the path parameter.", + "operationId": "get-v1-jit-settlements-single", + "parameters": [ + { + "description": "ID of the JIT settlement", + "in": "path", + "name": "settlement_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettlementResponse" + } + } + }, + "description": "Successful response." + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Error response." + } + }, + "summary": "Get a single JIT settlement", + "tags": [ + "Funding" + ] + } + }, + "/v1/journals": { + "get": { + "description": "Returns an array of journal objects.", + "operationId": "getAllJournals", + "parameters": [ + { + "description": "By journal creation date. Format: 2020-01-01", + "in": "query", + "name": "after", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "By journal creation date. Format: 2020-01-01", + "in": "query", + "name": "before", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "See the JournalStatus model for more info", + "in": "query", + "name": "status", + "schema": { + "$ref": "#/components/schemas/JournalStatus" + } + }, + { + "description": "JNLC or JNLS", + "in": "query", + "name": "entry_type", + "schema": { + "enum": [ + "JNLC", + "JNLS" + ], + "type": "string" + } + }, + { + "description": "The account id that received the journal", + "in": "query", + "name": "to_account", + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "The account id that initiated the journal", + "in": "query", + "name": "from_account", + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "The maximum number of results to return", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Journal" + }, + "type": "array" + } + } + }, + "description": "OK" + }, + "400": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "One of the parameters is invalid." + }, + "422": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Result set exceeds 100,000 records." + } + }, + "summary": "Retrieve a List Journals", + "tags": [ + "Journals" + ] + }, + "post": { + "description": "A journal can be JNLC (move cash) or JNLS (move shares), dictated by `entry_type`. Generally, journal requests are subject to approval and starts from the `pending` status. The status changes are propagated through the Event API. Under certain conditions agreed for the partner, such journal transactions that meet the criteria are executed right away.\n\n**Idempotency**: Reusing the same key with an identical request returns the\npreviously created journal without creating a duplicate. Reusing the same key with\na different request returns `422 Unprocessable Entity`.\n", + "operationId": "createJournal", + "parameters": [ + { + "$ref": "#/components/parameters/LegacyIdempotencyKey" + } + ], + "requestBody": { + "content": { + "application/json": { + "example": { + "amount": "115.5", + "entry_type": "JNLC", + "from_account": "7c891489-574f-4f9a-82f0-4082a07f4736", + "to_account": "2d47a229-0c25-40a2-8cc7-b2c8821ff93a" + }, + "schema": { + "$ref": "#/components/schemas/CreateJournalRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Journal" + } + } + }, + "description": "The New Journal object" + }, + "400": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "One of the parameters is invalid." + }, + "403": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "The amount requested to move is not available." + }, + "404": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "One of the account is not found." + }, + "422": { + "$ref": "#/components/responses/IdempotencyKeyConflict" + } + }, + "summary": "Create a Journal", + "tags": [ + "Journals" + ] + } + }, + "/v1/journals/{journal_id}": { + "delete": { + "description": "You can only delete a journal if the journal is still in a pending state, if a journal is executed you will not be able to delete. The alternative is to create a mirror journal entry to reverse the flow of funds.", + "operationId": "deleteJournalById", + "responses": { + "204": { + "description": "The cancel request succeeded. (No-content)\n" + }, + "404": { + "description": "The journal is not found.\n" + }, + "422": { + "description": "The journal is not in the pending status.\n" + } + }, + "summary": "Cancel a Pending Journal", + "tags": [ + "Journals" + ] + }, + "get": { + "description": "You can query a specific journal entry that you submitted to Alpaca by passing into the query the journal_id.\n\nWill return a journal entry if a journal entry with journal_id exists, otherwise will throw an error.", + "operationId": "get-v1-journals-journal_id", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Journal" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve a Single Journal Entry", + "tags": [ + "Journals" + ] + }, + "parameters": [ + { + "in": "path", + "name": "journal_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ] + }, + "/v1/journals/batch": { + "post": { + "description": "You can create a batch of journal requests by using this endpoint. This is enabled on JNLC type Journals for now only.\n\nEvery single request must be valid for the entire batch operation to succeed.\n\nIn the case of a successful request, the response will contain an array of journal objects with an extra attribute error_message in the case when a specific account fails to receive a journal.\n\n**Idempotency**: When the `Idempotency-Key` header is supplied, this endpoint is\nidempotent. Multiple requests with the same key and identical request body will\ncreate only one batch. A subsequent request returns the previously created\nbatch with the same response (no duplicate is created). If the same key is used\nwith a different request body, the API returns `422 Unprocessable Entity`.\n\n**Recommended for production**: Always supply `Idempotency-Key` when creating\njournal batches. This allows safe retries on timeouts, network errors, or 5xx responses\nwithout risking duplicate batches. Use a client-generated unique value (e.g. UUID).", + "operationId": "createBatchJournal", + "parameters": [ + { + "$ref": "#/components/parameters/LegacyIdempotencyKey" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BatchJournalRequest" + } + } + }, + "description": "", + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "examples": {}, + "schema": { + "items": { + "$ref": "#/components/schemas/BatchJournalResponse" + }, + "type": "array" + } + } + }, + "description": "an array of journal objects with an extra attribute error_message in the case when a specific account fails to receive a journal." + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Unprocessable Entity. Returned when an idempotency key is reused with a different request body." + } + }, + "summary": "Create a Batch Journal Transaction (One-to-Many)", + "tags": [ + "Journals" + ] + } + }, + "/v1/journals/reverse_batch": { + "post": { + "description": "You can also create a batch journal request by using the following endpoint. This is enabled on JNLC for now only.\n\nNote that if there is an invalid account_id the whole batch operation will be canceled.\nEvery single request must be valid for the entire batch operation to succeed.\n\nA successful response contains an array of JNLC journal objects. If any account or entry is invalid, the whole batch operation is canceled and no per-item error result is returned.", + "operationId": "post-v1-journals-reverse_batch", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReverseBatchJournalRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/JNLC" + }, + "type": "array" + } + } + }, + "description": "OK" + }, + "400": { + "description": "Invalid Request Body" + }, + "403": { + "description": "Insufficient Balance (JNLC) or Insufficient Assets (JNLS)" + }, + "404": { + "description": "Account not found" + } + }, + "summary": "Create a Reverse Batch Journal Transaction (Many-to-One)", + "tags": [ + "Journals" + ] + } + }, + "/v1/oauth/authorize": { + "post": { + "description": "The operation issues an OAuth code which can be used in the OAuth code flow.\n", + "operationId": "authorizeOAuthToken", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuthTokenRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthorizeOAuthTokenResponse" + } + } + }, + "description": "Successfully issued a code." + }, + "401": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Client does not exist, you do not have access to the client, or \"client_secret\" is incorrect.\n" + }, + "422": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Redirect URI or scope is invalid.\n" + } + }, + "summary": "Authorize an OAuth Token", + "tags": [ + "OAuth" + ] + } + }, + "/v1/oauth/clients/{client_id}": { + "get": { + "description": "The endpoint returns the details of OAuth client to display in the authorization page.\n", + "operationId": "getOAuthClient", + "parameters": [ + { + "description": "code or token", + "in": "query", + "name": "response_type", + "schema": { + "enum": [ + "code", + "token" + ], + "example": "token", + "type": "string" + } + }, + { + "description": "Redirect URI of the OAuth flow", + "in": "query", + "name": "redirect_uri", + "schema": { + "example": "https://example.com/authorize", + "type": "string" + } + }, + { + "description": "Requested scopes by the OAuth flow", + "in": "query", + "name": "scope", + "schema": { + "example": "general", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "example-1": { + "value": { + "client_id": "7a3c52a910e1dc2abbb14da2b6b8e711", + "description": "Sample description", + "live_trading_approved": false, + "name": "TradingApp", + "privacy_policy": "", + "redirect_uri": [ + "http://localhost" + ], + "status": "ACTIVE", + "terms_of_use": "", + "url": "http://test.com" + } + } + }, + "schema": { + "$ref": "#/components/schemas/OathClientResponse" + } + } + }, + "description": "Success." + }, + "401": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Client does not exist or you do not have access to the client.\n" + } + }, + "summary": "Get an OAuth client", + "tags": [ + "OAuth" + ] + }, + "parameters": [ + { + "in": "path", + "name": "client_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ] + }, + "/v1/oauth/token": { + "post": { + "description": "The operation issues an OAuth code which can be used in the OAuth code flow.\n", + "operationId": "issueOAuthToken", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuthTokenRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "example-1": { + "value": { + "access_token": "87586f14-c3f4-4912-b107-f75bc17ff87a", + "scope": "general", + "token_type": "Bearer" + } + } + }, + "schema": { + "$ref": "#/components/schemas/IssueOAuthTokenResponse" + } + } + }, + "description": "Success." + }, + "401": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Client does not exist, you do not have access to the client, or \"client_secret\" is incorrect.\n" + }, + "422": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "Redirect URI or scope is invalid.\n" + } + }, + "summary": "Issue an OAuth token", + "tags": [ + "OAuth" + ] + } + }, + "/v1/options/contracts": { + "get": { + "description": "This endpoint allows you to retrieve a list of option contracts based on various filtering criteria.\nBy default only active contracts that expire before the upcoming weekend are returned.\n", + "operationId": "get-options-contracts", + "parameters": [ + { + "description": "Filter contracts by one or more underlying symbols.", + "example": "AAPL,SPY", + "in": "query", + "name": "underlying_symbols", + "schema": { + "type": "string" + } + }, + { + "description": "Include deliverables array in the response.", + "example": true, + "in": "query", + "name": "show_deliverables", + "schema": { + "type": "boolean" + } + }, + { + "description": "Filter contracts by status (active/inactive). By default only active contracts are returned.", + "example": "active", + "in": "query", + "name": "status", + "schema": { + "enum": [ + "active", + "inactive" + ], + "type": "string" + } + }, + { + "description": "Filter contracts by the exact expiration date (format: YYYY-MM-DD). If no expiration date filters (`expiration_date`, `expiration_date_gte`, or `expiration_date_lte`) are provided, the endpoint defaults to returning contracts with expiration dates on or before the upcoming weekend.", + "example": "2025-06-20", + "in": "query", + "name": "expiration_date", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts with expiration date greater than or equal to the specified date.", + "example": "2025-06-20", + "in": "query", + "name": "expiration_date_gte", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts with expiration date less than or equal to the specified date. By default this is set to the next weekend.", + "example": "2025-06-20", + "in": "query", + "name": "expiration_date_lte", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts by the root symbol.", + "example": "AAPL", + "in": "query", + "name": "root_symbol", + "schema": { + "type": "string" + } + }, + { + "description": "Filter contracts by the type (call/put).", + "example": "call", + "in": "query", + "name": "type", + "schema": { + "enum": [ + "call", + "put" + ], + "type": "string" + } + }, + { + "description": "Filter contracts by the style (american/european).", + "example": "american", + "in": "query", + "name": "style", + "schema": { + "enum": [ + "american", + "european" + ], + "type": "string" + } + }, + { + "description": "Filter contracts with strike price greater than or equal to the specified value.", + "example": 50, + "in": "query", + "name": "strike_price_gte", + "schema": { + "type": "number" + } + }, + { + "description": "Filter contracts with strike price less than or equal to the specified value.", + "example": 100, + "in": "query", + "name": "strike_price_lte", + "schema": { + "type": "number" + } + }, + { + "$ref": "#/components/parameters/PageToken" + }, + { + "description": "The number of contracts to limit per page (default=100, max=10000).", + "example": 100, + "in": "query", + "name": "limit", + "schema": { + "type": "integer" + } + }, + { + "description": "The ppind (Penny Program Indicator) field indicates whether an option contract is eligible for penny price increments,\nwith `true` meaning it is part of the Penny Program and `false` meaning it is not.", + "example": true, + "in": "query", + "name": "ppind", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/NextPageToken" + }, + "option_contracts": { + "items": { + "$ref": "#/components/schemas/OptionContract" + }, + "type": "array" + } + }, + "required": [ + "option_contracts" + ], + "type": "object" + } + } + }, + "description": "Successful Response." + } + }, + "summary": "Get Option Contracts (BETA)", + "tags": [ + "Assets" + ] + } + }, + "/v1/options/contracts/{symbol_or_id}": { + "get": { + "description": "Get an option contract by symbol or contract ID. The symbol or id should be passed in as a path parameter.", + "operationId": "get-option-contract-symbol_or_id", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OptionContract" + } + } + }, + "description": "An option contract" + }, + "404": { + "content": { + "application/json": { + "examples": { + "Contract Not Found": { + "value": { + "code": 40410000, + "message": "option contract TSLA231110C00021000 not found" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Not Found" + } + }, + "summary": "Get an option contract by ID or Symbol (BETA)", + "tags": [ + "Assets" + ] + }, + "parameters": [ + { + "description": "The contract symbol or ID.", + "in": "path", + "name": "symbol_or_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/rebalancing/portfolios": { + "get": { + "description": "Lists portfolios.\n\nWhen more than one query parameter is passed, only portfolios meeting all provided values will be returned (logical AND between parameter values).", + "operationId": "get-v1-rebalancing-portfolios", + "parameters": [ + { + "description": "Name of portfolio", + "in": "query", + "name": "name", + "schema": { + "type": "string" + } + }, + { + "description": "Description of portfolio", + "in": "query", + "name": "description", + "schema": { + "type": "string" + } + }, + { + "description": "Symbol included in portfolio", + "in": "query", + "name": "symbol", + "schema": { + "type": "string" + } + }, + { + "description": "Portfolio ID", + "in": "query", + "name": "portfolio_id", + "schema": { + "type": "string" + } + }, + { + "description": "Portfolio Status", + "in": "query", + "name": "status", + "schema": { + "enum": [ + "active", + "inactive", + "needs_adjustment" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Portfolio" + }, + "type": "array" + } + } + }, + "description": "Array of Portfolios" + } + }, + "summary": "List Portfolios", + "tags": [ + "Rebalancing" + ] + }, + "post": { + "description": "Creates a portfolio allocation containing securities and/or cash. Having no rebalancing conditions is allowed but the rebalance event would need to be triggered manually. Portfolios created with API may have multiple rebalance_conditions, but only one of type calendar.", + "operationId": "post-v1-rebalancing-portfolios", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "cooldown_days": { + "description": "Count of calendar days following a rebalance before a subscription is eligible to trigger another rebalance", + "type": "integer" + }, + "description": { + "description": "Text to describe portfolio", + "type": "string" + }, + "name": { + "description": "Name of portfolio", + "type": "string" + }, + "rebalance_conditions": { + "description": "Rebalancing conditions for portfolio", + "items": { + "$ref": "#/components/schemas/RebalancingConditions" + }, + "type": "array" + }, + "weights": { + "description": "Weight configuration to portfolio. Sum of \"percent\" values in the weights array must be 100.00", + "items": { + "$ref": "#/components/schemas/PortfolioWeightRequest" + }, + "type": "array" + } + }, + "type": "object" + } + } + }, + "description": "" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Portfolio" + } + } + }, + "description": "OK" + } + }, + "summary": "Create Portfolio", + "tags": [ + "Rebalancing" + ] + } + }, + "/v1/rebalancing/portfolios/{portfolio_id}": { + "delete": { + "description": "Archives a portfolio (soft delete). Only permitted when the portfolio has no active subscriptions. Archived portfolios are hidden from the default list response and cannot be used for new subscriptions.", + "operationId": "delete-v1-rebalancing-portfolios-portfolio_id", + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + }, + "422": { + "description": "Unprocessable Entity " + } + }, + "summary": "Inactivate Portfolio By ID", + "tags": [ + "Rebalancing" + ] + }, + "get": { + "description": "Get a portfolio by its ID.", + "operationId": "get-v1-rebalancing-portfolios-portfolio_id", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Portfolio" + } + } + }, + "description": "OK" + } + }, + "summary": "Get Portfolio by ID", + "tags": [ + "Rebalancing" + ] + }, + "parameters": [ + { + "description": "The Portfolio ID", + "in": "path", + "name": "portfolio_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "patch": { + "description": "Updates a portfolio. If weights or conditions are changed, all subscribed accounts will be evaluated for rebalancing at the next opportunity (normal market hours). If a cooldown is active on the portfolio, the rebalancing will occur after the cooldown expired.", + "operationId": "patch-v1-rebalancing-portfolios-portfolio_id", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "cooldown_days": { + "description": "Used to update portfolio cooldown days.", + "type": "integer" + }, + "description": { + "description": "Used to update portfolio description.", + "type": "string" + }, + "name": { + "description": "Used to update portfolio name.", + "type": "string" + }, + "rebalancing_conditions": { + "description": "Used to update portfolio conditions.", + "items": { + "$ref": "#/components/schemas/RebalancingConditions" + }, + "type": "array" + }, + "weights": { + "description": "Used to update portfolio weights.", + "items": { + "$ref": "#/components/schemas/PortfolioWeightRequest" + }, + "type": "array" + } + }, + "required": [ + "cooldown_days" + ], + "type": "object" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Portfolio" + } + } + }, + "description": "The updated portfolio" + } + }, + "summary": "Update Portfolio by ID", + "tags": [ + "Rebalancing" + ] + } + }, + "/v1/rebalancing/runs": { + "get": { + "description": "Lists runs.", + "operationId": "get-v1-rebalancing-runs", + "parameters": [ + { + "description": "Any runs for this account_id will be returned", + "in": "query", + "name": "account_id", + "schema": { + "type": "string" + } + }, + { + "description": "Status of portfolio run to filter by", + "in": "query", + "name": "status", + "schema": { + "type": "string" + } + }, + { + "description": "Type of portfolio run (full_rebalance, invest_cash)", + "in": "query", + "name": "type", + "schema": { + "type": "string" + } + }, + { + "description": "Pagination token", + "in": "query", + "name": "page_token", + "schema": { + "type": "string" + } + }, + { + "description": "Max number of runs to return per page", + "in": "query", + "name": "limit", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/NextPageToken" + }, + "runs": { + "example": [ + { + "account_id": "4db36989-6565-4011-9126-39fe6b3d9bf6", + "id": "0f9e8a7b-1c2d-4e3f-9a0b-1c2d3e4f5a6b", + "initiated_from": "api", + "portfolio_id": "9b2c1d4e-8f7a-4c3b-9d2e-1f0a8b7c6d5e", + "status": "COMPLETED_SUCCESS", + "type": "full_rebalance", + "updated_at": "2025-01-15T16:30:00Z" + } + ], + "items": { + "$ref": "#/components/schemas/PortfolioRun" + }, + "type": "array" + } + }, + "required": [ + "runs", + "next_page_token" + ], + "type": "object" + } + } + }, + "description": "The runs which match the query" + } + }, + "summary": "List All Runs.", + "tags": [ + "Rebalancing" + ] + }, + "post": { + "description": "Creates a rebalance run.\n\nOmit `weights` or provide an empty array to create a subscription-driven run using the account's active subscription. Provide a non-empty `weights` array to create a manual one-off run. A manual run is rejected if the account already has an active subscription.\n\nThe determination of a run's orders and the execution of a run take place during normal market hours. Runs can be initiated outside normal market hours but remain `QUEUED` until normal market hours.\n\nOnly one run in a non-terminal status is allowed at any time.", + "operationId": "post-v1-rebalancing-runs", + "requestBody": { + "content": { + "application/json": { + "examples": { + "manualRun": { + "summary": "Manual one-off rebalance run", + "value": { + "account_id": "bf2b0f93-f296-4276-a9cf-288586cf4fb7", + "type": "full_rebalance", + "weights": [ + { + "percent": "35", + "symbol": "AAPL", + "type": "asset" + }, + { + "percent": "20", + "symbol": "TSLA", + "type": "asset" + }, + { + "percent": "45", + "symbol": "SPY", + "type": "asset" + } + ] + } + }, + "subscriptionRun": { + "summary": "Subscription-driven rebalance run", + "value": { + "account_id": "bf2b0f93-f296-4276-a9cf-288586cf4fb7", + "type": "full_rebalance" + } + } + }, + "schema": { + "properties": { + "account_id": { + "description": "The account to create the run for.", + "format": "uuid", + "type": "string" + }, + "amount": { + "description": "Optional decimal amount used by the run. JSON strings and numbers are accepted.", + "type": [ + "string", + "number", + "null" + ] + }, + "type": { + "description": "The kind of rebalance run to create.", + "enum": [ + "full_rebalance", + "invest_cash" + ], + "type": "string" + }, + "weights": { + "description": "Asset allocation weights. Omit this field or provide an empty array to use the account's active subscription. Provide a non-empty array to create a manual one-off run. A manual run is rejected if the account already has an active subscription.", + "items": { + "$ref": "#/components/schemas/PortfolioWeightRequest" + }, + "type": "array" + } + }, + "required": [ + "account_id", + "type" + ], + "type": "object" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + }, + "summary": "Create Run", + "tags": [ + "Rebalancing" + ] + } + }, + "/v1/rebalancing/runs/{run_id}": { + "delete": { + "description": "Cancels a run. Only runs within certain statuses (QUEUED, CANCELED, SELLS_IN_PROGRESS, BUYS_IN_PROGRESS) are cancelable. If this endpoint is called after orders have been submitted, we'll attempt to cancel the orders.", + "operationId": "delete-v1-rebalancing-runs-run_id", + "responses": { + "204": { + "description": "No Content" + } + }, + "summary": "Cancel Run by ID", + "tags": [ + "Rebalancing" + ] + }, + "get": { + "description": "Get a run by its ID.", + "operationId": "get-v1-rebalancing-runs-run_id", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PortfolioRun" + } + } + }, + "description": "The run object" + } + }, + "summary": "Get Run by ID", + "tags": [ + "Rebalancing" + ] + }, + "parameters": [ + { + "description": "the id of the portfolio run", + "in": "path", + "name": "run_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/rebalancing/subscriptions": { + "get": { + "description": "Lists subscriptions", + "operationId": "get-v1-rebalancing-subscriptions", + "parameters": [ + { + "description": "Any subscriptions for this account_id will be returned", + "in": "query", + "name": "account_id", + "schema": { + "type": "string" + } + }, + { + "description": "Portfolio ID", + "in": "query", + "name": "portfolio_id", + "schema": { + "type": "string" + } + }, + { + "description": "Pagination token", + "in": "query", + "name": "page_token", + "schema": { + "type": "string" + } + }, + { + "description": "Max number of subscriptions to return per page", + "in": "query", + "name": "limit", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/NextPageToken" + }, + "subscriptions": { + "items": { + "$ref": "#/components/schemas/PortfolioSubscription" + }, + "type": "array" + } + }, + "required": [ + "subscriptions", + "next_page_token" + ], + "type": "object" + } + } + }, + "description": "OK" + } + }, + "summary": "List All Subscriptions", + "tags": [ + "Rebalancing" + ] + }, + "post": { + "description": "Creates a subscription between an account and a portfolio.", + "operationId": "post-v1-rebalancing-subscriptions", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "account_id": { + "description": "Account ID. Account must be active and the account must not have any active subscriptions already (only 1 is permitted at a time)", + "type": "string" + }, + "portfolio_id": { + "description": "Portfolio ID. Portfolio must be active", + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PortfolioSubscription" + } + } + }, + "description": "OK" + } + }, + "summary": "Create Subscription", + "tags": [ + "Rebalancing" + ] + } + }, + "/v1/rebalancing/subscriptions/{subscription_id}": { + "delete": { + "description": "Deletes the subscription which stops the rebalancing of an account.", + "operationId": "delete-v1-rebalancing-subscriptions-subscription_id", + "responses": { + "204": { + "description": "No Content" + } + }, + "summary": "Unsubscribe Account (Delete Subscription)", + "tags": [ + "Rebalancing" + ] + }, + "get": { + "description": "Get a subscription by its ID.", + "operationId": "get-v1-rebalancing-subscriptions-subscription_id", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PortfolioSubscription" + } + } + }, + "description": "The portfolio subscription" + } + }, + "summary": "Get Subscription by ID", + "tags": [ + "Rebalancing" + ] + }, + "parameters": [ + { + "in": "path", + "name": "subscription_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/reporting/eod/aggregate_positions": { + "get": { + "description": "This API endpoint provides reporting data to partners for aggregate common stock and crypto positions across their account base. Partners can view historical snapshots of their holding across their entire account base. Please note that this API utilizes an 8:00 pm (EST) cutoff which aligns with the end of the Securities extended hours trading session as well as Alpaca's 24 hour Crypto trading window. Additionally, the endpoint supports indexing to help the partner efficiently filter by key information including date and symbol while being able to include or remove firm accounts.", + "operationId": "get-v1-reporting-eod-aggregate_positions", + "parameters": [ + { + "description": "\"YYYY-MM-DD\" format", + "in": "query", + "name": "date", + "required": true, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Comma-separated symbols. If populated, then only the specified symbols will be returned. If null, then all symbols will be included in the response.", + "in": "query", + "name": "symbols", + "schema": { + "type": "string" + } + }, + { + "description": "Defaults to True which includes firm accounts. Passing False will exclude all firm accounts.", + "in": "query", + "name": "firm_accounts", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/AggregatePositionResponse" + }, + "type": "array" + } + } + }, + "description": "Array of objects, each object pertains to the date specified in the request and a unique asset. See parameters below. Notes: Returns an empty array for non-trading days, assets with no positions are omitted." + } + }, + "summary": "Retrieve Aggregate Positions", + "tags": [ + "Reporting" + ] + } + }, + "/v1/reporting/eod/cash_interest": { + "get": { + "description": "This API retrieves a list of cash interest details for the given date(s) for a single account or all accounts. End-of-day (EOD) details are typically accessible after 8:00pm Eastern Time (ET) and reflect that day's ending state across cash balances, accrued interest, accrued fees, as well as additional ancillary details.", + "operationId": "get-v1-get-eod-cash-interest-report", + "parameters": [ + { + "description": "Account globally unique identifier. If not provided, the report will be generated for all accounts.", + "in": "query", + "name": "account_id", + "required": false, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "A date in the format YYYY-MM-DD. If not provided, the report will be generated for the most recent date this report is available.", + "in": "query", + "name": "date", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "A date in the format YYYY-MM-DD, valid only if account_id is provided and date is not provided. If not provided, this will use `before` value. If neither is provided the most recent available date is used for both `before` and `after`.", + "in": "query", + "name": "after", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "A date in the format YYYY-MM-DD, valid only if account_id is provided and date is not provided. If not provided, this will use the most recent available date.", + "in": "query", + "name": "before", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "The direction to use for sorting responses, either `asc` or `desc`. Only valid for account_id queries, for which only sorting by date is supported. Defaults to `desc`.", + "in": "query", + "name": "direction", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "The page size, used for paginating responses. Defaults to 1000, with a maximum of 10,000.", + "in": "query", + "name": "page_size", + "required": false, + "schema": { + "default": 1000, + "maximum": 10000, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "A token used to retrieve the next page for paginated queries. If provided the response will begin at the next page of the results for the response from which the `next_page_token` is used.", + "in": "query", + "name": "page_token", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EoDCashInterestReportResponse" + } + } + }, + "description": "Successful response, returns a list of daily interest accruals and an optional next page token." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "A client error occurred. Please check the provided request parameters and try again." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Unauthorized. Please check your API key and try again." + }, + "429": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Too many requests. Please wait a moment and try again." + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "A server error occurred. Please contact Alpaca." + } + }, + "summary": "Retrieve EOD Cash Interest Details", + "tags": [ + "Reporting", + "Cash Interest" + ] + } + }, + "/v1/reporting/eod/positions": { + "get": { + "description": "This API retrieves a comprehensive list of end-of-day positions for all accounts. End-of-day (EOD) positions are typically accessible after 4:00 am Eastern Time (ET) on the following day, providing a comprehensive view of the day's closing positions across all accounts.\nThis API currently only supports retrieving EOD positions for the last trading date.", + "operationId": "get-v1-reporting-eod-positions", + "parameters": [ + { + "description": "Filter the results by account_id (optional).", + "in": "query", + "name": "account_id", + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "Filter the results by asset ID or symbol (optional).", + "in": "query", + "name": "asset", + "schema": { + "type": "string" + } + }, + { + "description": "The positions date in 'YYYY-MM-DD' format. It's recommended to provide this parameter when the 'page' parameter is specified, to ensure precise data retrieval based on the desired date.\nOnly previous trading date is supported.", + "in": "query", + "name": "asof", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "$ref": "#/components/parameters/PageToken" + }, + { + "description": "The number of accounts to display per page (default=1000, max=10000).", + "in": "query", + "name": "limit", + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "asof": { + "description": "The date of the snapshot in the 'YYYY-MM-DD' format.", + "format": "date", + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/NextPageToken" + }, + "positions": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/Position" + }, + "type": "array" + }, + "description": "A detailed map of account IDs to their respective positions.", + "type": "object" + } + }, + "type": "object" + } + } + }, + "description": "Successful response containing the end-of-day positions for the specified accounts." + }, + "422": { + "description": "This can be returned if the asof param does not match the latest snap available at Alpaca." + } + }, + "summary": "Retrieve EOD Positions", + "tags": [ + "Reporting" + ] + } + }, + "/v1/trading/accounts/{account_id}/account": { + "get": { + "description": "As a broker you can view more trading details about your users.\n\nThe response is a Trading Account model.", + "operationId": "getTradingAccount", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TradeAccount" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve Trading Details for an Account", + "tags": [ + "Accounts" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ] + }, + "/v1/trading/accounts/{account_id}/account/configurations": { + "parameters": [ + { + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "patch": { + "description": "You can also set the margin settings for your users' account by passing a PATCH request. By default any account with funds under $2,000 is set a margin multiplier of 1.0, and accounts with over $2,000 are set to 2.0.", + "operationId": "patch-PATCH-v1-trading-accounts-account_id-account-configurations", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountConfigurations" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountConfigurations" + } + } + }, + "description": "Response will contain the account configuration settings for the account." + } + }, + "summary": "Update Trading Configurations for an Account", + "tags": [ + "Trading" + ] + } + }, + "/v1/trading/accounts/{account_id}/account/portfolio/history": { + "get": { + "description": "Returns timeseries data about equity and profit/loss (P/L) of the account in requested timespan.", + "operationId": "get-v1-trading-accounts-account_id-account-portfolio-history", + "parameters": [ + { + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The duration of the data in `number` + `unit` format, such as 1D, where `unit` can be D for day, W for week, M for month and A for year. Defaults to 1M.\n\nOnly two of `start`, `end` and `period` can be specified at the same time.\n\nFor intraday timeframes (\\<1D) only 30 days or less can be queried, for 1D resolutions there is no such limit, data is available since the\ncreation of the account.\n", + "in": "query", + "name": "period", + "schema": { + "type": "string" + } + }, + { + "description": "The resolution of time window. 1Min, 5Min, 15Min, 1H, or 1D. If omitted, 1Min for less than 7 days period,\n15Min for less than 30 days, or otherwise 1D.\n\nFor queries with longer than 30 days of `period`, the system only accepts 1D as `timeframe`.\n", + "in": "query", + "name": "timeframe", + "schema": { + "type": "string" + } + }, + { + "description": "For intraday resolutions (<1D) this specifies which timestamps to return data points for:\n\nAllowed values are:\n- **market_hours**\n\n Only timestamps for the core equity trading hours are returned (usually 9:30am to 4:00pm, trading days only)\n\n- **extended_hours**\n\n Returns timestamps for the whole session including extended hours (usually 4:00am to 8:00pm, trading days only)\n\n- **continuous**\n\n Returns price data points 24/7 (for off-session times too). To calculate the equity values we are using the following prices:\n\n Between 4:00am and 10:00pm on trading days the valuation will be calculated based on the last trade (extended hours and normal hours respectively).\n\n After 10:00pm, until the next session open the equities will be valued at their official closing price on the primary exchange.\n", + "in": "query", + "name": "intraday_reporting", + "schema": { + "default": "market_hours", + "enum": [ + "market_hours", + "extended_hours", + "continuous" + ], + "type": "string" + } + }, + { + "description": "The timestamp the data is returned starting from in RFC3339 format (including timezone specification). Defaults to `end` minus `period`\n\nIf provided, the `start` value is always normalized to the `America/New_York` timezone and adjusted to the nearest `timeframe` interval, e.g. seconds are always truncated and the time is rounded backwards to the nearest interval of `1Min`, `5Min`, `15Min`, or `1H`.\n\nIf `timeframe=1D` and `start` is not a valid trading date, find the next available trading date. For example, if `start` occurs on Saturday or Sunday after converting to the America/New_York timezone, `start` is adjusted to the first weekday that is not a market holiday (e.g. Monday).\n\nIf `timeframe` is less than `1D` and `intraday_reporting` is not `continuous`, `start` always reflects the beginning of a market session. If `start` is between midnight and the end (inclusive) of an active trading day, `start` is set to the beginning of the session on the specified day. Otherwise, if `start` occurs outside of the market session, the next available market date is used.\n\nFor example, when `intraday_reporting=market_hours` and `start=2023-10-19T23:59:59-04:00`, the provided `start` date occurs outside of the regular market session. The effective `start` timestamp is adjusted to the beginning of the next session: `2023-10-20T09:30:00-04:00`\n\n`start` may be be combined with one of `end` or `period`.\n\nProviding all of `start`, `end`, and `period` is invalid.\n", + "in": "query", + "name": "start", + "schema": { + "example": "2021-03-16T18:38:01Z", + "format": "date-time", + "type": "string" + } + }, + { + "description": "`pnl_reset` defines how we are calculating the baseline values for Profit And Loss (pnl) for queries with `timeframe` less than 1D (intraday queries).\n\nThe default behavior for intraday queries is that we reset the pnl value to the previous day's closing equity for each **trading** day.\n\nIn case of crypto (given its continuous nature), this might not be desired: specifying \"no_reset\" disables this behavior and all pnl values\nreturned will be relative to the closing equity of the previous trading day.\n\nFor 1D resolution all PnL values are calculated relative to the `base_value`, we are not resetting the base value.\n", + "in": "query", + "name": "pnl_reset", + "schema": { + "default": "per_day", + "enum": [ + "no_reset", + "per_day" + ], + "type": "string" + } + }, + { + "description": "The timestamp the data is returned up to in RFC3339 format (including timezone specification). Defaults to the current time.\n\nIf provided, the `end` value is always normalized to the `America/New_York` timezone and adjusted to the nearest `timeframe` interval, e.g. seconds are always truncated and the time is rounded backwards to the nearest interval of `1Min`, `5Min`, `15Min`, or `1H`.\n\nWhen `intraday_reporting` is either `market_hours` or `extended_hours`, the `end` value is adjusted to not occur after session close on the specified day. For example if the `intraday_reporting` is `extended_hours`, and the timestamp specified is `2023-10-19T21:33:00-04:00`, `end` is adjusted to `2023-10-19T20:00:00-04:00`.\n\n`end` may be combined with `start` or `period`.\n\nProviding all of `start`, `end`, and `period` is invalid.\n", + "in": "query", + "name": "end", + "schema": { + "example": "2021-03-16T18:38:01Z", + "format": "date-time", + "type": "string" + } + }, + { + "description": "**deprecated**: Users are strongly advised to **rely on the `intraday_reporting` query parameter** for better control\nof the reporting range.\n\nIf true, include extended hours in the result. This is effective only for timeframe less than 1D.\n", + "in": "query", + "name": "extended_hours", + "schema": { + "type": "string" + } + }, + { + "description": "The cashflow activities to include in the report. One of 'ALL', 'NONE', or a comma-separated list of activity types.", + "examples": { + "all": { + "value": "ALL" + }, + "cash_transfers": { + "summary": "Include cash movements.", + "value": "JNLC,CSD,CSW" + }, + "none": { + "value": "NONE" + } + }, + "in": "query", + "name": "cashflow_types", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "example-cashflows": { + "value": { + "base_value": 8413.04, + "base_value_asof": "2026-04-06", + "cashflow": { + "CSD": [ + 9.93, + 10.13, + 10.16, + 0 + ], + "DIV": [ + 0, + 0, + 0.63, + 0 + ] + }, + "equity": [ + 8425.21, + 8639.77, + 8766.1, + 8835.31 + ], + "profit_loss": [ + 12.17, + 214.56, + 126.33, + 69.21 + ], + "profit_loss_pct": [ + 0.0014, + 0.0255, + 0.0146, + 0.0079 + ], + "timeframe": "1D", + "timestamp": [ + 1775606400, + 1775692800, + 1775779200, + 1775865600 + ] + } + }, + "example-intraday-query-15min-1d": { + "value": { + "base_value": 2774.16, + "base_value_asof": "2023-10-18", + "cashflow": { + "CSD": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 100, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + "equity": [ + 2773.79, + 2769.04, + 2768.65, + 2765.11, + 2763.03, + 2763.17, + 2763.17, + 2763.47, + 2763.91, + 2768.13, + 2774.98, + 2757.94, + 2757.65, + 2774.54, + 2775.58, + 2775.28, + 2767.9, + 2762.26, + 2762.56, + 2756.99, + 2756.84, + 2752.43, + 2752.13, + 2748.44, + 2751.23, + 2747.54, + 2748.74 + ], + "profit_loss": [ + -0.37, + -5.12, + -5.51, + -9.05, + -11.13, + -10.99, + -10.99, + -10.69, + -10.25, + -6.03, + 0.82, + -16.22, + -16.51, + 0.38, + 1.42, + 1.12, + -6.26, + -11.9, + -11.6, + -17.17, + -17.32, + -21.73, + -22.03, + -25.72, + -22.93, + -26.62, + -25.42 + ], + "profit_loss_pct": [ + -0.0001, + -0.0018, + -0.002, + -0.0033, + -0.004, + -0.004, + -0.004, + -0.0039, + -0.0037, + -0.0022, + 0.0003, + -0.0058, + -0.006, + 0.0001, + 0.0005, + 0.0004, + -0.0023, + -0.0043, + -0.0042, + -0.0062, + -0.0062, + -0.0078, + -0.0079, + -0.0093, + -0.0083, + -0.0096, + -0.0092 + ], + "timeframe": "15Min", + "timestamp": [ + 1697722200, + 1697723100, + 1697724000, + 1697724900, + 1697725800, + 1697726700, + 1697727600, + 1697728500, + 1697729400, + 1697730300, + 1697731200, + 1697732100, + 1697733000, + 1697733900, + 1697734800, + 1697735700, + 1697736600, + 1697737500, + 1697738400, + 1697739300, + 1697740200, + 1697741100, + 1697742000, + 1697742900, + 1697743800, + 1697744700, + 1697745600 + ] + } + }, + "example-query-1d-7d": { + "value": { + "base_value": 2784.79, + "cashflow": { + "CSD": [ + 0, + 0, + 100, + 0, + 0 + ] + }, + "equity": [ + 2784.79, + 2794.79, + 2805.46, + 2774.16, + 2748.73 + ], + "profit_loss": [ + 0, + 10.0022, + 10.6692, + -31.2996, + -25.4232 + ], + "profit_loss_pct": [ + 0, + 0.0035, + 0.0074, + -0.0038, + -0.0129 + ], + "timeframe": "1D", + "timestamp": [ + 1697241600, + 1697500800, + 1697587200, + 1697673600, + 1697760000 + ] + } + } + }, + "schema": { + "$ref": "#/components/schemas/PortfolioHistory" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Get Account Portfolio History", + "tags": [ + "Portfolio History" + ] + } + }, + "/v1/trading/accounts/{account_id}/limits": { + "get": { + "description": "This endpoint is only available to accounts with the trading limits feature enabled, and not on JIT.\nThe daily trading limit is set at the correspondent level (or the account level) and is used as the limit for the total amount due to Alpaca on the date of settlement.\nThe limit in use returns the real time usage of this limit, based on the setup it uses the usage is calculated differently.\nIf the limit in use reaches the `daily_net_limit` or `available` is zero, further purchasing activity will be halted, however, the limit can be adjusted by reaching out to Alpaca with the proposed new limit and the reason for the change.", + "operationId": "get-v1-account-trading-limits", + "parameters": [ + { + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountTradingLimit" + } + } + }, + "description": "Returns the trading limit set for the account and the real-time usage of the limit" + }, + "404": { + "description": "Returned when the account is not configured for trading limits" + } + }, + "summary": "Retrieve real-time Trading Limits for an Account", + "tags": [ + "Trading" + ] + } + }, + "/v1/trading/accounts/{account_id}/orders": { + "delete": { + "description": "Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled.", + "operationId": "deleteAllOrdersForAccount", + "responses": { + "207": { + "content": { + "application/json": { + "examples": { + "example-1": { + "value": [ + { + "id": "872994c5-0620-40ad-8ae0-f224b9948df5", + "status": 200 + } + ] + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/OrderClosedResponse" + }, + "type": "array" + } + } + }, + "description": "HTTP 207 Multi-Status with body, which is an array of objects that include the order id, http status code and an order object for each cancellation request." + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "404": { + "$ref": "#/components/responses/NotFound" + } + }, + "summary": "Cancel all Open Orders For an Account", + "tags": [ + "Trading" + ] + }, + "get": { + "description": "Retrieves a list of orders for the account, filtered by the supplied query parameters.\n\nEndpoint defaults to open orders if no parameters are provided.", + "operationId": "getAllOrdersForAccount", + "parameters": [ + { + "description": "Order status to be queried. open, closed or all. Defaults to open.", + "in": "query", + "name": "status", + "schema": { + "enum": [ + "open", + "closed", + "all" + ], + "type": "string" + } + }, + { + "description": "The maximum number of orders in response. Defaults to 50 and max is 500.", + "in": "query", + "name": "limit", + "schema": { + "example": 500, + "type": "integer" + } + }, + { + "$ref": "#/components/parameters/AssetClass" + }, + { + "$ref": "#/components/parameters/After" + }, + { + "$ref": "#/components/parameters/Until" + }, + { + "$ref": "#/components/parameters/Direction" + }, + { + "description": "If true, the result will roll up multi-leg orders under the legs field of primary order.", + "in": "query", + "name": "nested", + "schema": { + "type": "boolean" + } + }, + { + "$ref": "#/components/parameters/Symbols" + }, + { + "in": "query", + "name": "qty_above", + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "qty_below", + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "subtag", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Order" + }, + "type": "array" + } + } + }, + "description": "Retrieves a list of orders for the account, filtered by the supplied query parameters." + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "404": { + "$ref": "#/components/responses/NotFound" + } + }, + "summary": "Retrieve a List of Orders", + "tags": [ + "Trading" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ], + "post": { + "description": "Creating an order for your end customer. Each trading request must pass in the account_id in the URL.\n\n- Note that when submitting crypto orders, `market`, `limit` and `stop_limit` orders are supported while the supported `time_in_force` values are `gtc`, and `ioc`.\n- For equities and crypto we accept fractional orders as well with either `notional` or `qty` provided.\n- Note that submitting an options order is only available for partners who have been enabled for Options BETA.\n- In case of Fixed Income, only `market` and `limit` order types with `day` `time_in_force` are supported, and order replacement is not supported.\nNote that submitting Fixed Income orders is only available for partners who have been enabled for Fixed Income.\n- Note that submitting DMA orders (using `advanced_instructions` with `algorithm: DMA`) is only available for partners/correspondents who have been enabled for DMA.\n- For IPO indications of interest (`asset_class: \"ipo\"`), the `symbol` is the offering reference returned by [`GET /v1/ipos`](#operation/listIPOOfferings) (e.g. `FI111225`). IPO orders are notional-only (`notional` required, `qty` must be omitted), buy-side, `market` type, and `gtc` time_in_force. Indications of interest can be replaced or canceled while the offering is open via [`PATCH /v1/trading/accounts/{account_id}/orders/{order_id}`](#operation/replaceOrderForAccount) and [`DELETE /v1/trading/accounts/{account_id}/orders/{order_id}`](#operation/deleteOrderForAccount).", + "operationId": "createOrderForAccount", + "requestBody": { + "content": { + "application/json": { + "examples": { + "Crypto": { + "summary": "Buy a crypto coin", + "value": { + "limit_price": "2100", + "qty": "0.02", + "side": "buy", + "symbol": "ETH/USD", + "time_in_force": "gtc", + "type": "limit" + } + }, + "Equity": { + "summary": "Buy an equity stock", + "value": { + "limit_price": "150", + "qty": "2", + "side": "buy", + "symbol": "AAPL", + "time_in_force": "gtc", + "type": "limit" + } + }, + "FixedIncome": { + "summary": "Buy a US Treasury Bill", + "value": { + "limit_price": "99.15", + "qty": "5000", + "side": "buy", + "symbol": "US912797QN08", + "time_in_force": "day", + "type": "limit" + } + }, + "IPO": { + "summary": "Submit an IPO indication of interest", + "value": { + "notional": "500", + "side": "buy", + "symbol": "FI111225", + "time_in_force": "gtc", + "type": "market" + } + }, + "Options": { + "summary": "Buy an option contract (BETA)", + "value": { + "limit_price": "10", + "qty": "2", + "side": "buy", + "symbol": "AAPL250620C00100000", + "time_in_force": "day", + "type": "limit" + } + } + }, + "schema": { + "$ref": "#/components/schemas/CreateOrderRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Crypto": { + "$ref": "#/components/examples/CryptoOrderResponse" + }, + "Equity": { + "$ref": "#/components/examples/EquityOrderResponse" + }, + "IPO": { + "$ref": "#/components/examples/IPOOrderResponse" + }, + "MultilegOptions": { + "$ref": "#/components/examples/MultilegOptionsOrderResponse" + }, + "Options": { + "$ref": "#/components/examples/OptionOrderResponse" + } + }, + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "OK" + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "403": { + "$ref": "#/components/responses/Forbidden" + }, + "404": { + "$ref": "#/components/responses/NotFound" + }, + "422": { + "description": "Some parameters are not valid" + } + }, + "summary": "Create an Order for an Account", + "tags": [ + "Trading" + ] + } + }, + "/v1/trading/accounts/{account_id}/orders/{order_id}": { + "delete": { + "description": "Attempts to cancel an open order. If the order is no longer cancelable (for example if the status is \"filled\"), the server will respond with status 422, and reject the request.\n\nUpon acceptance of the cancel request, it returns status 204.", + "operationId": "deleteOrderForAccount", + "responses": { + "204": { + "description": "Success (No Content)" + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "404": { + "$ref": "#/components/responses/NotFound" + } + }, + "summary": "Cancel an Open Order", + "tags": [ + "Trading" + ] + }, + "get": { + "description": "Retrieves a single order for the given order_id.", + "operationId": "getOrderForAccount", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "The requested Order object" + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "404": { + "$ref": "#/components/responses/NotFound" + } + }, + "summary": "Retrieve an Order by its ID", + "tags": [ + "Trading" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "$ref": "#/components/parameters/OrderID" + } + ], + "patch": { + "description": "Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order.\n\nA success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel found [here](https://docs.alpaca.markets/reference/subscribetotradev2sse).\n\nWhile an order is being replaced, the account's buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order.\n\nNote: Order cannot be replaced when the status is `accepted`, `pending_new`, `pending_cancel` or `pending_replace`.\n\nNote: Notional orders for non-IPO asset classes cannot be replaced. Any attempt to modify a non-IPO notional order via this endpoint will be rejected; cancel it and submit a new one instead.\n\nNote: IPO indications of interest (`asset_class: \"ipo\"`) **are** notional and **can** be replaced via this endpoint by providing a new `notional` value. `qty` and `notional` are mutually exclusive on a single replace request.\n\nNote that submitting DMA orders (using `advanced_instructions` with `algorithm: DMA`) is only available for partners/correspondents who have been enabled for DMA.", + "operationId": "replaceOrderForAccount", + "requestBody": { + "content": { + "application/json": { + "examples": { + "Equity": { + "summary": "Increase qty and limit price on an equity order", + "value": { + "limit_price": "155", + "qty": "4", + "time_in_force": "gtc" + } + }, + "IPO": { + "summary": "Update notional on an IPO indication of interest", + "value": { + "notional": "750" + } + }, + "Options": { + "summary": "Adjust an option order's limit price", + "value": { + "limit_price": "11.25", + "time_in_force": "day" + } + } + }, + "schema": { + "$ref": "#/components/schemas/UpdateOrderRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Equity": { + "$ref": "#/components/examples/EquityOrderResponse" + }, + "IPO": { + "$ref": "#/components/examples/IPOOrderResponse" + }, + "Options": { + "$ref": "#/components/examples/OptionOrderResponse" + } + }, + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "A new Order object with a new order_id" + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "403": { + "description": "Buying power or shares are not sufficient" + }, + "404": { + "$ref": "#/components/responses/NotFound" + } + }, + "summary": "Replace an Order", + "tags": [ + "Trading" + ] + } + }, + "/v1/trading/accounts/{account_id}/orders/estimation": { + "parameters": [ + { + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "post": { + "description": "Order estimation endpoint will display, based on user's account balance, the estimated quantity and price they will receive for their notional order.\n\nFor LCT - customer's order will include the Alpaca swap_fee, while correspondent side swap_fee is configurable in the API call. Utilising this API does not result in a real order and after the calculation - the user's buying power reverts to the previous state.\n\nResponses and Errors are the same as with the Orders API\n\nPlease note that the estimation is based on the market condition at the time of submission and a live order will differ. The output should be considered indicative.\n\n**Note:** This does not support Crypto or non-market orders at this time.", + "operationId": "get-v1-trading-accounts-account_id-orders-estimation", + "requestBody": { + "content": { + "application/json": { + "examples": { + "Example 1": { + "value": { + "notional": "40", + "side": "buy", + "swap_fee_bps": 45, + "symbol": "AAPL", + "time_in_force": "day", + "type": "market" + } + } + }, + "schema": { + "properties": { + "notional": { + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "swap_fee_bps": { + "type": "integer" + }, + "symbol": { + "type": "string" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "type": { + "$ref": "#/components/schemas/OrderType" + } + }, + "type": "object" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "OK" + } + }, + "summary": "Estimate an Order", + "tags": [ + "Trading" + ] + } + }, + "/v1/trading/accounts/{account_id}/orders:by_client_order_id": { + "get": { + "description": "Retrieves a single order specified by the client order ID.", + "operationId": "getOrderByClientOrderIdForAccount", + "parameters": [ + { + "description": "The client-assigned order ID.", + "in": "query", + "name": "client_order_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "Successfully retrieved the order matching the client_order_id." + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "404": { + "$ref": "#/components/responses/NotFound" + } + }, + "summary": "Retrieves a single order specified by the client order ID.", + "tags": [ + "Trading" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ] + }, + "/v1/trading/accounts/{account_id}/positions": { + "delete": { + "description": "Closes (liquidates) all of the account's open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.", + "operationId": "closeAllPositionsForAccount", + "parameters": [ + { + "description": "If true is specified, cancel all open orders before liquidating all positions.", + "in": "query", + "name": "cancel_orders", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "207": { + "content": { + "application/json": { + "examples": { + "example-1": { + "value": [ + { + "body": { + "asset_class": "us_equity", + "asset_id": "a4778bc8-fad1-47b7-87fe-d5cde10d43f4", + "canceled_at": null, + "client_order_id": "17dbfab4-cb86-4e0a-8fa6-f0606b0a9a4e", + "created_at": "2022-05-13T16:25:29.336330998Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "d1143025-89fc-4952-8936-db2409d899f3", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "", + "order_type": "market", + "qty": "4", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "sell", + "source": null, + "status": "accepted", + "stop_price": null, + "submitted_at": "2022-05-13T16:25:29.335776073Z", + "symbol": "TSLA", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "market", + "updated_at": "2022-05-13T16:25:29.336330998Z" + }, + "status": 200, + "symbol": "TSLA" + } + ] + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/PositionClosedResponse" + }, + "type": "array" + } + } + }, + "description": "HTTP 207 Multi-Status with body; an array of objects that include the order id and http status code for each status request." + }, + "500": { + "description": "Failed to liquidate some positions" + } + }, + "summary": "Close All Positions for an Account", + "tags": [ + "Trading" + ] + }, + "get": { + "description": "List open positions for an account", + "operationId": "getPositionsForAccount", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Position" + }, + "type": "array" + } + } + }, + "description": "Success" + } + }, + "summary": "List Open Positions for an Account", + "tags": [ + "Trading" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + } + ] + }, + "/v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id}": { + "delete": { + "description": "Closes (liquidates) the account's open position for the given symbol. Works for both long and short positions.", + "operationId": "closePositionForAccountBySymbol", + "parameters": [ + { + "description": "Optional the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage", + "in": "query", + "name": "qty", + "schema": { + "type": "string" + } + }, + { + "description": "percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty", + "in": "query", + "name": "percentage", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "OK" + } + }, + "summary": "Close a Position for an Account", + "tags": [ + "Trading" + ] + }, + "get": { + "description": "Retrieves the account's open position for the given symbol or asset_id.", + "operationId": "getPositionsForAccountBySymbol", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + }, + "description": "The requested Position object" + }, + "404": { + "description": "Account doesn't have a position for this symbol or asset_id " + } + }, + "summary": "Get an Open Position for account by Symbol or AssetId", + "tags": [ + "Trading" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "The symbol or asset_id ", + "in": "path", + "name": "symbol_or_asset_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/trading/accounts/{account_id}/positions/{symbol_or_contract_id}/do-not-exercise": { + "post": { + "description": "This endpoint enables users to submit a do-not-exercise (DNE) instruction for a held option contract, preventing automatic exercise at expiry.\nBy default, Alpaca will automatically exercise in-the-money (ITM) contracts at expiry. This endpoint allows users to override that behavior.\nDNE requests will be processed immediately once received. DNE requests submitted between market close and midnight will be rejected to avoid any confusion about when the instruction will take effect.\nTo cancel a DNE request or to submit an exercise instruction, please contact our support team.", + "operationId": "optionDoNotExercise", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "Option contract symbol or ID.", + "in": "path", + "name": "symbol_or_contract_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoNotExerciseRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoNotExerciseResponse" + } + } + }, + "description": "Successful Response" + }, + "403": { + "content": { + "application/json": { + "examples": { + "No Available Position": { + "value": { + "code": 40310000, + "message": "no available position for the specified contract" + } + }, + "Short Position": { + "value": { + "code": 40310001, + "message": "cannot submit DNE for short position" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Forbidden" + }, + "422": { + "content": { + "application/json": { + "examples": { + "Invalid Symbol": { + "value": { + "code": 42210000, + "message": "invalid symbol_or_contract_id" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Invalid Symbol\n\nThe specified symbol_or_contract_id is invalid." + } + }, + "summary": "Do Not Exercise an Options Position", + "tags": [ + "Trading" + ] + } + }, + "/v1/trading/accounts/{account_id}/positions/{symbol_or_contract_id}/exercise": { + "post": { + "description": "This endpoint enables users to exercise a held option contract, converting it into the underlying asset based on the specified terms.\nAll available held shares of this option contract will be exercised.\nBy default, Alpaca will automatically exercise in-the-money (ITM) contracts at expiry.\nExercise requests will be processed immediately once received. Exercise requests submitted between market close and midnight will be rejected to avoid any confusion about when the exercise will settle.\nTo cancel an exercise request or to submit a Do-not-exercise (DNE) instruction, you can use the do-not-exercise endpoint or contact our support team.", + "operationId": "optionExercise", + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "Option contract symbol or ID.", + "in": "path", + "name": "symbol_or_contract_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExerciseRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExerciseResponse" + } + } + }, + "description": "Successful Response" + }, + "403": { + "content": { + "application/json": { + "examples": { + "No Available Position": { + "value": { + "code": 40310000, + "message": "no available position for the specified contract" + } + }, + "Short Position": { + "value": { + "code": 40310001, + "message": "cannot exercise short position" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Forbidden\n\nAvailable position quantity is not sufficient." + } + }, + "summary": "Exercise an Options Position", + "tags": [ + "Trading" + ] + } + }, + "/v1/trading/accounts/{account_id}/watchlists": { + "get": { + "description": "Fetch a list of all watchlists currently in an account.", + "operationId": "getAllWatchlistsForAccount", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/WatchlistWithoutAsset" + }, + "type": "array" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve all Watchlists for an Account", + "tags": [ + "Watchlist" + ] + }, + "parameters": [ + { + "description": "Unique identifier of an account.", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "post": { + "description": "Returns the watchlist object", + "operationId": "createWatchlistForAccount", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateWatchlistRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Newly created watchlist" + } + }, + "summary": "Create a New Watchlist for an Account", + "tags": [ + "Watchlist" + ] + } + }, + "/v1/trading/accounts/{account_id}/watchlists/{watchlist_id}": { + "delete": { + "description": "Irrevocably delete a watchlist.", + "operationId": "deleteWatchlistFromAccountById", + "responses": { + "200": { + "description": "Watchlist deleted." + } + }, + "summary": "Remove a Watchlist", + "tags": [ + "Watchlist" + ] + }, + "get": { + "description": "Retrieve Watchlist by ID", + "operationId": "getWatchlistForAccountById", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "OK" + } + }, + "summary": "Manage watchlists", + "tags": [ + "Watchlist" + ] + }, + "parameters": [ + { + "description": "Unique identifier of an account", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "Unique identifier of a watchlist", + "in": "path", + "name": "watchlist_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "post": { + "description": "Adds an asset to an existing watchlist.", + "operationId": "post-v1-trading-accounts-account_id-watchlists-watchlist_id", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "symbol": { + "description": "The symbol name to add to the watchlist", + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "OK" + }, + "404": { + "description": "The requested watchlist is not found, or one of the symbols is not found in the assets" + }, + "422": { + "description": "Some parameters are not valid" + } + }, + "summary": "Add an Asset to a Watchlist", + "tags": [ + "Watchlist" + ] + }, + "put": { + "description": "Replace entirely the set of securities contained in the watchlist while optionally renaming it. Destructive operation.", + "operationId": "replaceWatchlistForAccountById", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateWatchlistRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Updated watchlist." + } + }, + "summary": "Update a Watchlist", + "tags": [ + "Watchlist" + ] + } + }, + "/v1/trading/accounts/{account_id}/watchlists/{watchlist_id}/{symbol}": { + "delete": { + "description": "Delete one entry for an asset by symbol name", + "operationId": "delete-DELETE-v1-trading-accounts-account_id-watchlists-watchlist_id-symbol", + "responses": { + "200": { + "description": "OK" + }, + "404": { + "description": "The requested watchlist is not found" + } + }, + "summary": "Remove a Symbol from a Watchlist", + "tags": [ + "Watchlist" + ] + }, + "parameters": [ + { + "description": "Account identifier.", + "in": "path", + "name": "account_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The Watchlist ID", + "in": "path", + "name": "watchlist_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The symbol ", + "in": "path", + "name": "symbol", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v1/transfers/jit/{ledger_id}/balances": { + "get": { + "description": "Returns an array of objects that correspond to each ledger account.", + "operationId": "get-v1-transfers-jit-ledger_id-balances", + "parameters": [ + { + "in": "path", + "name": "ledger_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The start date (inclusive) of the ledgerbalances and activities.", + "in": "query", + "name": "start_date", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "The end date (inclusive) of the ledgerbalances and activities.", + "in": "query", + "name": "end_date", + "schema": { + "format": "date", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "activity_amount": { + "description": "The number of transactions related to the ledger during the specified date range ", + "format": "decimal", + "type": "string" + }, + "ending_balance": { + "description": "Ledger balance at the end of the date range", + "format": "decimal", + "type": "string" + }, + "id": { + "description": "The ledger ID", + "type": "string" + }, + "ledger_name": { + "description": "The ledger name", + "type": "string" + }, + "ledger_no": { + "description": "The ledger account number", + "type": "string" + }, + "starting_balance": { + "description": "Ledger balance at the beginning of the date range", + "format": "decimal", + "type": "string" + }, + "transactions": { + "items": { + "$ref": "#/components/schemas/Transaction" + }, + "type": "array" + } + }, + "type": "object" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve JIT Ledger Balances", + "tags": [ + "Funding" + ] + } + }, + "/v1/transfers/jit/ledgers": { + "get": { + "description": "Returns an array of objects that correspond to each ledger account, each of whichcontain the following attributes.", + "operationId": "get-v1-transfers-jit-ledgers", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/JITLedgerAccount" + }, + "type": "array" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve JIT Ledgers", + "tags": [ + "Funding" + ] + } + }, + "/v1/transfers/jit/limits": { + "get": { + "description": "The JIT Securities daily trading limit is set at the correspondent level and is used as the limit for the total amount due to Alpaca on the date of settlement. The limit in use returns the real time usage of this limit and is calculated by taking the net of trade and non-trade activity inflows and outflows. If the limit in use reaches the daily net limit, further purchasing activity will be halted, however, the limit can be adjusted by reaching out to Alpaca with the proposed new limit and the reason for the change. The limit is reset at the start of every trading day at 8.00 PM ET", + "operationId": "get-v1-transfers-jit-limits", + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "open_cash_secured_put": { + "summary": "Correspondent with an open cash-secured put (cash_held present)", + "value": { + "cash_held": "20000", + "correspondent": "EXMP", + "daily_net_limit": "1000000", + "executed_buys": "43140", + "executed_sells": "0", + "in_use_limit": "103140", + "open_buys": "40000", + "open_sells": "0" + } + }, + "us_equity": { + "summary": "US equity correspondent with open and executed activity", + "value": { + "correspondent": "EXMP", + "daily_net_limit": "1000000", + "executed_buys": "55", + "executed_sells": "0", + "in_use_limit": "55", + "open_buys": "0", + "open_sells": "0" + } + } + }, + "schema": { + "$ref": "#/components/schemas/DailyTradingLimit" + } + } + }, + "description": "Returns the JIT Securities Daily Trading Limit Object based off of real time calculations." + } + }, + "summary": "Retrieve Daily Trading Limits", + "tags": [ + "Funding" + ] + } + }, + "/v1/transfers/jit/reports": { + "get": { + "description": "Retrieves a JIT report for the requested report type and system date. By default, the report is returned inline. For large reports, use response_type=download_url to receive a temporary signed download URL.\n", + "operationId": "get-v1-transfers-jit-reports", + "parameters": [ + { + "description": "The type of report you want to get.", + "in": "query", + "name": "report_type", + "required": true, + "schema": { + "enum": [ + "detail", + "net_summary", + "net_payment", + "net_payment_final", + "gross_summary", + "gross_payment", + "gross_payment_final", + "obligation" + ], + "type": "string" + } + }, + { + "description": "Date of file generation.", + "in": "query", + "name": "system_date", + "required": true, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "The asset class to retrieve for.", + "in": "query", + "name": "asset_class", + "schema": { + "enum": [ + "us_equity", + "crypto" + ], + "type": "string" + } + }, + { + "description": "Controls how the report is returned. Use inline to return the report content directly in the response. Use download_url to return a temporary signed URL that can be used to download the generated report. If omitted, the default value is inline.\n", + "in": "query", + "name": "response_type", + "required": false, + "schema": { + "default": "inline", + "enum": [ + "inline", + "download_url" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "download_url": { + "description": "Returned when response_type is download_url.", + "summary": "Download URL response", + "value": { + "expires_at": "2026-04-14T23:55:00Z", + "filename": "jit_detail_2026-04-14.csv", + "url": "" + } + }, + "inline": { + "description": "Returned when response_type is inline or omitted.", + "summary": "Inline report response", + "value": { + "detail": "" + } + } + }, + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/JITReport" + }, + { + "$ref": "#/components/schemas/JITReportDownloadURL" + } + ] + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve JIT Reports", + "tags": [ + "Funding" + ] + } + }, + "/v1/wallets/fees/estimate": { + "get": { + "description": "Returns the estimated on-chain network (gas) fee for a proposed crypto withdrawal at current chain conditions. Pass the `asset`, `from_address`, `to_address`, and `amount` you intend to send; the response reports the network fee that would be charged for the corresponding transaction.", + "operationId": "getCryptoTransferEstimate", + "parameters": [ + { + "description": "The asset for the proposed transaction", + "in": "query", + "name": "asset", + "schema": { + "type": "string" + } + }, + { + "description": "The originating address of the proposed transaction", + "in": "query", + "name": "from_address", + "schema": { + "type": "string" + } + }, + { + "description": "The destination address of the proposed transaction", + "in": "query", + "name": "to_address", + "schema": { + "type": "string" + } + }, + { + "description": "The amount, denoted in the specified asset, of the proposed transaction", + "in": "query", + "name": "amount", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "fee": { + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "OK" + }, + "default": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "error" + } + }, + "summary": "Returns the estimated gas fee for a proposed transaction.", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v1/wallets/travel-rule/vasps": { + "get": { + "description": "Search for Virtual Asset Service Providers, or crypto exchanges, on Notabene's network.\nThis endpoint can be used to find the VASP DID for your beneficiary's exchange when submitting\ntravel rule information for your whitelisted wallets. Use the `q` parameter to search for exchanges.", + "operationId": "searchVASPs", + "parameters": [ + { + "description": "General search query string.", + "in": "query", + "name": "q", + "schema": { + "type": "string" + } + }, + { + "description": "Filter by VASP email domain.", + "in": "query", + "name": "emailDomain", + "schema": { + "type": "string" + } + }, + { + "description": "Filter by Chainalysis-specific VASP name.", + "in": "query", + "name": "chainalysisName", + "schema": { + "type": "string" + } + }, + { + "description": "Specify which fields to return (comma-separated).", + "in": "query", + "name": "fields", + "schema": { + "type": "string" + } + }, + { + "description": "The zero-based page number to retrieve.", + "in": "query", + "name": "page", + "schema": { + "default": 0, + "minimum": 0, + "type": "integer" + } + }, + { + "description": "Number of items per page.", + "in": "query", + "name": "per_page", + "schema": { + "default": 10, + "maximum": 100, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Field-based sort expression, such as name:ASC. Multiple expressions may be comma-separated. Defaults to name:ASC.", + "in": "query", + "name": "order", + "schema": { + "default": "name:ASC", + "example": "name:ASC", + "pattern": "^([ A-Za-z]+(:(ASC|DESC))?(:NULLS (FIRST|LAST))?(,?))+$", + "type": "string" + } + }, + { + "description": "Whether to include child/subsidiary entities.", + "in": "query", + "name": "includeSubsidiaryVASPs", + "schema": { + "default": false, + "type": "boolean" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "page": 1, + "pages": 1, + "total": 1, + "vasps": [ + { + "country": "US", + "did": "did:ethr:0xf1c002f9e7ca88018d6dcf1e86403fb2f5f055f4", + "id": "vasp-1", + "name": "Example Exchange" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/SearchVASPsResponse" + } + } + }, + "description": "Successful request. Returns an array of VASPs or an empty list if no matches found." + } + }, + "summary": "Search for VASPs", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v2beta1/accounts/{account_id}/events/activities/{event_id}": { + "get": { + "description": "Returns a single account activity (V2) event for the specified account by ULID `event_id`, delivered as a server-sent event message.\n\nThis is the single-event counterpart to the `subscribeToActivitiesSSE` streaming endpoint, intended for re-fetching an individual activity that was previously observed on the activities stream.", + "operationId": "getAccountActivityEvent", + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "$ref": "#/components/schemas/ActivityEventV2" + } + } + }, + "description": "Returns a single activity v2 event, identified by the provided event_id ULID." + } + }, + "summary": "Get a single activity (V2) event by event_id ULID.", + "tags": [ + "Accounts" + ] + }, + "parameters": [ + { + "$ref": "#/components/parameters/AccountID" + }, + { + "description": "The ULID that uniquely identifies the activity event.", + "in": "path", + "name": "event_id", + "required": true, + "schema": { + "format": "ulid", + "type": "string" + } + } + ] + }, + "/v2beta1/events/activities": { + "get": { + "description": "The Events API sends the real-time events and provides historical queries with SSE (Server Sent Events).\n\nThis endpoint streams events on account activities.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery parameter rules:\n- If `until` is specified, `since` is required.\n- If `until_id` is specified, `since_id` is required.\n- You cannot use `since` and `since_id` together.\nBehavior:\n- If `since` or `since_id` is not specified, this will not return any historic data.\n- If `until` or `until_id` is specified, stream will end at the specified point with status 200.\n\n---\n\nWarning: Currently, OAS-3 does not fully support responses from an SSE API.\n\nIn case the client code is generated from this OAS spec, please do not specify `since` and `until`, as the generated client may hang forever waiting for the response to end.\n\nIf you require the streaming capabilities, we recommend not using the generated clients for this specific endpoint until the OAS-3 standards define how to represent this behavior.\n\n---\n\n### Comment messages\nAccording to the SSE specification, any line that starts with a colon is a comment which does not contain data. It is typically a free text that does not follow any data schema. A few examples mentioned below for comment messages.\n\n##### Slow client\n\nThe server sends a comment when the client is not consuming messages fast enough. Example: `: you are reading too slowly, dropped 10000 messages`\n\n##### Internal server error\n\nAn error message is sent as a comment when the server closes the connection on an internal server error (only sent by the v2 and v2beta1 endpoints). Example: `: internal server error`\n\n---", + "operationId": "subscribeToActivitiesSSE", + "parameters": [ + { + "description": "Format: RFC3339 or YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Format: RFC3339 or YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "in": "query", + "name": "since_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_id", + "schema": { + "format": "ulid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "items": { + "$ref": "#/components/schemas/ActivityEventV2" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to Activity Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v2/calendar/{market}": { + "get": { + "description": "This endpoint returns the market calendar.", + "operationId": "Calendar", + "parameters": [ + { + "$ref": "#/components/parameters/market" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/timezone" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/public_calendar_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get Market Calendar", + "tags": [ + "Calendar" + ] + } + }, + "/v2/clock": { + "get": { + "description": "This API serves information about multiple markets: the current time, if it's a market day, the current phase of the market, etc.\n", + "operationId": "Clock", + "parameters": [ + { + "$ref": "#/components/parameters/markets" + }, + { + "$ref": "#/components/parameters/time" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/clock_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get Market Clock", + "tags": [ + "Calendar" + ] + } + }, + "/v2/events/admin-actions": { + "get": { + "description": "The Events API provides event push as well as historical queries via SSE (server sent events).\n\nThis endpoint streams events related to administrative actions performed by our systems.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery Params Rules:\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since` and `since_id` can't be used at the same time\nBehavior:\n- if `since` or `since_id` not specified this will not return any historic data\n- if `until` or `until_id` reached stream will end (status 200)\n\n---\n\nWarning: Currently OAS-3 doesn't have full support for representing SSE style responses from an API.\n\nIn case the client code is generated from this OAS spec, don't specify a `since` and `until` there is a good chance the generated clients will hang forever waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific endpoint until the OAS-3 standards come to a consensus on how to represent this behavior in OAS-3.\n\n---\n\n### Comment messages\nAccording to the SSE specification, any line that starts with a colon is a comment which does not contain data. It is typically a free text that does not follow any data schema. A few examples mentioned below for comment messages.\n\n##### Slow client\n\nThe server sends a comment when the client is not consuming messages fast enough. Example: `: you are reading too slowly, dropped 10000 messages`\n\n##### Internal server error\n\nAn error message is sent as a comment when the server closes the connection on an internal server error (only sent by the v2 and v2beta1 endpoints). Example: `: internal server error`\n\n---\n\n**Event Types**\n\n- **LegacyNote:** Old free text based admin notes\n- **Liquidation:** Event for a position liquidation which initialized by an admin\n- **TransactionCancel:** Event for a manually cancelled transaction", + "operationId": "subscribeToAdminActionSSE", + "parameters": [ + { + "description": "Format: RFC3339 or YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Format: RFC3339 or YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "in": "query", + "name": "since_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_id", + "schema": { + "format": "ulid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/AdminActionLegacyNote" + }, + { + "$ref": "#/components/schemas/AdminActionLiquidation" + }, + { + "$ref": "#/components/schemas/AdminActionTransactionCancel" + } + ] + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to Admin Action Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v2/events/funding/status": { + "get": { + "description": "The Events API provides event push as well as historical queries via SSE (server sent events).\n\nYou can listen to funding status updates as they get processed by our backoffice, for both end-user and firm accounts.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery Params Rules:\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since` and `since_id` can't be used at the same time\n- `until` and `until_id` can't be used at the same time\nBehavior:\n- if `since` or `since_id` not specified this will not return any historic data\n- if `until` or `until_id` reached stream will end (status 200)\n\n---\n\nNote for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correctly in OAS-3.", + "operationId": "subscribeToFundingStatusSSE", + "parameters": [ + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "in": "query", + "name": "since_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_id", + "schema": { + "format": "ulid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "items": { + "$ref": "#/components/schemas/StatusFundingEvent" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to Funding Status Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v2/events/ipos": { + "get": { + "description": "The Events API provides event push as well as historical queries via SSE (server sent events).\n\nYou can listen to IPO offering lifecycle updates as they happen - including new offerings, offering updates, prospectus availability, the 60-minute pricing window, account-scoped allocation results, and offering cancellations.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\n---\n\n**Event types**\n\nEach event has a `verb` field that determines the shape of `payload`. See the `IPOEvent` schema for the full payload structure for each verb.\n\n- `Offering` - initial publication of an offering (system-wide).\n- `OfferingUpdate` - update to a previously published offering (system-wide).\n- `Prospectus` - prospectus document is now available (system-wide).\n- `SixtyMinMail` - 60-minute pricing window has opened, no new orders accepted (system-wide).\n- `Allocation` - final allocation result for a specific account. **Account-scoped** - `account_id` and `correspondent` are populated.\n- `OfferingCancellation` - offering was cancelled. **No `payload` field is present.**\n\nUse the `offering_reference` field on each event to fetch the full offering metadata via [`GET /v1/ipos/{offering_reference}`](#operation/getIPOOffering).\n\n---\n\nQuery Params Rules:\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since` and `since_id` can't be used at the same time\n- `until` and `until_id` can't be used at the same time\n\nBehavior:\n- if `since` or `since_id` not specified this will not return any historic data\n- if `until` or `until_id` reached stream will end (status 200)\n\n---\n\nNote for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correctly in OAS-3.\n", + "operationId": "subscribeToIPOEventsSSE", + "parameters": [ + { + "description": "Format: RFC3339 or YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Format: RFC3339 or YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "ULID `event_id` to resume the stream from. The first event returned will be the one immediately after `since_id`.", + "in": "query", + "name": "since_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "description": "ULID `event_id` at which the stream will end (inclusive). Useful for backfills.", + "in": "query", + "name": "until_id", + "schema": { + "format": "ulid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "examples": { + "Allocation": { + "$ref": "#/components/examples/IPOEventAllocation" + }, + "Offering": { + "$ref": "#/components/examples/IPOEventOffering" + }, + "OfferingCancellation": { + "$ref": "#/components/examples/IPOEventOfferingCancellation" + }, + "OfferingUpdate": { + "$ref": "#/components/examples/IPOEventOfferingUpdate" + }, + "Prospectus": { + "$ref": "#/components/examples/IPOEventProspectus" + }, + "SixtyMinMail": { + "$ref": "#/components/examples/IPOEventSixtyMinMail" + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/IPOEvent" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to IPO Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v2/events/journals/status": { + "get": { + "description": "The Events API provides event push as well as historical queries via SSE (server sent events).\n\nYou can listen to journal status updates as they get processed by our backoffice.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery Params Rules:\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since` and `since_id` can't be used at the same time\n- `until` and `until_id` can't be used at the same time\nBehavior:\n- if `since` or `since_id` not specified this will not return any historic data\n- if `until` or `until_id` reached stream will end (status 200)\n\n---\n\nThere is no compatibility between /v1/events/journals/status and /v2/events/journals/status, the ids (ulid) are always different, and the number of events might also different\n\nPlease note that the new `/v2` endpoint, is the same as, and was originally available under `/v2beta1`.\nWe encourage all customers to adjust their codebase from that interim beta endpoint to the `/v2` stable endpoint.\nIn the near future we will setup permanent redirect from `/v2beta1` to `/v2` before we completely remove the beta endpoint.\n\n---\n\nNote for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correctly in OAS-3.\n", + "operationId": "subscribeToJournalStatusV2SSE", + "parameters": [ + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "in": "query", + "name": "since_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "id", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "items": { + "$ref": "#/components/schemas/JournalStatusEventV2" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to Journal Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v2/events/system": { + "get": { + "description": "The Events API provides event push as well as historical queries via SSE (server sent events).\n\nYou can listen to system event updates as they happen in our backend.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery Params Rules:\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since` and `since_id` can't be used at the same time\n- `until` and `until_id` can't be used at the same time\nBehavior:\n- if `since` or `since_id` not specified this will not return any historic data\n- if `until` or `until_id` reached stream will end (status 200)\n\n---\n\nNote for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correctly in OAS-3.\n", + "operationId": "subscribeToSystemEventV2SSE", + "parameters": [ + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "in": "query", + "name": "since_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_id", + "schema": { + "format": "ulid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "items": { + "$ref": "#/components/schemas/SystemEventV2" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to System Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v2/events/trades": { + "get": { + "description": "The Events API provides event push as well as historical queries via SSE (server sent events).\n\nYou can listen to events related to trade updates. Most market trades sent during market hours are filled instantly; you can listen to limit order updates through this endpoint.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery Params Rules:\n- `since` required if `until` specified\n- `since_id` required if `until_id` specified\n- `since` and `since_id` can't be used at the same time\nBehavior:\n- if `since` or `since_id` not specified this will not return any historic data\n- if `until` or `until_id` reached stream will end (status 200)\n\n---\n\nNote for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end.\n\nIf you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correctly in OAS-3.\n\n---\n\n**Legacy trade events API deprecation**\n\nThe legacy v1 trade events endpoint has been fully deprecated and is no longer available. Use `/v2/events/trades` for all trade event integrations.\n\n---\n\n### Comment messages\nAccording to the SSE specification, any line that starts with a colon is a comment which does not contain data. It is typically a free text that does not follow any data schema. A few examples mentioned below for comment messages.\n\n##### Slow client\n\nThe server sends a comment when the client is not consuming messages fast enough. Example: `: you are reading too slowly, dropped 10000 messages`\n\n##### Internal server error\n\nAn error message is sent as a comment when the server closes the connection on an internal server error (only sent by the v2 and v2beta1 endpoints). Example: `: internal server error`\n\n---\n\n**Common events**\n\nThese are the events that are the expected results of actions you may have taken by sending API requests.\n\nThe meaning of the timestamp field changes for each type; the meanings have been specified here for which types the timestamp field will be present.\n\n- `accepted` Sent when an order is received and accepted by Alpaca\n- `pending_new` Sent when the order has been received by Alpaca and routed to the exchanges, but has not yet been accepted for execution.\n- `new` Sent when an order has been routed to exchanges for execution.\n- `fill` Sent when your order has been completely filled.\n - timestamp: The time at which the order was filled.\n- `partial_fill` Sent when a number of shares less than the total remaining quantity on your order has been filled.\n - timestamp: The time at which the shares were filled.\n- `canceled` Sent when your requested cancellation of an order is processed.\n - timestamp: The time at which the order was canceled.\n- `expired` Sent when an order has reached the end of its lifespan, as determined by the order's time in force value.\n - timestamp: The time at which the order expired.\n- `done_for_day` Sent when the order is done executing for the day, and will not receive further updates until the next trading day.\n- `replaced` Sent when your requested replacement of an order is processed.\n - timestamp: The time at which the order was replaced.\n\n**Rarer events**\n\nThese are events that may rarely be sent due to unexpected circumstances on the exchanges. It is unlikely you will need to design your code around them, but you may still wish to account for the possibility that they will occur.\n\n- `rejected` Sent when your order has been rejected.\n - timestamp: The time at which the rejection occurred.\n- `held` For multi-leg orders, the secondary orders (stop loss, take profit) will enter this state while waiting to be triggered.\n- `stopped` Sent when your order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred.\n- `pending_cancel` Sent when the order is awaiting cancellation. Most cancellations will occur without the order entering this state.\n- `pending_replace` Sent when the order is awaiting replacement.\n- `calculated` Sent when the order has been completed for the day - it is either filled or done_for_day - but remaining settlement calculations are still pending.\n- `suspended` Sent when the order has been suspended and is not eligible for trading.\n- `order_replace_rejected` Sent when the order replace has been rejected.\n- `order_cancel_rejected` Sent when the order cancel has been rejected.\n- `trade_bust`: Sent when a previously reported execution has been canceled (\"busted\") by the upstream exchange.\n- `trade_correct`: Sent when a previously reported trade has been corrected. For example, the exchange may have updated the price, quantity, or another execution parameter after the trade was initially reported.\n- `restated`: Sent when the order is manually modified.", + "operationId": "subscribeToTradeV2SSE", + "parameters": [ + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Format: YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "in": "query", + "name": "since_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_id", + "schema": { + "format": "ulid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "examples": { + "MultilegOptions-fill": { + "$ref": "#/components/examples/TradeUpdateEventV2MultilegOptionsFill" + }, + "new": { + "$ref": "#/components/examples/TradeUpdateEventV2New" + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/TradeUpdateEventV2" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to Trade Events (SSE)", + "tags": [ + "Events", + "Trading" + ] + } + } + }, + "security": [ + { + "BasicAuth": [] + } + ], + "servers": [ + { + "description": "Sandbox endpoint", + "url": "https://broker-api.sandbox.alpaca.markets" + }, + { + "description": "Production endpoint", + "url": "https://broker-api.alpaca.markets" + } + ], + "tags": [ + { + "name": "Accounts" + }, + { + "name": "Documents" + }, + { + "name": "Trading" + }, + { + "name": "Portfolio History" + }, + { + "name": "Assets" + }, + { + "name": "Calendar" + }, + { + "name": "Events" + }, + { + "name": "Funding" + }, + { + "name": "Funding Wallets" + }, + { + "name": "Instant Funding" + }, + { + "name": "OAuth" + }, + { + "name": "Clock" + }, + { + "name": "Journals" + }, + { + "name": "Corporate Actions" + }, + { + "name": "Watchlist" + }, + { + "name": "KYC" + }, + { + "name": "Rebalancing" + }, + { + "name": "Logos" + }, + { + "name": "Reporting" + }, + { + "name": "Country Info" + }, + { + "name": "Crypto Funding" + }, + { + "name": "IRA" + }, + { + "name": "Cash Interest" + }, + { + "name": "FPSL Program" + }, + { + "name": "Tokenization" + }, + { + "name": "ACATS" + }, + { + "description": "Endpoints for discovering and tracking IPO (Initial Public Offering) lifecycle data. Use [`GET /v1/ipos`](#operation/listIPOOfferings) and [`GET /v1/ipos/{offering_reference}`](#operation/getIPOOffering) to query offerings on demand, and the [IPO Events Stream](#operation/subscribeToIPOEventsSSE) under the **Events** group to receive real-time and historical lifecycle updates (new offerings, prospectus, 60-minute mail, allocations, cancellations).\n", + "name": "IPO" + } + ], + "x-readme": { + "explorer-enabled": true, + "proxy-enabled": false + } +} diff --git a/module/broker/src/main/java/net/jacobpeterson/alpacajava/broker/BrokerApiUtil.java b/module/broker/src/main/java/net/jacobpeterson/alpacajava/broker/BrokerApiUtil.java new file mode 100644 index 00000000..c6192c46 --- /dev/null +++ b/module/broker/src/main/java/net/jacobpeterson/alpacajava/broker/BrokerApiUtil.java @@ -0,0 +1,25 @@ +package net.jacobpeterson.alpacajava.broker; + +import org.jspecify.annotations.NullMarked; + +import java.util.Base64; + +import static java.nio.charset.StandardCharsets.US_ASCII; + +/** + * {@link BrokerApiUtil} is a utility class for {@link BrokerApi}. + */ +@NullMarked +public final class BrokerApiUtil { + + /** + * @return {@link Base64.Encoder#encodeToString(byte[])} apiKey + ":" + apiSecret + * + * @see docs.alpaca.markets + */ + public static String getAuthorizationToken(final String apiKey, final String apiSecret) { + return Base64.getEncoder().encodeToString((apiKey + ":" + apiSecret).getBytes(US_ASCII)); + } + + private BrokerApiUtil() {} +} diff --git a/module/common/build.gradle.kts b/module/common/build.gradle.kts new file mode 100644 index 00000000..a12c9978 --- /dev/null +++ b/module/common/build.gradle.kts @@ -0,0 +1,5 @@ +plugins { + id("module-common") +} + +description = "The common module for various Alpaca Java modules." diff --git a/module/common/src/main/java/net/jacobpeterson/alpacajava/common/ApiEnvironment.java b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/ApiEnvironment.java new file mode 100644 index 00000000..417fd8ee --- /dev/null +++ b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/ApiEnvironment.java @@ -0,0 +1,20 @@ +package net.jacobpeterson.alpacajava.common; + +import org.jspecify.annotations.NullMarked; + +/** + * {@link ApiEnvironment} is an enum that represents an API environment. + */ +@NullMarked +public enum ApiEnvironment { + + /** + * Production/live environment. + */ + PRODUCTION, + + /** + * Development/sandbox/paper environment. + */ + DEVELOPMENT +} diff --git a/module/common/src/main/java/net/jacobpeterson/alpacajava/common/ApiHeader.java b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/ApiHeader.java new file mode 100644 index 00000000..83bc03ca --- /dev/null +++ b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/ApiHeader.java @@ -0,0 +1,33 @@ +package net.jacobpeterson.alpacajava.common; + +import com.google.common.net.HttpHeaders; +import org.jspecify.annotations.NullMarked; + +/** + * {@link ApiHeader} contains API header {@link String} constants. + */ +@NullMarked +public final class ApiHeader { + + /** + * The API Key ID header {@link String}: "APCA-API-KEY-ID" + */ + public static final String API_KEY_ID = "APCA-API-KEY-ID"; + + /** + * The API Secret Key header {@link String}: "APCA-API-SECRET-KEY" + */ + public static final String API_SECRET_KEY = "APCA-API-SECRET-KEY"; + + /** + * The {@link HttpHeaders#AUTHORIZATION} basic prefix: "Basic " + */ + public static final String AUTHORIZATION_BASIC_PREFIX = "Basic "; + + /** + * The {@link HttpHeaders#AUTHORIZATION} bearer prefix: "Bearer " + */ + public static final String AUTHORIZATION_BEARER_PREFIX = "Bearer "; + + private ApiHeader() {} +} diff --git a/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseListener.java b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseListener.java new file mode 100644 index 00000000..55741db5 --- /dev/null +++ b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseListener.java @@ -0,0 +1,15 @@ +package net.jacobpeterson.alpacajava.common.sse; + +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface SseListener { + + void onData(final T data); + + void onComment(final String comment); + + void onClose(); + + void onError(final Throwable throwable); +} diff --git a/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseListenerAdapter.java b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseListenerAdapter.java new file mode 100644 index 00000000..b123a7f8 --- /dev/null +++ b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseListenerAdapter.java @@ -0,0 +1,29 @@ +package net.jacobpeterson.alpacajava.common.sse; + +import lombok.extern.slf4j.Slf4j; +import org.jspecify.annotations.NullMarked; + +@Slf4j +@NullMarked +public class SseListenerAdapter implements SseListener { + + @Override + public void onData(final T data) { + LOGGER.info("SSE data: {}", data); + } + + @Override + public void onComment(final String comment) { + LOGGER.debug("SSE comment: {}", comment); + } + + @Override + public void onClose() { + LOGGER.info("SSE closed"); + } + + @Override + public void onError(final Throwable throwable) { + LOGGER.error("SSE error", throwable); + } +} diff --git a/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseResponse.java b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseResponse.java new file mode 100644 index 00000000..49df3c55 --- /dev/null +++ b/module/common/src/main/java/net/jacobpeterson/alpacajava/common/sse/SseResponse.java @@ -0,0 +1,66 @@ +package net.jacobpeterson.alpacajava.common.sse; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.jspecify.annotations.NullMarked; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UncheckedIOException; +import java.net.http.HttpClient; +import java.net.http.HttpHeaders; +import java.net.http.HttpResponse; +import java.util.function.Function; + +import static java.nio.charset.StandardCharsets.UTF_8; + +@RequiredArgsConstructor +@NullMarked +public class SseResponse implements AutoCloseable { + + private static final String DATA_PREFIX = "data: "; + private static final String COMMENT_PREFIX = ": "; + + private final @Getter int statusCode; + private final @Getter HttpHeaders headers; + private final InputStream body; + private volatile boolean close; + + public SseResponse(final HttpClient httpClient, final HttpResponse response, + final SseListener sseListener, final Function dataFromJson) { + statusCode = response.statusCode(); + headers = response.headers(); + body = response.body(); + httpClient.executor().orElse(Thread::startVirtualThread).execute(() -> { + try (final var reader = new BufferedReader(new InputStreamReader(body, UTF_8))) { + String line; + while ((line = reader.readLine()) != null) { + if (line.startsWith(DATA_PREFIX)) { + sseListener.onData(dataFromJson.apply(line.substring(DATA_PREFIX.length()))); + } else if (!line.isBlank()) { + sseListener.onComment(line.startsWith(COMMENT_PREFIX) ? + line.substring(COMMENT_PREFIX.length()) : line); + } + } + } catch (final Throwable throwable) { + if (!close && !(throwable instanceof IOException)) { + sseListener.onError(throwable); + } + } finally { + sseListener.onClose(); + } + }); + } + + @Override + public void close() { + close = true; + try { + body.close(); + } catch (final IOException ioException) { + throw new UncheckedIOException(ioException); + } + } +} diff --git a/module/market-data/build.gradle.kts b/module/market-data/build.gradle.kts new file mode 100644 index 00000000..6e66e9c5 --- /dev/null +++ b/module/market-data/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("module-common") + id("openapi-generator-adapted") +} + +description = "A Java library for the Alpaca brokerage platform Market Data API." + +openApiGeneratorAdapted { + environmentUrlProduction = "https://data.alpaca.markets" + environmentUrlDevelopment = "https://data.sandbox.alpaca.markets" +} diff --git a/module/market-data/openapi.json b/module/market-data/openapi.json new file mode 100644 index 00000000..0c4ca563 --- /dev/null +++ b/module/market-data/openapi.json @@ -0,0 +1,10562 @@ +{ + "components": { + "headers": { + "ratelimit_limit": { + "description": "Request limit per minute.", + "example": 100, + "schema": { + "type": "integer" + } + }, + "ratelimit_remaining": { + "description": "Request limit per minute remaining.", + "example": 90, + "schema": { + "type": "integer" + } + }, + "ratelimit_reset": { + "description": "The UNIX epoch when the remaining quota changes.", + "example": 1674044551, + "schema": { + "type": "integer" + } + } + }, + "parameters": { + "cas_cusips": { + "description": "A comma-separated list of CUSIPs.", + "example": "037833100,88160R101", + "in": "query", + "name": "cusips", + "schema": { + "type": "string" + } + }, + "cas_data_quality": { + "description": "Controls which corporate actions are returned based on data quality.\n", + "in": "query", + "name": "data_quality", + "schema": { + "$ref": "#/components/schemas/data_quality" + } + }, + "cas_end": { + "description": "The inclusive end of the interval. The corporate actions are sorted by their `process_date`. Format: YYYY-MM-DD. Default: current day.\n", + "examples": { + "date": { + "summary": "Date", + "value": "2024-08-25" + } + }, + "in": "query", + "name": "end", + "schema": { + "format": "date", + "type": "string" + } + }, + "cas_events_last_event_id": { + "description": "Standard SSE reconnect header. ULID matching an `event_id`; replay events\nwhose `event_id` is greater than or equal to this value (inclusive -- the\nevent with this id is redelivered on reconnect, so clients should\ndeduplicate by `event_id` if needed). Overrides `since_id` when both are\nset.\n", + "example": "01J9RPMV5TKB8WX3M4F1KZ7QH2", + "in": "header", + "name": "Last-Event-Id", + "schema": { + "$ref": "#/components/schemas/event_id" + } + }, + "cas_events_region": { + "description": "Which markets to receive events for. Compared against the envelope's `region`\nfield and applied uniformly to historical and live events.\n\n- `all` (default): every event, regardless of market.\n- `us`: only events with `region == \"us\"`.\n- `non_us`: only events with `region == \"non_us\"`.\n\nUnknown values return `400` with the list of valid values in the error\nmessage. The value is case-insensitive.\n", + "in": "query", + "name": "region", + "schema": { + "default": "all", + "enum": [ + "all", + "us", + "non_us" + ], + "type": "string" + } + }, + "cas_events_since": { + "description": "Replay events emitted on or after this RFC-3339 date. Mutually exclusive with\n`since_id`. Required when `until` is specified.\n", + "example": "2026-03-20T00:00:00Z", + "in": "query", + "name": "since", + "schema": { + "format": "date-time", + "type": "string" + } + }, + "cas_events_since_id": { + "description": "ULID matching an `event_id`; replay events whose `event_id` is greater than\nor equal to this value (inclusive -- the event with this id, if it still\nexists, is redelivered). Mutually exclusive with `since`. Overridden by the\n`Last-Event-Id` header when both are set.\n", + "example": "01J9RPMV5TKB8WX3M4F1KZ7QH2", + "in": "query", + "name": "since_id", + "schema": { + "$ref": "#/components/schemas/event_id" + } + }, + "cas_events_type": { + "description": "Filter the stream to a subset of `event_type` values.\n\nPassed as a comma-separated list in the URL query, e.g.\n`?type=cash_dividend_corporateaction_event,stock_dividend_corporateaction_event`.\n\nOnly events whose `event_type` is in this list are delivered. An empty or\nomitted value is treated as \"no filter\" (deliver every type). Unknown values\nreturn `400` with the list of valid values in the error message. The filter\napplies uniformly to both replayed (historical) and live events.\n\nSee [`corporate_action_event_type`](#/components/schemas/corporate_action_event_type)\nfor the full list of accepted values.\n", + "example": [ + "cash_dividend_corporateaction_event", + "stock_dividend_corporateaction_event" + ], + "explode": false, + "in": "query", + "name": "type", + "schema": { + "items": { + "$ref": "#/components/schemas/corporate_action_event_type" + }, + "type": "array" + }, + "style": "form" + }, + "cas_events_until": { + "description": "Close the connection after the last event on this RFC-3339 date (inclusive).\nRequires `since`; cannot be in the future.\n", + "example": "2026-03-20T23:59:59Z", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + "cas_events_until_id": { + "description": "ULID matching an `event_id`; close the connection once this id has been\ndelivered (inclusive). Requires `since_id`; cannot be in the future.\n", + "example": "01J9RVB6Y4ZK8M3N7QD2WX1RFP", + "in": "query", + "name": "until_id", + "schema": { + "$ref": "#/components/schemas/event_id" + } + }, + "cas_ids": { + "description": "A comma-separated list of corporate action IDs. This parameter is mutually exclusive with all other filters (symbols, types, start, end, region, data_quality).\n", + "example": "1dbc7685-9517-4a77-a236-8527d49cefdc,f8489167-4e4b-431d-a0be-6017ae1cf08a", + "in": "query", + "name": "ids", + "schema": { + "type": "string" + } + }, + "cas_limit": { + "description": "Maximum number of corporate actions to return in a response.\nThe limit applies to the total number of data points, not the count per symbol!\nUse `next_page_token` to fetch the next set of corporate actions.\n", + "in": "query", + "name": "limit", + "schema": { + "default": 100, + "maximum": 1000, + "minimum": 1, + "type": "integer" + } + }, + "cas_region": { + "description": "The region to filter corporate actions by.", + "in": "query", + "name": "region", + "schema": { + "$ref": "#/components/schemas/region" + } + }, + "cas_start": { + "description": "The inclusive start of the interval. The corporate actions are sorted by their `process_date`. Format: YYYY-MM-DD. Default: current day.\n", + "examples": { + "date": { + "value": "2024-08-14" + } + }, + "in": "query", + "name": "start", + "schema": { + "format": "date", + "type": "string" + } + }, + "cas_symbols": { + "description": "A comma-separated list of symbols.", + "example": "AAPL,TSLA", + "in": "query", + "name": "symbols", + "schema": { + "type": "string" + } + }, + "cas_types": { + "description": "A comma-separated list of types. If not provided, search all types.\n\nThe following types are supported:\n - reverse_split\n - forward_split\n - unit_split\n - cash_dividend\n - stock_dividend\n - spin_off\n - cash_merger\n - stock_merger\n - stock_and_cash_merger\n - redemption\n - name_change\n - worthless_removal\n - rights_distribution\n - partial_call\n - reorganization\n - capital_gains_distribution\n", + "example": "forward_split,reverse_split", + "in": "query", + "name": "types", + "schema": { + "type": "string" + } + }, + "crypto_historical_loc": { + "description": "Crypto location from where the historical market data is retrieved.\n- `us`: Alpaca US\n- `us-1`: Kraken US\n- `eu-1`: Kraken EU\n", + "in": "path", + "name": "loc", + "required": true, + "schema": { + "$ref": "#/components/schemas/crypto_historical_loc" + } + }, + "crypto_latest_loc": { + "description": "Crypto location from where the latest market data is retrieved.\n- `us`: Alpaca US\n- `us-1`: Kraken US\n- `eu-1`: Kraken EU\n", + "in": "path", + "name": "loc", + "required": true, + "schema": { + "$ref": "#/components/schemas/crypto_latest_loc" + } + }, + "crypto_symbols": { + "description": "A comma-separated list of crypto symbols.", + "example": "BTC/USD,LTC/USD", + "in": "query", + "name": "symbols", + "required": true, + "schema": { + "type": "string" + } + }, + "end": { + "description": "The inclusive end of the interval. Format: RFC-3339 or YYYY-MM-DD.\nDefault: the current time if the user has a real-time access for the feed, otherwise 15 minutes before the current time.\n", + "examples": { + "RFC-3339 nanosecond": { + "summary": "RFC-3339 date-time with nanosecond accuracy", + "value": "2024-01-04T01:02:03.123456789Z" + }, + "RFC-3339 second": { + "summary": "RFC-3339 date-time with second accuracy", + "value": "2024-01-04T00:00:00Z" + }, + "RFC-3339 with timezone": { + "summary": "RFC-3339 date-time with time zone", + "value": "2024-01-04T09:30:00-04:00" + }, + "date": { + "summary": "Date", + "value": "2024-01-04" + } + }, + "in": "query", + "name": "end", + "required": false, + "schema": { + "format": "date-time", + "type": "string" + } + }, + "forex_currency_pairs": { + "in": "query", + "name": "currency_pairs", + "required": true, + "schema": { + "$ref": "#/components/schemas/forex_currency_pairs" + } + }, + "forex_timeframe": { + "in": "query", + "name": "timeframe", + "required": false, + "schema": { + "$ref": "#/components/schemas/forex_timeframe" + } + }, + "isins": { + "description": "A comma-separated list of ISINs with a limit of 1000.", + "example": "US912797KJ59,US912797KS58,US912797LB15", + "in": "query", + "name": "isins", + "required": true, + "schema": { + "type": "string" + } + }, + "limit": { + "description": "The maximum number of data points to return in the response page.\nThe API may return less, even if there are more available data points in the requested interval.\nAlways check the `next_page_token` for more pages.\nThe limit applies to the total number of data points, not per symbol!\n", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "default": 1000, + "maximum": 10000, + "minimum": 1, + "type": "integer" + } + }, + "most_actives_by": { + "description": "The metric used for ranking the most active stocks.", + "in": "query", + "name": "by", + "required": false, + "schema": { + "default": "volume", + "enum": [ + "volume", + "trades" + ], + "type": "string" + } + }, + "most_actives_top": { + "description": "The number of top most active stocks to fetch per day.", + "in": "query", + "name": "top", + "required": false, + "schema": { + "default": 10, + "format": "int32", + "maximum": 100, + "minimum": 1, + "type": "integer" + } + }, + "movers_market_type": { + "description": "Screen-specific market (stocks or crypto).", + "in": "path", + "name": "market_type", + "required": true, + "schema": { + "$ref": "#/components/schemas/market_type" + } + }, + "movers_top": { + "description": "Number of top market movers to fetch (gainers and losers). Will return this number of results for each. By default, 10 gainers and 10 losers.\n", + "in": "query", + "name": "top", + "required": false, + "schema": { + "default": 10, + "format": "int32", + "maximum": 50, + "minimum": 1, + "type": "integer" + } + }, + "news_sort": { + "description": "Sort articles by updated date.", + "in": "query", + "name": "sort", + "schema": { + "default": "desc", + "enum": [ + "asc", + "desc" + ], + "type": "string" + } + }, + "option_feed": { + "description": "The source feed of the data. `opra` is the official OPRA feed, `indicative` is a free indicative feed where trades are delayed and quotes are modified. Default: `opra` if the user has a subscription, otherwise `indicative`.\n", + "in": "query", + "name": "feed", + "schema": { + "$ref": "#/components/schemas/option_feed" + } + }, + "option_limit": { + "description": "Number of maximum snapshots to return in a response.\nThe limit applies to the total number of data points, not the number per symbol!\nUse `next_page_token` to fetch the next set of responses.\n", + "in": "query", + "name": "limit", + "schema": { + "default": 100, + "maximum": 1000, + "minimum": 1, + "type": "integer" + } + }, + "option_symbols": { + "description": "A comma-separated list of contract symbols with a limit of 100.", + "example": "AAPL241220C00300000,AAPL240315C00225000", + "in": "query", + "name": "symbols", + "required": true, + "schema": { + "type": "string" + } + }, + "option_underlying_symbol": { + "description": "The financial instrument on which an option contract is based or derived.", + "example": "AAPL", + "in": "path", + "name": "underlying_symbol", + "required": true, + "schema": { + "type": "string" + } + }, + "option_updated_since": { + "description": "Filter to snapshots that were updated since this timestamp, meaning that the timestamp of the trade or the quote is greater than or equal to this value.\nFormat: RFC-3339 or YYYY-MM-DD. If missing, all values are returned.\n", + "in": "query", + "name": "updated_since", + "required": false, + "schema": { + "format": "date-time", + "type": "string" + } + }, + "page_token": { + "description": "The pagination token from which to continue. The value to pass here is returned in specific requests when more data is available, usually because of a response result limit.\n", + "in": "query", + "name": "page_token", + "schema": { + "type": "string" + } + }, + "sort": { + "description": "Sort data in ascending or descending order.", + "in": "query", + "name": "sort", + "schema": { + "$ref": "#/components/schemas/sort" + } + }, + "start": { + "description": "The inclusive start of the interval. Format: RFC-3339 or YYYY-MM-DD.\nDefault: the beginning of the current day, but at least 15 minutes ago if the user doesn't have real-time access for the feed.\n", + "examples": { + "RFC-3339 nanosecond": { + "summary": "RFC-3339 date-time with nanosecond accuracy", + "value": "2024-01-03T01:02:03.123456789Z" + }, + "RFC-3339 second": { + "summary": "RFC-3339 date-time with second accuracy", + "value": "2024-01-03T00:00:00Z" + }, + "RFC-3339 with timezone": { + "summary": "RFC-3339 date-time with time zone", + "value": "2024-01-03T09:30:00-04:00" + }, + "date": { + "summary": "Date", + "value": "2024-01-03" + } + }, + "in": "query", + "name": "start", + "required": false, + "schema": { + "format": "date-time", + "type": "string" + } + }, + "stock_adjustment": { + "description": "Specifies the adjustments for the bars.\n\n - `raw`: no adjustments\n - `split`: adjust price and volume for forward and reverse stock splits\n - `dividend`: adjust price for cash dividends\n - `spin-off`: adjust price for spin-offs\n - `all`: apply all above adjustments\n\nYou can combine multiple adjustments by separating them with a comma, e.g. `split,spin-off`.\n", + "in": "query", + "name": "adjustment", + "schema": { + "default": "raw", + "type": "string" + } + }, + "stock_asof": { + "description": "The as-of date of the queried stock symbol(s). Format: YYYY-MM-DD. Default: current day.\n\nThis date is used to identify the underlying entity of the provided symbol(s), so that name changes for this entity can be found. Data for past symbol(s) is returned if the query date range spans the name change.\n\nThe special value of \"-\" means symbol mapping is skipped. Data is returned based on the symbol alone without looking up previous names. The same happens if the queried symbol is not found on the given `asof` date.\n\nExample: FB was renamed to META in 2022-06-09. Querying META with an `asof` date after 2022-06-09 will also yield FB data. The data for the FB ticker will be labeled as META because they are considered the same underlying entity as of 2022-06-09. Querying FB with an `asof` date after 2022-06-09 will only return data with the FB ticker, not with META. But with an `asof` date before 2022-06-09, META will also be returned (as FB).\n", + "in": "query", + "name": "asof", + "schema": { + "type": "string" + } + }, + "stock_auction_feed": { + "description": "Only `sip` is valid for auctions.", + "in": "query", + "name": "feed", + "schema": { + "$ref": "#/components/schemas/stock_auction_feed" + } + }, + "stock_currency": { + "description": "The currency of all prices in ISO 4217 format. Default: USD.\n", + "in": "query", + "name": "currency", + "schema": { + "type": "string" + } + }, + "stock_historical_feed": { + "description": "The source feed of the data.\n - `sip`: all US exchanges\n - `iex`: Investors EXchange\n - `boats`: Blue Ocean ATS, overnight US trading data\n - `otc`: over-the-counter exchanges\n", + "in": "query", + "name": "feed", + "schema": { + "$ref": "#/components/schemas/stock_historical_feed" + } + }, + "stock_latest_feed": { + "description": "The source feed of the data.\n\n - `sip`: all US exchanges\n - `iex`: Investors EXchange\n - `delayed_sip`: SIP with a 15 minute delay\n - `boats`: Blue Ocean, overnight US trading data\n - `overnight`: derived overnight US trading data\n - `otc`: over-the-counter exchanges\n\nDefault: `sip` if the user has the unlimited subscription, otherwise `iex`.\n", + "in": "query", + "name": "feed", + "schema": { + "$ref": "#/components/schemas/stock_latest_feed" + } + }, + "stock_symbol": { + "description": "The symbol to query.", + "example": "AAPL", + "in": "path", + "name": "symbol", + "required": true, + "schema": { + "type": "string" + } + }, + "stock_symbols": { + "description": "A comma-separated list of stock symbols.", + "example": "AAPL,TSLA", + "in": "query", + "name": "symbols", + "required": true, + "schema": { + "type": "string" + } + }, + "symbol": { + "description": "A unique series of letters assigned to a security for trading purposes.", + "example": "AAPL", + "in": "path", + "name": "symbol", + "required": true, + "schema": { + "type": "string" + } + }, + "timeframe": { + "description": "The timeframe represented by each bar in aggregation.\nYou can use any of the following values:\n - `[1-59]Min` or `[1-59]T`, e.g. `5Min` or `5T` creates 5-minute aggregations\n - `[1-23]Hour` or `[1-23]H`, e.g. `12Hour` or `12H` creates 12-hour aggregations\n - `1Day` or `1D` creates 1-day aggregations\n - `1Week` or `1W` creates 1-week aggregations\n - `[1,2,3,4,6,12]Month` or `[1,2,3,4,6,12]M`, e.g. `3Month` or `3M` creates 3-month aggregations\n", + "example": "1Min", + "in": "query", + "name": "timeframe", + "required": true, + "schema": { + "type": "string" + } + }, + "trade_size": { + "description": "Filters to best bid/ask where the minimum trade size is less than or equal to the given numeric value. For any negative value the best bid/ask will be returned for the smallest trade size on either side.\n", + "in": "query", + "name": "trade_size", + "required": false, + "schema": { + "format": "int32", + "type": "integer" + } + } + }, + "responses": { + "400": { + "description": "One of the request parameters is invalid. See the returned message for details.\n", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "401": { + "description": "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key.\n" + }, + "403": { + "description": "The requested resource is forbidden.\n" + }, + "429": { + "description": "Too many requests. You hit the rate limit. Use the X-RateLimit-... response headers to make sure you're under the rate limit.\n", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "500": { + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on [Slack](https://alpaca.markets/slack) or on the [Community Forum](https://forum.alpaca.markets/).\n" + } + }, + "schemas": { + "ca_event_base": { + "description": "Common fields present on every `ca` payload regardless of `event_type`.\nNot meant to be referenced directly by clients -- it exists so each\nper-type payload schema (`ca_event_cash_dividend`, `ca_event_forward_split`,\n...) can `allOf`-compose it instead of restating `id` and `process_date`.\nThis makes the \"always present\" invariant structural (guaranteed by the\nschema) rather than emergent from repetition, and matches the \"Common `ca`\nfields\" section of the event-streaming Corporate Actions SSE design doc.\n", + "properties": { + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + } + }, + "required": [ + "id", + "process_date" + ], + "type": "object" + }, + "ca_event_capital_gains_distribution": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "description": "CUSIP of the security.", + "type": "string" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "long_term_rate": { + "description": "Long-term capital-gains payment per share, as a decimal string.", + "examples": [ + "1.4372" + ], + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "short_term_rate": { + "description": "Short-term capital-gains payment per share, as a decimal string.", + "examples": [ + "0.1051" + ], + "type": "string" + }, + "symbol": { + "description": "Ticker paying the distribution.", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "ex_date" + ], + "type": "object" + } + ], + "description": "Capital-gains distribution payload delivered when\n`event_type == capital_gains_distribution_corporateaction_event`. Every\ndecimal field is emitted as a JSON string to preserve precision on the\nwire. At least one of `long_term_rate` / `short_term_rate` is present;\ncombined distributions carry both.\n" + }, + "ca_event_cash_dividend": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "description": "CUSIP of the security.", + "type": "string" + }, + "due_bill_off_date": { + "description": "End of the due-bill period.", + "format": "date", + "type": "string" + }, + "due_bill_on_date": { + "description": "Start of the due-bill period.", + "format": "date", + "type": "string" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "foreign": { + "description": "`true` if the issuer is not US-based.", + "type": "boolean" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "rate": { + "description": "Cash paid per share, as a decimal string.", + "examples": [ + "0.24" + ], + "type": "string" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "special": { + "description": "`true` if this is a one-off dividend outside the issuer's regular\ndistribution schedule.\n", + "type": "boolean" + }, + "sub_type": { + "description": "Optional sub-classification of the dividend.", + "enum": [ + "interest", + "return_of_capital" + ], + "type": "string" + }, + "symbol": { + "description": "Ticker paying the dividend.", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "rate", + "special", + "foreign", + "ex_date" + ], + "type": "object" + } + ], + "description": "Cash dividend payload delivered when\n`event_type == cash_dividend_corporateaction_event`. Corresponds to\n`cash_dividends` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_cash_merger": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "acquiree_cusip": { + "description": "CUSIP of the company being bought.", + "type": "string" + }, + "acquiree_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquiree_symbol": { + "description": "Ticker being bought (will disappear after the merger).", + "type": "string" + }, + "acquirer_cusip": { + "description": "Buyer's CUSIP.", + "type": "string" + }, + "acquirer_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquirer_symbol": { + "description": "Buyer's ticker (the surviving company).", + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "rate": { + "description": "Cash paid per share of the acquired company, as a decimal string.", + "examples": [ + "42.50" + ], + "type": "string" + } + }, + "required": [ + "acquiree_symbol", + "acquiree_cusip", + "rate", + "effective_date" + ], + "type": "object" + } + ], + "description": "Cash merger payload delivered when\n`event_type == cash_merger_corporateaction_event`. Corresponds to\n`cash_mergers` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_equity_partial_call": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "description": "CUSIP of the security.", + "type": "string" + }, + "dividend_rate": { + "description": "Dividend rate associated with the called shares, as a decimal string.", + "examples": [ + "0.05" + ], + "type": "string" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "lottery_date": { + "description": "When the lottery drawing happens.", + "format": "date", + "type": "string" + }, + "lottery_type": { + "description": "How called shares were allocated among holders.", + "enum": [ + "original", + "supplemental" + ], + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "price": { + "description": "Price paid per called share, as a decimal string.", + "examples": [ + "15.00" + ], + "type": "string" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "results_publication_date": { + "description": "When the lottery results are published.", + "format": "date", + "type": "string" + }, + "symbol": { + "description": "Ticker being partially called.", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Partial redemption of an equity issue where the issuer calls back only a\nfraction of outstanding shares -- typically allocated to holders via a\nlottery. Delivered when\n`event_type == equity_partial_call_corporateaction_event`. Corresponds to\n`partial_calls` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_forward_split": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "description": "CUSIP of the security.", + "type": "string" + }, + "due_bill_redemption_date": { + "$ref": "#/components/schemas/due_bill_redemption_date" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "description": "Shares after the split, as a decimal string.", + "examples": [ + "4" + ], + "type": "string" + }, + "old_rate": { + "description": "Shares before the split, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "symbol": { + "description": "Ticker being split.", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "old_rate", + "new_rate", + "ex_date" + ], + "type": "object" + } + ], + "description": "Forward stock split payload delivered when\n`event_type == forward_split_corporateaction_event`. Corresponds to\n`forward_splits` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_name_change": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "new_cusip": { + "description": "CUSIP after the change.", + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_symbol": { + "description": "Ticker after the change.", + "type": "string" + }, + "old_cusip": { + "description": "CUSIP before the change.", + "type": "string" + }, + "old_isin": { + "$ref": "#/components/schemas/isin" + }, + "old_symbol": { + "description": "Ticker before the change.", + "type": "string" + } + }, + "required": [ + "old_symbol", + "old_cusip", + "new_symbol", + "new_cusip" + ], + "type": "object" + } + ], + "description": "Name/ticker change payload delivered when\n`event_type == name_change_corporateaction_event`. Corresponds to\n`name_changes` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response.\n" + }, + "ca_event_redemption": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "description": "CUSIP of the security.", + "type": "string" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "rate": { + "description": "Cash paid per share, as a decimal string.", + "examples": [ + "25.00" + ], + "type": "string" + }, + "symbol": { + "description": "Ticker being redeemed.", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "rate" + ], + "type": "object" + } + ], + "description": "Full redemption payload delivered when\n`event_type == redemption_corporateaction_event`. Corresponds to\n`redemptions` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_reorganization": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "cash_rate": { + "description": "Cash paid per source share, as a decimal string.", + "examples": [ + "5.00" + ], + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "description": "CUSIP of the original security.", + "type": "string" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "stock_movements": { + "description": "One entry per replacement security delivered to holders.", + "items": { + "$ref": "#/components/schemas/ca_event_reorganization_stock_movement" + }, + "type": "array" + }, + "symbol": { + "description": "Ticker undergoing the reorganization.", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "effective_date" + ], + "type": "object" + } + ], + "description": "General-purpose corporate restructuring (e.g. Chapter 11 emergence) where\nexisting holders receive a mix of cash and/or one or more replacement\nsecurities. Each entry in `stock_movements` describes a separate\nshare-class distribution. Delivered when\n`event_type == reorganization_corporateaction_event`. Corresponds to\n`reorganizations` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_reorganization_stock_movement": { + "additionalProperties": false, + "description": "A single replacement-security leg of a\n[`ca_event_reorganization`](#/components/schemas/ca_event_reorganization)\npayload. All decimal fields are emitted as JSON strings to preserve\nprecision on the wire.\n", + "properties": { + "cusip": { + "description": "Replacement CUSIP.", + "type": "string" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "description": "Replacement shares delivered per `source_rate`, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "source_rate": { + "description": "Source shares required for each `new_rate`, as a decimal string.", + "examples": [ + "10" + ], + "type": "string" + }, + "symbol": { + "description": "Replacement ticker.", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "new_rate", + "source_rate" + ], + "type": "object" + }, + "ca_event_reverse_split": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "new_cusip": { + "description": "CUSIP after the split.", + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "description": "Shares after the split, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "new_symbol": { + "description": "Ticker after the split when the issuer also changes symbol (e.g. with\na \"D\" suffix). Omitted when the ticker doesn't change.\n", + "type": "string" + }, + "old_cusip": { + "description": "CUSIP before the split.", + "type": "string" + }, + "old_isin": { + "$ref": "#/components/schemas/isin" + }, + "old_rate": { + "description": "Shares before the split, as a decimal string.", + "examples": [ + "10" + ], + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "symbol": { + "description": "Ticker being split.", + "type": "string" + } + }, + "required": [ + "symbol", + "old_cusip", + "new_cusip", + "old_rate", + "new_rate", + "ex_date" + ], + "type": "object" + } + ], + "description": "Reverse stock split payload delivered when\n`event_type == reverse_split_corporateaction_event`. Corresponds to\n`reverse_splits` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_rights_distribution": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "expiration_date": { + "$ref": "#/components/schemas/expiration_date" + }, + "new_cusip": { + "description": "CUSIP of the new right.", + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_symbol": { + "description": "Ticker of the new right/warrant.", + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "rate": { + "description": "Rights given per share you own, as a decimal string.", + "examples": [ + "0.25" + ], + "type": "string" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "source_cusip": { + "description": "CUSIP of the underlying ticker.", + "type": "string" + }, + "source_isin": { + "$ref": "#/components/schemas/isin" + }, + "source_symbol": { + "description": "Ticker whose holders receive the rights.", + "type": "string" + } + }, + "required": [ + "source_symbol", + "source_cusip", + "new_symbol", + "new_cusip", + "rate", + "ex_date", + "payable_date" + ], + "type": "object" + } + ], + "description": "Rights distribution payload delivered when\n`event_type == rights_distribution_corporateaction_event`. Corresponds to\n`rights_distributions` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_spin_off": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "due_bill_redemption_date": { + "$ref": "#/components/schemas/due_bill_redemption_date" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "new_cusip": { + "description": "CUSIP of the new spin-off company.", + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "description": "New-company shares distributed per `source_rate` parent shares, as a decimal string.", + "examples": [ + "0.5" + ], + "type": "string" + }, + "new_symbol": { + "description": "Ticker of the new spin-off company.", + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "source_cusip": { + "description": "Parent CUSIP.", + "type": "string" + }, + "source_isin": { + "$ref": "#/components/schemas/isin" + }, + "source_rate": { + "description": "Parent shares required per ratio unit, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "source_symbol": { + "description": "Parent company's ticker.", + "type": "string" + } + }, + "required": [ + "source_symbol", + "source_cusip", + "source_rate", + "new_symbol", + "new_cusip", + "new_rate", + "ex_date" + ], + "type": "object" + } + ], + "description": "Spin-off payload delivered when\n`event_type == spin_off_corporateaction_event`. Corresponds to\n`spin_offs` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_stock_and_cash_merger": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "acquiree_cusip": { + "description": "CUSIP of the company being bought.", + "type": "string" + }, + "acquiree_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquiree_rate": { + "description": "Bought-side ratio, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "acquiree_symbol": { + "description": "Ticker being bought (will disappear).", + "type": "string" + }, + "acquirer_cusip": { + "description": "Buyer's CUSIP.", + "type": "string" + }, + "acquirer_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquirer_rate": { + "description": "Buyer shares given per unit ratio, as a decimal string.", + "examples": [ + "0.5" + ], + "type": "string" + }, + "acquirer_symbol": { + "description": "Buyer's ticker (the surviving company).", + "type": "string" + }, + "cash_rate": { + "description": "Extra cash paid per share of the acquired company, as a decimal string.", + "examples": [ + "10.00" + ], + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + } + }, + "required": [ + "acquirer_symbol", + "acquirer_cusip", + "acquirer_rate", + "acquiree_symbol", + "acquiree_cusip", + "acquiree_rate", + "cash_rate", + "effective_date" + ], + "type": "object" + } + ], + "description": "Merger paying a mix of stock and cash. Delivered when\n`event_type == stock_and_cash_merger_corporateaction_event`. Corresponds\nto `stock_and_cash_mergers` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_stock_dividend": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "description": "CUSIP of the security.", + "type": "string" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "rate": { + "description": "Extra shares received per share held, as a decimal string.", + "examples": [ + "0.05" + ], + "type": "string" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "symbol": { + "description": "Ticker paying the stock dividend.", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "rate", + "ex_date" + ], + "type": "object" + } + ], + "description": "Stock dividend payload delivered when\n`event_type == stock_dividend_corporateaction_event`. Corresponds to\n`stock_dividends` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_stock_merger": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "acquiree_cusip": { + "description": "CUSIP of the company being bought.", + "type": "string" + }, + "acquiree_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquiree_rate": { + "description": "Bought-side ratio, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "acquiree_symbol": { + "description": "Ticker being bought (will disappear).", + "type": "string" + }, + "acquirer_cusip": { + "description": "Buyer's CUSIP.", + "type": "string" + }, + "acquirer_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquirer_rate": { + "description": "Buyer-side ratio, as a decimal string.", + "examples": [ + "0.75" + ], + "type": "string" + }, + "acquirer_symbol": { + "description": "Buyer's ticker (the surviving company).", + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + } + }, + "required": [ + "acquirer_symbol", + "acquirer_cusip", + "acquirer_rate", + "acquiree_symbol", + "acquiree_cusip", + "acquiree_rate", + "effective_date" + ], + "type": "object" + } + ], + "description": "All-stock merger payload delivered when\n`event_type == stock_merger_corporateaction_event`. Corresponds to\n`stock_mergers` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_unit_split": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "alternate_cusip": { + "description": "CUSIP of the secondary leg.", + "type": "string" + }, + "alternate_isin": { + "$ref": "#/components/schemas/isin" + }, + "alternate_rate": { + "description": "Secondary-leg shares delivered per unit, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "alternate_symbol": { + "description": "Ticker of the secondary leg (usually a warrant).", + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "new_cusip": { + "description": "CUSIP of the primary leg.", + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "description": "Primary-leg shares delivered per unit, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "new_symbol": { + "description": "Ticker of the primary leg (usually the common share).", + "type": "string" + }, + "old_cusip": { + "description": "CUSIP of the unit.", + "type": "string" + }, + "old_isin": { + "$ref": "#/components/schemas/isin" + }, + "old_rate": { + "description": "Units per ratio unit, as a decimal string.", + "examples": [ + "1" + ], + "type": "string" + }, + "old_symbol": { + "description": "Ticker of the unit being split.", + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + } + }, + "required": [ + "old_symbol", + "old_cusip", + "old_rate", + "new_symbol", + "new_cusip", + "new_rate", + "alternate_symbol", + "alternate_cusip", + "alternate_rate", + "effective_date" + ], + "type": "object" + } + ], + "description": "Unit split payload delivered when\n`event_type == unit_split_corporateaction_event`. Corresponds to\n`unit_splits` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response, but\nevery decimal field is emitted as a JSON string to preserve precision on\nthe wire.\n" + }, + "ca_event_worthless_removal": { + "allOf": [ + { + "$ref": "#/components/schemas/ca_event_base" + }, + { + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "description": "CUSIP of the security.", + "type": "string" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "symbol": { + "description": "Ticker being removed.", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip" + ], + "type": "object" + } + ], + "description": "Worthless removal payload delivered when\n`event_type == worthless_removal_corporateaction_event`. Corresponds to\n`worthless_removals` on the REST\n[`GET /v1/corporate-actions`](#operation/CorporateActions) response.\n" + }, + "ca_id": { + "description": "The internal Alpaca identifier of the corporate action.", + "format": "uuid", + "type": "string" + }, + "capital_gains_distribution": { + "description": "Capital gains distribution paid by a fund. A single event may carry a long-term\nleg (`long_term_rate`), a short-term leg (`short_term_rate`), or both when\ncombined. At least one of the two rates is always present.\n", + "examples": [ + { + "currency": "USD", + "cusip": "36261K509", + "ex_date": "2025-12-26", + "id": "98c905a1-08c7-450c-8669-b8e7aee8b44d", + "isin": "US36261K5090", + "long_term_rate": 0.45855, + "payable_date": "2026-01-09", + "process_date": "2026-01-08", + "record_date": "2025-12-29", + "short_term_rate": 0.11019, + "symbol": "GCAD" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "type": "string" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "long_term_rate": { + "description": "Long-term capital-gain payment per share.", + "format": "double", + "type": "number" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "short_term_rate": { + "description": "Short-term capital-gain payment per share.", + "format": "double", + "type": "number" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "cusip", + "process_date", + "ex_date" + ], + "type": "object" + }, + "cash_dividend": { + "description": "Cash dividend.", + "examples": [ + { + "cusip": "319829107", + "ex_date": "2023-05-04", + "foreign": false, + "id": "11cfd108-292e-4cc6-bfbf-5999cdbc4029", + "payable_date": "2023-05-19", + "process_date": "2023-05-19", + "rate": 0.125, + "record_date": "2023-05-05", + "special": false, + "symbol": "FCF" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "type": "string" + }, + "due_bill_off_date": { + "format": "date", + "type": "string" + }, + "due_bill_on_date": { + "format": "date", + "type": "string" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "foreign": { + "type": "boolean" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "rate": { + "format": "double", + "type": "number" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "special": { + "type": "boolean" + }, + "sub_type": { + "description": "Sub-type of the cash dividend.", + "enum": [ + "interest", + "return_of_capital" + ], + "type": "string" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "cusip", + "rate", + "special", + "foreign", + "process_date", + "ex_date" + ], + "type": "object" + }, + "cash_merger": { + "description": "Cash merger.", + "examples": [ + { + "acquiree_cusip": "Y2687W108", + "acquiree_symbol": "GLOP", + "effective_date": "2023-07-17", + "id": "3772bbd7-4ad5-44d4-9cc0-f69156a2f8f5", + "payable_date": "2023-07-17", + "process_date": "2023-07-17", + "rate": 5.37 + } + ], + "properties": { + "acquiree_cusip": { + "type": "string" + }, + "acquiree_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquiree_symbol": { + "type": "string" + }, + "acquirer_cusip": { + "type": "string" + }, + "acquirer_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquirer_symbol": { + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "rate": { + "format": "double", + "type": "number" + } + }, + "required": [ + "id", + "acquiree_symbol", + "acquiree_cusip", + "rate", + "process_date", + "effective_date" + ], + "type": "object" + }, + "corporate_action_event": { + "description": "A single corporate-action mutation delivered over the\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n\nEvery event uses the same envelope. The `event_type` field selects which of\nthe 15 per-type schemas populates `ca`; see\n[`corporate_action_event_type`](#/components/schemas/corporate_action_event_type)\nfor the full mapping and follow the link on each row to the per-type `ca`\npayload schema.\n\nOptional fields (including `currency` and, on most CA types, `isin`) are\nomitted from the JSON when empty; `null` is never emitted.\n", + "discriminator": { + "mapping": { + "capital_gains_distribution_corporateaction_event": "#/components/schemas/corporate_action_event_capital_gains_distribution", + "cash_dividend_corporateaction_event": "#/components/schemas/corporate_action_event_cash_dividend", + "cash_merger_corporateaction_event": "#/components/schemas/corporate_action_event_cash_merger", + "equity_partial_call_corporateaction_event": "#/components/schemas/corporate_action_event_equity_partial_call", + "forward_split_corporateaction_event": "#/components/schemas/corporate_action_event_forward_split", + "name_change_corporateaction_event": "#/components/schemas/corporate_action_event_name_change", + "redemption_corporateaction_event": "#/components/schemas/corporate_action_event_redemption", + "reorganization_corporateaction_event": "#/components/schemas/corporate_action_event_reorganization", + "reverse_split_corporateaction_event": "#/components/schemas/corporate_action_event_reverse_split", + "rights_distribution_corporateaction_event": "#/components/schemas/corporate_action_event_rights_distribution", + "spin_off_corporateaction_event": "#/components/schemas/corporate_action_event_spin_off", + "stock_and_cash_merger_corporateaction_event": "#/components/schemas/corporate_action_event_stock_and_cash_merger", + "stock_dividend_corporateaction_event": "#/components/schemas/corporate_action_event_stock_dividend", + "stock_merger_corporateaction_event": "#/components/schemas/corporate_action_event_stock_merger", + "unit_split_corporateaction_event": "#/components/schemas/corporate_action_event_unit_split", + "worthless_removal_corporateaction_event": "#/components/schemas/corporate_action_event_worthless_removal" + }, + "propertyName": "event_type" + }, + "oneOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_capital_gains_distribution" + }, + { + "$ref": "#/components/schemas/corporate_action_event_cash_dividend" + }, + { + "$ref": "#/components/schemas/corporate_action_event_cash_merger" + }, + { + "$ref": "#/components/schemas/corporate_action_event_equity_partial_call" + }, + { + "$ref": "#/components/schemas/corporate_action_event_forward_split" + }, + { + "$ref": "#/components/schemas/corporate_action_event_name_change" + }, + { + "$ref": "#/components/schemas/corporate_action_event_redemption" + }, + { + "$ref": "#/components/schemas/corporate_action_event_reorganization" + }, + { + "$ref": "#/components/schemas/corporate_action_event_reverse_split" + }, + { + "$ref": "#/components/schemas/corporate_action_event_rights_distribution" + }, + { + "$ref": "#/components/schemas/corporate_action_event_spin_off" + }, + { + "$ref": "#/components/schemas/corporate_action_event_stock_and_cash_merger" + }, + { + "$ref": "#/components/schemas/corporate_action_event_stock_dividend" + }, + { + "$ref": "#/components/schemas/corporate_action_event_stock_merger" + }, + { + "$ref": "#/components/schemas/corporate_action_event_unit_split" + }, + { + "$ref": "#/components/schemas/corporate_action_event_worthless_removal" + } + ] + }, + "corporate_action_event_action": { + "description": "Kind of mutation that produced this event on the upstream corporate actions\nstore:\n\n- `insert`: a new corporate action was created.\n- `update`: an existing corporate action was modified (e.g. a date or rate\n correction). `ca.id` matches the original event.\n- `delete`: a previously published corporate action was removed. `ca.id`\n matches the original event; subsequent events for the same id (if any)\n will be new inserts.\n", + "enum": [ + "insert", + "update", + "delete" + ], + "type": "string" + }, + "corporate_action_event_base": { + "description": "Common envelope fields shared by every variant of\n[`corporate_action_event`](#/components/schemas/corporate_action_event).\nThis schema is not meant to be used directly by clients -- it exists so each\nper-`event_type` `oneOf` branch can `allOf`-compose the envelope basics\n(`event_id`, `at`, `action`, `region`) alongside its narrowed `event_type` /\n`ca` pair. Keeping these in one place is what makes the envelope's\n`discriminator` play nicely with strict OpenAPI validators.\n", + "properties": { + "action": { + "$ref": "#/components/schemas/corporate_action_event_action" + }, + "at": { + "description": "RFC-3339 timestamp when the streaming service emitted this event.", + "examples": [ + "2026-03-20T12:24:58.807230Z" + ], + "format": "date-time", + "type": "string" + }, + "event_id": { + "$ref": "#/components/schemas/event_id" + }, + "region": { + "$ref": "#/components/schemas/corporate_action_event_region" + } + }, + "required": [ + "event_id", + "at", + "action", + "region" + ], + "type": "object" + }, + "corporate_action_event_capital_gains_distribution": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_capital_gains_distribution" + }, + "event_type": { + "enum": [ + "capital_gains_distribution_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\ncapital_gains_distribution_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_cash_dividend": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_cash_dividend" + }, + "event_type": { + "enum": [ + "cash_dividend_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\ncash_dividend_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_cash_merger": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_cash_merger" + }, + "event_type": { + "enum": [ + "cash_merger_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\ncash_merger_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_equity_partial_call": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_equity_partial_call" + }, + "event_type": { + "enum": [ + "equity_partial_call_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nequity_partial_call_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_forward_split": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_forward_split" + }, + "event_type": { + "enum": [ + "forward_split_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nforward_split_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_name_change": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_name_change" + }, + "event_type": { + "enum": [ + "name_change_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nname_change_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_redemption": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_redemption" + }, + "event_type": { + "enum": [ + "redemption_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nredemption_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_region": { + "description": "Envelope-level classification derived from `metadata.global` on the upstream\ncorporate-action record. This is the only field the SSE `region` filter\ninspects on each event.\n\n- `us`: US-listed / US-regulated corporate action.\n- `non_us`: everything else.\n", + "enum": [ + "us", + "non_us" + ], + "type": "string" + }, + "corporate_action_event_reorganization": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_reorganization" + }, + "event_type": { + "enum": [ + "reorganization_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nreorganization_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_reverse_split": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_reverse_split" + }, + "event_type": { + "enum": [ + "reverse_split_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nreverse_split_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_rights_distribution": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_rights_distribution" + }, + "event_type": { + "enum": [ + "rights_distribution_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nrights_distribution_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_spin_off": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_spin_off" + }, + "event_type": { + "enum": [ + "spin_off_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nspin_off_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_stock_and_cash_merger": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_stock_and_cash_merger" + }, + "event_type": { + "enum": [ + "stock_and_cash_merger_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nstock_and_cash_merger_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_stock_dividend": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_stock_dividend" + }, + "event_type": { + "enum": [ + "stock_dividend_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nstock_dividend_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_stock_merger": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_stock_merger" + }, + "event_type": { + "enum": [ + "stock_merger_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nstock_merger_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_type": { + "description": "Discriminator that determines the shape of the `ca` field on a\n[`corporate_action_event`](#/components/schemas/corporate_action_event).\n\nEach value corresponds to a per-type payload schema:\n\n| `event_type` | `ca` schema |\n| --- | --- |\n| `capital_gains_distribution_corporateaction_event` | [`ca_event_capital_gains_distribution`](#/components/schemas/ca_event_capital_gains_distribution) |\n| `cash_dividend_corporateaction_event` | [`ca_event_cash_dividend`](#/components/schemas/ca_event_cash_dividend) |\n| `cash_merger_corporateaction_event` | [`ca_event_cash_merger`](#/components/schemas/ca_event_cash_merger) |\n| `equity_partial_call_corporateaction_event` | [`ca_event_equity_partial_call`](#/components/schemas/ca_event_equity_partial_call) |\n| `forward_split_corporateaction_event` | [`ca_event_forward_split`](#/components/schemas/ca_event_forward_split) |\n| `name_change_corporateaction_event` | [`ca_event_name_change`](#/components/schemas/ca_event_name_change) |\n| `redemption_corporateaction_event` | [`ca_event_redemption`](#/components/schemas/ca_event_redemption) |\n| `reorganization_corporateaction_event` | [`ca_event_reorganization`](#/components/schemas/ca_event_reorganization) |\n| `reverse_split_corporateaction_event` | [`ca_event_reverse_split`](#/components/schemas/ca_event_reverse_split) |\n| `rights_distribution_corporateaction_event` | [`ca_event_rights_distribution`](#/components/schemas/ca_event_rights_distribution) |\n| `spin_off_corporateaction_event` | [`ca_event_spin_off`](#/components/schemas/ca_event_spin_off) |\n| `stock_and_cash_merger_corporateaction_event` | [`ca_event_stock_and_cash_merger`](#/components/schemas/ca_event_stock_and_cash_merger) |\n| `stock_dividend_corporateaction_event` | [`ca_event_stock_dividend`](#/components/schemas/ca_event_stock_dividend) |\n| `stock_merger_corporateaction_event` | [`ca_event_stock_merger`](#/components/schemas/ca_event_stock_merger) |\n| `unit_split_corporateaction_event` | [`ca_event_unit_split`](#/components/schemas/ca_event_unit_split) |\n| `worthless_removal_corporateaction_event` | [`ca_event_worthless_removal`](#/components/schemas/ca_event_worthless_removal) |\n", + "enum": [ + "capital_gains_distribution_corporateaction_event", + "cash_dividend_corporateaction_event", + "cash_merger_corporateaction_event", + "equity_partial_call_corporateaction_event", + "forward_split_corporateaction_event", + "name_change_corporateaction_event", + "redemption_corporateaction_event", + "reorganization_corporateaction_event", + "reverse_split_corporateaction_event", + "rights_distribution_corporateaction_event", + "spin_off_corporateaction_event", + "stock_and_cash_merger_corporateaction_event", + "stock_dividend_corporateaction_event", + "stock_merger_corporateaction_event", + "unit_split_corporateaction_event", + "worthless_removal_corporateaction_event" + ], + "type": "string" + }, + "corporate_action_event_unit_split": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_unit_split" + }, + "event_type": { + "enum": [ + "unit_split_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nunit_split_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_action_event_worthless_removal": { + "allOf": [ + { + "$ref": "#/components/schemas/corporate_action_event_base" + }, + { + "properties": { + "ca": { + "$ref": "#/components/schemas/ca_event_worthless_removal" + }, + "event_type": { + "enum": [ + "worthless_removal_corporateaction_event" + ], + "type": "string" + } + }, + "required": [ + "event_type", + "ca" + ], + "type": "object" + } + ], + "description": "`corporate_action_event` envelope specialised to `event_type ==\nworthless_removal_corporateaction_event`. Emitted through\n[Corporate Actions Events Stream](#operation/SubscribeToCorporateActionsEventsSSE).\n" + }, + "corporate_actions": { + "properties": { + "capital_gains_distributions": { + "items": { + "$ref": "#/components/schemas/capital_gains_distribution" + }, + "type": "array" + }, + "cash_dividends": { + "items": { + "$ref": "#/components/schemas/cash_dividend" + }, + "type": "array" + }, + "cash_mergers": { + "items": { + "$ref": "#/components/schemas/cash_merger" + }, + "type": "array" + }, + "forward_splits": { + "items": { + "$ref": "#/components/schemas/forward_split" + }, + "type": "array" + }, + "name_changes": { + "items": { + "$ref": "#/components/schemas/name_change" + }, + "type": "array" + }, + "partial_calls": { + "items": { + "$ref": "#/components/schemas/partial_call" + }, + "type": "array" + }, + "redemptions": { + "items": { + "$ref": "#/components/schemas/redemption" + }, + "type": "array" + }, + "reorganizations": { + "items": { + "$ref": "#/components/schemas/reorganization" + }, + "type": "array" + }, + "reverse_splits": { + "items": { + "$ref": "#/components/schemas/reverse_split" + }, + "type": "array" + }, + "rights_distributions": { + "items": { + "$ref": "#/components/schemas/rights_distribution" + }, + "type": "array" + }, + "spin_offs": { + "items": { + "$ref": "#/components/schemas/spin_off" + }, + "type": "array" + }, + "stock_and_cash_mergers": { + "items": { + "$ref": "#/components/schemas/stock_and_cash_merger" + }, + "type": "array" + }, + "stock_dividends": { + "items": { + "$ref": "#/components/schemas/stock_dividend" + }, + "type": "array" + }, + "stock_mergers": { + "items": { + "$ref": "#/components/schemas/stock_merger" + }, + "type": "array" + }, + "unit_splits": { + "items": { + "$ref": "#/components/schemas/unit_split" + }, + "type": "array" + }, + "worthless_removals": { + "items": { + "$ref": "#/components/schemas/worthless_removal" + }, + "type": "array" + } + }, + "type": "object" + }, + "corporate_actions_resp": { + "properties": { + "corporate_actions": { + "$ref": "#/components/schemas/corporate_actions" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + } + }, + "required": [ + "corporate_actions", + "next_page_token" + ], + "type": "object" + }, + "crypto_bar": { + "description": "OHLC aggregate of all the trades in a given interval.", + "examples": [ + { + "c": 29003, + "h": 29003, + "l": 28999, + "n": 4, + "o": 28999, + "t": "2022-05-27T10:18:00Z", + "v": 0.01, + "vw": 29001 + } + ], + "properties": { + "c": { + "description": "Closing price.", + "format": "double", + "type": "number" + }, + "h": { + "description": "High price.", + "format": "double", + "type": "number" + }, + "l": { + "description": "Low price.", + "format": "double", + "type": "number" + }, + "n": { + "description": "Trade count in the bar.", + "format": "int64", + "type": "integer" + }, + "o": { + "description": "Opening price.", + "format": "double", + "type": "number" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "v": { + "description": "Bar volume.", + "format": "double", + "type": "number" + }, + "vw": { + "description": "Volume weighted average price.", + "format": "double", + "type": "number" + } + }, + "required": [ + "t", + "o", + "h", + "l", + "c", + "v", + "n", + "vw" + ], + "type": "object" + }, + "crypto_bars_resp": { + "properties": { + "bars": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/crypto_bar" + }, + "type": "array" + }, + "type": "object" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + } + }, + "required": [ + "bars", + "next_page_token" + ], + "type": "object" + }, + "crypto_historical_loc": { + "description": "Crypto location from where the historical market data is retrieved.", + "enum": [ + "us", + "us-1", + "us-2", + "eu-1", + "bs-1" + ], + "type": "string" + }, + "crypto_latest_bars_resp": { + "properties": { + "bars": { + "additionalProperties": { + "$ref": "#/components/schemas/crypto_bar" + }, + "type": "object" + } + }, + "required": [ + "bars" + ], + "type": "object" + }, + "crypto_latest_loc": { + "description": "Crypto location from where the latest market data is retrieved.", + "enum": [ + "us", + "us-1", + "us-2", + "eu-1", + "bs-1" + ], + "type": "string" + }, + "crypto_latest_orderbooks_resp": { + "properties": { + "orderbooks": { + "additionalProperties": { + "$ref": "#/components/schemas/crypto_orderbook" + }, + "type": "object" + } + }, + "required": [ + "orderbooks" + ], + "type": "object" + }, + "crypto_latest_quotes_resp": { + "properties": { + "quotes": { + "additionalProperties": { + "$ref": "#/components/schemas/crypto_quote" + }, + "type": "object" + } + }, + "required": [ + "quotes" + ], + "type": "object" + }, + "crypto_latest_trades_resp": { + "properties": { + "trades": { + "additionalProperties": { + "$ref": "#/components/schemas/crypto_trade" + }, + "type": "object" + } + }, + "required": [ + "trades" + ], + "type": "object" + }, + "crypto_orderbook": { + "description": "Snapshot of the orderbook.", + "examples": [ + { + "a": [ + { + "p": 20902, + "s": 0.0097 + }, + { + "p": 21444, + "s": 0 + } + ], + "b": [ + { + "p": 20846, + "s": 0.1902 + }, + { + "p": 20350, + "s": 0 + } + ], + "t": "2022-06-24T08:00:14.137774336Z" + } + ], + "properties": { + "a": { + "items": { + "$ref": "#/components/schemas/crypto_orderbook_entry" + }, + "type": "array" + }, + "b": { + "items": { + "$ref": "#/components/schemas/crypto_orderbook_entry" + }, + "type": "array" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + } + }, + "required": [ + "t", + "b", + "a" + ], + "type": "object" + }, + "crypto_orderbook_entry": { + "description": "A single entry in a crypto orderbook.", + "examples": [ + { + "p": 20846, + "s": 0.1902 + } + ], + "properties": { + "p": { + "description": "Price.", + "format": "double", + "type": "number" + }, + "s": { + "description": "Size.", + "format": "double", + "type": "number" + } + }, + "required": [ + "p", + "s" + ], + "type": "object" + }, + "crypto_quote": { + "description": "The best bid and ask information for a given security.", + "examples": [ + { + "ap": 29059, + "as": 3.252, + "bp": 29058, + "bs": 0.3544, + "t": "2022-05-26T11:47:18.44347136Z" + } + ], + "properties": { + "ap": { + "description": "Ask price.", + "format": "double", + "type": "number" + }, + "as": { + "description": "Ask size.", + "format": "double", + "type": "number" + }, + "bp": { + "description": "Bid price.", + "format": "double", + "type": "number" + }, + "bs": { + "description": "Bid size.", + "format": "double", + "type": "number" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + } + }, + "required": [ + "t", + "bp", + "bs", + "ap", + "as" + ], + "type": "object" + }, + "crypto_quotes_resp": { + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "quotes": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/crypto_quote" + }, + "type": "array" + }, + "type": "object" + } + }, + "required": [ + "quotes", + "next_page_token" + ], + "type": "object" + }, + "crypto_snapshot": { + "description": "A snapshot provides the latest trade, latest quote, latest minute bar, latest daily bar and previous daily bar.\n", + "properties": { + "dailyBar": { + "$ref": "#/components/schemas/crypto_bar" + }, + "latestQuote": { + "$ref": "#/components/schemas/crypto_quote" + }, + "latestTrade": { + "$ref": "#/components/schemas/crypto_trade" + }, + "minuteBar": { + "$ref": "#/components/schemas/crypto_bar" + }, + "prevDailyBar": { + "$ref": "#/components/schemas/crypto_bar" + } + }, + "type": "object" + }, + "crypto_snapshots_resp": { + "properties": { + "snapshots": { + "additionalProperties": { + "$ref": "#/components/schemas/crypto_snapshot" + }, + "type": "object" + } + }, + "required": [ + "snapshots" + ], + "type": "object" + }, + "crypto_trade": { + "description": "A crypto trade.", + "examples": [ + { + "i": 31455277, + "p": 29798, + "s": 0.1209, + "t": "2022-05-18T12:00:05.225055Z", + "tks": "S" + } + ], + "properties": { + "i": { + "description": "Trade ID.", + "format": "int64", + "type": "integer" + }, + "p": { + "description": "Trade price.", + "format": "double", + "type": "number" + }, + "s": { + "description": "Trade size.", + "format": "double", + "type": "number" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "tks": { + "description": "Taker side: B for buyer, S for seller\n", + "type": "string" + } + }, + "required": [ + "t", + "p", + "s", + "i", + "tks" + ], + "type": "object" + }, + "crypto_trades_resp": { + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "trades": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/crypto_trade" + }, + "type": "array" + }, + "type": "object" + } + }, + "required": [ + "trades", + "next_page_token" + ], + "type": "object" + }, + "currency": { + "description": "The ISO 4217 currency code associated with the corporate action.\nEmpty value can mean USD, non-applicable (e.g. for name changes) or unknown\n(can change later to a valid currency).\n", + "type": "string" + }, + "data_quality": { + "default": "complete", + "description": "Controls which corporate actions are returned based on data quality.\n\n- `complete` (default): exclude corporate actions that are still missing required\n fields (for example, ex-date or CUSIP/ISIN) and have not yet been processed.\n Already-processed corporate actions are always included, even if they would\n otherwise be considered incomplete.\n- `all`: return matching corporate actions regardless of field completeness.\n", + "enum": [ + "complete", + "all" + ], + "type": "string" + }, + "date": { + "description": "Date in RFC-3339.", + "format": "date", + "type": "string" + }, + "due_bill_redemption_date": { + "description": "The date when due bill obligations are redeemed.", + "format": "date", + "type": "string" + }, + "effective_date": { + "description": "The effective date marks the cutoff point for shareholders to be credited.", + "format": "date", + "type": "string" + }, + "event_id": { + "description": "Lexically sortable, monotonically increasing 26-character\n[ULID](https://github.com/ulid/spec) (Crockford Base32, uppercase) that\nidentifies a single SSE emission. Unique per message -- an `update` or\n`delete` for the same underlying corporate action carries a fresh\n`event_id`. Because ULIDs sort in emission order, they can be used as\nresume cursors via `since_id`, `until_id`, or the standard `Last-Event-Id`\nreconnect header.\n", + "examples": [ + "01J9RPMV5TKB8WX3M4F1KZ7QH2" + ], + "format": "ulid", + "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$", + "type": "string" + }, + "ex_date": { + "description": "The ex-date marks the cutoff point for shareholders to be credited.", + "format": "date", + "type": "string" + }, + "expiration_date": { + "format": "date", + "type": "string" + }, + "fixed_income_latest_prices_resp": { + "description": "Latest fixed-income prices keyed by ISIN.", + "examples": [ + { + "prices": { + "US912797KJ59": { + "p": 99.6459, + "t": "2025-02-14T20:58:00.648Z", + "ytm": 4.249, + "ytw": 4.249 + } + } + } + ], + "properties": { + "prices": { + "additionalProperties": { + "$ref": "#/components/schemas/fixed_income_price" + }, + "type": "object" + } + }, + "required": [ + "prices" + ], + "type": "object" + }, + "fixed_income_latest_quotes_resp": { + "description": "Latest fixed-income best bid and ask quotes keyed by ISIN.", + "examples": [ + { + "quotes": { + "US912797SX61": { + "ams": 1000, + "ap": 99.91958333, + "as": 1000000, + "aytm": 2.226923, + "aytw": 2.226923, + "bms": 1000, + "bp": 99.81091667, + "bs": 1000000, + "bytm": 5.236154, + "bytw": 5.236154, + "t": "2026-05-21T06:56:01.882466873Z" + } + } + } + ], + "properties": { + "quotes": { + "additionalProperties": { + "$ref": "#/components/schemas/fixed_income_quote" + }, + "type": "object" + } + }, + "required": [ + "quotes" + ], + "type": "object" + }, + "fixed_income_price": { + "description": "The price of the instrument as a percentage of its par value.", + "examples": [ + { + "p": 99.6459, + "t": "2025-02-14T20:58:00.648Z", + "ytm": 4.249, + "ytw": 4.249 + } + ], + "properties": { + "p": { + "description": "Price", + "format": "double", + "type": "number" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "ytm": { + "description": "Yield to maturity.", + "format": "double", + "type": "number" + }, + "ytw": { + "description": "Yield to worst.", + "format": "double", + "type": "number" + } + }, + "required": [ + "t", + "p" + ], + "type": "object" + }, + "fixed_income_quote": { + "description": "The best bid and ask information for a given fixed income security. A value of 0 means there is no active bid or ask for that field.\n", + "examples": [ + { + "ams": 1000, + "ap": 99.91958333, + "as": 1000000, + "aytm": 2.226923, + "aytw": 2.226923, + "bms": 1000, + "bp": 99.81091667, + "bs": 1000000, + "bytm": 5.236154, + "bytw": 5.236154, + "t": "2026-05-21T06:56:01.882466873Z" + } + ], + "properties": { + "ams": { + "description": "Best ask minimum trade size in par value.", + "format": "int64", + "type": "integer" + }, + "ap": { + "description": "Best ask price. 0 means there is no active ask.", + "format": "double", + "type": "number" + }, + "as": { + "description": "Best ask size in par value. 0 means there is no active ask.", + "format": "int64", + "type": "integer" + }, + "aytm": { + "description": "Best ask yield to maturity.", + "format": "double", + "type": "number" + }, + "aytw": { + "description": "Best ask yield to worst.", + "format": "double", + "type": "number" + }, + "bms": { + "description": "Best bid minimum trade size in par value.", + "format": "int64", + "type": "integer" + }, + "bp": { + "description": "Best bid price. 0 means there is no active bid.", + "format": "double", + "type": "number" + }, + "bs": { + "description": "Best bid size in par value. 0 means there is no active bid.", + "format": "int64", + "type": "integer" + }, + "bytm": { + "description": "Best bid yield to maturity.", + "format": "double", + "type": "number" + }, + "bytw": { + "description": "Best bid yield to worst.", + "format": "double", + "type": "number" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + } + }, + "required": [ + "t", + "bp", + "bs", + "bms", + "bytm", + "bytw", + "ap", + "as", + "ams", + "aytm", + "aytw" + ], + "type": "object" + }, + "forex_currency_pairs": { + "description": "A comma-separated string with currency pairs.", + "examples": [ + "USDJPY", + "USDMXN" + ], + "type": "string" + }, + "forex_latest_rates_resp": { + "description": "The response object of the latest forex rates.", + "properties": { + "rates": { + "additionalProperties": { + "$ref": "#/components/schemas/forex_rate" + }, + "type": "object" + } + }, + "required": [ + "rates" + ], + "type": "object" + }, + "forex_rate": { + "description": "A foreign exchange rate between two currencies at a given time.", + "examples": [ + { + "ap": 127.763, + "bp": 127.702, + "mp": 127.757, + "t": "2022-04-20T18:23:00Z" + } + ], + "properties": { + "ap": { + "description": "The last ask price value of the currency at the end of the timeframe.", + "format": "double", + "type": "number" + }, + "bp": { + "description": "The last bid price value of the currency at the end of the timeframe.", + "format": "double", + "type": "number" + }, + "mp": { + "description": "The last mid price value of the currency at the end of the timeframe.", + "format": "double", + "type": "number" + }, + "t": { + "description": "Timestamp of the rate.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "bp", + "mp", + "ap", + "t" + ], + "type": "object" + }, + "forex_rates_resp": { + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "rates": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/forex_rate" + }, + "type": "array" + }, + "type": "object" + } + }, + "required": [ + "rates", + "next_page_token" + ], + "type": "object" + }, + "forex_timeframe": { + "default": "1Min", + "description": "The sampling interval of the currency rates. For example, 5S returns forex rates sampled every five seconds.\nYou can use the following values:\n - `5Sec` or `5S`\n - `1Min` or `1T`\n - `1Day` or `1D`\n", + "type": "string" + }, + "forward_split": { + "description": "Forward split.", + "examples": [ + { + "cusip": "816851109", + "due_bill_redemption_date": "2023-08-23", + "ex_date": "2023-08-22", + "id": "189bd849-ab9f-4b4d-aaaa-a6d415fd976d", + "new_rate": 2, + "old_rate": 1, + "payable_date": "2023-08-21", + "process_date": "2023-08-22", + "record_date": "2023-08-14", + "symbol": "SRE" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "type": "string" + }, + "due_bill_redemption_date": { + "$ref": "#/components/schemas/due_bill_redemption_date" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "format": "double", + "type": "number" + }, + "old_rate": { + "format": "double", + "type": "number" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "cusip", + "new_rate", + "old_rate", + "process_date", + "ex_date" + ], + "type": "object" + }, + "isin": { + "description": "International Securities Identification Number (ISIN) as defined by ISO 6166.\nMay be empty for US corporate actions.\n", + "type": "string" + }, + "market_type": { + "description": "Market type (stocks or crypto).", + "enum": [ + "stocks", + "crypto" + ], + "type": "string" + }, + "most_active": { + "description": "A stock that is most active by either volume or trade count.", + "examples": [ + { + "symbol": "AAPL", + "trade_count": 639626, + "volume": 122709184 + } + ], + "properties": { + "symbol": { + "type": "string" + }, + "trade_count": { + "description": "Cumulative trade count for the current trading day.", + "format": "int64", + "type": "integer" + }, + "volume": { + "description": "Cumulative volume for the current trading day.", + "format": "int64", + "type": "integer" + } + }, + "required": [ + "symbol", + "volume", + "trade_count" + ], + "type": "object" + }, + "most_actives_resp": { + "properties": { + "last_updated": { + "description": "Time when the most actives were last computed. Formatted as a RFC-3339 date-time with nanosecond precision.\n", + "type": "string" + }, + "most_actives": { + "description": "List of top N most active symbols.", + "items": { + "$ref": "#/components/schemas/most_active" + }, + "type": "array" + } + }, + "required": [ + "most_actives", + "last_updated" + ], + "type": "object" + }, + "mover": { + "description": "A symbol whose price moved significantly.", + "examples": [ + { + "change": 2.46, + "percent_change": 145.56, + "price": 4.15, + "symbol": "AGRI" + } + ], + "properties": { + "change": { + "description": "Difference in change for the day.", + "format": "double", + "type": "number" + }, + "percent_change": { + "description": "Percentage difference change for the day.", + "format": "double", + "type": "number" + }, + "price": { + "description": "Current price of market moving asset.", + "format": "double", + "type": "number" + }, + "symbol": { + "description": "Symbol of market moving asset.", + "type": "string" + } + }, + "required": [ + "symbol", + "percent_change", + "change", + "price" + ], + "title": "Mover", + "type": "object" + }, + "movers_resp": { + "description": "Contains list of market movers.", + "properties": { + "gainers": { + "description": "List of top N gainers.", + "items": { + "$ref": "#/components/schemas/mover" + }, + "type": "array" + }, + "last_updated": { + "description": "Time when the movers were last computed. Formatted as a RFC-3339 date-time with nanosecond precision.\n", + "type": "string" + }, + "losers": { + "description": "List of top N losers.", + "items": { + "$ref": "#/components/schemas/mover" + }, + "type": "array" + }, + "market_type": { + "$ref": "#/components/schemas/market_type" + } + }, + "required": [ + "gainers", + "losers", + "market_type", + "last_updated" + ], + "type": "object" + }, + "name_change": { + "description": "Name change.", + "examples": [ + { + "id": "5a774c35-edec-4532-a812-a56d0bbb623a", + "new_cusip": "Y9390M103", + "new_symbol": "VFS", + "old_cusip": "G11537100", + "old_symbol": "BSAQ", + "process_date": "2023-08-15" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "new_cusip": { + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_symbol": { + "type": "string" + }, + "old_cusip": { + "type": "string" + }, + "old_isin": { + "$ref": "#/components/schemas/isin" + }, + "old_symbol": { + "type": "string" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + } + }, + "required": [ + "id", + "old_symbol", + "old_cusip", + "new_symbol", + "new_cusip", + "process_date" + ], + "type": "object" + }, + "news": { + "description": "Model representing a news article.", + "properties": { + "author": { + "description": "Original author of news article.", + "minLength": 1, + "type": "string" + }, + "content": { + "description": "Content of the news article (might contain HTML).", + "minLength": 1, + "type": "string" + }, + "created_at": { + "description": "Date article was created (RFC-3339).", + "format": "date-time", + "type": "string" + }, + "headline": { + "description": "Headline or title of the article.", + "minLength": 1, + "type": "string" + }, + "id": { + "description": "News article ID.", + "format": "int64", + "type": "integer" + }, + "images": { + "description": "List of images (URLs) related to given article (may be empty).", + "items": { + "$ref": "#/components/schemas/news_image" + }, + "type": "array", + "uniqueItems": true + }, + "source": { + "description": "Source where the news originated from (e.g. Benzinga).", + "minLength": 1, + "type": "string" + }, + "summary": { + "description": "Summary text for the article (may be first sentence of content).", + "minLength": 1, + "type": "string" + }, + "symbols": { + "description": "List of related or mentioned symbols.", + "items": { + "type": "string" + }, + "type": "array" + }, + "updated_at": { + "description": "Date article was updated (RFC-3339).", + "format": "date-time", + "type": "string" + }, + "url": { + "description": "URL of article (if applicable).", + "format": "uri", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "id", + "headline", + "author", + "created_at", + "updated_at", + "summary", + "content", + "images", + "symbols", + "source" + ], + "type": "object" + }, + "news_image": { + "description": "A model representing images for a news article. Simply a URL to the image along with a size parameter suggesting the display size of the image.", + "properties": { + "size": { + "description": "Possible values for size are thumb, small and large.", + "enum": [ + "thumb", + "small", + "large" + ], + "examples": [ + "thumb" + ], + "minLength": 1, + "type": "string" + }, + "url": { + "description": "URL to image from news article.", + "format": "uri", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "size", + "url" + ], + "type": "object" + }, + "news_resp": { + "properties": { + "news": { + "items": { + "$ref": "#/components/schemas/news" + }, + "type": "array" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + } + }, + "required": [ + "news", + "next_page_token" + ], + "type": "object" + }, + "next_page_token": { + "description": "Pagination token for the next page.", + "type": [ + "string", + "null" + ] + }, + "option_bar": { + "description": "OHLC aggregate of all the trades in a given interval.", + "examples": [ + { + "c": 0.23, + "h": 0.28, + "l": 0.23, + "n": 26, + "o": 0.28, + "t": "2024-01-18T05:00:00Z", + "v": 224, + "vw": 0.245045 + } + ], + "properties": { + "c": { + "description": "Closing price.", + "format": "double", + "type": "number" + }, + "h": { + "description": "High price.", + "format": "double", + "type": "number" + }, + "l": { + "description": "Low price.", + "format": "double", + "type": "number" + }, + "n": { + "description": "Trade count in the bar.", + "format": "int64", + "type": "integer" + }, + "o": { + "description": "Opening price.", + "format": "double", + "type": "number" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "v": { + "description": "Bar volume.", + "format": "int64", + "type": "integer" + }, + "vw": { + "description": "Volume weighted average price.", + "format": "double", + "type": "number" + } + }, + "required": [ + "t", + "o", + "h", + "l", + "c", + "v", + "n", + "vw" + ], + "type": "object" + }, + "option_bars_resp": { + "properties": { + "bars": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/option_bar" + }, + "type": "array" + }, + "type": "object" + }, + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + } + }, + "required": [ + "bars", + "next_page_token" + ], + "type": "object" + }, + "option_conditions": { + "additionalProperties": { + "type": "string" + }, + "examples": [ + { + "a": "SLAN - Single Leg Auction Non ISO", + "e": "SLFT - Single Leg Floor Trade", + "g": "MLAT - Multi Leg Auction" + } + ], + "type": "object" + }, + "option_exchanges": { + "additionalProperties": { + "type": "string" + }, + "examples": [ + { + "A": "NYSE American Options", + "Q": "Nasdaq Options" + } + ], + "type": "object" + }, + "option_feed": { + "default": "opra", + "enum": [ + "opra", + "indicative" + ], + "type": "string" + }, + "option_greeks": { + "description": "The greeks for the contract calculated using the Black-Scholes model.", + "properties": { + "delta": { + "format": "double", + "type": "number" + }, + "gamma": { + "format": "double", + "type": "number" + }, + "rho": { + "format": "double", + "type": "number" + }, + "theta": { + "format": "double", + "type": "number" + }, + "vega": { + "format": "double", + "type": "number" + } + }, + "required": [ + "delta", + "gamma", + "theta", + "vega", + "rho" + ], + "type": "object" + }, + "option_latest_quotes_resp": { + "properties": { + "quotes": { + "additionalProperties": { + "$ref": "#/components/schemas/option_quote" + }, + "type": "object" + } + }, + "required": [ + "quotes" + ], + "type": "object" + }, + "option_latest_trades_resp": { + "properties": { + "trades": { + "additionalProperties": { + "$ref": "#/components/schemas/option_trade" + }, + "type": "object" + } + }, + "required": [ + "trades" + ], + "type": "object" + }, + "option_quote": { + "description": "The best bid and ask information for a given option.\n", + "examples": [ + { + "ap": 0.16, + "as": 669, + "ax": "w", + "bp": 0.15, + "bs": 164, + "bx": "W", + "c": "A", + "t": "2024-02-28T15:30:28.046330624Z" + } + ], + "properties": { + "ap": { + "description": "Ask price.", + "format": "double", + "type": "number" + }, + "as": { + "description": "Ask size.", + "format": "uint32", + "type": "integer" + }, + "ax": { + "description": "Ask exchange.", + "type": "string" + }, + "bp": { + "description": "Bid price.", + "format": "double", + "type": "number" + }, + "bs": { + "description": "Bid size.", + "format": "uint32", + "type": "integer" + }, + "bx": { + "description": "Bid exchange.", + "type": "string" + }, + "c": { + "description": "Quote condition.", + "type": "string" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + } + }, + "required": [ + "t", + "bx", + "bp", + "bs", + "ap", + "as", + "ax", + "c" + ], + "type": "object" + }, + "option_snapshot": { + "description": "A snapshot provides the latest trade and latest quote.", + "properties": { + "dailyBar": { + "$ref": "#/components/schemas/option_bar" + }, + "greeks": { + "$ref": "#/components/schemas/option_greeks" + }, + "impliedVolatility": { + "description": "Implied volatility calculated using the Black-Scholes model.", + "format": "double", + "type": "number" + }, + "latestQuote": { + "$ref": "#/components/schemas/option_quote" + }, + "latestTrade": { + "$ref": "#/components/schemas/option_trade" + }, + "minuteBar": { + "$ref": "#/components/schemas/option_bar" + }, + "prevDailyBar": { + "$ref": "#/components/schemas/option_bar" + } + }, + "type": "object" + }, + "option_snapshots_resp": { + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "snapshots": { + "additionalProperties": { + "$ref": "#/components/schemas/option_snapshot" + }, + "type": "object" + } + }, + "required": [ + "snapshots", + "next_page_token" + ], + "type": "object" + }, + "option_trade": { + "description": "An option trade.", + "examples": [ + { + "c": "I", + "p": 0.37, + "s": 1, + "t": "2024-01-18T15:03:44.56339456Z", + "x": "B" + } + ], + "properties": { + "c": { + "description": "Trade condition.", + "type": "string" + }, + "p": { + "description": "Trade price.", + "format": "double", + "type": "number" + }, + "s": { + "description": "Trade size.", + "format": "uint32", + "type": "integer" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "x": { + "type": "string" + } + }, + "required": [ + "t", + "x", + "p", + "s", + "c" + ], + "type": "object" + }, + "option_trades_resp": { + "properties": { + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "trades": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/option_trade" + }, + "type": "array" + }, + "type": "object" + } + }, + "required": [ + "trades", + "next_page_token" + ], + "type": "object" + }, + "partial_call": { + "description": "Partial call.", + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "type": "string" + }, + "dividend_rate": { + "format": "double", + "type": "number" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "lottery_date": { + "format": "date", + "type": "string" + }, + "lottery_type": { + "description": "The type of lottery for the partial call.", + "enum": [ + "original", + "supplemental" + ], + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "price": { + "format": "double", + "type": "number" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "results_publication_date": { + "format": "date", + "type": "string" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "process_date" + ], + "type": "object" + }, + "payable_date": { + "description": "The date when the corporate action benefit is paid or distributed.", + "format": "date", + "type": "string" + }, + "process_date": { + "description": "The date when the corporate action is processed by Alpaca.", + "format": "date", + "type": "string" + }, + "record_date": { + "description": "The date shareholders must own shares to receive the benefit.", + "format": "date", + "type": "string" + }, + "redemption": { + "description": "Redemption.", + "examples": [ + { + "cusip": "687305102", + "id": "395da031-0e57-4918-a6fb-64a7c713aca4", + "payable_date": "2023-06-13", + "process_date": "2023-06-13", + "rate": 0.141134, + "symbol": "ORPHY" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "type": "string" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "rate": { + "format": "double", + "type": "number" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "cusip", + "rate", + "process_date" + ], + "type": "object" + }, + "region": { + "default": "us", + "description": "The region to filter corporate actions by.\n\n- `us`: only US corporate actions\n- `non_us`: only non-US corporate actions\n- `all`: both US and non-US corporate actions\n", + "enum": [ + "us", + "non_us", + "all" + ], + "type": "string" + }, + "reorganization": { + "description": "Reorganization (cash and/or multiple stock allocations).", + "properties": { + "cash_rate": { + "format": "double", + "type": "number" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "type": "string" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "isin": { + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "stock_movements": { + "items": { + "$ref": "#/components/schemas/reorganization_stock_movement" + }, + "type": "array" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "cusip", + "process_date", + "effective_date" + ], + "type": "object" + }, + "reorganization_stock_movement": { + "description": "A stock allocation leg in a reorganization.", + "properties": { + "cusip": { + "type": "string" + }, + "isin": { + "type": "string" + }, + "new_rate": { + "format": "double", + "type": "number" + }, + "source_rate": { + "format": "double", + "type": "number" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "new_rate", + "source_rate" + ], + "type": "object" + }, + "reverse_split": { + "description": "Reverse split.", + "examples": [ + { + "ex_date": "2023-08-24", + "id": "913de862-c02c-46dc-a89c-fc8779a50d30", + "new_cusip": "60879E200", + "new_rate": 1, + "old_cusip": "60879E101", + "old_rate": 50, + "process_date": "2023-08-24", + "record_date": "2023-08-24", + "symbol": "MNTS" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "new_cusip": { + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "format": "double", + "type": "number" + }, + "new_symbol": { + "description": "The post-split ticker. Empty when the reverse split does not change the\nticker (the most common case); only populated when the issuer assigns a\ndifferent symbol after the split.\n", + "type": "string" + }, + "old_cusip": { + "type": "string" + }, + "old_isin": { + "$ref": "#/components/schemas/isin" + }, + "old_rate": { + "format": "double", + "type": "number" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "old_cusip", + "new_cusip", + "new_rate", + "old_rate", + "process_date", + "ex_date" + ], + "type": "object" + }, + "rights_distribution": { + "description": "Rights distribution.", + "examples": [ + { + "ex_date": "2024-04-17", + "expiration_date": "2024-05-14", + "id": "69794cfd-0adc-4e11-9211-9210a9cf8932", + "new_cusip": "454089111", + "new_symbol": "IFN.RTWI", + "payable_date": "2024-04-19", + "process_date": "2024-04-19", + "rate": 1, + "record_date": "2024-04-18", + "source_cusip": "454089103", + "source_symbol": "IFN" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "expiration_date": { + "$ref": "#/components/schemas/expiration_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "new_cusip": { + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_symbol": { + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "rate": { + "format": "double", + "type": "number" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "source_cusip": { + "type": "string" + }, + "source_isin": { + "$ref": "#/components/schemas/isin" + }, + "source_symbol": { + "type": "string" + } + }, + "required": [ + "id", + "source_symbol", + "source_cusip", + "new_symbol", + "new_cusip", + "rate", + "process_date", + "ex_date", + "payable_date" + ], + "type": "object" + }, + "sort": { + "default": "asc", + "description": "Sort data in ascending or descending order.", + "enum": [ + "asc", + "desc" + ], + "type": "string" + }, + "spin_off": { + "description": "Spin-off.", + "examples": [ + { + "ex_date": "2023-08-15", + "id": "82e602f6-35bc-4651-a5dd-f6d88ff37c55", + "new_cusip": "85237B101", + "new_rate": 1, + "new_symbol": "SRM", + "process_date": "2023-08-15", + "record_date": "2023-08-15", + "source_cusip": "48208F105", + "source_rate": 19.35, + "source_symbol": "JUPW" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "due_bill_redemption_date": { + "$ref": "#/components/schemas/due_bill_redemption_date" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "new_cusip": { + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "format": "double", + "type": "number" + }, + "new_symbol": { + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "source_cusip": { + "type": "string" + }, + "source_isin": { + "$ref": "#/components/schemas/isin" + }, + "source_rate": { + "format": "double", + "type": "number" + }, + "source_symbol": { + "type": "string" + } + }, + "required": [ + "id", + "source_symbol", + "source_cusip", + "source_rate", + "new_symbol", + "new_cusip", + "new_rate", + "process_date", + "ex_date" + ], + "type": "object" + }, + "stock_and_cash_merger": { + "description": "Stock and cash merger.", + "examples": [ + { + "acquiree_cusip": "561409103", + "acquiree_rate": 1, + "acquiree_symbol": "MLVF", + "acquirer_cusip": "31931U102", + "acquirer_rate": 0.7733, + "acquirer_symbol": "FRBA", + "cash_rate": 7.8, + "effective_date": "2023-07-18", + "id": "e5248356-2c06-42cf-aeb9-1595bd616cdb", + "payable_date": "2023-07-18", + "process_date": "2023-07-18" + } + ], + "properties": { + "acquiree_cusip": { + "type": "string" + }, + "acquiree_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquiree_rate": { + "format": "double", + "type": "number" + }, + "acquiree_symbol": { + "type": "string" + }, + "acquirer_cusip": { + "type": "string" + }, + "acquirer_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquirer_rate": { + "format": "double", + "type": "number" + }, + "acquirer_symbol": { + "type": "string" + }, + "cash_rate": { + "format": "double", + "type": "number" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + } + }, + "required": [ + "id", + "acquirer_symbol", + "acquirer_cusip", + "acquirer_rate", + "acquiree_symbol", + "acquiree_cusip", + "acquiree_rate", + "cash_rate", + "process_date", + "effective_date" + ], + "type": "object" + }, + "stock_auction": { + "description": "An auction\n", + "examples": [ + { + "c": "O", + "p": 135, + "t": "2022-10-13T13:30:01.688322951Z", + "x": "Q" + } + ], + "properties": { + "c": { + "description": "The condition flag indicating that this is an auction. See `v2/stocks/meta/conditions/trade` for more details.\n", + "type": "string" + }, + "p": { + "description": "Auction price.", + "format": "double", + "type": "number" + }, + "s": { + "description": "Auction trade size.", + "format": "int64", + "type": "integer" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "x": { + "description": "Exchange code. See `v2/stocks/meta/exchanges` for more details.", + "type": "string" + } + }, + "required": [ + "t", + "x", + "p", + "c" + ], + "type": "object" + }, + "stock_auction_feed": { + "default": "sip", + "type": "string" + }, + "stock_auctions_resp": { + "properties": { + "auctions": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/stock_daily_auctions" + }, + "type": "array" + }, + "type": "object" + }, + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + } + }, + "required": [ + "auctions", + "next_page_token" + ], + "type": "object" + }, + "stock_auctions_resp_single": { + "properties": { + "auctions": { + "items": { + "$ref": "#/components/schemas/stock_daily_auctions" + }, + "type": "array" + }, + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "auctions", + "next_page_token", + "symbol" + ], + "type": "object" + }, + "stock_bar": { + "description": "OHLC aggregate of all the trades in a given interval.\n", + "examples": [ + { + "c": 178.08, + "h": 178.34, + "l": 177.76, + "n": 1727, + "o": 178.26, + "t": "2022-01-03T09:00:00Z", + "v": 60937, + "vw": 177.954244 + } + ], + "properties": { + "c": { + "description": "Closing price.", + "format": "double", + "type": "number" + }, + "h": { + "description": "High price.", + "format": "double", + "type": "number" + }, + "l": { + "description": "Low price.", + "format": "double", + "type": "number" + }, + "n": { + "description": "Trade count in the bar.", + "format": "int64", + "type": "integer" + }, + "o": { + "description": "Opening price.", + "format": "double", + "type": "number" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "v": { + "description": "Bar volume.", + "format": "int64", + "type": "integer" + }, + "vw": { + "description": "Volume weighted average price.", + "format": "double", + "type": "number" + } + }, + "required": [ + "t", + "o", + "h", + "l", + "c", + "v", + "n", + "vw" + ], + "type": "object" + }, + "stock_bars_resp": { + "properties": { + "bars": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/stock_bar" + }, + "type": "array" + }, + "type": "object" + }, + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + } + }, + "required": [ + "bars", + "next_page_token" + ], + "type": "object" + }, + "stock_bars_resp_single": { + "properties": { + "bars": { + "items": { + "$ref": "#/components/schemas/stock_bar" + }, + "type": "array" + }, + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "bars", + "next_page_token", + "symbol" + ], + "type": "object" + }, + "stock_conditions": { + "additionalProperties": { + "type": "string" + }, + "examples": [ + { + "@": "Regular Sale", + "A": "Acquisition", + "B": "Bunched Trade" + } + ], + "type": "object" + }, + "stock_daily_auctions": { + "description": "Opening and closing auction prices for a given day.\n", + "properties": { + "c": { + "description": "Closing auctions. Every price / exchange / condition triplet is only shown once, with its earliest timestamp.", + "items": { + "$ref": "#/components/schemas/stock_auction" + }, + "type": "array" + }, + "d": { + "$ref": "#/components/schemas/date" + }, + "o": { + "description": "Opening auctions.", + "items": { + "$ref": "#/components/schemas/stock_auction" + }, + "type": "array" + } + }, + "required": [ + "d", + "o", + "c" + ], + "type": "object" + }, + "stock_dividend": { + "description": "Stock dividend.", + "examples": [ + { + "cusip": "605015106", + "ex_date": "2023-05-19", + "id": "3ae94c30-2d37-473a-bf29-5f7b4ab6d3ca", + "payable_date": "2023-05-05", + "process_date": "2023-05-19", + "rate": 0.05, + "record_date": "2023-05-22", + "symbol": "MSBC" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "type": "string" + }, + "ex_date": { + "$ref": "#/components/schemas/ex_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "rate": { + "format": "double", + "type": "number" + }, + "record_date": { + "$ref": "#/components/schemas/record_date" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "cusip", + "rate", + "process_date", + "ex_date" + ], + "type": "object" + }, + "stock_exchanges": { + "additionalProperties": { + "type": "string" + }, + "examples": [ + { + "N": "New York Stock Exchange", + "V": "IEX" + } + ], + "type": "object" + }, + "stock_historical_feed": { + "default": "sip", + "enum": [ + "iex", + "otc", + "sip", + "boats" + ], + "type": "string" + }, + "stock_latest_bars_resp": { + "properties": { + "bars": { + "additionalProperties": { + "$ref": "#/components/schemas/stock_bar" + }, + "type": "object" + }, + "currency": { + "type": "string" + } + }, + "required": [ + "bars" + ], + "type": "object" + }, + "stock_latest_bars_resp_single": { + "properties": { + "bar": { + "$ref": "#/components/schemas/stock_bar" + }, + "currency": { + "type": "string" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "bar", + "symbol" + ], + "type": "object" + }, + "stock_latest_feed": { + "enum": [ + "delayed_sip", + "iex", + "otc", + "sip", + "boats", + "overnight" + ], + "type": "string" + }, + "stock_latest_quotes_resp": { + "properties": { + "currency": { + "type": "string" + }, + "quotes": { + "additionalProperties": { + "$ref": "#/components/schemas/stock_quote" + }, + "type": "object" + } + }, + "required": [ + "quotes" + ], + "type": "object" + }, + "stock_latest_quotes_resp_single": { + "properties": { + "currency": { + "type": "string" + }, + "quote": { + "$ref": "#/components/schemas/stock_quote" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "quote", + "symbol" + ], + "type": "object" + }, + "stock_latest_trades_resp": { + "properties": { + "currency": { + "type": "string" + }, + "trades": { + "additionalProperties": { + "$ref": "#/components/schemas/stock_trade" + }, + "type": "object" + } + }, + "required": [ + "trades" + ], + "type": "object" + }, + "stock_latest_trades_resp_single": { + "properties": { + "currency": { + "type": "string" + }, + "symbol": { + "type": "string" + }, + "trade": { + "$ref": "#/components/schemas/stock_trade" + } + }, + "required": [ + "trade", + "symbol" + ], + "type": "object" + }, + "stock_merger": { + "description": "Stock merger.", + "examples": [ + { + "acquiree_cusip": "53223X107", + "acquiree_rate": 1, + "acquiree_symbol": "LSI", + "acquirer_cusip": "30225T102", + "acquirer_rate": 0.895, + "acquirer_symbol": "EXR", + "effective_date": "2023-07-20", + "id": "728f8cb2-a00e-4bc7-ad14-d15fe82bbcff", + "payable_date": "2023-07-20", + "process_date": "2023-07-20" + } + ], + "properties": { + "acquiree_cusip": { + "type": "string" + }, + "acquiree_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquiree_rate": { + "format": "double", + "type": "number" + }, + "acquiree_symbol": { + "type": "string" + }, + "acquirer_cusip": { + "type": "string" + }, + "acquirer_isin": { + "$ref": "#/components/schemas/isin" + }, + "acquirer_rate": { + "format": "double", + "type": "number" + }, + "acquirer_symbol": { + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + } + }, + "required": [ + "id", + "acquirer_symbol", + "acquirer_cusip", + "acquirer_rate", + "acquiree_symbol", + "acquiree_cusip", + "acquiree_rate", + "process_date", + "effective_date" + ], + "type": "object" + }, + "stock_quote": { + "description": "The best bid and ask information for a given security.", + "examples": [ + { + "ap": 387.7, + "as": 1, + "ax": "C", + "bp": 387.67, + "bs": 1, + "bx": "N", + "c": [ + "R" + ], + "t": "2021-02-06T13:35:08.946977536Z", + "z": "C" + } + ], + "properties": { + "ap": { + "description": "Ask price. 0 means the security has no active ask.", + "format": "double", + "type": "number" + }, + "as": { + "description": "Ask size in shares (round lots prior to November 3, 2025).", + "format": "uint32", + "type": "integer" + }, + "ax": { + "description": "Ask exchange. See `v2/stocks/meta/exchanges` for more details.", + "type": "string" + }, + "bp": { + "description": "Bid price. 0 means the security has no active bid.", + "format": "double", + "type": "number" + }, + "bs": { + "description": "Bid size in shares (round lots prior to November 3, 2025).", + "format": "uint32", + "type": "integer" + }, + "bx": { + "description": "Bid exchange. See `v2/stocks/meta/exchanges` for more details.", + "type": "string" + }, + "c": { + "description": "Condition flags. See `v2/stocks/meta/conditions/quote` for more details. If the array contains one flag, it applies to both the bid and ask. If the array contains two flags, the first one applies to the bid and the second one to the ask.\n", + "items": { + "type": "string" + }, + "type": "array" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "z": { + "$ref": "#/components/schemas/stock_tape" + } + }, + "required": [ + "t", + "bx", + "bp", + "bs", + "ap", + "as", + "ax", + "c", + "z" + ], + "type": "object" + }, + "stock_quotes_resp": { + "properties": { + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "quotes": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/stock_quote" + }, + "type": "array" + }, + "type": "object" + } + }, + "required": [ + "quotes", + "next_page_token" + ], + "type": "object" + }, + "stock_quotes_resp_single": { + "properties": { + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "quotes": { + "items": { + "$ref": "#/components/schemas/stock_quote" + }, + "type": "array" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "quotes", + "next_page_token", + "symbol" + ], + "type": "object" + }, + "stock_snapshot": { + "description": "A snapshot provides the latest trade, latest quote, latest minute bar, current daily bar and previous daily bar.\n", + "properties": { + "dailyBar": { + "$ref": "#/components/schemas/stock_bar" + }, + "latestQuote": { + "$ref": "#/components/schemas/stock_quote" + }, + "latestTrade": { + "$ref": "#/components/schemas/stock_trade" + }, + "minuteBar": { + "$ref": "#/components/schemas/stock_bar" + }, + "prevDailyBar": { + "$ref": "#/components/schemas/stock_bar" + } + }, + "type": "object" + }, + "stock_snapshots_resp": { + "additionalProperties": { + "$ref": "#/components/schemas/stock_snapshot" + }, + "type": "object" + }, + "stock_snapshots_resp_single": { + "allOf": [ + { + "properties": { + "currency": { + "type": "string" + }, + "symbol": { + "type": "string" + } + }, + "type": "object" + }, + { + "$ref": "#/components/schemas/stock_snapshot" + } + ] + }, + "stock_tape": { + "description": "- A: New York Stock Exchange\n- B: NYSE Arca, Bats, IEX and other regional exchanges\n- C: NASDAQ\n- N: Overnight\n- O: OTC\n", + "enum": [ + "A", + "B", + "C", + "N", + "O" + ], + "type": "string" + }, + "stock_trade": { + "description": "A stock trade.", + "examples": [ + { + "c": [ + "@", + "T" + ], + "i": 1, + "p": 178.26, + "s": 246, + "t": "2022-01-03T09:00:00.086175744Z", + "x": "P", + "z": "C" + } + ], + "properties": { + "c": { + "description": "Condition flags. See `v2/stocks/meta/conditions/trade` for more details.", + "items": { + "type": "string" + }, + "type": "array" + }, + "i": { + "description": "Trade ID sent by the exchange.", + "format": "uint64", + "type": "integer" + }, + "p": { + "description": "Trade price.", + "format": "double", + "type": "number" + }, + "s": { + "description": "Trade size.", + "format": "uint32", + "type": "integer" + }, + "t": { + "$ref": "#/components/schemas/timestamp" + }, + "u": { + "description": "Update to the trade. This field is optional, if it's missing, the trade is valid. Otherwise, it can have these values:\n - canceled: indicates that the trade has been canceled\n - incorrect: indicates that the trade has been corrected and the given trade is no longer valid\n - corrected: indicates that this trade is the correction of a previous (incorrect) trade\n", + "type": "string" + }, + "x": { + "description": "Exchange code. See `v2/stocks/meta/exchanges` for more details.", + "type": "string" + }, + "z": { + "$ref": "#/components/schemas/stock_tape" + } + }, + "required": [ + "t", + "i", + "x", + "p", + "s", + "c", + "z" + ], + "type": "object" + }, + "stock_trades_resp": { + "properties": { + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "trades": { + "additionalProperties": { + "items": { + "$ref": "#/components/schemas/stock_trade" + }, + "type": "array" + }, + "type": "object" + } + }, + "required": [ + "trades", + "next_page_token" + ], + "type": "object" + }, + "stock_trades_resp_single": { + "properties": { + "currency": { + "type": "string" + }, + "next_page_token": { + "$ref": "#/components/schemas/next_page_token" + }, + "symbol": { + "type": "string" + }, + "trades": { + "items": { + "$ref": "#/components/schemas/stock_trade" + }, + "type": "array" + } + }, + "required": [ + "trades", + "next_page_token", + "symbol" + ], + "type": "object" + }, + "timestamp": { + "description": "Timestamp in RFC-3339 format with nanosecond precision.", + "format": "date-time", + "type": "string" + }, + "unit_split": { + "description": "Unit split.", + "examples": [ + { + "alternate_cusip": "G5391L110", + "alternate_rate": 0.3333, + "alternate_symbol": "LVROW", + "effective_date": "2023-03-01", + "id": "3e68e87e-ae95-4d68-91d1-715d52ef143a", + "new_cusip": "G5391L102", + "new_rate": 1, + "new_symbol": "LVRO", + "old_cusip": "G8990L119", + "old_rate": 1, + "old_symbol": "TPBAU", + "process_date": "2023-03-01" + } + ], + "properties": { + "alternate_cusip": { + "type": "string" + }, + "alternate_isin": { + "$ref": "#/components/schemas/isin" + }, + "alternate_rate": { + "format": "double", + "type": "number" + }, + "alternate_symbol": { + "type": "string" + }, + "currency": { + "$ref": "#/components/schemas/currency" + }, + "effective_date": { + "$ref": "#/components/schemas/effective_date" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "new_cusip": { + "type": "string" + }, + "new_isin": { + "$ref": "#/components/schemas/isin" + }, + "new_rate": { + "format": "double", + "type": "number" + }, + "new_symbol": { + "type": "string" + }, + "old_cusip": { + "type": "string" + }, + "old_isin": { + "$ref": "#/components/schemas/isin" + }, + "old_rate": { + "format": "double", + "type": "number" + }, + "old_symbol": { + "type": "string" + }, + "payable_date": { + "$ref": "#/components/schemas/payable_date" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + } + }, + "required": [ + "id", + "old_symbol", + "old_cusip", + "old_rate", + "new_symbol", + "new_cusip", + "new_rate", + "alternate_symbol", + "alternate_cusip", + "alternate_rate", + "process_date", + "effective_date" + ], + "type": "object" + }, + "worthless_removal": { + "description": "Worthless removal.", + "examples": [ + { + "cusip": "078771300", + "id": "106c2149-ee04-4d2e-a943-98dbb4d21a3c", + "process_date": "2024-12-19", + "symbol": "BLPH" + } + ], + "properties": { + "currency": { + "$ref": "#/components/schemas/currency" + }, + "cusip": { + "type": "string" + }, + "id": { + "$ref": "#/components/schemas/ca_id" + }, + "isin": { + "$ref": "#/components/schemas/isin" + }, + "process_date": { + "$ref": "#/components/schemas/process_date" + }, + "symbol": { + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "cusip", + "process_date" + ], + "type": "object" + } + }, + "securitySchemes": { + "BasicAuth": { + "scheme": "basic", + "type": "http" + }, + "apiKey": { + "in": "header", + "name": "APCA-API-KEY-ID", + "type": "apiKey" + }, + "apiSecret": { + "in": "header", + "name": "APCA-API-SECRET-KEY", + "type": "apiKey" + } + } + }, + "info": { + "contact": { + "email": "support@alpaca.markets", + "name": "Alpaca Support", + "url": "https://alpaca.markets/support" + }, + "description": "Access real-time and historical market data for US equities, options, crypto, and foreign exchange data through the Alpaca REST and WebSocket APIs. There are APIs for Stock Pricing, Option Pricing, Crypto Pricing, Forex, Logos, Fixed income, Corporate Actions, Screener, and News.\n", + "license": { + "name": "Creative Commons Attribution Share Alike 4.0 International", + "url": "https://spdx.org/licenses/CC-BY-SA-4.0.html" + }, + "termsOfService": "https://s3.amazonaws.com/files.alpaca.markets/disclosures/library/TermsAndConditions.pdf", + "title": "Market Data API", + "version": "1.1" + }, + "openapi": "3.1.2", + "paths": { + "/v1beta1/events/corporate-actions": { + "get": { + "description": "Server-Sent Events (SSE) stream that delivers every corporate-action mutation (`insert` / `update` / `delete`) across all supported CA types on a single long-lived `text/event-stream` connection. When `since`, `since_id`, or the `Last-Event-Id` reconnect header is provided, historical events are replayed first; otherwise only live events are pushed.\n\nEach event carries an `event_type` discriminator that selects the shape of the `ca` payload -- see the [`corporate_action_event`](#/components/schemas/corporate_action_event) schema for the mapping to each per-type schema. The same underlying data is available on demand via [`GET /v1/corporate-actions`](#operation/CorporateActions).\n", + "operationId": "SubscribeToCorporateActionsEventsSSE", + "parameters": [ + { + "$ref": "#/components/parameters/cas_events_type" + }, + { + "$ref": "#/components/parameters/cas_events_region" + }, + { + "$ref": "#/components/parameters/cas_events_since" + }, + { + "$ref": "#/components/parameters/cas_events_until" + }, + { + "$ref": "#/components/parameters/cas_events_since_id" + }, + { + "$ref": "#/components/parameters/cas_events_until_id" + }, + { + "$ref": "#/components/parameters/cas_events_last_event_id" + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "examples": { + "CapitalGainsDistribution": { + "description": "Example SSE payload delivered when\n`event_type == capital_gains_distribution_corporateaction_event`.\nCombined long-term + short-term distribution; single-leg events\ncarry only the applicable `long_term_rate` or `short_term_rate`.\n", + "summary": "Capital gains distribution inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T18:00:00.000000Z", + "ca": { + "currency": "USD", + "cusip": "36261K509", + "ex_date": "2025-12-26", + "id": "98c905a1-08c7-450c-8669-b8e7aee8b44d", + "isin": "US36261K5090", + "long_term_rate": "0.45855", + "payable_date": "2026-01-09", + "process_date": "2026-01-08", + "record_date": "2025-12-29", + "short_term_rate": "0.11019", + "symbol": "GCAD" + }, + "event_id": "01KMAGXP2FCJ4NR1TDX8ZWKR6E", + "event_type": "capital_gains_distribution_corporateaction_event", + "region": "us" + } + ] + }, + "CashDividend": { + "description": "Example SSE payload delivered when `event_type == cash_dividend_corporateaction_event`.", + "summary": "Cash dividend inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T12:24:58.807230Z", + "ca": { + "currency": "USD", + "cusip": "037833100", + "ex_date": "2026-05-09", + "foreign": false, + "id": "1dbc7685-9517-4a77-a236-8527d49cefdc", + "payable_date": "2026-05-15", + "process_date": "2026-05-15", + "rate": "0.24", + "record_date": "2026-05-12", + "special": false, + "symbol": "AAPL" + }, + "event_id": "01J9RPMV5TKB8WX3M4F1KZ7QH2", + "event_type": "cash_dividend_corporateaction_event", + "region": "us" + } + ] + }, + "CashMerger": { + "description": "Example SSE payload delivered when `event_type == cash_merger_corporateaction_event`.", + "summary": "Cash merger inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T15:42:11.118274Z", + "ca": { + "acquiree_cusip": "90184L102", + "acquiree_symbol": "TWTR", + "acquirer_cusip": "912656104", + "acquirer_symbol": "X", + "currency": "USD", + "effective_date": "2026-04-01", + "id": "f8489167-4e4b-431d-a0be-6017ae1cf08a", + "payable_date": "2026-04-05", + "process_date": "2026-04-01", + "rate": "54.20" + }, + "event_id": "01J9RQ5HNZQK7M3RDVJ8XBPCT1", + "event_type": "cash_merger_corporateaction_event", + "region": "us" + } + ] + }, + "EquityPartialCall": { + "description": "Example SSE payload delivered when `event_type == equity_partial_call_corporateaction_event`.", + "summary": "Equity partial call inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-19T23:26:46.853262Z", + "ca": { + "currency": "USD", + "cusip": "123456789", + "id": "b2f8b1a4-4c4a-4e8e-9c9a-1f3b8a7c5d6e", + "lottery_date": "2026-06-08", + "lottery_type": "original", + "payable_date": "2026-06-15", + "price": "25.00", + "process_date": "2026-06-10", + "record_date": "2026-06-05", + "results_publication_date": "2026-06-09", + "symbol": "EXMP" + }, + "event_id": "01J9RSGD8JR2A4K7MZNTPVQ5XW", + "event_type": "equity_partial_call_corporateaction_event", + "region": "us" + } + ] + }, + "ForwardSplit": { + "description": "Example SSE payload delivered when `event_type == forward_split_corporateaction_event`.", + "summary": "Forward split updated (US)", + "value": [ + { + "action": "update", + "at": "2026-03-19T22:50:11.729329Z", + "ca": { + "currency": "USD", + "cusip": "67066G104", + "ex_date": "2026-06-10", + "id": "78467a10-9aa2-4222-8927-abcdef012345", + "new_rate": "10", + "old_rate": "1", + "payable_date": "2026-06-09", + "process_date": "2026-06-07", + "record_date": "2026-06-06", + "symbol": "NVDA" + }, + "event_id": "01KM5CDQXQAE67Z5NHCJZHQ5XV", + "event_type": "forward_split_corporateaction_event", + "region": "us" + } + ] + }, + "NameChange": { + "description": "Example SSE payload delivered when `event_type == name_change_corporateaction_event`.", + "summary": "Name change inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T00:15:42.318901Z", + "ca": { + "currency": "USD", + "id": "c1a2b3c4-d5e6-4f78-8912-abcdef012345", + "new_cusip": "30303M102", + "new_symbol": "META", + "old_cusip": "30303M102", + "old_symbol": "FB", + "process_date": "2026-06-09" + }, + "event_id": "01KM5CDZN6KX5V8WQ8KXDH917J", + "event_type": "name_change_corporateaction_event", + "region": "us" + } + ] + }, + "Redemption": { + "description": "Example SSE payload delivered when `event_type == redemption_corporateaction_event`.", + "summary": "Redemption inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T12:24:52.325158Z", + "ca": { + "currency": "USD", + "cusip": "987654321", + "id": "4e5f6a7b-8c9d-4e01-a234-56789abcdef0", + "payable_date": "2026-07-03", + "process_date": "2026-07-01", + "rate": "10.00", + "symbol": "XYZ" + }, + "event_id": "01J9RVB6Y4ZK8M3N7QD2WX1RFP", + "event_type": "redemption_corporateaction_event", + "region": "us" + } + ] + }, + "Reorganization": { + "description": "Example SSE payload delivered when `event_type == reorganization_corporateaction_event`.", + "summary": "Reorganization inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T13:12:03.500000Z", + "ca": { + "cash_rate": "5.00", + "currency": "USD", + "cusip": "111222333", + "effective_date": "2026-08-15", + "id": "6a7b8c9d-0e1f-4234-5678-90abcdef1234", + "payable_date": "2026-08-20", + "process_date": "2026-08-15", + "stock_movements": [ + { + "cusip": "444555666", + "new_rate": "1", + "source_rate": "10", + "symbol": "NEWCO" + } + ], + "symbol": "OLDCO" + }, + "event_id": "01KM5CE7CNA84WKP9M7T9BM2EX", + "event_type": "reorganization_corporateaction_event", + "region": "us" + } + ] + }, + "ReverseSplit": { + "description": "Example SSE payload delivered when `event_type == reverse_split_corporateaction_event`.", + "summary": "Reverse split inserted (non-US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T14:00:00.000000Z", + "ca": { + "currency": "GBP", + "ex_date": "2026-09-01", + "id": "7b8c9d0e-1f23-4456-7890-abcdef123456", + "new_cusip": "G12345679", + "new_isin": "GB0001234568", + "new_rate": "1", + "old_cusip": "G12345678", + "old_isin": "GB0001234567", + "old_rate": "20", + "payable_date": "2026-09-02", + "process_date": "2026-09-01", + "record_date": "2026-08-30", + "symbol": "EXMP.L" + }, + "event_id": "01KM5CEF44KN9DZNWV9NV456V1", + "event_type": "reverse_split_corporateaction_event", + "region": "non_us" + } + ] + }, + "RightsDistribution": { + "description": "Example SSE payload delivered when `event_type == rights_distribution_corporateaction_event`.", + "summary": "Rights distribution inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T14:30:15.100000Z", + "ca": { + "currency": "USD", + "ex_date": "2026-05-15", + "expiration_date": "2026-06-15", + "id": "8c9d0e1f-2345-4678-9012-abcdef234567", + "new_cusip": "123456790", + "new_symbol": "EXMPR", + "payable_date": "2026-05-22", + "process_date": "2026-05-20", + "rate": "0.25", + "record_date": "2026-05-18", + "source_cusip": "123456789", + "source_symbol": "EXMP" + }, + "event_id": "01KM5CEPVKF869Z7RD7EJNP360", + "event_type": "rights_distribution_corporateaction_event", + "region": "us" + } + ] + }, + "SpinOff": { + "description": "Example SSE payload delivered when `event_type == spin_off_corporateaction_event`.", + "summary": "Spin-off updated (US)", + "value": [ + { + "action": "update", + "at": "2026-03-20T15:00:22.220000Z", + "ca": { + "currency": "USD", + "ex_date": "2026-04-08", + "id": "9d0e1f23-4567-4890-1234-abcdef345678", + "new_cusip": "9344D2109", + "new_rate": "0.241917", + "new_symbol": "WBD", + "payable_date": "2026-04-11", + "process_date": "2026-04-08", + "record_date": "2026-04-05", + "source_cusip": "00206R102", + "source_rate": "1", + "source_symbol": "T" + }, + "event_id": "01KM5CEYK2TRA4S2456P21NJZ0", + "event_type": "spin_off_corporateaction_event", + "region": "us" + } + ] + }, + "StockAndCashMerger": { + "description": "Example SSE payload delivered when `event_type == stock_and_cash_merger_corporateaction_event`.", + "summary": "Stock-and-cash merger inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T15:30:45.300000Z", + "ca": { + "acquiree_cusip": "35137L204", + "acquiree_rate": "1", + "acquiree_symbol": "FOXA", + "acquirer_cusip": "254687106", + "acquirer_rate": "0.35", + "acquirer_symbol": "DIS", + "cash_rate": "10.00", + "currency": "USD", + "effective_date": "2026-05-01", + "id": "0e1f2345-6789-4a01-b234-cdef56789012", + "payable_date": "2026-05-05", + "process_date": "2026-05-01" + }, + "event_id": "01KM5CF6AHE2DGEP087XGX6XDW", + "event_type": "stock_and_cash_merger_corporateaction_event", + "region": "us" + } + ] + }, + "StockDividend": { + "description": "Example SSE payload delivered when `event_type == stock_dividend_corporateaction_event`.", + "summary": "Stock dividend inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T16:00:00.400000Z", + "ca": { + "currency": "USD", + "cusip": "123456789", + "ex_date": "2026-05-28", + "id": "1f234567-89ab-4c01-d234-ef5678901234", + "payable_date": "2026-06-01", + "process_date": "2026-06-01", + "rate": "0.05", + "record_date": "2026-05-30", + "symbol": "EXMP" + }, + "event_id": "01KM5CFE200AT1VX7S34MY33YT", + "event_type": "stock_dividend_corporateaction_event", + "region": "us" + } + ] + }, + "StockMerger": { + "description": "Example SSE payload delivered when `event_type == stock_merger_corporateaction_event`.", + "summary": "Stock merger inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T16:30:11.500000Z", + "ca": { + "acquiree_cusip": "555666777", + "acquiree_rate": "1", + "acquiree_symbol": "SMLCO", + "acquirer_cusip": "222333444", + "acquirer_rate": "0.75", + "acquirer_symbol": "BIGCO", + "currency": "USD", + "effective_date": "2026-07-15", + "id": "23456789-abcd-4e01-f234-567890123456", + "payable_date": "2026-07-18", + "process_date": "2026-07-15" + }, + "event_id": "01KM5CFNSFKSQR5SAEEJ783SWY", + "event_type": "stock_merger_corporateaction_event", + "region": "us" + } + ] + }, + "UnitSplit": { + "description": "Example SSE payload delivered when `event_type == unit_split_corporateaction_event`.", + "summary": "Unit split inserted (US)", + "value": [ + { + "action": "insert", + "at": "2026-03-20T17:00:30.600000Z", + "ca": { + "alternate_cusip": "888999002", + "alternate_rate": "0.5", + "alternate_symbol": "SPACW", + "currency": "USD", + "effective_date": "2026-08-01", + "id": "3456789a-bcde-4f01-2345-67890abcdef1", + "new_cusip": "888999001", + "new_rate": "1", + "new_symbol": "SPAC", + "old_cusip": "888999000", + "old_rate": "1", + "old_symbol": "SPACU", + "payable_date": "2026-08-03", + "process_date": "2026-08-01" + }, + "event_id": "01KM5CFXGY9EYPZRTCVJX88FQ8", + "event_type": "unit_split_corporateaction_event", + "region": "us" + } + ] + }, + "WorthlessRemoval": { + "description": "Example SSE payload delivered when `event_type == worthless_removal_corporateaction_event`.", + "summary": "Worthless removal deleted (US)", + "value": [ + { + "action": "delete", + "at": "2026-03-20T17:30:00.700000Z", + "ca": { + "currency": "USD", + "cusip": "777888999", + "id": "456789ab-cdef-4012-3456-7890abcdef12", + "process_date": "2026-09-15", + "symbol": "DEADCO" + }, + "event_id": "01KM5CG58DTRZ8RKZY3KNYMN3D", + "event_type": "worthless_removal_corporateaction_event", + "region": "us" + } + ] + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/corporate_action_event" + }, + "type": "array" + } + } + }, + "description": "Connected. Corporate-action events will now start streaming as long as you keep the connection open.", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "servers": [ + { + "description": "Production", + "url": "https://stream.data.alpaca.markets" + }, + { + "description": "Sandbox", + "url": "https://stream.data.sandbox.alpaca.markets" + }, + { + "description": "Staging", + "url": "https://stream.data.staging-v2.tradetalk.us" + } + ], + "summary": "Subscribe to Corporate Actions Events (SSE)", + "tags": [ + "Corporate actions" + ] + } + }, + "/v1beta1/fixed_income/latest/prices": { + "get": { + "description": "This endpoint returns the latest prices for the given fixed income securities.\n", + "operationId": "FixedIncomeLatestPrices", + "parameters": [ + { + "$ref": "#/components/parameters/isins" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "prices": { + "value": { + "prices": { + "US912797KJ59": { + "p": 99.6459, + "t": "2025-02-14T20:58:00.648Z", + "ytm": 4.249, + "ytw": 4.249 + }, + "US912797KS58": { + "p": 99.3193, + "t": "2025-02-14T20:58:00.648Z", + "ytm": 4.2245, + "ytw": 4.2245 + }, + "US912797LB15": { + "p": 98.9927, + "t": "2025-02-14T20:58:00.648Z", + "ytm": 4.2165, + "ytw": 4.2165 + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/fixed_income_latest_prices_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest prices", + "tags": [ + "Fixed income" + ] + } + }, + "/v1beta1/fixed_income/latest/quotes": { + "get": { + "description": "This endpoint returns the latest quotes for the given fixed income securities.\n", + "operationId": "FixedIncomeLatestQuotes", + "parameters": [ + { + "description": "A comma-separated list of ISINs with a limit of 100.", + "example": "US912797SX61,US912810SK51", + "in": "query", + "name": "isins", + "required": true, + "schema": { + "type": "string" + } + }, + { + "$ref": "#/components/parameters/trade_size" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "quotes": { + "value": { + "quotes": { + "US912797SX61": { + "ams": 1000, + "ap": 99.91958333, + "as": 1000000, + "aytm": 2.226923, + "aytw": 2.226923, + "bms": 1000, + "bp": 99.81091667, + "bs": 1000000, + "bytm": 5.236154, + "bytw": 5.236154, + "t": "2026-05-21T06:56:01.882466873Z" + }, + "US912810SK51": { + "ams": 1000, + "ap": 63.06436526, + "as": 1000000, + "aytm": 5.08819, + "aytw": 5.08819, + "bms": 1000, + "bp": 60.60009769, + "bs": 1000000, + "bytm": 5.338343, + "bytw": 5.338343, + "t": "2026-05-21T07:27:53.683424845Z" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/fixed_income_latest_quotes_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest quotes", + "tags": [ + "Fixed income" + ] + } + }, + "/v1beta1/forex/latest/rates": { + "get": { + "description": "Get the latest forex rates for the given currency pairs.\n", + "operationId": "LatestRates", + "parameters": [ + { + "$ref": "#/components/parameters/forex_currency_pairs" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "USDJPY": { + "value": { + "rates": { + "USDJPY": { + "ap": 128.112, + "bp": 127.752, + "mp": 127.779, + "t": "2022-05-20T05:38:41.311530885Z" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/forex_latest_rates_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "BasicAuth": [] + }, + { + "apiKey": [], + "apiSecret": [] + } + ], + "summary": "Latest rates for currency pairs", + "tags": [ + "Forex" + ] + } + }, + "/v1beta1/forex/rates": { + "get": { + "description": "Get historical forex rates for the given currency pairs in the given time interval and at the given timeframe (snapshot frequency).\n", + "operationId": "Rates", + "parameters": [ + { + "$ref": "#/components/parameters/forex_currency_pairs" + }, + { + "$ref": "#/components/parameters/forex_timeframe" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/sort" + }, + { + "$ref": "#/components/parameters/page_token" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "USDJPY": { + "value": { + "next_page_token": "VVNESlBZfDIwMjItMDEtMDNUMDA6MDM6MDBa", + "rates": { + "USDJPY": [ + { + "ap": 115.18, + "bp": 114.192, + "mp": 115.144, + "t": "2022-01-03T00:01:00Z" + }, + { + "ap": 115.185, + "bp": 114.189, + "mp": 115.138, + "t": "2022-01-03T00:02:00Z" + }, + { + "ap": 115.148, + "bp": 115.122, + "mp": 115.131, + "t": "2022-01-03T00:03:00Z" + } + ] + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/forex_rates_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "BasicAuth": [] + }, + { + "apiKey": [], + "apiSecret": [] + } + ], + "summary": "Historical rates for currency pairs", + "tags": [ + "Forex" + ] + } + }, + "/v1beta1/logos/{symbol}": { + "get": { + "description": "Get the image of the company logo for the given symbol.", + "operationId": "Logos", + "parameters": [ + { + "$ref": "#/components/parameters/symbol" + }, + { + "description": "If true, returns a placeholder image when no logo is available. Defaults to true.", + "in": "query", + "name": "placeholder", + "schema": { + "default": true, + "type": "boolean" + } + } + ], + "responses": { + "200": { + "content": { + "image/png": { + "schema": { + "contentMediaType": "image/png", + "type": "string" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Logos", + "tags": [ + "Logos" + ] + } + }, + "/v1beta1/news": { + "get": { + "description": "Returns the latest news articles across stocks and crypto. By default, returns the latest 10 news articles.\n", + "operationId": "News", + "parameters": [ + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/news_sort" + }, + { + "description": "A comma-separated list of symbols for which to query news.", + "in": "query", + "name": "symbols", + "schema": { + "example": "AAPL,TSLA,BTCUSD", + "type": "string" + } + }, + { + "description": "Limit of news items to be returned for a result page.", + "example": 10, + "in": "query", + "name": "limit", + "schema": { + "maximum": 50, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Boolean indicator to include content for news articles (if available).", + "in": "query", + "name": "include_content", + "schema": { + "type": "boolean" + } + }, + { + "description": "Boolean indicator to exclude news articles that do not contain content.", + "in": "query", + "name": "exclude_contentless", + "schema": { + "type": "boolean" + } + }, + { + "$ref": "#/components/parameters/page_token" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "news-response-example": { + "value": { + "news": [ + { + "author": "Charles Gross", + "content": "

This headline-only article is meant to show you why a stock is moving, the most difficult aspect of stock trading....

", + "created_at": "2021-12-31T11:08:42Z", + "headline": "Apple Leader in Phone Sales in China for Second Straight Month in November With 23.6% Share, According to Market Research Data", + "id": 24843171, + "images": [], + "source": "benzinga", + "summary": "This headline-only article is meant to show you why a stock is moving, the most difficult aspect of stock trading", + "symbols": [ + "AAPL" + ], + "updated_at": "2021-12-31T11:08:43Z", + "url": "https://www.benzinga.com/news/21/12/24843171/apple-leader-in-phone-sales-in-china-for-second-straight-month-in-november-with-23-6-share-according" + } + ], + "next_page_token": "MTY0MDk0ODkyMzAwMDAwMDAwMHwyNDg0MzE3MQ==" + } + } + }, + "schema": { + "$ref": "#/components/schemas/news_resp" + } + } + }, + "description": "OK" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "News articles", + "tags": [ + "News" + ] + } + }, + "/v1beta1/options/bars": { + "get": { + "description": "The historical option bars API provides aggregates for a list of option symbols between the specified dates.\n\nThe returned results are sorted by symbol first, then by bar timestamp.\nThis means that you are likely to see only one symbol in your first response if there are enough bars for that symbol to hit the limit you requested.\n\nIn these situations, if you keep requesting again with the `next_page_token` from the previous response, you will eventually reach the other symbols if any bars were found for them.", + "operationId": "optionBars", + "parameters": [ + { + "$ref": "#/components/parameters/option_symbols" + }, + { + "$ref": "#/components/parameters/timeframe" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "bars": { + "value": { + "bars": { + "AAPL240419P00140000": [ + { + "c": 0.34, + "h": 0.38, + "l": 0.34, + "n": 7, + "o": 0.38, + "t": "2024-01-18T05:00:00Z", + "v": 12, + "vw": 0.3525 + } + ] + }, + "next_page_token": "QUFQTHxNfDIwMjItMDEtMDNUMDk6MDA6MDAuMDAwMDAwMDAwWg==" + } + } + }, + "schema": { + "$ref": "#/components/schemas/option_bars_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical bars", + "tags": [ + "Option" + ] + } + }, + "/v1beta1/options/meta/conditions/{ticktype}": { + "get": { + "description": "Returns the mapping between the condition codes and names.", + "operationId": "OptionMetaConditions", + "parameters": [ + { + "description": "The type of ticks.", + "in": "path", + "name": "ticktype", + "required": true, + "schema": { + "enum": [ + "trade", + "quote" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/option_conditions" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Condition codes", + "tags": [ + "Option" + ] + } + }, + "/v1beta1/options/meta/exchanges": { + "get": { + "description": "Returns the mapping between the option exchange codes and the corresponding exchange names.", + "operationId": "OptionMetaExchanges", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/option_exchanges" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Exchange codes", + "tags": [ + "Option" + ] + } + }, + "/v1beta1/options/quotes/latest": { + "get": { + "description": "The latest multi-quotes endpoint provides the latest bid and ask prices for each given contract symbol.\n", + "operationId": "OptionLatestQuotes", + "parameters": [ + { + "$ref": "#/components/parameters/option_symbols" + }, + { + "$ref": "#/components/parameters/option_feed" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "quotes": { + "value": { + "quotes": { + "AAPL240419P00140000": { + "ap": 0.16, + "as": 669, + "ax": "w", + "bp": 0.15, + "bs": 164, + "bx": "W", + "c": "A", + "t": "2024-02-28T15:30:28.046330624Z" + }, + "AAPL250321C00190000": { + "ap": 17, + "as": 622, + "ax": "X", + "bp": 16.75, + "bs": 368, + "bx": "X", + "c": " ", + "t": "2024-02-28T15:47:13.663636224Z" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/option_latest_quotes_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest quotes", + "tags": [ + "Option" + ] + } + }, + "/v1beta1/options/snapshots": { + "get": { + "description": "The snapshots endpoint provides the latest trade, latest quote and greeks for each given contract symbol.\n", + "operationId": "OptionSnapshots", + "parameters": [ + { + "$ref": "#/components/parameters/option_symbols" + }, + { + "$ref": "#/components/parameters/option_feed" + }, + { + "$ref": "#/components/parameters/option_updated_since" + }, + { + "$ref": "#/components/parameters/option_limit" + }, + { + "$ref": "#/components/parameters/page_token" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "snapshots": { + "value": { + "next_page_token": "QUFQTDI0MDYyMTAwMDIyMHwx", + "snapshots": { + "AAPL240426C00162500": { + "greeks": { + "delta": 0.7521304109871954, + "gamma": 0.06241426404871288, + "rho": 0.009910739032549095, + "theta": -0.2847623059595503, + "vega": 0.047540520834498785 + }, + "impliedVolatility": 0.3372405712050441, + "latestQuote": { + "ap": 4.3, + "as": 91, + "ax": "B", + "bp": 4.15, + "bs": 16, + "bx": "C", + "c": "A", + "t": "2024-04-22T19:59:59.992734208Z" + }, + "latestTrade": { + "c": "I", + "p": 4.1, + "s": 1, + "t": "2024-04-22T19:57:32.589554432Z", + "x": "A" + } + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/option_snapshots_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Snapshots", + "tags": [ + "Option" + ] + } + }, + "/v1beta1/options/snapshots/{underlying_symbol}": { + "get": { + "description": "The option chain endpoint provides the latest trade, latest quote, and greeks for each contract symbol of the underlying symbol.\n", + "operationId": "OptionChain", + "parameters": [ + { + "$ref": "#/components/parameters/option_underlying_symbol" + }, + { + "$ref": "#/components/parameters/option_feed" + }, + { + "$ref": "#/components/parameters/option_limit" + }, + { + "$ref": "#/components/parameters/option_updated_since" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "description": "Filter contracts by the type (call or put).", + "in": "query", + "name": "type", + "schema": { + "enum": [ + "call", + "put" + ], + "type": "string" + } + }, + { + "description": "Filter contracts with strike price greater than or equal to the specified value.", + "in": "query", + "name": "strike_price_gte", + "schema": { + "format": "double", + "type": "number" + } + }, + { + "description": "Filter contracts with strike price less than or equal to the specified value.", + "in": "query", + "name": "strike_price_lte", + "schema": { + "format": "double", + "type": "number" + } + }, + { + "description": "Filter contracts by the exact expiration date (format: YYYY-MM-DD).", + "in": "query", + "name": "expiration_date", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts with expiration date greater than or equal to the specified date.", + "in": "query", + "name": "expiration_date_gte", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts with expiration date less than or equal to the specified date.", + "in": "query", + "name": "expiration_date_lte", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts by the root symbol.", + "example": "AAPL1", + "in": "query", + "name": "root_symbol", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "snapshots": { + "value": { + "next_page_token": "QUFQTDI0MDYyMTAwMDIyMHwx", + "snapshots": { + "AAPL240426C00162500": { + "greeks": { + "delta": 0.7521304109871954, + "gamma": 0.06241426404871288, + "rho": 0.009910739032549095, + "theta": -0.2847623059595503, + "vega": 0.047540520834498785 + }, + "impliedVolatility": 0.3372405712050441, + "latestQuote": { + "ap": 4.3, + "as": 91, + "ax": "B", + "bp": 4.15, + "bs": 16, + "bx": "C", + "c": "A", + "t": "2024-04-22T19:59:59.992734208Z" + }, + "latestTrade": { + "c": "I", + "p": 4.1, + "s": 1, + "t": "2024-04-22T19:57:32.589554432Z", + "x": "A" + } + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/option_snapshots_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Option chain", + "tags": [ + "Option" + ] + } + }, + "/v1beta1/options/trades": { + "get": { + "description": "The historical option trades API provides trade data for a list of contract symbols between the specified dates.\n\nThe returned results are sorted by symbol first then by trade timestamp.\nThis means that you are likely to see only one symbol in your first response if there are enough trades for that symbol to hit the limit you requested.\n\nIn these situations, if you keep requesting again with the `next_page_token` from the previous response, you will eventually reach the other symbols if any trades were found for them.", + "operationId": "OptionTrades", + "parameters": [ + { + "$ref": "#/components/parameters/option_symbols" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "trades": { + "value": { + "next_page_token": "QUFQTHwyMDIyLTAxLTAzVDA5OjAwOjAwLjI0NDgzOTY4MFp8UHwwOTIyMzM3MjAzNjg1NDc3NTgxMA==", + "trades": { + "AAPL240112C00182500": [ + { + "c": "I", + "p": 0.37, + "s": 1, + "t": "2024-01-18T15:03:44.56339456Z", + "x": "B" + }, + { + "c": "g", + "p": 0.34, + "s": 1, + "t": "2024-01-18T16:02:38.994758144Z", + "x": "C" + } + ] + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/option_trades_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical trades", + "tags": [ + "Option" + ] + } + }, + "/v1beta1/options/trades/latest": { + "get": { + "description": "The latest multi-trades endpoint provides the latest historical trade data for multiple given contract symbols.\n", + "operationId": "OptionLatestTrades", + "parameters": [ + { + "$ref": "#/components/parameters/option_symbols" + }, + { + "$ref": "#/components/parameters/option_feed" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "trades": { + "value": { + "trades": { + "AAPL250321C00190000": { + "c": "e", + "p": 17.15, + "s": 900, + "t": "2024-02-28T15:26:12.728701696Z", + "x": "B" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/option_latest_trades_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest trades", + "tags": [ + "Option" + ] + } + }, + "/v1beta1/screener/{market_type}/movers": { + "get": { + "description": "Returns the top market movers (gainers and losers) based on real time SIP data.\nThe change for each symbol is calculated from the previous closing price and the latest closing price.\n\nFor stocks, the endpoint resets at market open. Until then, it shows the previous market day's movers.\nThe data is split-adjusted. Only tradable symbols in exchanges are included.\n\nFor crypto, the endpoint resets at midnight.", + "operationId": "Movers", + "parameters": [ + { + "$ref": "#/components/parameters/movers_market_type" + }, + { + "$ref": "#/components/parameters/movers_top" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "movers": { + "value": { + "gainers": [ + { + "change": 2.46, + "percent_change": 145.56, + "price": 4.15, + "symbol": "AGRI" + }, + { + "change": 0.03, + "percent_change": 85.63, + "price": 0.0594, + "symbol": "GRCYW" + } + ], + "last_updated": "2022-03-10T17:53:30.088309839Z", + "losers": [ + { + "change": -0.26, + "percent_change": -63.07, + "price": 0.1502, + "symbol": "MTACW" + }, + { + "change": -3.61, + "percent_change": -51.21, + "price": 3.435, + "symbol": "TIG" + } + ], + "market_type": "stocks" + } + } + }, + "schema": { + "$ref": "#/components/schemas/movers_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Top market movers", + "tags": [ + "Screener" + ] + } + }, + "/v1beta1/screener/stocks/most-actives": { + "get": { + "description": "Returns the most active stocks by volume or trade count based on real time SIP data. By default, returns the top 10 symbols by volume.\n", + "operationId": "MostActives", + "parameters": [ + { + "$ref": "#/components/parameters/most_actives_by" + }, + { + "$ref": "#/components/parameters/most_actives_top" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/most_actives_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Most active stocks", + "tags": [ + "Screener" + ] + } + }, + "/v1beta3/crypto/{loc}/bars": { + "get": { + "description": "The crypto bars API provides historical aggregates for a list of crypto symbols between the specified dates.\n", + "operationId": "CryptoBars", + "parameters": [ + { + "$ref": "#/components/parameters/crypto_historical_loc" + }, + { + "$ref": "#/components/parameters/crypto_symbols" + }, + { + "$ref": "#/components/parameters/timeframe" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "bars": { + "value": { + "bars": { + "BTC/USD": [ + { + "c": 29003, + "h": 29003, + "l": 28999, + "n": 4, + "o": 28999, + "t": "2022-05-27T10:18:00Z", + "v": 0.01, + "vw": 29001 + } + ] + }, + "next_page_token": "MTY0MDk0ODkyMzAwMDAwMDAwMHwyNDg0MzE3MQ==" + } + } + }, + "schema": { + "$ref": "#/components/schemas/crypto_bars_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical bars", + "tags": [ + "Crypto" + ] + } + }, + "/v1beta3/crypto/{loc}/latest/bars": { + "get": { + "description": "The latest multi-bars endpoint returns the latest minute-aggregated historical bar data for each of the crypto symbols provided.\n", + "operationId": "CryptoLatestBars", + "parameters": [ + { + "$ref": "#/components/parameters/crypto_latest_loc" + }, + { + "$ref": "#/components/parameters/crypto_symbols" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "bars": { + "value": { + "bars": { + "BTC/USD": { + "c": 29003, + "h": 29003, + "l": 28999, + "n": 4, + "o": 28999, + "t": "2022-05-27T10:18:00Z", + "v": 0.01, + "vw": 29001 + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/crypto_latest_bars_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest bars", + "tags": [ + "Crypto" + ] + } + }, + "/v1beta3/crypto/{loc}/latest/orderbooks": { + "get": { + "description": "The latest orderbook endpoint returns the latest bid and ask orderbook for the crypto symbols provided.\n", + "operationId": "CryptoLatestOrderbooks", + "parameters": [ + { + "$ref": "#/components/parameters/crypto_latest_loc" + }, + { + "$ref": "#/components/parameters/crypto_symbols" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "orderbooks": { + "value": { + "orderbooks": { + "BTC/USD": { + "a": [ + { + "p": 20902, + "s": 0.0097 + }, + { + "p": 21444, + "s": 0 + } + ], + "b": [ + { + "p": 20846, + "s": 0.1902 + }, + { + "p": 20350, + "s": 0 + } + ], + "t": "2022-06-24T08:00:14.137774336Z" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/crypto_latest_orderbooks_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest orderbook", + "tags": [ + "Crypto" + ] + } + }, + "/v1beta3/crypto/{loc}/latest/quotes": { + "get": { + "description": "The latest quotes endpoint returns the latest bid and ask prices for the crypto symbols provided.\n", + "operationId": "CryptoLatestQuotes", + "parameters": [ + { + "$ref": "#/components/parameters/crypto_latest_loc" + }, + { + "$ref": "#/components/parameters/crypto_symbols" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "quotes": { + "value": { + "quotes": { + "BTC/USD": { + "ap": 29059, + "as": 3.252, + "bp": 29058, + "bs": 0.3544, + "t": "2022-05-26T11:47:18.44347136Z" + }, + "ETH/USD": { + "ap": 1817.7, + "as": 6.137, + "bp": 1817, + "bs": 4.76, + "t": "2022-05-26T11:47:18.499478272Z" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/crypto_latest_quotes_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest quotes", + "tags": [ + "Crypto" + ] + } + }, + "/v1beta3/crypto/{loc}/latest/trades": { + "get": { + "description": "The latest trades endpoint returns the latest trade data for the crypto symbols provided.\n", + "operationId": "CryptoLatestTrades", + "parameters": [ + { + "$ref": "#/components/parameters/crypto_latest_loc" + }, + { + "$ref": "#/components/parameters/crypto_symbols" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "trades": { + "value": { + "trades": { + "BTC/USD": { + "i": 31455289, + "p": 29791, + "s": 0.0016, + "t": "2022-05-18T12:01:00.537052Z", + "tks": "S" + }, + "ETH/USD": { + "i": 31455287, + "p": 2027.6, + "s": 0.06, + "t": "2022-05-18T12:01:00.363547Z", + "tks": "S" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/crypto_latest_trades_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest trades", + "tags": [ + "Crypto" + ] + } + }, + "/v1beta3/crypto/{loc}/quotes": { + "get": { + "description": "The crypto quotes API provides historical quote data for a list of crypto symbols between the specified dates.\nThe oldest date to retrieve historical quotes of us-1 location is 14th October, 2025 12AM UTC.", + "operationId": "CryptoQuotes", + "parameters": [ + { + "$ref": "#/components/parameters/crypto_historical_loc" + }, + { + "$ref": "#/components/parameters/crypto_symbols" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "quotes": { + "value": { + "next_page_token": "MTY1MzU2NzYzODQ5OTQ3ODI3Mnwx", + "quotes": { + "BTC/USD": [ + { + "ap": 29059, + "as": 3.252, + "bp": 29058, + "bs": 0.3544, + "t": "2022-05-26T11:47:18.44347136Z" + } + ], + "ETH/USD": [ + { + "ap": 1817.7, + "as": 6.137, + "bp": 1817, + "bs": 4.76, + "t": "2022-05-26T11:47:18.499478272Z" + } + ] + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/crypto_quotes_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical quotes", + "tags": [ + "Crypto" + ] + } + }, + "/v1beta3/crypto/{loc}/snapshots": { + "get": { + "description": "The snapshots endpoint returns the latest trade, latest quote, latest minute bar, latest daily bar, and previous daily bar data for crypto symbols.\n", + "operationId": "CryptoSnapshots", + "parameters": [ + { + "$ref": "#/components/parameters/crypto_latest_loc" + }, + { + "$ref": "#/components/parameters/crypto_symbols" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "snapshots": { + "value": { + "snapshots": { + "BTC/USD": { + "dailyBar": { + "c": 31744, + "h": 31807, + "l": 31416, + "n": 438, + "o": 31660, + "t": "2022-05-31T05:00:00Z", + "v": 67.3518, + "vw": 31582.7034526175 + }, + "latestQuote": { + "ap": 31742, + "as": 0.395, + "bp": 31741, + "bs": 0.395, + "t": "2022-05-31T11:55:58.507608832Z" + }, + "latestTrade": { + "i": 32396097, + "p": 31744, + "s": 0.0543, + "t": "2022-05-31T11:53:45.027481Z", + "tks": "B" + }, + "minuteBar": { + "c": 31744, + "h": 31744, + "l": 31744, + "n": 2, + "o": 31744, + "t": "2022-05-31T11:53:00Z", + "v": 0.0886, + "vw": 31744 + }, + "prevDailyBar": { + "c": 31649, + "h": 32251, + "l": 30251, + "n": 8221, + "o": 30310, + "t": "2022-05-30T05:00:00Z", + "v": 1856.4065, + "vw": 30877.2751897281 + } + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/crypto_snapshots_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Snapshots", + "tags": [ + "Crypto" + ] + } + }, + "/v1beta3/crypto/{loc}/trades": { + "get": { + "description": "The crypto trades API provides historical trade data for a list of crypto symbols between the specified dates.\n", + "operationId": "CryptoTrades", + "parameters": [ + { + "$ref": "#/components/parameters/crypto_historical_loc" + }, + { + "$ref": "#/components/parameters/crypto_symbols" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "trades": { + "value": { + "next_page_token": "MTY1MzA1MDgwMDAwMDAwMDAwMHwzMTQ1NTI4OQ==", + "trades": { + "BTC/USD": [ + { + "i": 31455289, + "p": 29791, + "s": 0.0016, + "t": "2022-05-18T12:01:00.537052Z", + "tks": "S" + } + ], + "ETH/USD": [ + { + "i": 31455287, + "p": 2027.6, + "s": 0.06, + "t": "2022-05-18T12:01:00.363547Z", + "tks": "S" + }, + { + "i": 31455288, + "p": 2027.6, + "s": 0.136, + "t": "2022-05-18T12:01:00.363547Z", + "tks": "S" + } + ] + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/crypto_trades_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical trades", + "tags": [ + "Crypto" + ] + } + }, + "/v1/corporate-actions": { + "get": { + "description": "This endpoint provides data about the corporate actions for each given symbol over a specified time period.\n\nBy default (`data_quality=complete`), corporate actions that are still incomplete (for example, missing required fields such as ex-date or CUSIP/ISIN) and have not yet been processed are excluded from the response. Pass `data_quality=all` to also receive those early, incomplete records. Already-processed corporate actions are always returned when `data_quality=complete`, even if they would otherwise be considered incomplete.\n\n> ⚠️ Warning\n>\n> Currently Alpaca has no guarantees on the creation time of corporate actions. There may be delays in receiving corporate actions from our data providers, and there may be delays in processing and making them available via this API. As a result, corporate actions may not be available immediately after they are announced.\n", + "operationId": "CorporateActions", + "parameters": [ + { + "$ref": "#/components/parameters/cas_symbols" + }, + { + "$ref": "#/components/parameters/cas_cusips" + }, + { + "$ref": "#/components/parameters/cas_types" + }, + { + "$ref": "#/components/parameters/cas_region" + }, + { + "$ref": "#/components/parameters/cas_start" + }, + { + "$ref": "#/components/parameters/cas_end" + }, + { + "$ref": "#/components/parameters/cas_ids" + }, + { + "$ref": "#/components/parameters/cas_limit" + }, + { + "$ref": "#/components/parameters/cas_data_quality" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/corporate_actions_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Corporate actions", + "tags": [ + "Corporate actions" + ] + } + }, + "/v2/stocks/{symbol}/auctions": { + "get": { + "description": "The historical auctions endpoint provides auction prices for the given stock symbol between the specified dates.\n", + "operationId": "StockAuctionSingle", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbol" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/stock_asof" + }, + { + "$ref": "#/components/parameters/stock_auction_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "auctions": { + "value": { + "auctions": [ + { + "c": [ + { + "c": "M", + "p": 221.7, + "t": "2022-10-13T20:00:00.152902912Z", + "x": "P" + } + ], + "d": "2022-10-13", + "o": [ + { + "c": "Q", + "p": 208.37, + "t": "2022-10-13T13:30:00.068034304Z", + "x": "P" + }, + { + "c": "O", + "p": 208.49, + "t": "2022-10-13T13:30:01.079567733Z", + "x": "Q" + }, + { + "c": "Q", + "p": 208.49, + "t": "2022-10-13T13:30:01.090802222Z", + "x": "Q" + } + ] + } + ], + "next_page_token": "MjAyMi0xMC0xM1QyMDowMDowMC4xNTI5MDI5MTJafFA=", + "symbol": "TSLA" + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_auctions_resp_single" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical auctions (single)", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/{symbol}/bars": { + "get": { + "description": "The historical stock bars API provides aggregates for the stock symbol between the specified dates.", + "operationId": "StockBarSingle", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbol" + }, + { + "$ref": "#/components/parameters/timeframe" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/stock_adjustment" + }, + { + "$ref": "#/components/parameters/stock_asof" + }, + { + "$ref": "#/components/parameters/stock_historical_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "bars": { + "value": { + "bars": [ + { + "c": 178.21, + "h": 178.26, + "l": 178.21, + "n": 65, + "o": 178.26, + "t": "2022-01-03T09:00:00Z", + "v": 1118, + "vw": 178.235733 + } + ], + "next_page_token": "QUFQTHxNfDIwMjItMDEtMDNUMDk6MDA6MDAuMDAwMDAwMDAwWg==", + "symbol": "AAPL" + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_bars_resp_single" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical bars (single symbol)", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/{symbol}/bars/latest": { + "get": { + "description": "The latest bar endpoint returns the latest minute bar for the given ticker symbol.\n", + "operationId": "StockLatestBarSingle", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbol" + }, + { + "$ref": "#/components/parameters/stock_latest_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "bar": { + "value": { + "bar": { + "c": 173, + "h": 173.04, + "l": 172.98, + "n": 49, + "o": 172.98, + "t": "2022-08-17T09:07:00Z", + "v": 2748, + "vw": 173.007817 + }, + "symbol": "AAPL" + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_latest_bars_resp_single" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest bar (single symbol)", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/{symbol}/quotes": { + "get": { + "description": "The historical stock quotes API provides quote data for a stock symbol between the specified dates.", + "operationId": "StockQuoteSingle", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbol" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/stock_asof" + }, + { + "$ref": "#/components/parameters/stock_historical_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "quotes": { + "value": { + "next_page_token": "QUFQTHwyMDIyLTAxLTAzVDA5OjAwOjAwLjAyODI5NDQ1MVp8MjM3NjQ0Qzg=", + "quotes": [ + { + "ap": 0, + "as": 0, + "ax": " ", + "bp": 177.92, + "bs": 4, + "bx": "Q", + "c": [ + "Y" + ], + "t": "2022-01-03T09:00:00.028160898Z", + "z": "C" + }, + { + "ap": 178.8, + "as": 4, + "ax": "Q", + "bp": 177.92, + "bs": 4, + "bx": "Q", + "c": [ + "R" + ], + "t": "2022-01-03T09:00:00.028294451Z", + "z": "C" + } + ], + "symbol": "AAPL" + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_quotes_resp_single" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical quotes (single symbol)", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/{symbol}/quotes/latest": { + "get": { + "description": "The latest quote endpoint provides the latest best bid and ask prices for a given ticker symbol.\n", + "operationId": "StockLatestQuoteSingle", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbol" + }, + { + "$ref": "#/components/parameters/stock_latest_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "quotes": { + "value": { + "quote": { + "ap": 172.7, + "as": 1, + "ax": "Q", + "bp": 172.6, + "bs": 2, + "bx": "Q", + "c": [ + "R" + ], + "t": "2022-08-17T10:09:34.055031265Z", + "z": "C" + }, + "symbol": "AAPL" + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_latest_quotes_resp_single" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest quote (single symbol)", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/{symbol}/snapshot": { + "get": { + "description": "The snapshot endpoint provides the latest trade, latest quote, minute bar, daily bar, and previous daily bar data for a given ticker symbol.\n", + "operationId": "StockSnapshotSingle", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbol" + }, + { + "$ref": "#/components/parameters/stock_latest_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "snapshot": { + "value": { + "dailyBar": { + "c": 173.03, + "h": 173.71, + "l": 171.6618, + "n": 515139, + "o": 172.62, + "t": "2022-08-16T04:00:00Z", + "v": 56457696, + "vw": 172.743391 + }, + "latestQuote": { + "ap": 172.65, + "as": 1, + "ax": "Q", + "bp": 172.51, + "bs": 1, + "bx": "P", + "c": [ + "R" + ], + "t": "2022-08-17T10:19:30.805564086Z", + "z": "C" + }, + "latestTrade": { + "c": [ + "@", + "T" + ], + "i": 1040, + "p": 172.55, + "s": 229, + "t": "2022-08-17T10:19:30.735811394Z", + "x": "Q", + "z": "C" + }, + "minuteBar": { + "c": 172.6, + "h": 172.65, + "l": 172.6, + "n": 57, + "o": 172.65, + "t": "2022-08-17T10:18:00Z", + "v": 3746, + "vw": 172.618377 + }, + "prevDailyBar": { + "c": 173.19, + "h": 173.39, + "l": 171.345, + "n": 501626, + "o": 171.5, + "t": "2022-08-15T04:00:00Z", + "v": 54091719, + "vw": 172.625371 + }, + "symbol": "AAPL" + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_snapshots_resp_single" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Snapshot (single symbol)", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/{symbol}/trades": { + "get": { + "description": "The historical stock trades API provides trade data for a stock symbol between the specified dates.", + "operationId": "StockTradeSingle", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbol" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/stock_asof" + }, + { + "$ref": "#/components/parameters/stock_historical_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "trades": { + "value": { + "next_page_token": "QUFQTHwyMDIyLTAxLTAzVDE3OjAwOjAwLjAyOTU5MTQ3Nlp8UXwwOTIyMzM3MjAzNjg1NDg0OTY0Mg==", + "symbol": "AAPL", + "trades": [ + { + "c": [ + "@", + "I" + ], + "i": 73833, + "p": 181.47, + "s": 1, + "t": "2022-01-03T17:00:00.029591476Z", + "x": "Q", + "z": "C" + }, + { + "c": [ + "@", + "I" + ], + "i": 73834, + "p": 181.47, + "s": 1, + "t": "2022-01-03T17:00:00.029591476Z", + "x": "Q", + "z": "C" + } + ] + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_trades_resp_single" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical trades (single symbol)", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/{symbol}/trades/latest": { + "get": { + "description": "The latest trade endpoint provides the latest trade for the given ticker symbol.\n\nTrades with any conditions that causes them to not update the bar price are excluded. For example a trade with condition `I` (odd lot) will never appear on this endpoint. You can find the complete list of excluded conditions in [this FAQ](https://docs.alpaca.markets/docs/market-data-faq#how-are-bars-aggregated).", + "operationId": "StockLatestTradeSingle", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbol" + }, + { + "$ref": "#/components/parameters/stock_latest_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "trade": { + "value": { + "symbol": "AAPL", + "trade": { + "c": [ + "@", + "T" + ], + "i": 689, + "p": 172.6, + "s": 100, + "t": "2022-08-17T09:53:16.845580544Z", + "x": "P", + "z": "C" + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_latest_trades_resp_single" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest trade (single symbol)", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/auctions": { + "get": { + "description": "The historical auctions endpoint provides auction prices for a list of stock symbols between the specified dates.\n", + "operationId": "StockAuctions", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbols" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/stock_asof" + }, + { + "$ref": "#/components/parameters/stock_auction_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "auction": { + "value": { + "auctions": { + "AAPL": [ + { + "c": [ + { + "c": "6", + "p": 138.36, + "t": "2022-10-12T20:00:00.120649216Z", + "x": "P" + }, + { + "c": "M", + "p": 138.36, + "t": "2022-10-12T20:00:00.125925888Z", + "x": "P" + }, + { + "c": "6", + "p": 138.34, + "t": "2022-10-12T20:00:00.875570864Z", + "x": "Q" + }, + { + "c": "M", + "p": 138.34, + "t": "2022-10-12T20:00:00.875603021Z", + "x": "Q" + } + ], + "d": "2022-10-12", + "o": [ + { + "c": "Q", + "p": 139.12, + "t": "2022-10-12T13:30:00.188390144Z", + "x": "P" + }, + { + "c": "O", + "p": 138.99, + "t": "2022-10-12T13:30:01.474665705Z", + "x": "Q" + }, + { + "c": "Q", + "p": 138.99, + "t": "2022-10-12T13:30:01.475216565Z", + "x": "Q" + } + ] + }, + { + "c": [ + { + "c": "M", + "p": 142.94, + "t": "2022-10-13T20:00:00.166980864Z", + "x": "P" + } + ], + "d": "2022-10-13", + "o": [ + { + "c": "Q", + "p": 134.8, + "t": "2022-10-13T13:30:00.20304384Z", + "x": "P" + }, + { + "c": "O", + "p": 135, + "t": "2022-10-13T13:30:01.688322951Z", + "x": "Q" + }, + { + "c": "Q", + "p": 135, + "t": "2022-10-13T13:30:01.699259366Z", + "x": "Q" + } + ] + } + ], + "TSLA": [ + { + "c": [ + { + "c": "M", + "p": 217.23, + "t": "2022-10-12T20:00:00.124164096Z", + "x": "P" + }, + { + "c": "6", + "p": 217.24, + "t": "2022-10-12T20:00:00.469874365Z", + "x": "Q" + }, + { + "c": "M", + "p": 217.24, + "t": "2022-10-12T20:00:00.469912641Z", + "x": "Q" + } + ], + "d": "2022-10-12", + "o": [ + { + "c": "Q", + "p": 215.39, + "t": "2022-10-12T13:30:00.065736192Z", + "x": "P" + }, + { + "c": "O", + "p": 215.79, + "t": "2022-10-12T13:30:01.349399539Z", + "x": "Q" + }, + { + "c": "Q", + "p": 215.79, + "t": "2022-10-12T13:30:01.349965972Z", + "x": "Q" + } + ] + }, + { + "c": [ + { + "c": "M", + "p": 221.7, + "t": "2022-10-13T20:00:00.152902912Z", + "x": "P" + } + ], + "d": "2022-10-13", + "o": [ + { + "c": "Q", + "p": 208.37, + "t": "2022-10-13T13:30:00.068034304Z", + "x": "P" + }, + { + "c": "O", + "p": 208.49, + "t": "2022-10-13T13:30:01.079567733Z", + "x": "Q" + }, + { + "c": "Q", + "p": 208.49, + "t": "2022-10-13T13:30:01.090802222Z", + "x": "Q" + } + ] + } + ] + }, + "next_page_token": "MjAyMi0xMC0xM1QyMDowMDowMC4xNTI5MDI5MTJafFA=" + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_auctions_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical auctions", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/bars": { + "get": { + "description": "The historical stock bars API provides aggregates for a list of stock symbols between the specified dates.\n\nThe returned results are sorted by symbol first, then by bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough bars for that symbol to hit the limit you requested.\n\nIn these situations, if you keep requesting again with the `next_page_token` from the previous response, you will eventually reach the other symbols if any bars were found for them.", + "operationId": "StockBars", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbols" + }, + { + "$ref": "#/components/parameters/timeframe" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/stock_adjustment" + }, + { + "$ref": "#/components/parameters/stock_asof" + }, + { + "$ref": "#/components/parameters/stock_historical_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "bars": { + "value": { + "bars": { + "AAPL": [ + { + "c": 178.21, + "h": 178.26, + "l": 178.21, + "n": 65, + "o": 178.26, + "t": "2022-01-03T09:00:00Z", + "v": 1118, + "vw": 178.235733 + } + ] + }, + "next_page_token": "QUFQTHxNfDIwMjItMDEtMDNUMDk6MDA6MDAuMDAwMDAwMDAwWg==" + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_bars_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical bars", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/bars/latest": { + "get": { + "description": "The latest bars endpoint provides the latest minute bar for the given ticker symbols.\n", + "operationId": "StockLatestBars", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbols" + }, + { + "$ref": "#/components/parameters/stock_latest_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "bars": { + "value": { + "bars": { + "AAPL": { + "c": 172.79, + "h": 172.81, + "l": 172.78, + "n": 20, + "o": 172.81, + "t": "2022-08-17T08:58:00Z", + "v": 1002, + "vw": 172.791417 + }, + "TSLA": { + "c": 914.3, + "h": 914.3, + "l": 914.3, + "n": 20, + "o": 914.3, + "t": "2022-08-17T08:57:00Z", + "v": 751, + "vw": 914.294634 + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_latest_bars_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest bars", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/meta/conditions/{ticktype}": { + "get": { + "description": "Returns the mapping between the condition codes and names.", + "operationId": "StockMetaConditions", + "parameters": [ + { + "description": "The type of ticks.", + "in": "path", + "name": "ticktype", + "required": true, + "schema": { + "enum": [ + "trade", + "quote" + ], + "type": "string" + } + }, + { + "description": "The one character name of the tape.", + "in": "query", + "name": "tape", + "required": true, + "schema": { + "enum": [ + "A", + "B", + "C" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/stock_conditions" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Condition codes", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/meta/exchanges": { + "get": { + "description": "Returns the mapping between the stock exchange codes and the corresponding exchange names.\n", + "operationId": "StockMetaExchanges", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/stock_exchanges" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Exchange codes", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/quotes": { + "get": { + "description": "The historical stock quotes API provides quote data for a list of stock symbols between the specified dates.\n\nThe returned results are sorted by symbol first, then by the quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough quotes for that symbol to hit the limit you requested.\n\nIn these situations, if you keep requesting again with the `next_page_token` from the previous response, you will eventually reach the other symbols if any quotes were found for them.", + "operationId": "StockQuotes", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbols" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/stock_asof" + }, + { + "$ref": "#/components/parameters/stock_historical_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "quotes": { + "value": { + "next_page_token": "QUFQTHwyMDIyLTAxLTAzVDA5OjAwOjAwLjAyODI5NDQ1MVp8MjM3NjQ0Qzg=", + "quotes": { + "AAPL": [ + { + "ap": 0, + "as": 0, + "ax": " ", + "bp": 177.92, + "bs": 4, + "bx": "Q", + "c": [ + "Y" + ], + "t": "2022-01-03T09:00:00.028160898Z", + "z": "C" + }, + { + "ap": 178.8, + "as": 4, + "ax": "Q", + "bp": 177.92, + "bs": 4, + "bx": "Q", + "c": [ + "R" + ], + "t": "2022-01-03T09:00:00.028294451Z", + "z": "C" + } + ] + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_quotes_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical quotes", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/quotes/latest": { + "get": { + "description": "The latest quotes endpoint provides the latest best bid and ask prices for the given ticker symbols.\n", + "operationId": "StockLatestQuotes", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbols" + }, + { + "$ref": "#/components/parameters/stock_latest_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "quotes": { + "value": { + "quotes": { + "AAPL": { + "ap": 172.7, + "as": 1, + "ax": "Q", + "bp": 172.62, + "bs": 2, + "bx": "Q", + "c": [ + "R" + ], + "t": "2022-08-17T10:07:40.286587431Z", + "z": "C" + }, + "TSLA": { + "ap": 911.6, + "as": 1, + "ax": "Q", + "bp": 911.3, + "bs": 1, + "bx": "K", + "c": [ + "R" + ], + "t": "2022-08-17T10:07:49.387064037Z", + "z": "C" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_latest_quotes_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest quotes", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/snapshots": { + "get": { + "description": "The snapshot endpoint for multiple tickers provides the latest trade, latest quote, minute bar, daily bar, and previous daily bar data for each given ticker symbol.\n", + "operationId": "StockSnapshots", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbols" + }, + { + "$ref": "#/components/parameters/stock_latest_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "snapshots": { + "value": { + "AAPL": { + "dailyBar": { + "c": 173.03, + "h": 173.71, + "l": 171.6618, + "n": 515139, + "o": 172.62, + "t": "2022-08-16T04:00:00Z", + "v": 56457696, + "vw": 172.743391 + }, + "latestQuote": { + "ap": 172.7, + "as": 5, + "ax": "Q", + "bp": 172.6, + "bs": 2, + "bx": "Q", + "c": [ + "R" + ], + "t": "2022-08-17T10:18:27.052763263Z", + "z": "C" + }, + "latestTrade": { + "c": [ + "@", + "T" + ], + "i": 1011, + "p": 172.61, + "s": 160, + "t": "2022-08-17T10:18:24.114694956Z", + "x": "Q", + "z": "C" + }, + "minuteBar": { + "c": 172.69, + "h": 172.69, + "l": 172.69, + "n": 3, + "o": 172.69, + "t": "2022-08-17T10:16:00Z", + "v": 106, + "vw": 172.688113 + }, + "prevDailyBar": { + "c": 173.19, + "h": 173.39, + "l": 171.345, + "n": 501626, + "o": 171.5, + "t": "2022-08-15T04:00:00Z", + "v": 54091719, + "vw": 172.625371 + } + }, + "TSLA": { + "dailyBar": { + "c": 919.69, + "h": 944, + "l": 908.65, + "n": 805572, + "o": 935, + "t": "2022-08-16T04:00:00Z", + "v": 29378774, + "vw": 925.215087 + }, + "latestQuote": { + "ap": 911.75, + "as": 4, + "ax": "P", + "bp": 911.31, + "bs": 1, + "bx": "Q", + "c": [ + "R" + ], + "t": "2022-08-17T10:18:23.84717767Z", + "z": "C" + }, + "latestTrade": { + "c": [ + "@", + "T" + ], + "i": 2047, + "p": 911.99, + "s": 100, + "t": "2022-08-17T10:13:12.952851456Z", + "x": "P", + "z": "C" + }, + "minuteBar": { + "c": 911.99, + "h": 911.99, + "l": 911.99, + "n": 64, + "o": 911.99, + "t": "2022-08-17T10:13:00Z", + "v": 740, + "vw": 911.780405 + }, + "prevDailyBar": { + "c": 927.96, + "h": 939.4, + "l": 903.69, + "n": 825109, + "o": 905.32, + "t": "2022-08-15T04:00:00Z", + "v": 29786389, + "vw": 923.982755 + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_snapshots_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Snapshots", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/trades": { + "get": { + "description": "The historical stock trades API provides trade data for a list of stock symbols between the specified dates.\n\nThe returned results are sorted by symbol first then by trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough trades for that symbol to hit the limit you requested.\n\nIn these situations, if you keep requesting again with the `next_page_token` from the previous response, you will eventually reach the other symbols if any trades were found for them.", + "operationId": "StockTrades", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbols" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/limit" + }, + { + "$ref": "#/components/parameters/stock_asof" + }, + { + "$ref": "#/components/parameters/stock_historical_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + }, + { + "$ref": "#/components/parameters/page_token" + }, + { + "$ref": "#/components/parameters/sort" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "trades": { + "value": { + "next_page_token": "QUFQTHwyMDIyLTAxLTAzVDA5OjAwOjAwLjI0NDgzOTY4MFp8UHwwOTIyMzM3MjAzNjg1NDc3NTgxMA==", + "trades": { + "AAPL": [ + { + "c": [ + "@", + "T" + ], + "i": 1, + "p": 178.26, + "s": 246, + "t": "2022-01-03T09:00:00.086175744Z", + "x": "P", + "z": "C" + }, + { + "c": [ + "@", + "F", + "T", + "I" + ], + "i": 2, + "p": 178.26, + "s": 1, + "t": "2022-01-03T09:00:00.24483968Z", + "x": "P", + "z": "C" + } + ] + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_trades_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Historical trades", + "tags": [ + "Stock" + ] + } + }, + "/v2/stocks/trades/latest": { + "get": { + "description": "The latest trades endpoint provides the latest trades for the given ticker symbols.\n\nTrades with any conditions that causes them to not update the bar price are excluded. For example a trade with condition `I` (odd lot) will never appear on this endpoint. You can find the complete list of excluded conditions in [this FAQ](https://docs.alpaca.markets/docs/market-data-faq#how-are-bars-aggregated).", + "operationId": "StockLatestTrades", + "parameters": [ + { + "$ref": "#/components/parameters/stock_symbols" + }, + { + "$ref": "#/components/parameters/stock_latest_feed" + }, + { + "$ref": "#/components/parameters/stock_currency" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "trades": { + "value": { + "trades": { + "AAPL": { + "c": [ + "@", + "F", + "T" + ], + "i": 826, + "p": 172.78, + "s": 100, + "t": "2022-08-17T09:50:43.361102308Z", + "x": "Q", + "z": "C" + } + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/stock_latest_trades_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "apiKey": [], + "apiSecret": [] + }, + { + "BasicAuth": [] + } + ], + "summary": "Latest trades", + "tags": [ + "Stock" + ] + } + } + }, + "servers": [ + { + "description": "Production", + "url": "https://data.alpaca.markets" + }, + { + "description": "Sandbox", + "url": "https://data.sandbox.alpaca.markets" + } + ], + "tags": [ + { + "description": "Endpoints for stocks.", + "name": "Stock" + }, + { + "description": "Endpoints for option data.", + "name": "Option" + }, + { + "description": "Endpoints for indices.", + "name": "Index" + }, + { + "description": "Endpoints for cryptocurrencies.", + "name": "Crypto" + }, + { + "description": "Endpoints for fixed income data.", + "name": "Fixed income" + }, + { + "description": "Endpoints for forex currency rates.", + "name": "Forex" + }, + { + "description": "Endpoints for getting company logo images.", + "name": "Logos" + }, + { + "description": "Endpoints for most active stocks and top movers.", + "name": "Screener" + }, + { + "description": "Endpoints for getting news articles about the stock market.", + "name": "News" + }, + { + "description": "Corporate actions (splits, dividends, etc.).", + "name": "Corporate actions" + }, + { + "description": "Endpoints for event contract (prediction market) assets metadata.", + "name": "Event contracts" + } + ] +} diff --git a/module/trading/build.gradle.kts b/module/trading/build.gradle.kts new file mode 100644 index 00000000..3ce72e81 --- /dev/null +++ b/module/trading/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("module-common") + id("openapi-generator-adapted") +} + +description = "A Java library for the Alpaca brokerage platform Trading API." + +openApiGeneratorAdapted { + environmentUrlProduction = "https://api.alpaca.markets" + environmentUrlDevelopment = "https://paper-api.alpaca.markets" +} diff --git a/module/trading/openapi.json b/module/trading/openapi.json new file mode 100644 index 00000000..c7170a87 --- /dev/null +++ b/module/trading/openapi.json @@ -0,0 +1,10729 @@ +{ + "components": { + "examples": { + "CryptoOrderResponse": { + "value": { + "asset_class": "crypto", + "asset_id": "a1733398-6acc-4e92-af24-0d0667f78713", + "canceled_at": null, + "client_order_id": "5b5d3d67-06ad-4ffa-af65-a117d0fc5a59", + "created_at": "2023-12-12T22:36:51.337711497Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "38e482f3-79a8-4f75-a057-f07a1ec6a397", + "legs": null, + "limit_price": "2100", + "notional": null, + "order_class": "", + "order_type": "limit", + "qty": "0.02", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "pending_new", + "stop_price": null, + "submitted_at": "2023-12-12T22:36:51.313261061Z", + "subtag": null, + "symbol": "ETH/USD", + "time_in_force": "gtc", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2023-12-12T22:36:51.337754768Z" + } + }, + "EquityOrderResponse": { + "value": { + "asset_class": "us_equity", + "asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "canceled_at": null, + "client_order_id": "5680c4bc-9ac1-4a12-a44c-df427ba53032", + "created_at": "2023-12-12T22:31:24.668464435Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "7b08df51-c1ac-453c-99f9-323a5f075f0d", + "legs": null, + "limit_price": "150", + "notional": null, + "order_class": "", + "order_type": "limit", + "qty": "2", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "accepted", + "stop_price": null, + "submitted_at": "2023-12-12T22:31:24.577215743Z", + "subtag": null, + "symbol": "AAPL", + "time_in_force": "gtc", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2023-12-12T22:31:24.668464435Z" + } + }, + "IPOOrderResponse": { + "value": { + "asset_class": "ipo", + "asset_id": "9b6c7c1a-9eb2-4d4a-8a3a-1bf4c1d5cbaa", + "canceled_at": null, + "client_order_id": "0b3a90b6-6b5c-4d83-8c0e-9b3eaf4a8d11", + "created_at": "2025-09-15T13:30:42.117344821Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "5e2a8f1a-9c10-4d3a-8c64-7f59c1d18c11", + "legs": null, + "limit_price": null, + "notional": "500", + "order_class": "", + "order_type": "market", + "qty": null, + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "accepted", + "stop_price": null, + "submitted_at": "2025-09-15T13:30:42.094518219Z", + "subtag": null, + "symbol": "FI111225", + "time_in_force": "gtc", + "trail_percent": null, + "trail_price": null, + "type": "market", + "updated_at": "2025-09-15T13:30:42.117344821Z" + } + }, + "MultilegOptionsOrderResponse": { + "value": { + "asset_class": "", + "asset_id": "", + "canceled_at": null, + "client_order_id": "646b1fe6-b212-4f54-94c6-429e7bcdee04", + "created_at": "2024-12-10T16:15:53.677230742Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": "2024-12-10T16:15:53.694Z", + "filled_avg_price": "1.28", + "filled_qty": "1", + "hwm": null, + "id": "83f37e9f-6b1f-49ed-8fc6-3e6af716323f", + "legs": [ + { + "asset_class": "us_option", + "asset_id": "f0ea14b2-8a49-4e9b-89d1-894c6e518a76", + "canceled_at": null, + "client_order_id": "cc8cc104-fe43-476c-b25c-f62650fb73f9", + "created_at": "2024-12-10T16:15:53.677230742Z", + "expired_at": null, + "expires_at": "2024-12-10T21:00:00Z", + "extended_hours": false, + "failed_at": null, + "filled_at": "2024-12-10T16:15:53.694Z", + "filled_avg_price": "0.43", + "filled_qty": "3", + "hwm": null, + "id": "df4ff24a-c58a-4e37-8b9f-ef32b83a11f2", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "mleg", + "order_type": "", + "position_intent": "buy_to_open", + "qty": "3", + "ratio_qty": "3", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "filled", + "stop_price": null, + "submitted_at": "2024-12-10T16:15:53.684952901Z", + "subtag": null, + "symbol": "AAPL241213C00250000", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "", + "updated_at": "2024-12-10T16:15:53.725091158Z" + }, + { + "asset_class": "us_option", + "asset_id": "f89940db-eeb1-46e6-8f9b-bb1f27a0b395", + "canceled_at": null, + "client_order_id": "0bd2d36d-4af2-4dfb-8418-333a5d5026fa", + "created_at": "2024-12-10T16:15:53.677230742Z", + "expired_at": null, + "expires_at": "2024-12-10T21:00:00Z", + "extended_hours": false, + "failed_at": null, + "filled_at": "2024-12-10T16:15:53.694Z", + "filled_avg_price": "0.01", + "filled_qty": "1", + "hwm": null, + "id": "ecd91110-c34d-4e9d-a7bf-a9c27c40f8b5", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "mleg", + "order_type": "", + "position_intent": "sell_to_open", + "qty": "1", + "ratio_qty": "1", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "sell", + "source": null, + "status": "filled", + "stop_price": null, + "submitted_at": "2024-12-10T16:15:53.684952901Z", + "subtag": null, + "symbol": "AAPL241213C00260000", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "", + "updated_at": "2024-12-10T16:15:53.708983759Z" + } + ], + "limit_price": "10", + "notional": null, + "order_class": "mleg", + "order_type": "limit", + "qty": "1", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "", + "source": null, + "status": "filled", + "stop_price": null, + "submitted_at": "2024-12-10T16:15:53.684952901Z", + "subtag": null, + "symbol": "", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2024-12-10T16:15:53.725139688Z" + } + }, + "OptionOrderResponse": { + "value": { + "asset_class": "us_option", + "asset_id": "98359ef7-5124-49f3-85ea-5cf02df6defa", + "canceled_at": null, + "client_order_id": "58cd43a7-029e-457e-b77f-cd4f61f00f2a", + "created_at": "2023-12-12T21:35:49.102449524Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "30a077fa-96f6-4f20-a052-4b921ee2f243", + "legs": null, + "limit_price": "10", + "notional": null, + "order_class": "simple", + "order_type": "limit", + "qty": "2", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "buy", + "source": null, + "status": "pending_new", + "stop_price": null, + "submitted_at": "2023-12-12T21:35:49.056332248Z", + "subtag": null, + "symbol": "AAPL250620C00100000", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "limit", + "updated_at": "2023-12-12T21:35:49.102504673Z" + } + }, + "TravelRuleValidationError": { + "description": "The request requires the beneficiary's name before the transfer can proceed.", + "summary": "Missing beneficiary name", + "value": { + "error_code": "BENEFICIARY_NAME_REQUIRED", + "message": "Please provide the beneficiary's name. Select one of the following options.", + "next_actions": [ + { + "description": "Provide the recipient's first and last name.", + "name": "supply_beneficiaryName_naturalPerson", + "required_fields": [ + { + "description": "The recipient's first name.", + "field": "beneficiary_given_name", + "value_type": "string" + }, + { + "description": "The recipient's last name.", + "field": "beneficiary_family_name", + "value_type": "string" + } + ], + "type": "ONE_OF" + }, + { + "description": "Provide the entity's legal name.", + "name": "supply_beneficiaryName_legalEntity", + "required_fields": [ + { + "description": "The legal name of the receiving entity.", + "field": "beneficiary_entity_name", + "value_type": "string" + } + ], + "type": "ONE_OF" + } + ] + } + } + }, + "headers": { + "ratelimit_limit": { + "description": "Request limit per minute.", + "example": 100, + "schema": { + "type": "integer" + } + }, + "ratelimit_remaining": { + "description": "Request limit per minute remaining.", + "example": 90, + "schema": { + "type": "integer" + } + }, + "ratelimit_reset": { + "description": "The UNIX epoch when the remaining quota changes.", + "example": 1674044551, + "schema": { + "type": "integer" + } + } + }, + "parameters": { + "LegacyIdempotencyKey": { + "description": "Optional client-generated key for safe retries and duplicate request detection.\nThis endpoint currently accepts keys up to 128 characters. Alpaca is moving toward\na 36-character maximum; new implementations should generate a unique UUIDv7 or\nUUIDv4 value (36 characters including hyphens) for each logical operation. Do not\nreuse a key across operations.\n", + "in": "header", + "name": "Idempotency-Key", + "required": false, + "schema": { + "maxLength": 128, + "type": "string" + } + }, + "PageToken": { + "description": "Used for pagination, this token retrieves the next page of results. It is obtained from the response of the preceding page when additional pages are available.", + "in": "query", + "name": "page_token", + "required": false, + "schema": { + "example": "eyJpZCI6IjU1MGU4NDAwLWUyOWItNDFkNC1hNzE2LTQ0NjY1NTQ0MDAwMCJ9Cg", + "type": "string" + } + }, + "end": { + "description": "The last date to retrieve data for (inclusive). Default: one week from the start date.\n", + "example": "2030-01-01", + "in": "query", + "name": "end", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + "legacy_date_type": { + "description": "Indicates what start and end mean. Default: TRADING. If TRADING is specified, returns a calendar whose trading date matches start, end. If SETTLEMENT is specified, returns the calendar whose settlement date matches start and end.\n", + "in": "query", + "name": "date_type", + "schema": { + "enum": [ + "TRADING", + "SETTLEMENT" + ], + "type": "string" + } + }, + "legacy_end": { + "description": "The last date to retrieve data for (inclusive).", + "in": "query", + "name": "end", + "schema": { + "format": "date-time", + "type": "string" + } + }, + "legacy_start": { + "description": "The first date to retrieve data for (inclusive).", + "in": "query", + "name": "start", + "schema": { + "format": "date-time", + "type": "string" + } + }, + "market": { + "description": "The market identifier. MIC, BIC, or acronym.\n\nAvailable market codes by region:\n\n**United States**\n- `BMO`: Bank of Montreal. US banking calendar (US operations).\n- `BNYM`: The Bank of New York Mellon. US banking calendar.\n- `BOATS`: Blue Ocean Alternative Trading System. US overnight trading.\n- `IEX`: Investors Exchange. US equities.\n- `IEXG`: Investors Exchange. US equities.\n- `NASDAQ`: National Association of Securities Dealers Automated Quotations. US equities.\n- `NYSE`: New York Stock Exchange. US equities.\n- `OCEA`: BlueOcean ATS. US overnight trading.\n- `OPRA`: Options Price Reporting Authority. US options.\n- `OTC`: Over-The-Counter. US OTC equities.\n- `OTCM`: OTC Markets. US OTC equities.\n- `SIFMA`: Securities Industry and Financial Markets Association. US bonds.\n- `XNAS`: NASDAQ. US equities.\n- `XNYS`: New York Stock Exchange. US equities.\n\n**Europe**\n- `CEUX`: Cboe CEUX Europe. European equities (Cboe Netherlands).\n- `CHIX`: Cboe CHIX Europe. European equities (Cboe UK).\n- `ISE`: Euronext Dublin. Irish equities.\n- `LSE`: London Stock Exchange. UK equities.\n- `MTA`: Euronext Milan. Italian equities.\n- `MTAA`: Euronext Milan. Italian equities.\n- `XAMS`: Euronext Amsterdam. Dutch equities.\n- `XBRU`: Euronext Brussels. Belgian equities.\n- `XDUB`: Euronext Dublin. Irish equities.\n- `XETR`: Frankfurt Stock Exchange. German equities.\n- `XETRA`: Frankfurt Stock Exchange. German equities.\n- `XLIS`: Euronext Lisbon. Portuguese equities.\n- `XLON`: London Stock Exchange. UK equities.\n- `XPAR`: Euronext Paris. French equities.\n\n**Asia & Middle East**\n- `HKEX`: Hong Kong Stock Exchange. Hong Kong equities.\n- `JPX`: Japan Exchange Group. Japanese equities.\n- `TADAWUL`: Saudi Stock Exchange. Saudi equities.\n- `XHKG`: Hong Kong Stock Exchange. Hong Kong equities.\n- `XSAU`: Saudi Stock Exchange. Saudi equities.\n- `XTKS`: Japan Exchange Group. Japanese equities.\n", + "in": "path", + "name": "market", + "required": true, + "schema": { + "$ref": "#/components/schemas/market" + } + }, + "markets": { + "description": "Comma-separated list of markets. Available market codes by region:\n\n**United States**\n- `BMO`: Bank of Montreal. US banking calendar (US operations).\n- `BNYM`: The Bank of New York Mellon. US banking calendar.\n- `BOATS`: Blue Ocean Alternative Trading System. US overnight trading.\n- `IEX`: Investors Exchange. US equities.\n- `IEXG`: Investors Exchange. US equities.\n- `NASDAQ`: National Association of Securities Dealers Automated Quotations. US equities.\n- `NYSE`: New York Stock Exchange. US equities.\n- `OCEA`: BlueOcean ATS. US overnight trading.\n- `OPRA`: Options Price Reporting Authority. US options.\n- `OTC`: Over-The-Counter. US OTC equities.\n- `OTCM`: OTC Markets. US OTC equities.\n- `SIFMA`: Securities Industry and Financial Markets Association. US bonds.\n- `XNAS`: NASDAQ. US equities.\n- `XNYS`: New York Stock Exchange. US equities.\n\n**Europe**\n- `CEUX`: Cboe CEUX Europe. European equities (Cboe Netherlands).\n- `CHIX`: Cboe CHIX Europe. European equities (Cboe UK).\n- `ISE`: Euronext Dublin. Irish equities.\n- `LSE`: London Stock Exchange. UK equities.\n- `MTA`: Euronext Milan. Italian equities.\n- `MTAA`: Euronext Milan. Italian equities.\n- `XAMS`: Euronext Amsterdam. Dutch equities.\n- `XBRU`: Euronext Brussels. Belgian equities.\n- `XDUB`: Euronext Dublin. Irish equities.\n- `XETR`: Frankfurt Stock Exchange. German equities.\n- `XETRA`: Frankfurt Stock Exchange. German equities.\n- `XLIS`: Euronext Lisbon. Portuguese equities.\n- `XLON`: London Stock Exchange. UK equities.\n- `XPAR`: Euronext Paris. French equities.\n\n**Asia & Middle East**\n- `HKEX`: Hong Kong Stock Exchange. Hong Kong equities.\n- `JPX`: Japan Exchange Group. Japanese equities.\n- `TADAWUL`: Saudi Stock Exchange. Saudi equities.\n- `XHKG`: Hong Kong Stock Exchange. Hong Kong equities.\n- `XSAU`: Saudi Stock Exchange. Saudi equities.\n- `XTKS`: Japan Exchange Group. Japanese equities.\n", + "example": "NYSE,LSE", + "in": "query", + "name": "markets", + "schema": { + "type": "string" + } + }, + "start": { + "description": "The first date to retrieve data for (inclusive). Default: today.\n", + "example": "2025-01-01", + "in": "query", + "name": "start", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + "time": { + "description": "Instead of the current time, use this time for the clock.", + "in": "query", + "name": "time", + "required": false, + "schema": { + "format": "date-time", + "type": "string" + } + }, + "timezone": { + "description": "Timezone of the times. Default: the timezone of the market.\n", + "in": "query", + "name": "timezone", + "required": false, + "schema": { + "enum": [ + "UTC" + ], + "type": "string" + } + } + }, + "responses": { + "400": { + "description": "One of the request parameters is invalid. See the returned message for details.\n", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "429": { + "description": "Too many requests. You hit the rate limit. Use the X-RateLimit-... response headers to make sure you're under the rate limit.\n", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "500": { + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on Slack or on the Community Forum.\n" + } + }, + "schemas": { + "AcatcActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonAcatActivityV2" + } + ], + "description": "Automated customer account transfer service (cash)", + "type": "object" + }, + "AcatsActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonAcatActivityV2" + }, + { + "properties": { + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Automated customer account transfer service (stock)", + "type": "object" + }, + "Account": { + "description": "The account API serves important information related to an account, including account status, funds available for trade, funds available for withdrawal, and various flags relevant to an account's ability to trade. An account maybe be blocked for just for trades (trades_blocked flag) or for both trades and transfers (account_blocked flag) if Alpaca identifies the account to engaging in any suspicious activity. Please note that cryptocurrencies are not eligible assets to be used as collateral for margin accounts and will require the asset be traded using cash only.\n", + "examples": [ + { + "account_blocked": false, + "account_number": "010203ABCD", + "balance_asof": "2023-09-27", + "buying_power": "262113.632", + "cash": "-23140.2", + "created_at": "2019-06-12T22:47:07.99658Z", + "currency": "USD", + "equity": "103820.56", + "id": "e6fe16f3-64a4-4921-8928-cadf02f92f98", + "initial_margin": "63480.38", + "intraday_adjustments": "0", + "last_equity": "103529.24", + "last_maintenance_margin": "38000.832", + "long_market_value": "126960.76", + "maintenance_margin": "38088.228", + "multiplier": "4", + "options_approved_level": 2, + "options_buying_power": "40340.18", + "options_trading_level": 1, + "pending_reg_taf_fees": "0", + "portfolio_value": "103820.56", + "regt_buying_power": "80680.36", + "short_market_value": "0", + "shorting_enabled": true, + "sma": "0", + "status": "ACTIVE", + "trade_suspended_by_user": false, + "trading_blocked": false, + "transfers_blocked": false + } + ], + "properties": { + "account_blocked": { + "description": "If true, the account activity by user is prohibited.", + "type": "boolean" + }, + "account_number": { + "description": "Account number.", + "type": "string" + }, + "accrued_fees": { + "description": "The fees collected.", + "type": "string" + }, + "balance_asof": { + "description": "The date of the snapshot for `last_*` fields", + "example": "2021-04-01", + "type": "string" + }, + "buying_power": { + "description": "Current available $ buying power; If multiplier = 4, this is your daytrade buying power which is calculated as (last_equity - (last) maintenance_margin) * 4; If multiplier = 2, buying_power = max(equity - initial_margin,0) * 2; If multiplier = 1, buying_power = cash", + "type": "string" + }, + "cash": { + "description": "Cash Balance\n", + "type": "string" + }, + "created_at": { + "description": "Timestamp this account was created at\n", + "format": "date-time", + "type": "string" + }, + "crypto_status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "currency": { + "description": "USD\n", + "example": "USD", + "type": "string" + }, + "equity": { + "description": "Cash + long_market_value + short_market_value", + "type": "string" + }, + "id": { + "description": "Account Id.\n", + "format": "uuid", + "type": "string" + }, + "initial_margin": { + "description": "Reg T initial margin requirement (continuously updated value)", + "type": "string" + }, + "intraday_adjustments": { + "description": "The intraday adjustment by non_trade_activities such as fund deposit/withdraw.\n", + "example": "0", + "type": "string" + }, + "last_equity": { + "description": "Equity as of previous trading day at 16:00:00 ET", + "type": "string" + }, + "last_maintenance_margin": { + "description": "Your maintenance margin requirement on the previous trading day", + "type": "string" + }, + "long_market_value": { + "description": "Real-time MtM value of all long positions held in the account\n", + "type": "string" + }, + "maintenance_margin": { + "description": "Maintenance margin requirement (continuously updated value)", + "type": "string" + }, + "multiplier": { + "description": "Buying power multiplier that represents account margin classification; valid values 1 (standard limited margin account with 1x buying power), 2 (reg T margin account with 2x intraday and overnight buying power; this is the default for all non-PDT accounts with $2,000 or more equity), 4 (PDT account with 4x intraday buying power and 2x reg T overnight buying power)", + "type": "string" + }, + "non_marginable_buying_power": { + "description": "Current available non-margin dollar buying power", + "type": "string" + }, + "options_approved_level": { + "description": "The options trading level that was approved for this account.\n0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.\n", + "enum": [ + 0, + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + }, + "options_buying_power": { + "description": "Your buying power for options trading\n", + "type": "string" + }, + "options_trading_level": { + "description": "The effective options trading level of the account.\nThis is the minimum between account options_approved_level and account configurations max_options_trading_level.\n0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.\n", + "enum": [ + 0, + 1, + 2, + 3 + ], + "example": 3, + "type": "integer" + }, + "pending_reg_taf_fees": { + "description": "Pending regulatory fees for the account.\n", + "type": "string" + }, + "pending_transfer_in": { + "description": "Cash pending transfer in.", + "type": "string" + }, + "pending_transfer_out": { + "description": "Cash pending transfer out.", + "type": "string" + }, + "portfolio_value": { + "description": "Total value of cash + holding positions (This field is deprecated. It is equivalent to the equity field.)", + "type": "string" + }, + "regt_buying_power": { + "description": "Your buying power under Regulation T (your excess equity - equity minus margin value - times your margin multiplier)\n", + "type": "string" + }, + "short_market_value": { + "description": "Real-time MtM value of all short positions held in the account", + "type": "string" + }, + "shorting_enabled": { + "description": "Flag to denote whether or not the account is permitted to short", + "type": "boolean" + }, + "sma": { + "description": "Value of special memorandum account (will be used at a later date to provide additional buying_power)", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/AccountStatus" + }, + "trade_suspended_by_user": { + "description": "User setting. If true, the account is not allowed to place orders.", + "type": "boolean" + }, + "trading_blocked": { + "description": "If true, the account is not allowed to place orders.\n", + "type": "boolean" + }, + "transfers_blocked": { + "description": "If true, the account is not allowed to request money transfers.", + "type": "boolean" + } + }, + "required": [ + "id", + "status" + ], + "title": "Account", + "type": "object" + }, + "AccountConfigurations": { + "description": "The account configuration API provides custom configurations about your trading account settings. These configurations control various allow you to modify settings to suit your trading needs.", + "examples": [ + { + "disable_overnight_trading": false, + "fractional_trading": true, + "max_margin_multiplier": "4", + "no_shorting": false, + "suspend_trade": false, + "trade_confirm_email": "all" + } + ], + "properties": { + "disable_overnight_trading": { + "description": "If true, overnight trading is disabled.", + "type": "boolean" + }, + "fractional_trading": { + "description": "If true, account is able to participate in fractional trading", + "type": "boolean" + }, + "max_margin_multiplier": { + "description": "Can be \"1\", \"2\", or \"4\"", + "type": "string" + }, + "max_options_trading_level": { + "description": "The desired maximum options trading level. 0=disabled, 1=Covered Call/Cash-Secured Put, 2=Long Call/Put, 3=Spreads/Straddles.", + "enum": [ + 0, + 1, + 2, + 3 + ], + "type": "integer" + }, + "no_shorting": { + "description": "If true, account becomes long-only mode.", + "type": "boolean" + }, + "ptp_no_exception_entry": { + "description": "If set to true then Alpaca will accept orders for PTP symbols with no exception. Default is false.", + "type": "boolean" + }, + "suspend_trade": { + "description": "If true, new orders are blocked.", + "type": "boolean" + }, + "trade_confirm_email": { + "description": "all or none. If none, emails for order fills are not sent.", + "type": "string" + } + }, + "title": "AccountConfigurations", + "type": "object" + }, + "AccountStatus": { + "description": "An enum representing the various possible account status values.\n\nMost likely, the account status is ACTIVE unless there is any problem. The account status may get in ACCOUNT_UPDATED when personal information is being updated from the dashboard, in which case you may not be allowed trading for a short period of time until the change is approved.\n\n- ONBOARDING\n The account is onboarding.\n- SUBMISSION_FAILED\n The account application submission failed for some reason.\n- SUBMITTED\n The account application has been submitted for review.\n- ACCOUNT_UPDATED\n The account information is being updated.\n- APPROVAL_PENDING\n The final account approval is pending.\n- ACTIVE\n The account is active for trading.\n- REJECTED\n The account application has been rejected.", + "enum": [ + "INACTIVE", + "PAPER_ONLY", + "ONBOARDING", + "SUBMISSION_FAILED", + "SUBMITTED", + "ACCOUNT_UPDATED", + "APPROVAL_PENDING", + "ACTIVE", + "REJECTED", + "ACCOUNT_CLOSED", + "APPROVED", + "ACCOUNT_CLOSED_PENDING", + "ACTION_REQUIRED", + "LIMITED" + ], + "example": "ACTIVE", + "examples": [ + "ACTIVE" + ], + "title": "AccountStatus", + "type": "string" + }, + "ActivityEventV2": { + "allOf": [ + { + "$ref": "#/components/schemas/ActivityEventV2CommonFields" + }, + { + "properties": { + "details": { + "oneOf": [ + { + "$ref": "#/components/schemas/ActivityV2DetailTRD" + }, + { + "$ref": "#/components/schemas/ActivityV2DetailNTA" + } + ] + } + }, + "required": [ + "details" + ], + "type": "object" + } + ], + "description": "Represents an account activity, sent over the Event Streaming API.", + "title": "ActivityEventV2", + "type": "object" + }, + "ActivityEventV2CommonFields": { + "description": "Represents the common fields for all Activity V2 Events", + "properties": { + "activity_subtype": { + "description": "Sub category for activity type, if any", + "type": "string" + }, + "activity_type": { + "description": "The type of the activity, which can be trade or any of the non trade activities", + "type": "string" + }, + "at": { + "description": "Timestamp of event", + "format": "date-time", + "minLength": 1, + "type": "string" + }, + "currency": { + "description": "Currency code in ISO format", + "type": "string" + }, + "event_id": { + "description": "Lexically sortable, monotonically increasing character string", + "format": "ulid", + "type": "string" + }, + "executed_at": { + "description": "Execution time for the activity event", + "format": "date-time", + "minLength": 1, + "type": "string" + }, + "net_amount": { + "description": "The net amount of money (positive or negative) associated with the activity", + "format": "decimal", + "type": "string" + }, + "previous_id": { + "description": "Previous ID is presented if this activity corrects or cancels a previous trade or non trade activity. It contains execution_id or trns_id respectively", + "format": "uuid", + "type": "string" + }, + "price": { + "description": "The price of the security involved with the activity", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "The quantity of the security involved with the activity", + "format": "decimal", + "type": "string" + }, + "ref_id": { + "description": "The unique identifier for the activity. For trades, the execution_id is used, for other activities the trns_id is used.", + "format": "uuid", + "type": "string" + }, + "settle_date": { + "description": "Date when the activity settled", + "format": "date", + "minLength": 1, + "type": "string" + }, + "status": { + "description": "Status of the activity", + "type": "string" + }, + "swap_fee_bps": { + "description": "Currency conversion fee rate base-point in case of local currency activity", + "format": "decimal", + "type": "string" + }, + "swap_rate": { + "description": "Conversion rate for local currency activities", + "format": "decimal", + "type": "string" + } + }, + "required": [ + "at", + "event_id", + "activity_type", + "executed_at", + "status", + "settle_date", + "currency", + "ref_id" + ], + "type": "object" + }, + "ActivitySubType": { + "description": "Represents a more specific classification to the `activity_type`.\nThis field is optional and may not always be populated, depending on the activity type and the available data.\nEach `activity_type` has a set of valid `activity_sub_type` values.\n\nFull mapping of `activity_type` to `activity_sub_type`:\n\n- **CGD**: Capital Gains Distribution activity sub-types:\n - **LTCG**: Long-Term Capital Gain\n - **STCG**: Short-Term Capital Gain\n\n- **DIV**: Dividend activity sub-types:\n - **CDIV**: Cash Dividend\n - **ROC**: Return of Capital\n - **SDIV**: Stock Dividend\n - **SPD**: Substitute Payment In Lieu Of Dividend\n\n- **FEE**: Fee-related activity sub-types:\n - **REG**: Regulatory Fee\n - **TAF**: Trading Activity Fee\n - **LCT**: Local Currency Trading Fee\n - **ORF**: Options Regulatory Fee\n - **OCC**: Options Clearing Corporation Fee\n - **NRC**: Non-Retail Commission Fee\n - **NRV**: Non-Retail Venue Fee\n - **COM**: Commission\n - **CAT**: Consolidated Audit Trail Fee\n\n- **INT**: Interest-related activity sub-types:\n - **MGN**: Margin Interest\n - **CDT**: Credit Interest\n - **SWP**: Sweep Interest\n - **QII**: Qualified Interest\n - **FI**: Fixed Income Interest (coupon or accrued)\n\n- **MA**: Merger and Acquisition activity sub-types:\n - **CMA**: Cash Merger\n - **SMA**: Stock Merger\n - **SCMA**: Stock & Cash Merger\n\n- **NC**: Name Change activity sub types\n - **SNC**: Symbol Name Change\n - **CNC**: CUSIP Name Change\n - **SCNC**: Symbol & CUSIP Name Change\n\n- **OPCA**: Option Corporate Action activity sub-types:\n - **DIV.CDIV**: Cash Dividend\n - **DIV.ROC**: Return of Capital\n - **DIV.SDIV**: Stock Dividend\n - **MA.CMA**: Cash Merger\n - **MA.SMA**: Stock Merger\n - **MA.SCMA**: Stock & Cash Merger\n - **NC.CNC**: CUSIP Name Change\n - **NC.SNC**: Symbol Name Change\n - **NC.SCNC**: Symbol & CUSIP Name Change\n - **SPIN**: Spin-off\n - **SPLIT.FSPLIT**: Forward Stock Split\n - **SPLIT.RSPLIT**: Reverse Stock Split\n - **SPLIT.USPLIT**: Unit Split\n\n- **REO**: Reorganization activity sub-types\n - **REOS**: Stock only (1 or more stock legs)\n - **REOC**: Cash only (1 cash leg)\n - **REOSC**: Stock and cash\n\n- **REORG**: Activity sub-types:\n - **WRM**: Worthless Removal\n\n- **SPLIT**: Stock Split activity sub-types:\n - **FSPLIT**: Forward Stock Split\n - **RSPLIT**: Reverse Stock Split\n - **USPLIT**: Unit Split\n\n- **VOF**: Voluntary Offering activity sub-types:\n - **VTND**: Tender Offer\n - **VWRT**: Warrant Exercise\n - **VRGT**: Rights Offer\n - **VEXH**: Exchange Offer\n\n- **WH**: Withholding activity sub-types:\n - **SWH**: State Withholding\n - **FWH**: Federal Withholding\n - **SLWH**: Sales Withholding", + "title": "ActivitySubType", + "type": "string" + }, + "ActivityType": { + "description": "- FILL\n Order fills (both partial and full fills)\n\n- TRANS\n Cash transactions (both CSD and CSW)\n\n- MISC\n Miscellaneous or rarely used activity types (All types except those in TRANS, DIV, or FILL)\n\n- ACATC\n ACATS IN/OUT (Cash)\n\n- ACATS\n ACATS IN/OUT (Securities)\n\n- CFEE\n Crypto fee\n\n- CGD\n Capital gains distribution\n\n- CSD\n Cash deposit(+)\n\n- CSW\n Cash withdrawal(-)\n\n- DIV\n Dividends\n\n- DIVCGL\n Dividend (capital gains long term)\n\n- DIVCGS\n Dividend (capital gains short term)\n\n- DIVFEE\n Dividend fee\n\n- DIVFT\n Dividend adjusted (Foreign Tax Withheld)\n\n- DIVNRA\n Dividend adjusted (NRA Withheld)\n\n- DIVROC\n Dividend return of capital\n\n- DIVTW\n Dividend adjusted (Tefra Withheld)\n\n- DIVTXEX\n Dividend (tax exempt)\n\n- FEE\n Fee denominated in USD\n\n- INT\n Interest (credit/margin)\n\n- INTNRA\n Interest adjusted (NRA Withheld)\n\n- INTTW\n Interest adjusted (Tefra Withheld)\n\n- JNL\n Journal entry\n\n- JNLC\n Journal entry (cash)\n\n- JNLS\n Journal entry (stock)\n\n- MA\n Merger/Acquisition\n\n- NC\n Name change\n\n- OPASN\n Option assignment\n\n- OPCA\n Option corporate action\n\n- OPCSH\n Option cash deliverable for non-standard contracts\n\n- OPEXC\n Option exercise\n\n- OPEXP\n Option expiration\n\n- OPTRD\n Option trade\n\n- PTC\n Pass Thru Charge\n\n- PTR\n Pass Thru Rebate\n\n- REO\n Reorganization\n\n- REORG\n Worthless removal CA\n\n- SPIN\n Stock spinoff\n\n- SPLIT\n Stock split\n\n- FOPT\n Free of Payment Transfers\n\n- OCT\n On chain transactions (blockchain deposits/withdrawals)", + "enum": [ + "FILL", + "TRANS", + "MISC", + "ACATC", + "ACATS", + "CFEE", + "CGD", + "CSD", + "CSW", + "DIV", + "DIVCGL", + "DIVCGS", + "DIVFEE", + "DIVFT", + "DIVNRA", + "DIVROC", + "DIVTW", + "DIVTXEX", + "FEE", + "INT", + "INTNRA", + "INTTW", + "JNL", + "JNLC", + "JNLS", + "MA", + "NC", + "OPASN", + "OPCA", + "OPCSH", + "OPEXC", + "OPEXP", + "OPTRD", + "PTC", + "PTR", + "REO", + "REORG", + "SPIN", + "SPLIT", + "FOPT", + "OCT" + ], + "examples": [ + "FILL" + ], + "title": "ActivityType", + "type": "string" + }, + "ActivityV2DetailNTA": { + "oneOf": [ + { + "$ref": "#/components/schemas/DIVSPDActivityV2" + }, + { + "$ref": "#/components/schemas/CDIVActivityV2" + }, + { + "$ref": "#/components/schemas/SDIVActivityV2" + }, + { + "$ref": "#/components/schemas/CGDActivityV2" + }, + { + "$ref": "#/components/schemas/ForwardSplitActivityV2" + }, + { + "$ref": "#/components/schemas/ReverseSplitActivityV2" + }, + { + "$ref": "#/components/schemas/UnitSplitActivityV2" + }, + { + "$ref": "#/components/schemas/SpinoffActivityV2" + }, + { + "$ref": "#/components/schemas/MAActivityV2" + }, + { + "$ref": "#/components/schemas/NCActivityV2" + }, + { + "$ref": "#/components/schemas/FixedIncomeRedemptionActivityV2" + }, + { + "$ref": "#/components/schemas/FixedIncomeInterestActivityV2" + }, + { + "$ref": "#/components/schemas/REOActivityV2" + }, + { + "$ref": "#/components/schemas/RightsDistributionActivityV2" + }, + { + "$ref": "#/components/schemas/RightsSubscriptionElectionActivityV2" + }, + { + "$ref": "#/components/schemas/TenderOfferActivityV2" + }, + { + "$ref": "#/components/schemas/ExchangeOfferActivityV2" + }, + { + "$ref": "#/components/schemas/WarrantExerciseElectionActivityV2" + }, + { + "$ref": "#/components/schemas/WRMActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaCDIVActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaSDIVActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaMAActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaNCActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaSPINActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaFSPLITActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaUSPLITActivityV2" + }, + { + "$ref": "#/components/schemas/OpcaRSPLITActivityV2" + }, + { + "$ref": "#/components/schemas/OPASNActivityV2" + }, + { + "$ref": "#/components/schemas/OPEXCActivityV2" + }, + { + "$ref": "#/components/schemas/OPEXPActivityV2" + }, + { + "$ref": "#/components/schemas/OPTRDActivityV2" + }, + { + "$ref": "#/components/schemas/OPCSHActivityV2" + }, + { + "$ref": "#/components/schemas/AcatsActivityV2" + }, + { + "$ref": "#/components/schemas/AcatcActivityV2" + }, + { + "$ref": "#/components/schemas/FOPTActivityV2" + }, + { + "$ref": "#/components/schemas/DIVNRAActivityV2" + }, + { + "$ref": "#/components/schemas/DIVWHActivityV2" + }, + { + "$ref": "#/components/schemas/JNLSActivityV2" + }, + { + "$ref": "#/components/schemas/JNLCActivityV2" + }, + { + "$ref": "#/components/schemas/CSWActivityV2" + }, + { + "$ref": "#/components/schemas/FEEActivityV2" + }, + { + "$ref": "#/components/schemas/MEMActivityV2" + }, + { + "$ref": "#/components/schemas/OCTActivityV2" + } + ], + "type": "object" + }, + "ActivityV2DetailTRD": { + "description": "Activity details for a fill or partial_fill event", + "properties": { + "asset_id": { + "description": "Asset ID (For options this represents the option contract ID)", + "format": "uuid", + "type": "string" + }, + "client_order_id": { + "description": "Order ID provided by the customer", + "type": "string" + }, + "commission": { + "description": "Commission to collect from the account holder", + "format": "decimal", + "type": "string" + }, + "cum_qty": { + "description": "Total filled quantity on the order", + "format": "decimal", + "type": "string" + }, + "cusip": { + "description": "CUSIP of the security involved with the activity", + "type": "string" + }, + "execution_type": { + "description": "The execution type", + "enum": [ + "fill", + "trade_correct", + "trade_bust" + ], + "type": "string" + }, + "leaves_qty": { + "description": "Unfilled quantity on the order, when order is filled value could be 0", + "format": "decimal", + "type": "string" + }, + "order_id": { + "description": "Order ID generated by Alpaca", + "format": "uuid", + "type": "string" + }, + "order_status": { + "description": "Identifies the current status of the order", + "type": "string" + }, + "side": { + "description": "Represents what side of the transaction an order was on", + "enum": [ + "buy", + "sell" + ], + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "order_id", + "side", + "symbol", + "asset_id", + "leaves_qty", + "cum_qty", + "order_status", + "execution_type" + ], + "type": "object" + }, + "AddAssetToWatchlistRequest": { + "description": "Request format used for appending an asset to an existing watchlist.", + "properties": { + "symbol": { + "description": "the symbol name to add to the watchlist", + "example": "AAPL", + "type": "string" + } + }, + "title": "AddAssetToWatchlistRequest", + "type": "object" + }, + "AdvancedInstructions": { + "description": "Advanced instructions for Elite Smart Router: https://docs.alpaca.markets/docs/alpaca-elite-smart-router", + "examples": [ + { + "algorithm": "DMA", + "destination": "NYSE", + "display_qty": "100" + }, + { + "algorithm": "TWAP", + "end_time": "2025-07-21T15:30:00-04:00", + "max_percentage": "0.314", + "start_time": "2025-07-21T09:30:00-04:00" + }, + { + "algorithm": "VWAP", + "end_time": "2025-07-21T15:30:00-04:00", + "max_percentage": "0.314", + "start_time": "2025-07-21T09:30:00-04:00" + } + ], + "properties": { + "algorithm": { + "description": "The advanced routing algorithm to use for the order", + "enum": [ + "DMA", + "TWAP", + "VWAP" + ], + "example": "DMA", + "type": "string" + }, + "destination": { + "description": "Target exchange for order execution", + "enum": [ + "NYSE", + "NASDAQ", + "ARCA", + "IEX", + "MEMX" + ], + "example": "NYSE", + "type": "string" + }, + "display_qty": { + "description": "Maximum shares/contracts displayed on the exchange at any time. Must be in round lot increments", + "example": "100", + "format": "decimal", + "type": "string" + }, + "end_time": { + "description": "When the algorithm is to be done executing. Must be within current market trading hours", + "example": "2025-07-21T15:30:00-04:00", + "format": "date-time", + "type": "string" + }, + "max_percentage": { + "description": "Maximum percentage of the ticker's period volume this order might participate in. Must be 0 < max_percentage < 1, with up to 3 decimal points precision.", + "example": "0.314", + "format": "decimal", + "type": "string" + }, + "start_time": { + "description": "When the algorithm is to start executing. Must be within current market trading hours", + "example": "2025-07-21T09:30:00-04:00", + "format": "date-time", + "type": "string" + } + }, + "title": "AdvancedInstructions", + "type": "object" + }, + "AssetAttribute": { + "description": "Unique characteristic of an asset. Supported values:\n- `ptp_no_exception`: Asset is a Publicly Traded Partnership (PTP) without a qualified notice; non-U.S. customers may incur 10% withholding on gross proceeds as per IRS guidance, and are blocked from being purchased by default.\n- `ptp_with_exception`: Users can open positions in these PTPs without general restrictions.\n- `ipo`: Accepting limit orders only before the stock begins trading on the secondary market.\n- `has_options`: The underlying equity has listed options available on the platform. Note: if the equity had inactive/expired contracts in the past, this will still show up.\n- `options_late_close`: Indicates the underlying asset's options contracts close at 4:15pm ET instead of the standard 4:00pm ET.\n- `fractional_eh_enabled`: Indicates the asset accepts fractional orders during extended hours sessions (pre-market, post-market, and overnight if enabled).\n- `overnight_tradable`: Asset is eligible for overnight (24x5) trading in supported venues on the platform.\n- `overnight_halted`: Asset is eligible for overnight trading but is currently halted/blocked for overnight sessions due to risk, corporate action, compliance, or venue constraints.", + "enum": [ + "ptp_no_exception", + "ptp_with_exception", + "ipo", + "has_options", + "options_late_close", + "fractional_eh_enabled", + "overnight_tradable", + "overnight_halted" + ], + "example": "ptp_no_exception", + "type": "string" + }, + "AssetClass": { + "description": "This represents the category to which the asset belongs to. It serves to identify the nature of the financial instrument, with options including \"us_equity\" for U.S. equities, \"us_option\" for U.S. options, \"crypto\" for cryptocurrencies, and \"ipo\" for IPO indications of interest/orders. This `asset_class: ipo` value is distinct from the assets API `attributes: [\"ipo\"]` flag.", + "enum": [ + "us_equity", + "us_option", + "crypto", + "crypto_perp", + "treasury", + "corporate", + "global_equity", + "us_index", + "us_equity_chain", + "ipo" + ], + "example": "us_equity", + "examples": [ + "us_equity" + ], + "title": "AssetClass", + "type": "string" + }, + "Assets": { + "description": "The assets API serves as the master list of assets available for trade and data consumption from Alpaca. Assets are sorted by asset class, exchange and symbol. Some assets are only available for data consumption via Polygon, and are not tradable with Alpaca. These assets will be marked with the flag tradable=false.\n", + "examples": [ + { + "borrow_status": "easy_to_borrow", + "class": "us_equity", + "easy_to_borrow": true, + "exchange": "NASDAQ", + "fractionable": true, + "id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "marginable": true, + "name": "Apple Inc. Common Stock", + "shortable": true, + "status": "active", + "symbol": "AAPL", + "tradable": true + } + ], + "properties": { + "attributes": { + "example": [ + "ptp_no_exception", + "ipo" + ], + "items": { + "$ref": "#/components/schemas/AssetAttribute" + }, + "type": "array" + }, + "borrow_status": { + "description": "Borrow status for US equity assets. This field is omitted for non-US-equity assets.", + "enum": [ + "easy_to_borrow", + "hard_to_borrow" + ], + "example": "easy_to_borrow", + "type": "string" + }, + "class": { + "$ref": "#/components/schemas/AssetClass" + }, + "cusip": { + "description": "The CUSIP identifier for the asset (US Equities only).\nTo request a specific CUSIP, please reach out to Alpaca support.\n", + "example": "987654321", + "type": [ + "string", + "null" + ] + }, + "exchange": { + "$ref": "#/components/schemas/Exchange" + }, + "fractionable": { + "description": "Asset is fractionable or not", + "type": "boolean" + }, + "id": { + "description": "Asset ID", + "format": "uuid", + "type": "string" + }, + "maintenance_margin_requirement": { + "deprecated": true, + "description": "**deprecated**: Please use margin_requirement_long or margin_requirement_short instead. Note that these fields are of type string.\nShows the margin requirement percentage for the asset (equities only).\n", + "type": "number" + }, + "margin_requirement_long": { + "description": "The margin requirement percentage for the asset's long positions (equities only), encoded as a decimal string.", + "example": "100", + "format": "decimal", + "type": "string" + }, + "margin_requirement_short": { + "description": "The margin requirement percentage for the asset's short positions (equities only), encoded as a decimal string.", + "example": "30", + "format": "decimal", + "type": "string" + }, + "marginable": { + "description": "Asset is marginable or not", + "type": "boolean" + }, + "min_order_size": { + "description": "Minimum order size. Field available for crypto only.", + "format": "decimal", + "type": "string" + }, + "min_trade_increment": { + "description": "Amount a trade quantity can be incremented by. Field available for crypto only.", + "format": "decimal", + "type": "string" + }, + "name": { + "description": "The official name of the asset", + "minLength": 1, + "type": "string" + }, + "price_increment": { + "description": "Amount the price can be incremented by. Field available for crypto only.", + "format": "decimal", + "type": "string" + }, + "shortable": { + "description": "Asset is shortable or not", + "type": "boolean" + }, + "status": { + "description": "active or inactive", + "enum": [ + "active", + "inactive" + ], + "example": "active", + "type": "string" + }, + "symbol": { + "description": "The symbol of the asset", + "example": "AAPL", + "type": "string" + }, + "tradable": { + "description": "Asset is tradable on Alpaca or not", + "type": "boolean" + } + }, + "required": [ + "id", + "class", + "exchange", + "symbol", + "name", + "status", + "tradable", + "marginable", + "shortable", + "fractionable" + ], + "title": "Assets", + "type": "object" + }, + "CDIVActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonCDIVActivityV2" + }, + { + "properties": { + "cash_payout": { + "description": "Total cash amount paid", + "type": "string" + }, + "entitled_qty": { + "description": "Quantity of shares entitled to receive the dividend or return of capital", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "cash_payout" + ], + "type": "object" + } + ], + "description": "Cash-dividend related details. Used for both Cash Dividend and Return of Capital.", + "type": "object" + }, + "CGDActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "cash_payout": { + "description": "Cash amount paid for this leg", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "entitled_qty": { + "description": "Quantity of shares entitled to receive the capital gains distribution", + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "long_term_rate": { + "description": "Long-term capital gains distribution rate per share, when applicable", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "Distribution rate per share for this leg (LTCG or STCG)", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "short_term_rate": { + "description": "Short-term capital gains distribution rate per share, when applicable", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "cash_payout", + "symbol", + "cusip", + "rate" + ], + "type": "object" + } + ], + "description": "Capital gains distribution. Used for both Long-Term (LTCG) and Short-Term (STCG) sub-types. Each activity represents a single leg; `long_term_rate` and/or `short_term_rate` are populated based on the source event, and `rate` matches the leg's own rate.", + "type": "object" + }, + "CSWActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "bank_transaction_id": { + "description": "The bank transaction's ID", + "format": "uuid", + "type": "string" + } + }, + "type": "object" + } + ], + "description": "Cash withdrawal", + "type": "object" + }, + "CanceledOrderResponse": { + "description": "Represents the result of a request to cancel and order", + "examples": [ + { + "id": "d56ba3ea-6d04-48ce-8175-817e242ee608", + "status": 200 + } + ], + "properties": { + "id": { + "description": "orderId", + "format": "uuid", + "type": "string" + }, + "status": { + "description": "http response code", + "example": 200, + "type": "integer" + } + }, + "title": "CanceledOrderResponse", + "type": "object" + }, + "CommonAcatActivityV2": { + "properties": { + "external_id": { + "description": "The ID that DTCC assigned to this transfer", + "type": "string" + }, + "hold_date": { + "description": "Hold date when the transfers settle", + "format": "date", + "minLength": 1, + "type": "string" + }, + "request_id": { + "description": "The ID for original ACATS request", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "external_id", + "request_id" + ], + "type": "object" + }, + "CommonCDIVActivityV2": { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "due_bill_off_date": { + "description": "When due bills stop applying for this event", + "format": "date", + "minLength": 1, + "type": "string" + }, + "due_bill_on_date": { + "description": "When due bills begin to apply for this event", + "format": "date", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "foreign": { + "description": "Indicates if related to a non-US security. Serialized as the JSON strings `\"true\"` or `\"false\"`, not a JSON boolean.", + "enum": [ + "true", + "false" + ], + "example": "false", + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "Dividend rate per share", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "special": { + "description": "Indicates if this is a special dividend. Serialized as the JSON strings `\"true\"` or `\"false\"`, not a JSON boolean.", + "enum": [ + "true", + "false" + ], + "example": "false", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "rate", + "foreign", + "special" + ], + "type": "object" + }, + "CommonCaActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "ca_id": { + "description": "The unique identifier for this corporate action", + "format": "uuid", + "type": "string" + }, + "position_date": { + "description": "The position_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "reorg_id": { + "description": "The reorg identifier, if present in the source corporate action definition", + "type": "string" + } + }, + "required": [ + "position_date" + ], + "type": "object" + } + ], + "type": "object" + }, + "CommonFixedIncomeInterestActivityV2": { + "description": "Fixed income interest fields (INT/FI). Variants from the same activity type:\n\n- Coupon: `interest_type` is `coupon`. Includes `rate` (no `price` / `accrued_interest_rate`). No `order_id`.\n- Accrued interest on call: `interest_type` is `accrued`. Includes `price` and `accrued_interest_rate` (no `rate`). No `order_id`.\n- Trade accrued: `interest_type` is `accrued`. Includes `order_id` so the interest NTA can be linked to the fill. `parent_id` is set when a parent trade `ref_id` is available.", + "properties": { + "accrued_interest_rate": { + "description": "Accrued interest rate (present for accrued-interest-on-call variants)", + "format": "decimal", + "type": "string" + }, + "cash_payout": { + "description": "The cash payout for this interest activity", + "format": "decimal", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "entitled_qty": { + "description": "The entitled quantity (principal / face amount)", + "example": "1000", + "type": "string" + }, + "interest_type": { + "$ref": "#/components/schemas/FixedIncomeInterestType" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "order_id": { + "description": "The order that generated this accrued interest. Present for trade-accrued INT/FI.", + "example": "257bf308-a6b7-4777-8cf6-00dc441dc4d3", + "format": "uuid", + "type": "string" + }, + "parent_id": { + "description": "The ref_id of the parent trade this interest is attached to. Present for trade-accrued INT/FI when a parent trade `ref_id` is available.", + "example": "46aecae1-4629-4bcf-b441-0d8c847a1787", + "format": "uuid", + "type": "string" + }, + "payment_date": { + "description": "The payment date", + "format": "date", + "type": "string" + }, + "price": { + "description": "Call price used for accrued-interest-on-call variants", + "format": "decimal", + "type": "string" + }, + "rate": { + "description": "Coupon rate amount (present for regular coupon payments)", + "format": "decimal", + "type": "string" + }, + "record_date": { + "description": "The record date", + "format": "date", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "cash_payout", + "cusip", + "interest_type" + ], + "type": "object" + }, + "CommonJournalActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "journal_id": { + "description": "The journal's ID", + "format": "uuid", + "type": "string" + } + }, + "type": "object" + } + ], + "description": "Shared fields for journal non-trade activity records.", + "type": "object" + }, + "CommonMAActivityV2": { + "properties": { + "acquiree_cusip": { + "description": "CUSIP of the acquiree", + "type": "string" + }, + "acquiree_isin": { + "description": "ISIN of the acquiree", + "type": "string" + }, + "acquiree_rate": { + "description": "Rate of the acquiree", + "type": "string" + }, + "acquiree_symbol": { + "description": "Symbol of the acquiree", + "type": "string" + }, + "acquirer_cusip": { + "description": "CUSIP of the acquirer", + "type": "string" + }, + "acquirer_isin": { + "description": "ISIN of the acquirer", + "type": "string" + }, + "acquirer_rate": { + "description": "Rate of the acquirer", + "type": "string" + }, + "acquirer_symbol": { + "description": "Symbol of the acquirer", + "type": "string" + }, + "effective_date": { + "description": "When the merger/acquisition becomes effective", + "format": "date", + "minLength": 1, + "type": "string" + }, + "payable_date": { + "description": "The payable date", + "format": "date", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "acquiree_cusip", + "acquiree_symbol", + "effective_date", + "payable_date" + ], + "type": "object" + }, + "CommonNCActivityV2": { + "properties": { + "new_cusip": { + "description": "New CUSIP for the name change", + "type": "string" + }, + "new_symbol": { + "description": "New symbol for the name change", + "type": "string" + }, + "old_cusip": { + "description": "Old CUSIP for the name change", + "type": "string" + }, + "old_symbol": { + "description": "Old symbol for the name change", + "type": "string" + } + }, + "required": [ + "old_cusip", + "old_symbol", + "new_cusip", + "new_symbol" + ], + "type": "object" + }, + "CommonNTAActivityV2": { + "description": "Shared fields for non-trade (NTA) activity records.", + "properties": { + "group_id": { + "description": "Optional group ID which can help grouping together related activities", + "format": "uuid", + "type": "string" + }, + "system_date": { + "description": "The date when the activity was booked", + "format": "date", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "system_date" + ], + "type": "object" + }, + "CommonOPCAActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "new_contract_symbol": { + "description": "The new contract symbol", + "type": "string" + }, + "new_qty": { + "description": "used when the old contract's quantity is not equal to the new contract's quantity. Mutually exclusive with 'qty'.", + "type": "string" + }, + "old_contract_symbol": { + "description": "The old contract symbol", + "type": "string" + }, + "old_qty": { + "description": "used when the old contract's quantity is not equal to the new contract's quantity. Mutually exclusive with 'qty'.", + "type": "string" + }, + "qty": { + "description": "used when the old contract's quantity is equal to the new contract's quantity. Mutually exclusive with 'old_qty' and 'new_qty'", + "type": "string" + } + }, + "required": [ + "old_contract_symbol", + "new_contract_symbol" + ], + "type": "object" + } + ], + "type": "object" + }, + "CommonOptionsActivityV2": { + "allOf": [ + { + "description": "Shared fields for option-related non-trade activity records.", + "properties": { + "contract_symbol": { + "description": "The contract symbol of the security involved with the activity", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "group_id" + ], + "type": "object" + }, + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + } + ] + }, + "CommonREOActivityV2": { + "description": "Reorganization (REO) activity sub-types:\n- **REOS**: Stock only (1 or more stock legs)\n- **REOC**: Cash only (one cash leg)\n- **REOSC**: Stock and cash", + "properties": { + "cash_payout": { + "description": "Cash payout amount", + "format": "decimal", + "type": "string" + }, + "cash_rate": { + "description": "Cash rate per share", + "format": "decimal", + "type": "string" + }, + "cusip": { + "description": "CUSIP received on this stock leg", + "type": "string" + }, + "effective_date": { + "description": "Effective date of the reorganization", + "format": "date", + "type": "string" + }, + "isin": { + "description": "ISIN received on this stock leg", + "type": "string" + }, + "new_rate": { + "description": "New ratio for this stock leg", + "format": "decimal", + "type": "string" + }, + "payable_date": { + "description": "Payable date of the reorganization", + "format": "date", + "type": "string" + }, + "qty": { + "description": "Quantity received on this stock leg", + "format": "decimal", + "type": "string" + }, + "removed_qty": { + "description": "Positive quantity removed from the source position", + "format": "decimal", + "type": "string" + }, + "source_cusip": { + "description": "CUSIP of the source security", + "type": "string" + }, + "source_isin": { + "description": "ISIN of the source security", + "type": "string" + }, + "source_qty": { + "description": "Source position quantity", + "format": "decimal", + "type": "string" + }, + "source_rate": { + "description": "Source ratio for this stock leg", + "format": "decimal", + "type": "string" + }, + "source_symbol": { + "description": "Symbol of the source security", + "example": "CEPT", + "type": "string" + }, + "symbol": { + "description": "Symbol received on this stock leg", + "example": "SECZ", + "type": "string" + } + }, + "required": [ + "source_symbol", + "source_cusip", + "payable_date" + ], + "type": "object" + }, + "CommonSDIVActivityV2": { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "Dividend rate per share", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol", + "cusip", + "rate" + ], + "type": "object" + }, + "CommonSpinoffActivityV2": { + "properties": { + "due_bill_redemption_date": { + "description": "When due bills related to the spinoff are redeemed", + "format": "date", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_cusip": { + "description": "CUSIP of the new security", + "type": "string" + }, + "new_isin": { + "description": "ISIN of the new security", + "type": "string" + }, + "new_price": { + "description": "Market price of new shares after the spinoff", + "type": "string" + }, + "new_rate": { + "description": "Ratio of new shares received", + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "source_cusip": { + "description": "CUSIP of the parent security", + "type": "string" + }, + "source_isin": { + "description": "ISIN of the parent security", + "type": "string" + }, + "source_price": { + "description": "Market price of parent shares before the spinoff", + "type": "string" + }, + "source_rate": { + "description": "Ratio of parent shares", + "type": "string" + }, + "source_symbol": { + "description": "Symbol of the parent security", + "type": "string" + } + }, + "required": [ + "source_cusip", + "source_symbol", + "source_rate", + "source_price", + "new_cusip", + "new_symbol", + "new_rate", + "new_price" + ], + "type": "object" + }, + "CommonSplitActivityV2": { + "properties": { + "new_cusip": { + "description": "CUSIP of the new security after the split", + "type": "string" + }, + "new_isin": { + "description": "ISIN of the new security after the split", + "type": "string" + }, + "new_rate": { + "description": "Ratio of new shares received", + "type": "string" + }, + "old_cusip": { + "description": "CUSIP of the old security before the split", + "type": "string" + }, + "old_isin": { + "description": "ISIN of the old security before the split", + "type": "string" + }, + "old_rate": { + "description": "Ratio of old shares exchanged", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + } + }, + "required": [ + "old_cusip", + "new_cusip", + "old_rate", + "new_rate" + ], + "type": "object" + }, + "CommonSplitStockActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSplitActivityV2" + }, + { + "properties": { + "new_qty": { + "description": "The new quantity after the split", + "type": "string" + }, + "old_qty": { + "description": "The old quantity before the split", + "type": "string" + } + }, + "required": [ + "old_qty", + "new_qty" + ], + "type": "object" + } + ], + "type": "object" + }, + "CommonVOFSubtypeActivityV2": { + "properties": { + "new_cusip": { + "description": "CUSIP of the new security", + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security", + "type": "string" + }, + "source_cusip": { + "description": "CUSIP of the parent security", + "type": "string" + }, + "source_symbol": { + "description": "Symbol of the parent security", + "type": "string" + } + }, + "required": [ + "source_cusip", + "source_symbol" + ], + "type": "object" + }, + "CorporateActionCaType": { + "description": "The type of corporate action.", + "enum": [ + "Spinoff", + "Merger", + "Split", + "Reorg", + "Dividend" + ], + "example": "Dividend", + "title": "CorporateActionCaType", + "type": "string" + }, + "CorporateAnnouncement": { + "description": "A corporate action announcement.", + "examples": [ + { + "ca_sub_type": "DIV", + "ca_type": "Dividend", + "cash": "0.018", + "corporate_action_id": "F58684224_XY37", + "declaration_date": "2021-01-05", + "effective_date": "2021-01-08", + "ex_date": "2021-01-12", + "id": "be3c368a-4c7c-4384-808e-f02c9f5a8afe", + "initiating_original_cusip": "55275E101", + "initiating_symbol": "MLLAX", + "new_rate": "1", + "old_rate": "1", + "payable_date": "2021-01-14", + "record_date": "2021-01-13", + "target_original_cusip": "55275E101", + "target_symbol": "MLLAX" + } + ], + "properties": { + "ca_sub_type": { + "type": "string" + }, + "ca_type": { + "$ref": "#/components/schemas/CorporateActionCaType" + }, + "cash": { + "format": "decimal", + "type": "string" + }, + "corporate_action_id": { + "type": "string" + }, + "declaration_date": { + "format": "date", + "type": "string" + }, + "effective_date": { + "format": "date", + "type": "string" + }, + "ex_date": { + "format": "date", + "type": "string" + }, + "id": { + "type": "string" + }, + "initiating_original_cusip": { + "type": "string" + }, + "initiating_symbol": { + "type": "string" + }, + "new_rate": { + "format": "decimal", + "type": "string" + }, + "old_rate": { + "format": "decimal", + "type": "string" + }, + "payable_date": { + "format": "date", + "type": "string" + }, + "record_date": { + "format": "date", + "type": "string" + }, + "target_original_cusip": { + "type": "string" + }, + "target_symbol": { + "type": "string" + } + }, + "title": "CorporateAnnouncement", + "type": "object" + }, + "CreateCryptoTransferRequest": { + "properties": { + "address": { + "description": "The destination wallet address", + "type": "string" + }, + "amount": { + "description": "The amount, denoted in the specified asset, to be withdrawn from the user's wallet", + "type": "string" + }, + "asset": { + "description": "The crypto asset symbol, e.g. BTC, ETH, USDT.", + "type": "string" + }, + "chain": { + "$ref": "#/components/schemas/CryptoChain" + } + }, + "required": [ + "amount", + "address", + "asset" + ], + "title": "CreateCryptoTransferRequest", + "type": "object" + }, + "CreateLocateRequest": { + "description": "Request to locate shares for a short sale.", + "example": { + "all_or_none": false, + "limit_price": "0.05", + "qty": 100, + "symbol": "TSLA" + }, + "properties": { + "all_or_none": { + "default": false, + "description": "Reject the locate unless the full requested quantity is available.", + "example": false, + "type": "boolean" + }, + "limit_price": { + "description": "Maximum acceptable locate fee per share, as a decimal string in USD.\nIf omitted, any quoted fee is accepted.\n", + "example": "0.05", + "type": [ + "string", + "null" + ] + }, + "qty": { + "description": "Number of shares to locate. Must be positive and in round lots of 100; invalid quantities return HTTP 400.", + "example": 100, + "format": "int64", + "minimum": 1, + "type": "integer" + }, + "symbol": { + "description": "Stock symbol.", + "example": "TSLA", + "type": "string" + } + }, + "required": [ + "symbol", + "qty" + ], + "type": "object" + }, + "CreateOrderRequest": { + "description": "Represents a request to create an order.", + "properties": { + "advanced_instructions": { + "$ref": "#/components/schemas/AdvancedInstructions" + }, + "client_order_id": { + "description": "A unique identifier for the order. Automatically generated if not sent. (<= 128 characters)", + "example": "5680c4bc-9ac1-4a12-a44c-df427ba53032", + "maxLength": 128, + "type": "string" + }, + "extended_hours": { + "description": "(default) false. If true, order will be eligible for execution in the pre-market, after-hours, and overnight sessions. Only works with type `limit` and time_in_force set to either `day` or `gtc`", + "example": false, + "type": "boolean" + }, + "legs": { + "description": "list of order legs (<= 4)", + "example": [ + { + "position_intent": "buy_to_open", + "ratio_qty": "3", + "side": "buy", + "symbol": "AAPL241213C00250000" + } + ], + "items": { + "$ref": "#/components/schemas/MLegOrderLeg" + }, + "maxItems": 4, + "type": "array" + }, + "limit_price": { + "description": "Required if type is `limit` or `stop_limit`.\nIn case of `mleg`, the limit_price parameter is expressed with the following notation:\n- A positive value indicates a debit, representing a cost or payment to be made.\n- A negative value signifies a credit, reflecting an amount to be received.", + "example": "150", + "type": "string" + }, + "notional": { + "description": "dollar amount to trade. Cannot work with `qty`. Can only work for market order types and day for time in force.", + "example": "500", + "type": "string" + }, + "order_class": { + "$ref": "#/components/schemas/OrderClass" + }, + "position_intent": { + "$ref": "#/components/schemas/PositionIntent" + }, + "qty": { + "description": "number of shares to trade. Can be fractionable for only market and day order types. Required for `mleg` order class, represents the number of units to trade of this strategy.", + "example": "2", + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "stop_loss": { + "description": "Takes in string/number values for stop_price and limit_price", + "properties": { + "limit_price": { + "example": "3.14", + "format": "decimal", + "type": "string" + }, + "stop_price": { + "example": "3.14", + "format": "decimal", + "type": "string" + } + }, + "type": "object" + }, + "stop_price": { + "description": "required if type is `stop` or `stop_limit`", + "example": "140", + "type": "string" + }, + "symbol": { + "description": "symbol, asset ID, or currency pair to identify the asset to trade, required for all order classes except for `mleg`.", + "example": "AAPL", + "type": "string" + }, + "take_profit": { + "description": "Takes in a string/number value for limit_price", + "properties": { + "limit_price": { + "example": "3.14", + "format": "decimal", + "type": "string" + } + }, + "type": "object" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "trail_percent": { + "description": "this or `trail_price` is required if type is `trailing_stop`", + "example": "1.5", + "type": "string" + }, + "trail_price": { + "description": "this or `trail_percent` is required if type is `trailing_stop`", + "example": "1.00", + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/OrderType" + } + }, + "required": [ + "type", + "time_in_force" + ], + "title": "CreateOrderRequest", + "type": "object" + }, + "CreateWatchlistRequest": { + "description": "Request format used for creating a new watchlist with a set of assets and name.", + "properties": { + "name": { + "description": "The watchlist name.", + "example": "Tech Stocks", + "type": "string" + }, + "symbols": { + "description": "List of asset symbols to include in the watchlist.", + "example": [ + "AAPL", + "TSLA" + ], + "items": { + "type": [ + "string", + "null" + ] + }, + "type": "array" + } + }, + "required": [ + "name" + ], + "title": "PostWatchlistRequest", + "type": "object" + }, + "CreateWhitelistedAddressRequest": { + "description": "Request format used for whitelisting a crypto address for transfers.", + "properties": { + "address": { + "description": "The address to be whitelisted", + "example": "5dXY1aH2tQpV3wXmJg6Z7c8B4nKvF9bA1pQrSt2uVwYxXz", + "type": "string" + }, + "asset": { + "description": "Symbol of underlying asset for the whitelisted address", + "example": "USDT", + "type": "string" + }, + "chain": { + "$ref": "#/components/schemas/CryptoChain" + }, + "travel_rule_info": { + "$ref": "#/components/schemas/TravelRuleInfo" + } + }, + "title": "CreateWhitelistedAddressRequest", + "type": "object" + }, + "CryptoChain": { + "description": "Chain identifier for multi-chain crypto assets.", + "enum": [ + "SOL", + "ETH", + "BTC", + "XRP", + "ARB" + ], + "example": "ETH", + "type": "string" + }, + "CryptoTransfer": { + "description": "Transfers allow you to transfer assets into your end customer's account (deposits) or out (withdrawal).", + "properties": { + "amount": { + "description": "Amount of transfer denominated in the underlying crypto asset", + "type": "string" + }, + "asset": { + "description": "Symbol of crypto asset for given transfer (e.g. BTC)", + "type": "string" + }, + "chain": { + "description": "Underlying network for given transfer", + "type": "string" + }, + "created_at": { + "description": "Timestamp when transfer was created", + "format": "date-time", + "type": "string" + }, + "direction": { + "$ref": "#/components/schemas/TransferDirection" + }, + "fees": { + "type": "string" + }, + "from_address": { + "description": "Originating address of the transfer", + "type": "string" + }, + "id": { + "description": "The crypto transfer ID", + "format": "uuid", + "type": "string" + }, + "network_fee": { + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/CryptoTransferStatus" + }, + "to_address": { + "description": "Destination address of the transfer", + "type": "string" + }, + "tx_hash": { + "description": "On-chain transaction hash (e.g. 0xabc...xyz)", + "type": "string" + }, + "usd_value": { + "description": "Equivalent USD value at time of transfer", + "type": "string" + } + }, + "type": "object" + }, + "CryptoTransferStatus": { + "enum": [ + "PROCESSING", + "FAILED", + "COMPLETE" + ], + "example": "PROCESSING", + "type": "string" + }, + "CryptoWallet": { + "properties": { + "address": { + "type": "string" + }, + "chain": { + "type": "string" + }, + "created_at": { + "description": "Timestamp (RFC3339) of account creation.", + "format": "date-time", + "type": "string" + } + }, + "type": "object" + }, + "DIVNRAActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "parent_id": { + "description": "The ref_id of the parent dividend", + "format": "uuid", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + }, + "tax_country": { + "description": "Tax country used as the primary jurisdiction when determining withholding treatment for the dividend. Other factors may affect the final withholding rate.\nThe value is an [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html) country code.\n", + "example": "THA", + "type": "string" + }, + "tax_rate": { + "description": "The tax withholding rate applied to the dividend, represented as a value between 0 and 1", + "example": "0.15", + "format": "decimal", + "type": "string" + } + }, + "required": [ + "cusip", + "symbol", + "parent_id" + ], + "type": "object" + } + ], + "description": "Dividend withholding for non resident aliens", + "type": "object" + }, + "DIVSPDActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "cash_payout": { + "description": "Total cash amount paid", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "due_bill_off_date": { + "description": "When due bills stop applying for this event", + "format": "date", + "minLength": 1, + "type": "string" + }, + "due_bill_on_date": { + "description": "When due bills begin to apply for this event", + "format": "date", + "minLength": 1, + "type": "string" + }, + "entitled_qty": { + "description": "Quantity of shares entitled to receive cash in lieu", + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "foreign": { + "description": "Indicates if related to a non-US security. Serialized as the JSON strings `\"true\"` or `\"false\"`, not a JSON boolean.", + "enum": [ + "true", + "false" + ], + "example": "false", + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "Cash payout per share", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "special": { + "description": "Indicates if this is a special dividend. Serialized as the JSON strings `\"true\"` or `\"false\"`, not a JSON boolean.", + "enum": [ + "true", + "false" + ], + "example": "false", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "cash_payout", + "symbol", + "cusip", + "rate", + "foreign", + "special" + ], + "type": "object" + } + ], + "description": "Substitute payment in lieu of dividend", + "type": "object" + }, + "DIVWHActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "parent_id": { + "description": "The ref_id of the parent dividend", + "format": "uuid", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "cusip", + "symbol", + "parent_id" + ], + "type": "object" + } + ], + "description": "Dividend tax withholding (e.g. foreign withholding on global securities)", + "type": "object" + }, + "Error": { + "properties": { + "code": { + "type": "number" + }, + "message": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ], + "title": "Error", + "type": "object" + }, + "ErrorResponse": { + "description": "API error response.", + "properties": { + "message": { + "example": "Internal Server Error", + "type": "string" + } + }, + "type": "object" + }, + "Exchange": { + "description": "Represents the current exchanges Alpaca supports. List is currently:\n\n- AMEX\n- ARCA\n- BATS\n- NYSE\n- NASDAQ\n- NYSEARCA\n- OTC\n- CRYPTO", + "enum": [ + "AMEX", + "ARCA", + "BATS", + "NYSE", + "NASDAQ", + "NYSEARCA", + "OTC", + "CRYPTO" + ], + "example": "NYSE", + "title": "Exchange", + "type": "string" + }, + "ExchangeForPosition": { + "description": "Represents the current exchanges Alpaca supports. List is currently:\n\n- AMEX\n- ARCA\n- BATS\n- NYSE\n- NASDAQ\n- NYSEARCA\n- OTC\n- CRYPTO\n\nCan be empty if not applicable (e.g., for options contracts)", + "enum": [ + "AMEX", + "ARCA", + "BATS", + "NYSE", + "NASDAQ", + "NYSEARCA", + "OTC", + "CRYPTO", + "" + ], + "example": "NYSE", + "title": "Exchange", + "type": "string" + }, + "ExchangeOfferActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonVOFSubtypeActivityV2" + } + ], + "type": "object" + }, + "FEEActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "parent_id": { + "description": "The parent transaction's ID", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "parent_id" + ], + "type": "object" + } + ], + "description": "Fee", + "type": "object" + }, + "FOPTActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "contra": { + "description": "Contra for the transfer", + "type": "string" + }, + "external_id": { + "description": "External ID of the transfer", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "external_id", + "contra", + "symbol" + ], + "type": "object" + } + ], + "description": "Free-of-payment (FOP) transfers", + "type": "object" + }, + "FixedIncomeInterestActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonFixedIncomeInterestActivityV2" + } + ], + "description": "Fixed income interest (INT/FI)", + "type": "object" + }, + "FixedIncomeInterestType": { + "description": "Distinguishes coupon payments from accrued interest on INT/FI activities.", + "enum": [ + "coupon", + "accrued" + ], + "example": "accrued", + "title": "FixedIncomeInterestType", + "type": "string" + }, + "FixedIncomeRedemptionActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "ca_id": { + "description": "The unique identifier for this corporate action", + "format": "uuid", + "type": "string" + }, + "cash_payout": { + "description": "The cash payout", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "payment_date": { + "description": "The payment date", + "format": "date", + "minLength": 1, + "type": "string" + }, + "qty": { + "description": "Quantity for the redemption", + "type": "string" + } + }, + "required": [ + "ca_id", + "payment_date", + "cusip", + "qty", + "cash_payout" + ], + "type": "object" + } + ], + "description": "Redemption", + "type": "object" + }, + "ForwardSplitActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonSplitStockActivityV2" + }, + { + "properties": { + "due_bill_redemption_date": { + "description": "When due bills related to the split are redeemed", + "format": "date", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security being split", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Forward stock split", + "type": "object" + }, + "JNLCActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonJournalActivityV2" + }, + { + "type": "object" + } + ], + "description": "Journal entry (cash)", + "type": "object" + }, + "JNLSActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonJournalActivityV2" + }, + { + "properties": { + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Journal entry (stock)", + "type": "object" + }, + "ListLocateQuotesResponse": { + "description": "Response to a successful request for locate quotes.", + "example": { + "errors": [ + { + "code": "symbol_not_found", + "message": "symbol not found", + "symbol": "META" + } + ], + "quotes": [ + { + "available_qty": 1000, + "price": "0.0123", + "quoted_at": "2026-01-02T15:04:05Z", + "symbol": "TSLA" + } + ] + }, + "properties": { + "errors": { + "description": "Symbols that could not be quoted.", + "items": { + "$ref": "#/components/schemas/LocateQuoteError" + }, + "type": "array" + }, + "quotes": { + "description": "Locate quotes returned for requested symbols.", + "items": { + "$ref": "#/components/schemas/LocateQuote" + }, + "type": "array" + } + }, + "required": [ + "quotes" + ], + "type": "object" + }, + "ListLocatesResponse": { + "description": "Response to a successful request for a list of locates.", + "example": { + "locates": [ + { + "all_or_none": false, + "created_at": "2026-01-02T15:04:05Z", + "expires_at": "2026-01-03T01:00:00Z", + "id": "550e8400-e29b-41d4-a716-446655440000", + "limit_price": "0.05", + "located_price": "0.05", + "located_qty": 100, + "requested_qty": 100, + "status": "active", + "symbol": "TSLA", + "total_fee": "5.00" + } + ], + "next_page_token": "eyJpZCI6IjU1MGU4NDAwLWUyOWItNDFkNC1hNzE2LTQ0NjY1NTQ0MDAwMCJ9Cg" + }, + "properties": { + "locates": { + "description": "Locates matching the filter criteria.", + "items": { + "$ref": "#/components/schemas/Locate" + }, + "type": "array" + }, + "next_page_token": { + "description": "The token to use to retrieve the next page of results. If `null`, there are no more pages.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "locates", + "next_page_token" + ], + "type": "object" + }, + "Locate": { + "description": "A locate request and its current lifecycle status.", + "example": { + "all_or_none": false, + "created_at": "2026-01-02T15:04:05Z", + "expires_at": "2026-01-03T01:00:00Z", + "id": "550e8400-e29b-41d4-a716-446655440000", + "limit_price": "0.05", + "located_price": "0.05", + "located_qty": 100, + "requested_qty": 100, + "status": "active", + "symbol": "TSLA", + "total_fee": "5.00" + }, + "properties": { + "all_or_none": { + "description": "Whether the request required the full quantity.", + "example": false, + "type": "boolean" + }, + "created_at": { + "description": "Time when the locate was created.", + "example": "2026-01-02T15:04:05Z", + "format": "date-time", + "type": "string" + }, + "expires_at": { + "description": "Time when the active locate expires. Omitted when rejected.", + "example": "2026-01-03T01:00:00Z", + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "id": { + "description": "Locate ID.", + "example": "550e8400-e29b-41d4-a716-446655440000", + "format": "uuid", + "type": "string" + }, + "limit_price": { + "description": "Maximum acceptable fee per share from the request.", + "example": "0.05", + "type": [ + "string", + "null" + ] + }, + "located_price": { + "description": "Locate fee per share in USD. Omitted when rejected.", + "example": "0.05", + "type": [ + "string", + "null" + ] + }, + "located_qty": { + "description": "Number of shares located. Omitted when rejected.", + "example": 100, + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "rejection_reason": { + "description": "Machine-readable rejection reason.", + "example": "inventory_unavailable", + "type": [ + "string", + "null" + ] + }, + "requested_qty": { + "description": "Number of shares requested.", + "example": 100, + "format": "int64", + "type": "integer" + }, + "status": { + "$ref": "#/components/schemas/LocateStatus" + }, + "symbol": { + "description": "Stock symbol.", + "example": "TSLA", + "type": "string" + }, + "total_fee": { + "description": "Total locate fee in USD. Omitted when rejected.", + "example": "5.00", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "id", + "symbol", + "requested_qty", + "all_or_none", + "status", + "created_at" + ], + "type": "object" + }, + "LocateError": { + "description": "Locates API error response. Locate-specific 400 and create locate 422 errors include a machine-readable `code`.", + "properties": { + "code": { + "description": "Machine-readable error code. Present on locate-specific 400 and create locate 422 errors.", + "enum": [ + "invalid_input", + "invalid_request_body", + "invalid_limit_price", + "invalid_symbols", + "symbol_not_found", + "security_not_found", + "insufficient_buying_power", + "easy_to_borrow", + "threshold_security", + "idempotency_key_conflict", + "quote_unavailable" + ], + "example": "invalid_symbols", + "type": "string" + }, + "message": { + "description": "Error message.", + "example": "symbols must contain at most 100 unique symbols", + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "LocateQuote": { + "description": "Current locate pricing and availability for a symbol.", + "example": { + "available_qty": 1000, + "price": "0.0123", + "quoted_at": "2026-01-02T15:04:05Z", + "symbol": "TSLA" + }, + "properties": { + "available_qty": { + "description": "Available locate quantity.", + "example": 1000, + "format": "int64", + "type": "integer" + }, + "price": { + "description": "Locate fee per share. Omitted when no quantity is available.", + "example": "0.0123", + "type": "string" + }, + "quoted_at": { + "description": "Time when the quote was issued.", + "example": "2026-01-02T15:04:05Z", + "format": "date-time", + "type": "string" + }, + "symbol": { + "description": "Stock symbol.", + "example": "TSLA", + "type": "string" + } + }, + "required": [ + "symbol", + "available_qty", + "quoted_at" + ], + "type": "object" + }, + "LocateQuoteError": { + "description": "Error returned for a symbol that could not be quoted.", + "example": { + "code": "symbol_not_found", + "message": "symbol not found", + "symbol": "META" + }, + "properties": { + "code": { + "description": "Error code.", + "enum": [ + "symbol_not_found", + "easy_to_borrow", + "threshold_security", + "corporate_action", + "quote_unavailable" + ], + "example": "symbol_not_found", + "type": "string" + }, + "message": { + "description": "Error message.", + "example": "symbol not found", + "type": "string" + }, + "symbol": { + "description": "Requested stock symbol that could not be quoted.", + "example": "FB", + "type": "string" + } + }, + "required": [ + "symbol", + "code", + "message" + ], + "type": "object" + }, + "LocateStatus": { + "description": "Locate status.", + "enum": [ + "active", + "expired", + "rejected" + ], + "example": "active", + "type": "string" + }, + "MAActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonMAActivityV2" + }, + { + "properties": { + "acquiree_qty": { + "description": "Quantity of the acquiree", + "type": "string" + }, + "acquirer_qty": { + "description": "Quantity of the acquirer", + "type": "string" + }, + "cash_payout": { + "description": "The cash payout", + "type": "string" + }, + "cash_rate": { + "description": "The cash rate", + "type": "string" + } + }, + "required": [ + "acquiree_qty" + ], + "type": "object" + } + ], + "description": "Merger and acquisition", + "type": "object" + }, + "MEMActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "transfer_id": { + "description": "The transfer's ID", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "transfer_id" + ], + "type": "object" + } + ], + "description": "Instant funding memopost", + "type": "object" + }, + "MLegOrderLeg": { + "description": "Represents an individual leg of a multi-leg options order.", + "properties": { + "position_intent": { + "$ref": "#/components/schemas/PositionIntent" + }, + "ratio_qty": { + "description": "proportional quantity of this leg in relation to the overall multi-leg order qty", + "type": "string" + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "symbol": { + "description": "symbol or asset ID to identify the asset to trade", + "type": "string" + } + }, + "required": [ + "symbol", + "ratio_qty" + ], + "title": "MLegOrderLeg", + "type": "object" + }, + "NCActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonNCActivityV2" + }, + { + "properties": { + "position_qty": { + "description": "The position quantity", + "type": "string" + } + }, + "required": [ + "position_qty" + ], + "type": "object" + } + ], + "description": "Name change", + "type": "object" + }, + "NextPageToken": { + "description": "Use this token in your next API call to paginate through the dataset and retrieve the next page of results. A null token indicates there are no more data to fetch.\n", + "example": "MTAwMA==", + "type": [ + "string", + "null" + ] + }, + "NonTradeActivities": { + "examples": [ + { + "activity_sub_type": "SDIV", + "activity_type": "DIV", + "created_at": "2021-05-10T14:01:04.650275Z", + "currency": "USD", + "date": "2019-08-01", + "id": "20190801011955195::5f596936-6f23-4cef-bdf1-3806aae57dbf", + "net_amount": "1.02", + "per_share_amount": "0.51", + "qty": "2", + "status": "executed", + "symbol": "T" + } + ], + "properties": { + "activity_sub_type": { + "$ref": "#/components/schemas/ActivitySubType" + }, + "activity_type": { + "$ref": "#/components/schemas/ActivityType" + }, + "created_at": { + "description": "Valid only for non-trading activity types. Null for trading activites.", + "format": "date-time", + "type": "string" + }, + "currency": { + "description": "Currency denomination of the activity (e.g. USD). Included in NTA stream events and activity responses.", + "example": "USD", + "type": "string" + }, + "cusip": { + "description": "The CUSIP of the security involved with the activity. Not present for all activity types.", + "type": "string" + }, + "date": { + "description": "The date on which the activity occurred or on which the transaction associated with the activity settled.", + "format": "date-time", + "type": "string" + }, + "group_id": { + "description": "ID used to link activities who share a sibling relationship.", + "type": "string" + }, + "id": { + "description": "An ID for the activity, always in \"::\" format. Can be sent as page_token in requests to facilitate the paging of results.", + "type": "string" + }, + "net_amount": { + "description": "The net amount of money (positive or negative) associated with the activity.", + "type": "string" + }, + "per_share_amount": { + "description": "For dividend activities, the average amount paid per share. Not present for other activity types.", + "type": "string" + }, + "qty": { + "description": "For dividend activities, the number of shares that contributed to the payment. Not present for other activity types.\n", + "type": "string" + }, + "status": { + "description": "The activity status.", + "enum": [ + "executed", + "correct", + "canceled" + ], + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity. Not present for all activity types.", + "type": "string" + } + }, + "title": "AccountNonTradeActivities", + "type": "object" + }, + "OCTActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "properties": { + "symbol": { + "description": "The symbol of the asset involved with the on chain transaction", + "type": "string" + }, + "transfer_id": { + "description": "The transfer ID of the associated deposit or withdrawal", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "transfer_id", + "symbol" + ], + "type": "object" + } + ], + "description": "On chain transaction (blockchain deposit/withdrawal)", + "example": { + "symbol": "USDCUSD", + "system_date": "2026-07-31", + "transfer_id": "08d7a129-bd3e-4480-94ff-1a7288166845" + }, + "type": "object" + }, + "OPASNActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Option assignment", + "type": "object" + }, + "OPCSHActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Option cash deliverable for non-standard contracts", + "type": "object" + }, + "OPEXCActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Option exercise", + "type": "object" + }, + "OPEXPActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Option expiry", + "type": "object" + }, + "OPTRDActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOptionsActivityV2" + }, + { + "type": "object" + } + ], + "description": "Trading activity that is paired with the assignment/exercise", + "type": "object" + }, + "OpcaCDIVActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonCDIVActivityV2" + } + ], + "description": "Options corporate action of cash dividend or return of capital", + "type": "object" + }, + "OpcaFSPLITActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSplitActivityV2" + }, + { + "properties": { + "due_bill_redemption_date": { + "description": "When due bills related to the split are redeemed", + "format": "date", + "minLength": 1, + "type": "string" + }, + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Options corporate action of forward-splits", + "type": "object" + }, + "OpcaMAActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonMAActivityV2" + } + ], + "description": "Options corporate action of Mergers & Acquisitions", + "type": "object" + }, + "OpcaNCActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonNCActivityV2" + } + ], + "description": "Options corporate action of name changes", + "type": "object" + }, + "OpcaRSPLITActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSplitActivityV2" + }, + { + "properties": { + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security after the split", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Options corporate action of reverse-splits", + "type": "object" + }, + "OpcaSDIVActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSDIVActivityV2" + } + ], + "description": "Options corporate action of stock dividend", + "type": "object" + }, + "OpcaSPINActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSpinoffActivityV2" + } + ], + "description": "Options corporate action of spin-offs", + "type": "object" + }, + "OpcaUSPLITActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonOPCAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSplitActivityV2" + }, + { + "properties": { + "alternate_cusip": { + "description": "CUSIP for the alternate security after the split", + "type": "string" + }, + "alternate_rate": { + "description": "Ratio of alternate shares received", + "type": "string" + }, + "alternate_symbol": { + "description": "Symbol for the alternate security after the split", + "type": "string" + }, + "effective_date": { + "description": "When the unit split becomes effective", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security after the unit split", + "type": "string" + }, + "old_symbol": { + "description": "The old symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "old_symbol", + "new_symbol", + "alternate_cusip", + "alternate_symbol", + "alternate_rate", + "effective_date" + ], + "type": "object" + } + ], + "description": "Options corporate action of unit-splits", + "type": "object" + }, + "OptionContract": { + "properties": { + "close_price": { + "description": "The close price of the option contract.", + "example": "148.38", + "type": "string" + }, + "close_price_date": { + "description": "The date of the close price data.", + "example": "2023-12-11", + "format": "date", + "type": "string" + }, + "deliverables": { + "description": "Represents the deliverables tied to the option contract. While standard contracts entail a single deliverable, non-standard ones can encompass multiple deliverables, each potentially customized with distinct parameters.\nThis array is included in the list contracts response only if the query parameter show_deliverables=true is provided.\n", + "items": { + "$ref": "#/components/schemas/OptionDeliverable" + }, + "type": "array" + }, + "expiration_date": { + "description": "The expiration date of the option contract.", + "example": "2025-06-20", + "format": "date", + "type": "string" + }, + "id": { + "description": "The unique identifier of the option contract.", + "example": "98359ef7-5124-49f3-85ea-5cf02df6defa", + "format": "uuid", + "type": "string" + }, + "multiplier": { + "description": "The multiplier of the option contract is crucial for calculating both the trade premium and the extended strike price. In standard contracts, the multiplier is always set to 100.\nFor instance, if a contract is traded at $1.50 and the multiplier is 100, the total amount debited when buying the contract would be $150.00.\nSimilarly, when exercising a call contract, the total cost will be equal to the strike price times the multiplier.", + "example": "100", + "format": "decimal", + "type": "string" + }, + "name": { + "description": "The name of the option contract.", + "example": "AAPL Jun 20 2025 100 Call", + "type": "string" + }, + "open_interest": { + "description": "The open interest of the option contract.", + "example": "237", + "type": "string" + }, + "open_interest_date": { + "description": "The date of the open interest data.", + "example": "2023-12-11", + "format": "date", + "type": "string" + }, + "ppind": { + "description": "The ppind (Penny Program Indicator) field indicates whether an option contract is eligible for penny price increments,\nwith `true` meaning it is part of the Penny Program and `false` meaning it is not.", + "example": true, + "type": "boolean" + }, + "root_symbol": { + "description": "The root symbol of the option contract.", + "example": "AAPL", + "type": "string" + }, + "size": { + "description": "Represents the number of underlying shares to be delivered in case the contract is exercised/assigned. For standard contracts, this is always 100.\nThis field should **not** be used as a multiplier, specially for non-standard contracts.", + "example": "100", + "type": "string" + }, + "status": { + "description": "The status of the option contract.", + "enum": [ + "active", + "inactive" + ], + "example": "active", + "type": "string" + }, + "strike_price": { + "description": "The strike price of the option contract.", + "example": "100", + "format": "decimal", + "type": "string" + }, + "style": { + "$ref": "#/components/schemas/OptionContractStyle" + }, + "symbol": { + "description": "The symbol representing the option contract.", + "example": "AAPL250620C00100000", + "type": "string" + }, + "tradable": { + "description": "Indicates whether the option contract is tradable.", + "example": true, + "type": "boolean" + }, + "type": { + "$ref": "#/components/schemas/OptionContractType" + }, + "underlying_asset_id": { + "description": "The unique identifier of the underlying asset.", + "example": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "format": "uuid", + "type": "string" + }, + "underlying_symbol": { + "description": "The underlying symbol of the option contract.", + "example": "AAPL", + "type": "string" + } + }, + "required": [ + "id", + "symbol", + "name", + "status", + "tradable", + "expiration_date", + "underlying_symbol", + "underlying_asset_id", + "type", + "style", + "strike_price", + "multiplier", + "size", + "ppind" + ], + "type": "object" + }, + "OptionContractStyle": { + "description": "The style of the option contract.", + "enum": [ + "american", + "european" + ], + "example": "american", + "type": "string" + }, + "OptionContractType": { + "description": "The type of the option contract.", + "enum": [ + "call", + "put" + ], + "example": "call", + "type": "string" + }, + "OptionContractsResponse": { + "description": "Paginated list of option contracts.", + "properties": { + "next_page_token": { + "$ref": "#/components/schemas/NextPageToken" + }, + "option_contracts": { + "example": [ + { + "expiration_date": "2025-06-20", + "id": "98359ef7-5124-49f3-85ea-5cf02df6defa", + "multiplier": "100", + "name": "AAPL Jun 20 2025 100 Call", + "ppind": true, + "root_symbol": "AAPL", + "size": "100", + "status": "active", + "strike_price": "100", + "style": "american", + "symbol": "AAPL250620C00100000", + "tradable": true, + "type": "call", + "underlying_asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "underlying_symbol": "AAPL" + } + ], + "items": { + "$ref": "#/components/schemas/OptionContract" + }, + "type": "array" + } + }, + "required": [ + "option_contracts" + ], + "title": "OptionContractsResponse", + "type": "object" + }, + "OptionDeliverable": { + "properties": { + "allocation_percentage": { + "description": "Cost allocation percentage of the deliverable.\nThis is used to determine the cost basis of the equity shares received from the exercise, specially for non-standard contracts with multiple deliverables.\n", + "example": "100", + "type": "string" + }, + "amount": { + "description": "The deliverable amount. For cash deliverables, this is the cash amount.\nFor standard contract, this is always 100.\nThis field can be null in case the deliverable settlement is delayed and the amount is yet to be determined.\n", + "example": "100", + "type": "string" + }, + "asset_id": { + "description": "Unique identifier of the deliverable asset. For standard contracts, this is equivalent to underlying_asset_id of the contracts.\nThis field is not returned for cash deliverables.\n", + "example": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "format": "uuid", + "type": "string" + }, + "delayed_settlement": { + "description": "If true, the settlement of the deliverable will be delayed.\nFor instance, in the event of a contract with a delayed deliverable being exercised, both the availability of the deliverable and its settlement may be postponed beyond the typical timeframe.\n", + "example": false, + "type": "boolean" + }, + "settlement_method": { + "description": "Indicates the settlement method that will be used:\n- **BTOB**: Broker to Broker\n- **CADF**: Cash Difference\n- **CAFX**: Cash Fixed\n- **CCC**: Correspondent Clearing Corp\n", + "enum": [ + "BTOB", + "CADF", + "CAFX", + "CCC" + ], + "example": "CCC", + "type": "string" + }, + "settlement_type": { + "description": "Indicates when the deliverable will be settled if the contract is exercised/assigned.\n", + "enum": [ + "T+0", + "T+1", + "T+2", + "T+3", + "T+4", + "T+5" + ], + "example": "T+2", + "type": "string" + }, + "symbol": { + "description": "Symbol of the deliverable. For standard contracts, this is equivalent to the underlying symbol of the contract.\n", + "example": "AAPL", + "type": "string" + }, + "type": { + "description": "Type of deliverable, indicating whether it's cash or equity. For standard contracts, it is always \"equity\".\n", + "enum": [ + "cash", + "equity" + ], + "example": "equity", + "type": "string" + } + }, + "required": [ + "type", + "symbol", + "amount", + "allocation_percentage", + "settlement_type", + "settlement_method", + "delayed_settlement" + ], + "type": "object" + }, + "Order": { + "description": "The Orders API allows a user to monitor, place and cancel their orders with Alpaca.\n\nEach order has a unique identifier provided by the client. This client-side unique order ID will be automatically generated by the system if not provided by the client, and will be returned as part of the order object along with the rest of the fields described below. Once an order is placed, it can be queried using the client-side order ID to check the status.\n\nUpdates on open orders at Alpaca will also be sent over the streaming interface, which is the recommended method of maintaining order state.", + "properties": { + "asset_class": { + "$ref": "#/components/schemas/AssetClass" + }, + "asset_id": { + "description": "Asset ID (For options this represents the option contract ID)", + "format": "uuid", + "type": "string" + }, + "canceled_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "client_order_id": { + "description": "Client unique order ID", + "maxLength": 128, + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "expired_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "expires_at": { + "format": "date-time", + "type": "string" + }, + "extended_hours": { + "description": "If true, eligible for execution outside regular trading hours.", + "type": "boolean" + }, + "failed_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "filled_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "filled_avg_price": { + "description": "Filled average price", + "type": [ + "string", + "null" + ] + }, + "filled_qty": { + "description": "Filled quantity", + "minLength": 1, + "type": "string" + }, + "hwm": { + "description": "The highest (lowest) market price seen since the trailing stop order was submitted.", + "type": [ + "string", + "null" + ] + }, + "id": { + "description": "Order ID", + "format": "uuid", + "type": "string" + }, + "legs": { + "description": "When querying non-simple order_class orders in a nested style, an array of Order entities associated with this order. Otherwise, null. Required if order class is `mleg`.", + "example": null, + "items": { + "$ref": "#/components/schemas/OrderLeg" + }, + "type": [ + "array", + "null" + ] + }, + "limit_price": { + "description": "Limit price", + "type": [ + "string", + "null" + ] + }, + "notional": { + "description": "Ordered notional amount. If entered, qty will be null. Can take up to 9 decimal points.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "order_class": { + "$ref": "#/components/schemas/OrderClass" + }, + "order_type": { + "deprecated": true, + "description": "Deprecated in favour of the field \"type\" ", + "type": "string" + }, + "position_intent": { + "$ref": "#/components/schemas/PositionIntent" + }, + "qty": { + "description": "Ordered quantity. If entered, notional will be null. Can take up to 9 decimal points. Required if order class is `mleg`.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "ratio_qty": { + "description": "The proportional quantity of this leg in relation to the overall multi-leg order quantity.", + "format": "decimal", + "type": [ + "string", + "null" + ] + }, + "replaced_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "replaced_by": { + "description": "The order ID that this order was replaced by", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "replaces": { + "description": "The order ID that this order replaces", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "status": { + "$ref": "#/components/schemas/OrderStatus" + }, + "stop_price": { + "description": "Stop price", + "type": [ + "string", + "null" + ] + }, + "submitted_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "symbol": { + "description": "Asset symbol, required for all order classes except for `mleg`", + "minLength": 1, + "type": "string" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "trail_percent": { + "description": "The percent value away from the high water mark for trailing stop orders.", + "type": [ + "string", + "null" + ] + }, + "trail_price": { + "description": "The dollar value away from the high water mark for trailing stop orders.", + "type": [ + "string", + "null" + ] + }, + "type": { + "$ref": "#/components/schemas/OrderType" + }, + "updated_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "notional", + "type", + "time_in_force" + ], + "title": "Order", + "type": "object" + }, + "OrderClass": { + "description": "The order classes supported by Alpaca vary based on the order's security type. The following provides a comprehensive breakdown of the supported order classes for each category:\n - Equity trading: simple (or \"\"), oco, oto, bracket.\n - Options trading:\n - simple (or \"\")\n - mleg (required for multi-leg complex option strategies)\n - Crypto trading: simple (or \"\").", + "enum": [ + "simple", + "bracket", + "oco", + "oto", + "mleg", + "" + ], + "example": "bracket", + "title": "OrderClass", + "type": "string" + }, + "OrderLeg": { + "description": "This is copy of Order response schemas as a workaround of displaying issue of nested Order recursively for legs", + "properties": { + "asset_class": { + "$ref": "#/components/schemas/AssetClass" + }, + "asset_id": { + "description": "Asset ID (For options this represents the option contract ID)", + "format": "uuid", + "type": "string" + }, + "canceled_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "client_order_id": { + "description": "Client unique order ID", + "maxLength": 128, + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "expired_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "extended_hours": { + "description": "If true, eligible for execution outside regular trading hours.", + "type": "boolean" + }, + "failed_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "filled_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "filled_avg_price": { + "description": "Filled average price", + "type": [ + "string", + "null" + ] + }, + "filled_qty": { + "description": "Filled quantity", + "minLength": 1, + "type": "string" + }, + "hwm": { + "description": "The highest (lowest) market price seen since the trailing stop order was submitted.", + "type": [ + "string", + "null" + ] + }, + "id": { + "description": "Order ID", + "format": "uuid", + "type": "string" + }, + "legs": { + "description": "Always null for an order leg; legs are not nested beyond one level. An empty array is accepted for generated-client compatibility.", + "example": null, + "items": { + "type": "object" + }, + "maxItems": 0, + "type": [ + "array", + "null" + ] + }, + "limit_price": { + "description": "Limit price", + "type": [ + "string", + "null" + ] + }, + "notional": { + "description": "Ordered notional amount. If entered, qty will be null. Can take up to 9 decimal points.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "order_class": { + "$ref": "#/components/schemas/OrderClass" + }, + "order_type": { + "deprecated": true, + "description": "Deprecated in favour of the field \"type\" ", + "type": "string" + }, + "position_intent": { + "$ref": "#/components/schemas/PositionIntent" + }, + "qty": { + "description": "Ordered quantity. If entered, notional will be null. Can take up to 9 decimal points.", + "minLength": 1, + "type": [ + "string", + "null" + ] + }, + "replaced_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "replaced_by": { + "description": "The order ID that this order was replaced by", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "replaces": { + "description": "The order ID that this order replaces", + "format": "uuid", + "type": [ + "string", + "null" + ] + }, + "side": { + "$ref": "#/components/schemas/OrderSide" + }, + "status": { + "$ref": "#/components/schemas/OrderStatus" + }, + "stop_price": { + "description": "Stop price", + "type": [ + "string", + "null" + ] + }, + "submitted_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "symbol": { + "description": "Asset symbol", + "minLength": 1, + "type": "string" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "trail_percent": { + "description": "The percent value away from the high water mark for trailing stop orders.", + "type": [ + "string", + "null" + ] + }, + "trail_price": { + "description": "The dollar value away from the high water mark for trailing stop orders.", + "type": [ + "string", + "null" + ] + }, + "type": { + "$ref": "#/components/schemas/OrderType" + }, + "updated_at": { + "format": "date-time", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "symbol", + "type", + "time_in_force", + "notional", + "qty", + "side" + ], + "title": "Order", + "type": "object" + }, + "OrderSide": { + "description": "Represents which side this order was on:\n- buy\n- sell\nRequired for all order classes except for mleg.", + "enum": [ + "buy", + "sell" + ], + "example": "buy", + "title": "OrderSide", + "type": "string" + }, + "OrderStatus": { + "description": "An order executed through Alpaca can experience several status changes during its lifecycle. The most common statuses are described in detail below:\n\n- new\n The order has been received by Alpaca, and routed to exchanges for execution. This is the usual initial state of an order.\n\n- partially_filled\n The order has been partially filled.\n\n- filled\n The order has been filled, and no further updates will occur for the order.\n\n- done_for_day\n The order is done executing for the day, and will not receive further updates until the next trading day.\n\n- canceled\n The order has been canceled, and no further updates will occur for the order. This can be either due to a cancel request by the user, or the order has been canceled by the exchanges due to its time-in-force.\n\n- expired\n The order has expired, and no further updates will occur for the order.\n\n- replaced\n The order was replaced by another order, or was updated due to a market event such as corporate action.\n\n- pending_cancel\n The order is waiting to be canceled.\n\n- pending_replace\n The order is waiting to be replaced by another order. The order will reject cancel request while in this state.\n\nLess common states are described below. Note that these states only occur on very rare occasions, and most users will likely never see their orders reach these states:\n\n- accepted\n The order has been received by Alpaca, but hasn't yet been routed to the execution venue. This could be seen often out side of trading session hours.\n\n- pending_new\n The order has been received by Alpaca, and routed to the exchanges, but has not yet been accepted for execution. This state only occurs on rare occasions.\n\n- accepted_for_bidding\n The order has been received by exchanges, and is evaluated for pricing. This state only occurs on rare occasions.\n\n- stopped\n The order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. This state only occurs on rare occasions.\n\n- rejected\n The order has been rejected, and no further updates will occur for the order. This state occurs on rare occasions and may occur based on various conditions decided by the exchanges.\n\n- suspended\n The order has been suspended, and is not eligible for trading. This state only occurs on rare occasions.\n\n- calculated\n The order has been completed for the day (either filled or done for day), but remaining settlement calculations are still pending. This state only occurs on rare occasions.\n\n\nAn order may be canceled through the API up until the point it reaches a state of either filled, canceled, or expired.", + "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", + "held" + ], + "example": "new", + "title": "OrderStatus", + "type": "string" + }, + "OrderType": { + "description": "The order types supported by Alpaca vary based on the order's security type. The following provides a comprehensive breakdown of the supported order types for each category:\n - Equity trading: market, limit, stop, stop_limit, trailing_stop.\n - Options trading: market, limit, stop, stop_limit.\n - Multileg Options trading: market, limit.\n - Crypto trading: market, limit, stop_limit.", + "enum": [ + "market", + "limit", + "stop", + "stop_limit", + "trailing_stop" + ], + "example": "market", + "title": "OrderType", + "type": "string" + }, + "PatchOrderRequest": { + "description": "Represents a request to patch an order.\n\nNote: `qty` and `notional` are mutually exclusive on a single replace request. `notional` is only valid for IPO indications of interest (`asset_class: \"ipo\"`); non-IPO notional orders cannot be replaced at all.", + "properties": { + "advanced_instructions": { + "$ref": "#/components/schemas/AdvancedInstructions" + }, + "client_order_id": { + "description": "A unique identifier for the new order. Automatically generated if not sent. (<= 128 characters)", + "maxLength": 128, + "type": "string" + }, + "limit_price": { + "description": "Required if original order's `type` field was `limit` or `stop_limit`.\nIn case of `mleg`, the limit_price parameter is expressed with the following notation:\n- A positive value indicates a debit, representing a cost or payment to be made.\n- A negative value signifies a credit, reflecting an amount to be received.", + "example": "3.14", + "type": "string" + }, + "notional": { + "description": "New notional (dollar amount) for the order. Only valid for IPO indications of interest (`asset_class: \"ipo\"`); will be rejected for any other asset class.\nMutually exclusive with `qty` on the same replace request.", + "example": "750", + "type": "string" + }, + "qty": { + "description": "number of shares to trade.\n\nYou can only patch full shares for now.\n\nQty of equity fractional orders are not allowed to change. Non-IPO notional orders cannot be replaced at all - no fields (qty, limit_price, stop_price, etc.) can be modified; cancel and resubmit instead.", + "example": "4", + "type": "string" + }, + "stop_price": { + "description": "required if original order type is limit or stop_limit", + "example": "3.14", + "type": "string" + }, + "time_in_force": { + "$ref": "#/components/schemas/TimeInForce" + }, + "trail": { + "description": "the new value of the trail_price or trail_percent value (works only for type=\"trailing_stop\")", + "example": "3.14", + "type": "string" + } + }, + "title": "PatchOrderRequest", + "type": "object" + }, + "PortfolioHistory": { + "description": "Timeseries data for equity and profit loss information of the account.", + "properties": { + "base_value": { + "description": "basis in dollar of the profit loss calculation", + "type": [ + "number", + "null" + ] + }, + "base_value_asof": { + "description": "If included, then it indicates that the base_value is the account's closing\nequity value at this trading date.\n\nIf not specified, then the baseline calculation is done against the earliest returned data item. This could happen for\naccounts without prior closing balances (e.g. new account) or for queries with 1D timeframes, where the first data point\nis used as a reference point.\n", + "example": "2023-10-20", + "format": "date", + "type": "string" + }, + "cashflow": { + "additionalProperties": { + "items": { + "type": "number" + }, + "type": "array" + }, + "description": "accumulated value in dollar amount as of the end of each time window", + "type": "object" + }, + "equity": { + "description": "equity value of the account in dollar amount as of the end of each time window", + "items": { + "type": [ + "number", + "null" + ] + }, + "type": "array" + }, + "profit_loss": { + "description": "profit/loss in dollar from the base value", + "items": { + "type": [ + "number", + "null" + ] + }, + "type": "array" + }, + "profit_loss_pct": { + "description": "profit/loss in percentage from the base value", + "example": [ + 0.001, + 0.002 + ], + "items": { + "type": [ + "number", + "null" + ] + }, + "type": "array" + }, + "timeframe": { + "description": "time window size of each data element", + "example": "15Min", + "type": "string" + }, + "timestamp": { + "description": "Time of each data element, left-labeled (the beginning of time window).\n\nThe values returned are in [UNIX epoch format](https://en.wikipedia.org/wiki/Unix_time).\n", + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "required": [ + "timestamp", + "equity", + "profit_loss", + "profit_loss_pct", + "base_value", + "timeframe" + ], + "title": "PortfolioHistory", + "type": "object" + }, + "Position": { + "description": "The positions API provides information about an account's current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API.", + "examples": [ + { + "asset_class": "us_equity", + "asset_id": "904837e3-3b76-47ec-b432-046db621571b", + "asset_marginable": true, + "avg_entry_price": "100.0", + "change_today": "0.0084", + "cost_basis": "500.0", + "current_price": "120.0", + "exchange": "NASDAQ", + "lastday_price": "119.0", + "market_value": "600.0", + "qty": "5", + "qty_available": "4", + "side": "long", + "symbol": "AAPL", + "unrealized_intraday_pl": "10.0", + "unrealized_intraday_plpc": "0.0084", + "unrealized_pl": "100.0", + "unrealized_plpc": "0.20" + }, + { + "asset_class": "us_equity", + "asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "asset_marginable": false, + "avg_entry_price": "174.78", + "change_today": "-0.0018326556325525", + "cost_basis": "349.56", + "current_price": "174.29", + "exchange": "NASDAQ", + "lastday_price": "174.61", + "market_value": "348.58", + "qty": "2", + "qty_available": "2", + "side": "long", + "symbol": "AAPL", + "unrealized_intraday_pl": "-0.98", + "unrealized_intraday_plpc": "-0.0028035244307129", + "unrealized_pl": "-0.98", + "unrealized_plpc": "-0.0028035244307129" + } + ], + "properties": { + "asset_class": { + "$ref": "#/components/schemas/AssetClass" + }, + "asset_id": { + "description": "Asset ID (For options this represents the option contract ID)", + "format": "uuid", + "type": "string" + }, + "asset_marginable": { + "type": "boolean" + }, + "avg_entry_price": { + "description": "Average entry price of the position", + "minLength": 1, + "type": "string" + }, + "avg_entry_swap_rate": { + "description": "The weighted-average exchange rate at the time the position was entered.", + "format": "decimal", + "type": "string" + }, + "change_today": { + "description": "Percent change from last day price (by a factor of 1)", + "minLength": 1, + "type": "string" + }, + "cost_basis": { + "description": "Total cost basis in dollar", + "minLength": 1, + "type": "string" + }, + "current_price": { + "description": "Current asset price per share", + "minLength": 1, + "type": "string" + }, + "exchange": { + "$ref": "#/components/schemas/ExchangeForPosition" + }, + "lastday_price": { + "description": "Last day's asset price per share based on the closing value of the last trading day", + "minLength": 1, + "type": "string" + }, + "market_value": { + "description": "Total dollar amount of the position", + "minLength": 1, + "type": "string" + }, + "prev_swap_rate": { + "description": "The exchange rate as of the previous close (i.e. yesterday's rate)", + "format": "decimal", + "type": "string" + }, + "qty": { + "description": "The number of shares", + "minLength": 1, + "type": "string" + }, + "qty_available": { + "description": "Total number of shares available minus open orders / locked for options covered call", + "minLength": 1, + "type": "string" + }, + "side": { + "description": "long", + "enum": [ + "long", + "short" + ], + "type": "string" + }, + "swap_rate": { + "description": "The current exchange rate (without mark-up) used to convert local-currency position values into USD. Present only for LCT (Local Currency Trading) accounts", + "format": "decimal", + "type": "string" + }, + "symbol": { + "description": "Symbol name of the asset", + "example": "AAPL", + "type": "string" + }, + "unrealized_intraday_pl": { + "description": "Unrealized profit/loss in dollars for the day", + "minLength": 1, + "type": "string" + }, + "unrealized_intraday_plpc": { + "description": "Unrealized profit/loss percent (by a factor of 1)", + "minLength": 1, + "type": "string" + }, + "unrealized_pl": { + "description": "Unrealized profit/loss in dollars", + "minLength": 1, + "type": "string" + }, + "unrealized_plpc": { + "description": "Unrealized profit/loss percent (by a factor of 1)", + "minLength": 1, + "type": "string" + }, + "usd": { + "$ref": "#/components/schemas/USDPositionValues" + } + }, + "required": [ + "asset_id", + "symbol", + "exchange", + "asset_class", + "avg_entry_price", + "qty", + "side", + "market_value", + "cost_basis", + "unrealized_pl", + "unrealized_plpc", + "unrealized_intraday_pl", + "unrealized_intraday_plpc", + "current_price", + "lastday_price", + "change_today", + "asset_marginable" + ], + "title": "Position", + "type": "object" + }, + "PositionClosedReponse": { + "description": "Represents the result of asking the api to close a position. ", + "examples": [ + { + "body": { + "asset_class": "us_equity", + "asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415", + "canceled_at": null, + "client_order_id": "52f8574c-96d5-49b6-94c1-2570a268434e", + "created_at": "2022-02-04T16:53:29.53427917Z", + "expired_at": null, + "extended_hours": false, + "failed_at": null, + "filled_at": null, + "filled_avg_price": null, + "filled_qty": "0", + "hwm": null, + "id": "f7f25e89-939a-4587-aaf6-414a6b3c341d", + "legs": null, + "limit_price": null, + "notional": null, + "order_class": "", + "order_type": "market", + "qty": "2", + "replaced_at": null, + "replaced_by": null, + "replaces": null, + "side": "sell", + "status": "accepted", + "stop_price": null, + "submitted_at": "2022-02-04T16:53:29.533738219Z", + "symbol": "AAPL", + "time_in_force": "day", + "trail_percent": null, + "trail_price": null, + "type": "market", + "updated_at": "2022-02-04T16:53:29.53427917Z" + }, + "status": 200, + "symbol": "AAPL" + } + ], + "properties": { + "body": { + "$ref": "#/components/schemas/Order" + }, + "status": { + "description": "HTTP status code for the attempt to close this position", + "type": "integer" + }, + "symbol": { + "description": "Symbol name of the asset", + "type": "string" + } + }, + "required": [ + "symbol", + "status" + ], + "title": "PositionClosedReponse", + "type": "object" + }, + "PositionIntent": { + "description": "Represents the desired position strategy.", + "enum": [ + "buy_to_open", + "buy_to_close", + "sell_to_open", + "sell_to_close" + ], + "example": "buy_to_open", + "title": "PositionIntent", + "type": "string" + }, + "REOActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonREOActivityV2" + } + ], + "description": "Reorganization (REO)", + "type": "object" + }, + "ReverseSplitActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonSplitStockActivityV2" + }, + { + "properties": { + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security after the split", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + } + ], + "description": "Reverse stock split", + "type": "object" + }, + "RightsDistributionActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "ex_date": { + "description": "The ex_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "expiration_date": { + "description": "The expiration date for the rights distribution", + "format": "date", + "type": "string" + }, + "new_cusip": { + "description": "The new CUSIP", + "type": "string" + }, + "new_qty": { + "description": "The new quantity", + "type": "string" + }, + "new_symbol": { + "description": "The new symbol", + "type": "string" + }, + "payable_date": { + "description": "The payable_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "rate": { + "description": "The rate for the rights distribution", + "type": "string" + }, + "record_date": { + "description": "The record_date for this corporate action", + "format": "date", + "minLength": 1, + "type": "string" + }, + "source_cusip": { + "description": "The source CUSIP", + "type": "string" + }, + "source_qty": { + "description": "The source quantity", + "type": "string" + }, + "source_symbol": { + "description": "The source symbol", + "type": "string" + } + }, + "required": [ + "source_cusip", + "source_symbol", + "source_qty", + "new_cusip", + "new_symbol", + "new_qty", + "rate" + ], + "type": "object" + } + ], + "description": "Rights distribution", + "type": "object" + }, + "RightsSubscriptionElectionActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonVOFSubtypeActivityV2" + } + ], + "type": "object" + }, + "SDIVActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSDIVActivityV2" + }, + { + "properties": { + "entitled_qty": { + "description": "Quantity of shares entitled to receive the dividend", + "type": "string" + }, + "new_qty": { + "description": "The total number of shares after the dividend", + "type": "string" + }, + "paid_qty": { + "description": "The paid quantity", + "type": "string" + } + }, + "required": [ + "entitled_qty", + "paid_qty", + "new_qty" + ], + "type": "object" + } + ], + "description": "Stock dividend", + "type": "object" + }, + "SearchVASPsResponse": { + "description": "Paginated VASP directory search results.", + "properties": { + "page": { + "example": 1, + "type": "integer" + }, + "pages": { + "example": 1, + "type": "integer" + }, + "total": { + "description": "Total count of matching records.", + "example": 1, + "type": "integer" + }, + "vasps": { + "example": [ + { + "id": "vasp-1", + "name": "Example Exchange" + } + ], + "items": { + "$ref": "#/components/schemas/VASP" + }, + "type": "array" + } + }, + "type": "object" + }, + "SpinoffActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "$ref": "#/components/schemas/CommonSpinoffActivityV2" + }, + { + "properties": { + "new_qty": { + "description": "The new quantity", + "type": "string" + }, + "source_qty": { + "description": "The source quantity", + "type": "string" + } + }, + "required": [ + "source_qty", + "new_qty" + ], + "type": "object" + } + ], + "description": "Spinoff", + "type": "object" + }, + "TenderOfferActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonVOFSubtypeActivityV2" + } + ], + "type": "object" + }, + "TimeInForce": { + "description": "The Time-In-Force values supported by Alpaca vary based on the order's security type. Here is a breakdown of the supported TIFs for each specific security type:\n- Equity trading: day, gtc, opg, cls, ioc, fok.\n- Options trading: day, gtc.\n- Crypto trading: gtc, ioc.\n\nBelow are the descriptions of each TIF:\n- day:\n A day order is eligible for execution only on the day it is live. By default, the order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled after the closing auction, it is automatically canceled. If submitted after the close, it is queued and submitted the following trading day. However, if marked as eligible for extended hours, the order can also execute during supported extended hours.\n\n- gtc:\n The order is good until canceled. Non-marketable GTC limit orders are subject to price adjustments to offset corporate actions affecting the issue. We do not currently support Do Not Reduce (DNR) orders to opt out of such price adjustments.\n\n- opg:\n Use this TIF with a market/limit order type to submit \"market on open\" (MOO) and \"limit on open\" (LOO) orders. This order is eligible to execute only in the market opening auction. Any unfilled orders after the open will be cancelled. OPG orders submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted after 7:00pm will be queued and routed to the following day's opening auction. On open/on close orders are routed to the primary exchange. Such orders do not necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange's auction rules.\n\n- cls:\n Use this TIF with a market/limit order type to submit \"market on close\" (MOC) and \"limit on close\" (LOC) orders. This order is eligible to execute only in the market closing auction. Any unfilled orders after the close will be cancelled. CLS orders submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted after 7:00pm will be queued and routed to the following day's closing auction. Only available with API v2.\n\n- ioc:\n An Immediate Or Cancel (IOC) order requires all or part of the order to be executed immediately. Any unfilled portion of the order is canceled. Only available with API v2. Most market makers who receive IOC orders will attempt to fill the order on a principal basis only, and cancel any unfilled balance. On occasion, this can result in the entire order being cancelled if the market maker does not have any existing inventory of the security in question.\n\n- fok:\n A Fill or Kill (FOK) order is only executed if the entire order quantity can be filled, otherwise the order is canceled. Only available with API v2.", + "enum": [ + "day", + "gtc", + "opg", + "cls", + "ioc", + "fok" + ], + "example": "day", + "title": "TimeInForce", + "type": "string" + }, + "TokenizationIssuer": { + "description": "The tokenized asset's issuer", + "enum": [ + "binance", + "coinbase", + "ondo", + "st0x", + "xstocks" + ], + "example": "xstocks", + "title": "TokenizationIssuer", + "type": "string" + }, + "TokenizationMintRequest": { + "properties": { + "issuer": { + "$ref": "#/components/schemas/TokenizationIssuer" + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "qty": { + "description": "The underlying quantity to convert into the tokenized asset. It can be fractional.", + "type": "string" + }, + "underlying_symbol": { + "description": "The underlying asset symbol", + "type": "string" + }, + "wallet_address": { + "description": "The wallet address to receive the tokenized asset", + "type": "string" + } + }, + "required": [ + "underlying_symbol", + "qty", + "issuer", + "network", + "wallet_address" + ], + "title": "TokenizationMintRequest", + "type": "object" + }, + "TokenizationMintResponse": { + "properties": { + "created_at": { + "format": "date-time", + "type": "string" + }, + "issuer": { + "$ref": "#/components/schemas/TokenizationIssuer" + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "qty": { + "description": "The quantity to convert for this tokenization request. It can be fractional.", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/TokenizationRequestStatus" + }, + "token_symbol": { + "description": "The tokenized asset symbol", + "type": "string" + }, + "tokenization_request_id": { + "description": "Unique identifier of the tokenization request set by Alpaca", + "type": "string" + }, + "underlying_symbol": { + "description": "The underlying asset symbol", + "type": "string" + } + }, + "required": [ + "tokenization_request_id", + "status", + "underlying_symbol", + "token_symbol", + "qty", + "created_at", + "issuer", + "network" + ], + "title": "TokenizationMintResponse", + "type": "object" + }, + "TokenizationNetwork": { + "description": "The token's blockchain network", + "enum": [ + "arbitrum", + "base", + "binance", + "cronos", + "ethereum", + "hypercore", + "hyperevm", + "mantle", + "robinhood", + "solana", + "ton", + "tron" + ], + "example": "solana", + "title": "TokenizationNetwork", + "type": "string" + }, + "TokenizationRequest": { + "properties": { + "account": { + "deprecated": true, + "description": "Alpaca account ID associated with this tokenization request. Use `client_account_id` instead.", + "example": "06b9d76e-1733-460c-844e-48d1ae0f10c3", + "type": "string", + "x-deprecation": { + "reason": "Use client_account_id instead.", + "since": "2026-07-15", + "sunset": "2026-10-15" + } + }, + "client_account_id": { + "description": "Alpaca account UUID of the Authorized Participant associated with this tokenization request", + "example": "06b9d76e-1733-460c-844e-48d1ae0f10c3", + "format": "uuid", + "type": "string" + }, + "client_external_account_id": { + "description": "Issuer-side account identifier of the Authorized Participant associated with this tokenization request", + "example": "AP-EXT-001", + "type": "string" + }, + "client_request_id": { + "description": "Authorized Participant-supplied label associated with this tokenization request", + "example": "ap-mint-2026-01-05-001", + "type": "string" + }, + "created_at": { + "example": "2026-01-02T15:04:05Z", + "format": "date-time", + "type": "string" + }, + "fees": { + "description": "Fees charged for this tokenization request", + "example": null, + "type": [ + "string", + "null" + ] + }, + "issuer": { + "$ref": "#/components/schemas/TokenizationIssuer" + }, + "issuer_account": { + "deprecated": true, + "description": "Issuer's account ID associated with this tokenization request. Use `client_external_account_id` instead.", + "example": "AP-EXT-001", + "type": "string", + "x-deprecation": { + "reason": "Use client_external_account_id instead.", + "since": "2026-07-15", + "sunset": "2026-10-15" + } + }, + "issuer_request_id": { + "description": "Unique identifier of the tokenization request set by the issuer", + "example": null, + "type": [ + "string", + "null" + ] + }, + "network": { + "$ref": "#/components/schemas/TokenizationNetwork" + }, + "qty": { + "description": "The quantity to convert for this tokenization request. It can be fractional.", + "example": "10", + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/TokenizationRequestStatus" + }, + "token_symbol": { + "description": "The tokenized asset symbol", + "example": "AAPLx", + "type": "string" + }, + "tokenization_request_id": { + "description": "Unique identifier of the tokenization request set by Alpaca", + "example": "5b1d6a3e-7f0a-4d2c-b8e1-9e6f1c0d2c4a", + "type": "string" + }, + "tx_hash": { + "description": "Transaction hash of the completed request on the blockchain", + "example": null, + "type": [ + "string", + "null" + ] + }, + "type": { + "$ref": "#/components/schemas/TokenizationRequestType" + }, + "underlying_symbol": { + "description": "The underlying asset symbol", + "example": "AAPL", + "type": "string" + }, + "updated_at": { + "example": null, + "format": "date-time", + "type": [ + "string", + "null" + ] + }, + "wallet_address": { + "description": "The wallet address associated with this tokenization request", + "example": "5dXY1aH2tQpV3wXmJg6Z7c8B4nKvF9bA1pQrSt2uVwYxXz", + "type": "string" + } + }, + "required": [ + "tokenization_request_id", + "created_at", + "type", + "status", + "underlying_symbol", + "token_symbol", + "qty", + "issuer", + "network", + "wallet_address" + ], + "title": "TokenizationRequest", + "type": "object" + }, + "TokenizationRequestStatus": { + "description": "Status of the tokenization request", + "enum": [ + "pending", + "rejected", + "completed" + ], + "example": "completed", + "title": "TokenizationRequestStatus", + "type": "string" + }, + "TokenizationRequestType": { + "description": "Tokenization request type", + "enum": [ + "mint", + "redeem" + ], + "example": "mint", + "title": "TokenizationRequestType", + "type": "string" + }, + "TradingActivities": { + "examples": [ + { + "activity_type": "FILL", + "cum_qty": "2", + "id": "20220202135509981::2d7be4ff-d1f3-43e9-856a-0f5cf5c5088e", + "leaves_qty": "0", + "order_id": "b5abe576-6a8a-49f3-a353-46b72c1ccae9", + "order_status": "filled", + "price": "174.78", + "qty": "2", + "side": "buy", + "symbol": "AAPL", + "transaction_time": "2022-02-02T18:55:09.981482Z", + "type": "fill" + } + ], + "properties": { + "activity_type": { + "$ref": "#/components/schemas/ActivityType" + }, + "cum_qty": { + "description": "The cumulative quantity of shares involved in the execution.", + "type": "string" + }, + "id": { + "description": "An id for the activity. Always in \"::\" format. Can be sent as page_token in requests to facilitate the paging of results.", + "type": "string" + }, + "leaves_qty": { + "description": "For partially_filled orders, the quantity of shares that are left to be filled.\n", + "type": "string" + }, + "order_id": { + "description": "The id for the order that filled.", + "format": "uuid", + "type": "string" + }, + "order_status": { + "$ref": "#/components/schemas/OrderStatus" + }, + "price": { + "description": "The per-share price that the trade was executed at.", + "type": "string" + }, + "qty": { + "description": "The number of shares involved in the trade execution.", + "type": "string" + }, + "side": { + "description": "buy or sell", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security being traded.", + "example": "AAPL", + "type": "string" + }, + "transaction_time": { + "description": "The time at which the execution occurred.", + "format": "date-time", + "type": "string" + }, + "type": { + "description": "fill or partial_fill", + "enum": [ + "fill", + "partial_fill" + ], + "example": "fill", + "type": "string" + } + }, + "title": "AccountTradingActivities", + "type": "object" + }, + "TransferDirection": { + "enum": [ + "INCOMING", + "OUTGOING" + ], + "example": "INCOMING", + "type": "string" + }, + "TravelRuleErrorResponse": { + "description": "A wallet or travel rule validation error.", + "oneOf": [ + { + "$ref": "#/components/schemas/TravelRuleValidationError" + }, + { + "$ref": "#/components/schemas/WalletError" + } + ] + }, + "TravelRuleFieldOption": { + "description": "Allowed value for a travel rule field that accepts a fixed set of choices.", + "properties": { + "description": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "value", + "description" + ], + "type": "object" + }, + "TravelRuleInfo": { + "description": "Travel rule information pertaining to the wallet being whitelisted. Identify the destination by providing beneficiary_vasp_id, setting beneficiary_is_self_hosted to true, or providing beneficiary_manual_entry. Either beneficiary_entity_name (for legal entities) or beneficiary_given_name and beneficiary_family_name (for natural persons) must be provided.", + "properties": { + "beneficiary_country_of_residence": { + "description": "ISO 3166-1 country code for the beneficiary's country of residence.", + "example": "US", + "type": "string" + }, + "beneficiary_entity_name": { + "description": "The beneficiary's legal entity name (required for legal entities)", + "example": "Alpaca Crypto LLC", + "minLength": 1, + "type": "string" + }, + "beneficiary_family_name": { + "description": "The beneficiary's last name (required for natural persons)", + "example": "Doe", + "minLength": 1, + "type": "string" + }, + "beneficiary_geographic_address_building_number": { + "description": "Building number in the beneficiary's geographic address.", + "example": "1", + "type": "string" + }, + "beneficiary_geographic_address_country": { + "description": "ISO 3166-1 alpha-2 or alpha-3 country code in the beneficiary's geographic address.", + "example": "US", + "type": "string" + }, + "beneficiary_geographic_address_post_code": { + "description": "Postal code in the beneficiary's geographic address.", + "example": "10001", + "type": "string" + }, + "beneficiary_geographic_address_street_name": { + "description": "Street name in the beneficiary's geographic address.", + "example": "Main Street", + "type": "string" + }, + "beneficiary_geographic_address_town_name": { + "description": "Town or city in the beneficiary's geographic address.", + "example": "New York", + "type": "string" + }, + "beneficiary_given_name": { + "description": "The beneficiary's first name (required for natural persons)", + "example": "John", + "minLength": 1, + "type": "string" + }, + "beneficiary_is_self_hosted": { + "description": "Beneficiary is receiving funds to a self-hosted / non-custodial wallet", + "example": true, + "type": "boolean" + }, + "beneficiary_manual_entry": { + "$ref": "#/components/schemas/TravelRuleManualEntry" + }, + "beneficiary_vasp_id": { + "description": "The W3C Decentralized Identifier (DID) representing the beneficiary's VASP.", + "example": "did:ethr:0xf1c002f9e7ca88018d6dcf1e86403fb2f5f055f4", + "pattern": "^did:[a-zA-Z0-9]*:.*$", + "type": "string" + } + }, + "title": "TravelRuleInfo", + "type": "object" + }, + "TravelRuleManualEntry": { + "description": "Information about a beneficiary VASP that is not available in the VASP directory.", + "properties": { + "vasp_name": { + "description": "The name of the receiving exchange.", + "example": "Alpaca", + "type": "string" + }, + "vasp_website": { + "description": "The receiving exchange's website.", + "example": "https://alpaca.markets", + "format": "uri", + "type": "string" + } + }, + "required": [ + "vasp_name", + "vasp_website" + ], + "type": "object" + }, + "TravelRuleNextAction": { + "description": "Action the client must take to satisfy travel rule requirements.", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "required_fields": { + "items": { + "$ref": "#/components/schemas/TravelRuleRequiredField" + }, + "type": "array" + }, + "type": { + "enum": [ + "REQUIRED", + "ONE_OF" + ], + "type": "string" + } + }, + "required": [ + "name", + "description", + "type" + ], + "type": "object" + }, + "TravelRuleRequiredField": { + "description": "Request field required to complete a travel rule action.", + "properties": { + "description": { + "type": "string" + }, + "field": { + "type": "string" + }, + "options": { + "description": "List of valid choices for 'enum' types. Null for simple strings or booleans.", + "items": { + "$ref": "#/components/schemas/TravelRuleFieldOption" + }, + "type": [ + "array", + "null" + ] + }, + "value_type": { + "enum": [ + "string", + "bool" + ], + "type": "string" + } + }, + "required": [ + "field", + "value_type", + "description" + ], + "type": "object" + }, + "TravelRuleValidationError": { + "description": "Travel rule validation failure and the actions required to correct it.", + "properties": { + "error_code": { + "$ref": "#/components/schemas/TravelRuleValidationErrorCode" + }, + "message": { + "example": "Please provide the beneficiary's name. Select one of the following options.", + "type": "string" + }, + "next_actions": { + "description": "A list of actions to be taken to fulfill information requirements.", + "example": [ + { + "description": "Provide the recipient's first and last name.", + "name": "supply_beneficiaryName_naturalPerson", + "required_fields": [ + { + "description": "The recipient's first name.", + "field": "beneficiary_given_name", + "value_type": "string" + }, + { + "description": "The recipient's last name.", + "field": "beneficiary_family_name", + "value_type": "string" + } + ], + "type": "ONE_OF" + }, + { + "description": "Provide the entity's legal name.", + "name": "supply_beneficiaryName_legalEntity", + "required_fields": [ + { + "description": "The legal name of the receiving entity.", + "field": "beneficiary_entity_name", + "value_type": "string" + } + ], + "type": "ONE_OF" + } + ], + "items": { + "$ref": "#/components/schemas/TravelRuleNextAction" + }, + "type": "array" + } + }, + "required": [ + "error_code", + "message", + "next_actions" + ], + "type": "object" + }, + "TravelRuleValidationErrorCode": { + "description": "Machine-readable code identifying the travel rule validation failure.", + "enum": [ + "INVALID_DATA", + "UNKNOWN_VASP", + "ADDRESS_BELONGS_TO_VASP", + "TRAVEL_RULE_ACTION_REQUIRED", + "BENEFICIARY_NAME_REQUIRED" + ], + "example": "BENEFICIARY_NAME_REQUIRED", + "type": "string" + }, + "USDPositionValues": { + "description": "Position values in USD. This is returned for LCT (non-USD) accounts only.", + "properties": { + "avg_entry_price": { + "description": "Average entry price of the position in USD", + "example": "71.43", + "format": "decimal", + "type": "string" + }, + "change_today": { + "description": "Percent change from last day price (by a factor of 1)", + "example": "0.67", + "format": "decimal", + "type": "string" + }, + "cost_basis": { + "description": "Total cost basis in USD", + "example": "333.33", + "format": "decimal", + "type": "string" + }, + "current_price": { + "description": "Current asset price per share in USD", + "example": "80.0", + "format": "decimal", + "type": "string" + }, + "lastday_price": { + "description": "Last day's asset price per share based on the closing value of the last trading day in USD", + "example": "79.33", + "format": "decimal", + "type": "string" + }, + "market_value": { + "description": "Total market value of the position in USD", + "example": "400.00", + "format": "decimal", + "type": "string" + }, + "unrealized_intraday_pl": { + "description": "Unrealized profit/loss in USD for the day", + "example": "6.67", + "format": "decimal", + "type": "string" + }, + "unrealized_intraday_plpc": { + "description": "Unrealized intraday profit/loss percent (by a factor of 1)", + "example": "0.0084", + "format": "decimal", + "type": "string" + }, + "unrealized_pl": { + "description": "Unrealized profit/loss in USD", + "example": "66.67", + "format": "decimal", + "type": "string" + }, + "unrealized_plpc": { + "description": "Unrealized profit/loss percent (by a factor of 1)", + "example": "0.2", + "format": "decimal", + "type": "string" + } + }, + "required": [ + "avg_entry_price", + "cost_basis" + ], + "title": "USDPositionValues", + "type": "object" + }, + "UnitSplitActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonSplitStockActivityV2" + }, + { + "properties": { + "alternate_cusip": { + "description": "CUSIP for the alternate security after the split", + "type": "string" + }, + "alternate_isin": { + "description": "ISIN for the alternate security after the split", + "type": "string" + }, + "alternate_qty": { + "description": "Quantity of alternate shares received", + "type": "string" + }, + "alternate_rate": { + "description": "Ratio of alternate shares received", + "type": "string" + }, + "alternate_symbol": { + "description": "Symbol for the alternate security after the split", + "type": "string" + }, + "effective_date": { + "description": "When the unit split becomes effective", + "format": "date", + "minLength": 1, + "type": "string" + }, + "new_symbol": { + "description": "Symbol of the new security after the split", + "type": "string" + }, + "old_symbol": { + "description": "Symbol of the old security before the split", + "type": "string" + } + }, + "required": [ + "old_symbol", + "new_symbol", + "alternate_cusip", + "alternate_symbol", + "alternate_rate", + "alternate_qty", + "effective_date" + ], + "type": "object" + } + ], + "description": "Unit split", + "type": "object" + }, + "UpdateWatchlistRequest": { + "anyOf": [ + { + "required": [ + "name" + ] + }, + { + "required": [ + "symbols" + ] + } + ], + "description": "Request format used for updating an existing watchlist with a set of assets and/or a name.", + "properties": { + "name": { + "description": "The new watchlist name.", + "type": "string" + }, + "symbols": { + "description": "List of asset symbols to include in the watchlist. The existing assets will be replaced with the new list.", + "items": { + "type": [ + "string", + "null" + ] + }, + "type": "array" + } + }, + "title": "PutWatchlistRequest", + "type": "object" + }, + "UpdateWhitelistedAddressTravelRuleInfoRequest": { + "description": "Travel rule information to associate with a whitelisted address.", + "properties": { + "travel_rule_info": { + "$ref": "#/components/schemas/TravelRuleInfo" + } + }, + "required": [ + "travel_rule_info" + ], + "type": "object" + }, + "VASP": { + "description": "Virtual Asset Service Provider returned by the directory search.", + "properties": { + "address": { + "type": "string" + }, + "city": { + "type": "string" + }, + "country": { + "description": "ISO 3166-1 alpha-2 country code for the VASP.", + "example": "US", + "type": "string" + }, + "did": { + "description": "The W3C Decentralized Identifier (DID) representing the VASP.", + "example": "did:ethr:0xf1c002f9e7ca88018d6dcf1e86403fb2f5f055f4", + "pattern": "^did:[a-zA-Z0-9]*:.*$", + "type": "string" + }, + "emailDomain": { + "type": "string" + }, + "id": { + "description": "Opaque identifier for the VASP directory record.", + "example": "vasp-1", + "type": "string" + }, + "name": { + "type": "string" + }, + "postalCode": { + "type": "string" + }, + "state": { + "type": "string" + }, + "website": { + "format": "uri", + "type": "string" + } + }, + "required": [ + "id", + "name" + ], + "type": "object" + }, + "WRMActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonCaActivityV2" + }, + { + "properties": { + "cusip": { + "description": "The CUSIP of the security involved with the activity", + "type": "string" + }, + "isin": { + "description": "The ISIN of the security involved with the activity", + "type": "string" + }, + "removed_qty": { + "description": "The removed quantity", + "type": "string" + }, + "symbol": { + "description": "The symbol of the security involved with the activity", + "type": "string" + } + }, + "required": [ + "cusip", + "symbol", + "removed_qty" + ], + "type": "object" + } + ], + "description": "Worthless Removal", + "type": "object" + }, + "WalletError": { + "additionalProperties": false, + "description": "A wallet error response.", + "properties": { + "message": { + "example": "travel_rule_info is missing", + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "WalletFeeEstimateResponse": { + "description": "Estimated on-chain fee breakdown for a proposed crypto withdrawal, including the total fee and the underlying network (gas) fee.", + "properties": { + "fee": { + "example": "0.0505", + "format": "decimal", + "type": "string" + }, + "network_fee": { + "example": "0.0825", + "format": "decimal", + "type": "string" + } + }, + "type": "object" + }, + "WarrantExerciseElectionActivityV2": { + "allOf": [ + { + "$ref": "#/components/schemas/CommonNTAActivityV2" + }, + { + "$ref": "#/components/schemas/CommonVOFSubtypeActivityV2" + } + ], + "type": "object" + }, + "Watchlist": { + "description": "The watchlist API provides CRUD operation for the account's watchlist. An account can have multiple watchlists and each is uniquely identified by id but can also be addressed by user-defined name. Each watchlist is an ordered list of assets.\n", + "examples": [ + { + "account_id": "abe25343-a7ba-4255-bdeb-f7e013e9ee5d", + "assets": [ + { + "class": "us_equity", + "easy_to_borrow": true, + "exchange": "NASDAQ", + "fractionable": true, + "id": "8ccae427-5dd0-45b3-b5fe-7ba5e422c766", + "marginable": true, + "name": "Tesla, Inc. Common Stock", + "shortable": true, + "status": "active", + "symbol": "TSLA", + "tradable": true + } + ], + "created_at": "2022-01-31T21:49:05.14628Z", + "id": "3174d6df-7726-44b4-a5bd-7fda5ae6e009", + "name": "Primary Watchlist", + "updated_at": "2022-01-31T21:49:05.14628Z" + } + ], + "properties": { + "account_id": { + "description": "account ID", + "format": "uuid", + "type": "string" + }, + "assets": { + "description": "the content of this watchlist, in the order as registered by the client", + "items": { + "$ref": "#/components/schemas/Assets" + }, + "type": "array" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "id": { + "description": "watchlist id", + "format": "uuid", + "type": "string" + }, + "name": { + "description": "user-defined watchlist name (up to 64 characters)", + "minLength": 1, + "type": "string" + }, + "updated_at": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "account_id", + "created_at", + "updated_at", + "name" + ], + "title": "Watchlist", + "type": "object" + }, + "WatchlistWithoutAsset": { + "description": "The watchlist API provides CRUD operation for the account's watchlist. An account can have multiple watchlists and each is uniquely identified by id but can also be addressed by user-defined name.\n", + "examples": [ + { + "account_id": "abe25343-a7ba-4255-bdeb-f7e013e9ee5d", + "created_at": "2022-01-31T21:49:05.14628Z", + "id": "3174d6df-7726-44b4-a5bd-7fda5ae6e009", + "name": "Primary Watchlist", + "updated_at": "2022-01-31T21:49:05.14628Z" + } + ], + "properties": { + "account_id": { + "description": "account ID", + "format": "uuid", + "type": "string" + }, + "created_at": { + "format": "date-time", + "type": "string" + }, + "id": { + "description": "watchlist id", + "format": "uuid", + "type": "string" + }, + "name": { + "description": "user-defined watchlist name (up to 64 characters)", + "minLength": 1, + "type": "string" + }, + "updated_at": { + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "account_id", + "created_at", + "updated_at", + "name" + ], + "title": "Watchlist", + "type": "object" + }, + "WhitelistedAddress": { + "properties": { + "address": { + "description": "The whitelisted address", + "type": "string" + }, + "asset": { + "description": "Symbol of underlying asset for the whitelisted address", + "type": "string" + }, + "chain": { + "description": "Underlying network this address represents", + "type": "string" + }, + "created_at": { + "description": "Timestamp (RFC3339) of account creation.", + "format": "date-time", + "type": "string" + }, + "id": { + "description": "Unique ID for whitelisted address", + "type": "string" + }, + "status": { + "description": "Status of whitelisted address which is either APPROVED or PENDING. Whitelisted addresses will be subjected to a 24 waiting period. After the waiting period is over the status will become APPROVED.", + "enum": [ + "APPROVED", + "PENDING" + ], + "type": "string" + }, + "travel_rule_info": { + "allOf": [ + { + "$ref": "#/components/schemas/TravelRuleInfo" + } + ], + "description": "Travel rule information associated with the whitelisted address." + } + }, + "type": "object" + }, + "bic": { + "description": "Business Identifier Code (BIC/SWIFT).", + "example": "IRVTUS3NXXX", + "maxLength": 11, + "minLength": 11, + "pattern": "^[A-Z0-9]{11}$", + "type": "string" + }, + "calendar_day": { + "description": "A calendar day.", + "properties": { + "core_end": { + "description": "The end time of the core market session.", + "example": "2025-01-02T16:00:00-05:00", + "format": "date-time", + "type": "string" + }, + "core_start": { + "description": "The start time of the core market session.", + "example": "2025-01-02T09:30:00-05:00", + "format": "date-time", + "type": "string" + }, + "date": { + "description": "The date of the calendar day.", + "example": "2025-01-02", + "format": "date", + "type": "string" + }, + "lunch_end": { + "description": "The end time of the lunch session.", + "format": "date-time", + "type": "string" + }, + "lunch_start": { + "description": "The start time of the lunch session.", + "format": "date-time", + "type": "string" + }, + "post_end": { + "description": "The end time of the after-hours session.", + "example": "2025-01-02T20:00:00-05:00", + "format": "date-time", + "type": "string" + }, + "post_start": { + "description": "The start time of the after-hours session.", + "example": "2025-01-02T16:00:00-05:00", + "format": "date-time", + "type": "string" + }, + "pre_end": { + "description": "The end time of the pre-market session.", + "example": "2025-01-02T09:30:00-05:00", + "format": "date-time", + "type": "string" + }, + "pre_start": { + "description": "The start time of the pre-market session.", + "example": "2025-01-02T04:00:00-05:00", + "format": "date-time", + "type": "string" + }, + "settlement_date": { + "description": "The settlement date.", + "example": "2025-01-03", + "format": "date", + "type": "string" + } + }, + "required": [ + "date", + "core_start", + "core_end" + ], + "type": "object" + }, + "clock": { + "properties": { + "is_market_day": { + "description": "Whether the clock is on a market day.", + "type": "boolean" + }, + "market": { + "$ref": "#/components/schemas/public_market" + }, + "next_market_close": { + "description": "Next market close timestamp", + "format": "date-time", + "type": "string" + }, + "next_market_open": { + "description": "Next market open timestamp", + "format": "date-time", + "type": "string" + }, + "phase": { + "$ref": "#/components/schemas/phase" + }, + "phase_until": { + "description": "The end of the current phase.", + "format": "date-time", + "type": "string" + }, + "timestamp": { + "description": "The time on the clock.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "market", + "timestamp", + "is_market_day", + "next_market_open", + "next_market_close", + "phase", + "phase_until" + ], + "type": "object" + }, + "clock_resp": { + "description": "Clock response.", + "properties": { + "clocks": { + "items": { + "$ref": "#/components/schemas/clock" + }, + "type": "array" + } + }, + "required": [ + "clocks" + ], + "type": "object" + }, + "legacy_calendar_day": { + "description": "A calendar day.", + "properties": { + "close": { + "description": "The time the market closes at on this date in HH:MM format.", + "example": "16:00", + "type": "string" + }, + "date": { + "description": "Date string in YYYY-MM-DD format.", + "example": "2025-01-02", + "format": "date", + "type": "string" + }, + "open": { + "description": "The time the market opens at on this date in HH:MM format.", + "example": "09:30", + "type": "string" + }, + "session_close": { + "description": "The time the session closes at on this date in HHMM format.", + "example": "2000", + "type": "string" + }, + "session_open": { + "description": "The time the session opens at on this date in HHMM format.", + "example": "0400", + "type": "string" + }, + "settlement_date": { + "description": "Date string in YYYY-MM-DD format. Representing the settlement date for the trade date.", + "example": "2025-01-03", + "format": "date", + "type": "string" + } + }, + "required": [ + "date", + "open", + "close", + "session_open", + "session_close", + "settlement_date" + ], + "type": "object" + }, + "legacy_clock": { + "example": { + "is_open": true, + "next_close": "2025-06-24T16:00:00-04:00", + "next_open": "2025-06-25T09:30:00-04:00", + "timestamp": "2025-06-24T14:15:22-04:00" + }, + "properties": { + "is_open": { + "description": "Whether or not the market is open.", + "type": "boolean" + }, + "next_close": { + "description": "Next market close timestamp.", + "format": "date-time", + "type": "string" + }, + "next_open": { + "description": "Next market open timestamp.", + "format": "date-time", + "type": "string" + }, + "timestamp": { + "description": "Current timestamp.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "timestamp", + "is_open", + "next_open", + "next_close" + ], + "title": "Clock", + "type": "object" + }, + "legacy_public_calendar_resp": { + "items": { + "$ref": "#/components/schemas/legacy_calendar_day" + }, + "type": "array" + }, + "market": { + "description": "The market identifier (MIC, BIC, or acronym).", + "enum": [ + "BMO", + "BNYM", + "BOATS", + "CEUX", + "CHIX", + "HKEX", + "IEX", + "IEXG", + "ISE", + "LSE", + "MTA", + "MTAA", + "NASDAQ", + "NYSE", + "OCEA", + "OPRA", + "OTC", + "OTCM", + "SIFMA", + "TADAWUL", + "XAMS", + "XBRU", + "XDUB", + "XETR", + "XETRA", + "XHKG", + "XLIS", + "XLON", + "XNAS", + "XNYS", + "XPAR", + "XSAU" + ], + "type": "string" + }, + "market_acronym": { + "description": "The acronym of the market.", + "example": "NYSE", + "type": "string" + }, + "market_name": { + "description": "The full name of the market.", + "example": "New York Stock Exchange", + "type": "string" + }, + "market_timezone": { + "description": "The timezone of the market.", + "example": "America/New_York", + "type": "string" + }, + "mic": { + "description": "Market identifier code (ISO 10383).", + "example": "XNYS", + "maxLength": 4, + "minLength": 4, + "pattern": "^[A-Z0-9]{4}$", + "type": "string" + }, + "phase": { + "enum": [ + "closed", + "pre", + "core", + "lunch", + "post" + ], + "type": "string" + }, + "public_calendar_resp": { + "description": "Calendar response.", + "properties": { + "calendar": { + "description": "The market calendar.", + "items": { + "$ref": "#/components/schemas/calendar_day" + }, + "type": "array" + }, + "market": { + "$ref": "#/components/schemas/public_market" + } + }, + "required": [ + "market", + "calendar" + ], + "type": "object" + }, + "public_market": { + "description": "A market.", + "properties": { + "acronym": { + "$ref": "#/components/schemas/market_acronym" + }, + "bic": { + "$ref": "#/components/schemas/bic" + }, + "mic": { + "$ref": "#/components/schemas/mic" + }, + "name": { + "$ref": "#/components/schemas/market_name" + }, + "timezone": { + "$ref": "#/components/schemas/market_timezone" + } + }, + "required": [ + "acronym", + "name", + "timezone" + ], + "type": "object" + } + }, + "securitySchemes": { + "API_Key": { + "description": "", + "in": "header", + "name": "APCA-API-KEY-ID", + "type": "apiKey" + }, + "API_Secret": { + "description": "", + "in": "header", + "name": "APCA-API-SECRET-KEY", + "type": "apiKey" + } + } + }, + "info": { + "contact": { + "email": "support@alpaca.markets", + "name": "Alpaca Support", + "url": "https://alpaca.markets/support" + }, + "description": "Alpaca's Trading API is a modern platform for algorithmic trading.", + "termsOfService": "https://s3.amazonaws.com/files.alpaca.markets/disclosures/library/TermsAndConditions.pdf", + "title": "Trading API", + "version": "2.0.1" + }, + "openapi": "3.1.2", + "paths": { + "/v1/locates": { + "get": { + "description": "Returns locates filtered by status, symbol, or date range. Results are sorted by `created_at` descending, with `id` descending as the tie-breaker. This endpoint is not available in paper trading.", + "operationId": "listLocates", + "parameters": [ + { + "$ref": "#/components/parameters/PageToken" + }, + { + "description": "Maximum number of results to return.", + "in": "query", + "name": "limit", + "required": false, + "schema": { + "default": 1000, + "maximum": 10000, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Filter by locate status.", + "example": "active", + "in": "query", + "name": "status", + "required": false, + "schema": { + "$ref": "#/components/schemas/LocateStatus" + } + }, + { + "description": "Filter by stock symbol.", + "example": "TSLA", + "in": "query", + "name": "symbol", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Filter locates with locate trading date on or after this date. Format: YYYY-MM-DD. The locate trading date uses America/New_York and rolls at 8pm ET.", + "in": "query", + "name": "start", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter locates with locate trading date before this date (exclusive). Format: YYYY-MM-DD. The locate trading date uses America/New_York and rolls at 8pm ET.", + "in": "query", + "name": "end", + "required": false, + "schema": { + "format": "date", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListLocatesResponse" + } + } + }, + "description": "Returns a list of locates for the account, or an empty list if no locates are found." + }, + "400": { + "content": { + "application/json": { + "examples": { + "invalid_input": { + "value": { + "code": "invalid_input", + "message": "invalid input" + } + } + }, + "schema": { + "$ref": "#/components/schemas/LocateError" + } + } + }, + "description": "Invalid locate request." + }, + "401": { + "content": { + "application/json": { + "example": { + "message": "Unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key." + }, + "403": { + "content": { + "application/json": { + "example": { + "message": "Forbidden" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "User has no access to a resource." + }, + "500": { + "content": { + "application/json": { + "example": { + "message": "Internal Server Error" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on Slack or on the Community Forum." + } + }, + "summary": "List Locates", + "tags": [ + "Locates" + ] + }, + "post": { + "description": "Creates a locate request for a short sale. This endpoint is not available in paper trading.\n\n**Idempotency**: Reusing the same key with the same request returns the original\nlocate response. Reusing the same key with a different request returns HTTP 422.\n", + "operationId": "createLocates", + "parameters": [ + { + "$ref": "#/components/parameters/LegacyIdempotencyKey" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateLocateRequest" + } + } + }, + "description": "Locate request details.", + "required": true + }, + "responses": { + "201": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Locate" + } + } + }, + "description": "Created" + }, + "400": { + "content": { + "application/json": { + "examples": { + "invalid_input": { + "value": { + "code": "invalid_input", + "message": "invalid input: quantity must be in round lots of 100" + } + }, + "invalid_limit_price": { + "value": { + "code": "invalid_limit_price", + "message": "invalid limit_price" + } + }, + "invalid_request_body": { + "value": { + "code": "invalid_request_body", + "message": "invalid request body" + } + } + }, + "schema": { + "$ref": "#/components/schemas/LocateError" + } + } + }, + "description": "Invalid locate request." + }, + "401": { + "content": { + "application/json": { + "example": { + "message": "Unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key." + }, + "403": { + "content": { + "application/json": { + "example": { + "message": "Forbidden" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "User has no access to a resource." + }, + "422": { + "content": { + "application/json": { + "examples": { + "easy_to_borrow": { + "value": { + "code": "easy_to_borrow", + "message": "security is easy-to-borrow and does not require a locate" + } + }, + "idempotency_key_conflict": { + "value": { + "code": "idempotency_key_conflict", + "message": "idempotency key was already used with a different request" + } + }, + "insufficient_buying_power": { + "value": { + "code": "insufficient_buying_power", + "message": "insufficient buying power to cover locate fee" + } + }, + "quote_unavailable": { + "value": { + "code": "quote_unavailable", + "message": "locate quote is unavailable for this symbol" + } + }, + "symbol_not_found": { + "value": { + "code": "symbol_not_found", + "message": "symbol not found" + } + }, + "threshold_security": { + "value": { + "code": "threshold_security", + "message": "security is on the threshold list and cannot be located" + } + } + }, + "schema": { + "$ref": "#/components/schemas/LocateError" + } + } + }, + "description": "Cannot complete locate request." + }, + "500": { + "content": { + "application/json": { + "example": { + "message": "Internal Server Error" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on Slack or on the Community Forum." + } + }, + "summary": "Create Locate", + "tags": [ + "Locates" + ] + } + }, + "/v1/locates/{locate_id}": { + "get": { + "description": "Returns a locate by ID. This endpoint is not available in paper trading.", + "operationId": "getLocate", + "parameters": [ + { + "description": "The locate ID.", + "example": "550e8400-e29b-41d4-a716-446655440000", + "in": "path", + "name": "locate_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Locate" + } + } + }, + "description": "Returns the requested locate." + }, + "400": { + "content": { + "application/json": { + "examples": { + "invalid_input": { + "value": { + "code": "invalid_input", + "message": "invalid input" + } + } + }, + "schema": { + "$ref": "#/components/schemas/LocateError" + } + } + }, + "description": "Invalid locate request." + }, + "401": { + "content": { + "application/json": { + "example": { + "message": "Unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key." + }, + "403": { + "content": { + "application/json": { + "example": { + "message": "Forbidden" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "User has no access to a resource." + }, + "404": { + "content": { + "application/json": { + "example": { + "message": "locate not found" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Not found" + }, + "500": { + "content": { + "application/json": { + "example": { + "message": "Internal Server Error" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on Slack or on the Community Forum." + } + }, + "summary": "Get Locate", + "tags": [ + "Locates" + ] + } + }, + "/v1/locates/quotes": { + "get": { + "description": "Returns locate availability and pricing for one or more symbols. This endpoint is not available in paper trading.", + "operationId": "listLocateQuotes", + "parameters": [ + { + "description": "Comma-separated list of stock symbols. Maximum 100 unique symbols.", + "example": "TSLA,AAPL", + "in": "query", + "name": "symbols", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListLocateQuotesResponse" + } + } + }, + "description": "Returns locate quotes for the requested symbols." + }, + "400": { + "content": { + "application/json": { + "examples": { + "invalid_symbols": { + "value": { + "code": "invalid_symbols", + "message": "symbols must contain at most 100 unique symbols" + } + } + }, + "schema": { + "$ref": "#/components/schemas/LocateError" + } + } + }, + "description": "Invalid locate quote request." + }, + "401": { + "content": { + "application/json": { + "example": { + "message": "Unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key." + }, + "403": { + "content": { + "application/json": { + "example": { + "message": "Forbidden" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "User has no access to a resource." + }, + "500": { + "content": { + "application/json": { + "example": { + "message": "Internal Server Error" + }, + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + }, + "description": "Internal server error. We recommend retrying these later. If the issue persists, please contact us on Slack or on the Community Forum." + } + }, + "summary": "Get Locate Quotes", + "tags": [ + "Locates" + ] + } + }, + "/v2beta1/events/activities": { + "get": { + "description": "The Events API sends the real-time events and provides historical queries with SSE (Server Sent Events).\n\nThis endpoint streams events on account activities.\n\nHistorical events are streamed immediately if queried, and updates are pushed as events occur.\n\nQuery parameter rules:\n- If `until` is specified, `since` is required.\n- If `until_id` is specified, `since_id` is required.\n- You cannot use `since` and `since_id` together.\nBehavior:\n- If `since` or `since_id` is not specified, this will not return any historic data.\n- If `until` or `until_id` is specified, stream will end at the specified point with status 200.\n\n---\n\nWarning: Currently, OAS-3 does not fully support responses from an SSE API.\n\nIn case the client code is generated from this OAS spec, please do not specify `since` and `until`, as the generated client may hang forever waiting for the response to end.\n\nIf you require the streaming capabilities, we recommend not using the generated clients for this specific endpoint until the OAS-3 standards define how to represent this behavior.\n\n---\n\n### Comment messages\nAccording to the SSE specification, any line that starts with a colon is a comment which does not contain data. It is typically a free text that does not follow any data schema. A few examples mentioned below for comment messages.\n\n##### Slow client\n\nThe server sends a comment when the client is not consuming messages fast enough. Example: `: you are reading too slowly, dropped 10000 messages`\n\n##### Internal server error\n\nAn error message is sent as a comment when the server closes the connection on an internal server error (only sent by the v2 and v2beta1 endpoints). Example: `: internal server error`\n\n---", + "operationId": "subscribeToActivitiesSSE", + "parameters": [ + { + "description": "Format: RFC3339 or YYYY-MM-DD", + "in": "query", + "name": "since", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Format: RFC3339 or YYYY-MM-DD", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "in": "query", + "name": "since_id", + "schema": { + "format": "ulid", + "type": "string" + } + }, + { + "in": "query", + "name": "until_id", + "schema": { + "format": "ulid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/event-stream": { + "schema": { + "items": { + "$ref": "#/components/schemas/ActivityEventV2" + }, + "type": "array" + } + } + }, + "description": "Connected. Events will now start streaming as long as you keep the connection open." + } + }, + "summary": "Subscribe to Activity Events (SSE)", + "tags": [ + "Events" + ] + } + }, + "/v2/account": { + "get": { + "description": "Returns your account details.", + "operationId": "getAccount", + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "account_blocked": false, + "account_number": "PALPACA_123", + "accrued_fees": "0", + "admin_configurations": {}, + "balance_asof": "2023-09-27", + "buying_power": "245432.61", + "cash": "122086.5", + "created_at": "2023-01-01T18:20:20.272275Z", + "crypto_status": "ACTIVE", + "crypto_tier": 1, + "currency": "USD", + "effective_buying_power": "245432.61", + "equity": "123346.11", + "id": "1d9eed04-be39-4e01-9b84-a48ac5bbafcf", + "initial_margin": "629.8", + "intraday_adjustments": "0", + "last_equity": "122011.09751111286868", + "last_maintenance_margin": "480.73", + "long_market_value": "1259.61", + "maintenance_margin": "377.88", + "multiplier": "2", + "non_marginable_buying_power": "122086.5", + "options_buying_power": "122716.305", + "options_trading_level": 2, + "pending_reg_taf_fees": "0", + "pending_transfer_in": "0", + "portfolio_value": "123346.11", + "position_market_value": "1259.61", + "regt_buying_power": "245432.61", + "short_market_value": "0", + "shorting_enabled": true, + "sma": "123369.74", + "status": "ACTIVE", + "trade_suspended_by_user": false, + "trading_blocked": false, + "transfers_blocked": false, + "user_configurations": null + }, + "schema": { + "$ref": "#/components/schemas/Account" + } + } + }, + "description": "OK" + } + }, + "summary": "Get Account", + "tags": [ + "Accounts" + ] + } + }, + "/v2/account/activities": { + "get": { + "description": "Returns a list of activities\n\nNotes:\n* Pagination is handled using the `page_token` and `page_size` parameters.\n* `page_token` represents the ID of the last item on your current page of results.\n For example, if the ID of the last activity in your first response is `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you would pass that value as `page_token` to retrieve the next page of results.", + "operationId": "getAccountActivities", + "parameters": [ + { + "description": "A comma-separated list of activity types used to filter the results.", + "explode": false, + "in": "query", + "name": "activity_types", + "schema": { + "items": { + "$ref": "#/components/schemas/ActivityType" + }, + "type": "array" + }, + "style": "form" + }, + { + "description": "The activity category. Cannot be used with \"activity_types\" parameter.", + "in": "query", + "name": "category", + "schema": { + "enum": [ + "trade_activity", + "non_trade_activity" + ], + "type": "string" + } + }, + { + "description": "Filter activities associated with a specific order. Useful for retrieving the fills that make up a completely filled order.", + "in": "query", + "name": "order_id", + "schema": { + "example": "fe060a1b-5b45-4eba-ba46-c3a3345d8255", + "format": "uuid", + "type": "string" + } + }, + { + "description": "Filter activities by their creation date (created_at), not the activity's settlement date. For non-trade activities such as fees, the creation date is typically the day after the trade date (in UTC). Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "date", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Get activities created before this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Get activities created after this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "after", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "The chronological order of response based on the activity datetime.", + "in": "query", + "name": "direction", + "schema": { + "default": "desc", + "enum": [ + "asc", + "desc" + ], + "example": "desc", + "type": "string" + } + }, + { + "description": "The maximum number of entries to return in the response.", + "in": "query", + "name": "page_size", + "schema": { + "default": 100, + "maximum": 100, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Token used for pagination. Provide the ID of the last activity from the last page to retrieve the next set of results.", + "in": "query", + "name": "page_token", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/TradingActivities" + }, + { + "$ref": "#/components/schemas/NonTradeActivities" + } + ], + "description": "Will be a mix of TradingActivity or NonTradeActivity objects based on what is passed in the activity_types parameter" + }, + "type": "array" + } + } + }, + "description": "returns an array of Account activities" + } + }, + "summary": "Retrieve Account Activities", + "tags": [ + "Account Activities" + ] + } + }, + "/v2/account/activities/{activity_type}": { + "get": { + "description": "Returns account activity entries for a specific type of activity.", + "operationId": "getAccountActivitiesByActivityType", + "parameters": [ + { + "description": "Filter activities associated with a specific order. Useful for retrieving the fills that make up a completely filled order.", + "in": "query", + "name": "order_id", + "schema": { + "example": "fe060a1b-5b45-4eba-ba46-c3a3345d8255", + "format": "uuid", + "type": "string" + } + }, + { + "description": "Filter activities by their creation date (created_at), not the activity's settlement date. For non-trade activities such as fees, the creation date is typically the day after the trade date (in UTC). Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "date", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Get activities created before this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "until", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "Get activities created after this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.", + "in": "query", + "name": "after", + "schema": { + "format": "date-time", + "type": "string" + } + }, + { + "description": "The chronological order of response based on the activity datetime.", + "in": "query", + "name": "direction", + "schema": { + "default": "desc", + "enum": [ + "asc", + "desc" + ], + "example": "desc", + "type": "string" + } + }, + { + "description": "The maximum number of entries to return in the response.", + "in": "query", + "name": "page_size", + "schema": { + "default": 100, + "maximum": 100, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Token used for pagination. Provide the ID of the last activity from the last page to retrieve the next set of results.", + "in": "query", + "name": "page_token", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "description": "Will be one of a TradingActivity or NonTradeActivity based on activity_type used in path", + "oneOf": [ + { + "$ref": "#/components/schemas/TradingActivities" + }, + { + "$ref": "#/components/schemas/NonTradeActivities" + } + ] + }, + "type": "array" + } + } + }, + "description": "returns an array of Account activities" + } + }, + "summary": "Retrieve Account Activities of Specific Type", + "tags": [ + "Account Activities" + ] + }, + "parameters": [ + { + "description": "The activity type you want to view entries for. A list of valid activity types can be found at the bottom of this page.", + "in": "path", + "name": "activity_type", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v2/account/configurations": { + "get": { + "description": "gets the current account configuration values", + "operationId": "getAccountConfig", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountConfigurations" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Get Account Configurations", + "tags": [ + "Account Configurations" + ] + }, + "patch": { + "description": "Updates and returns the current account configuration values", + "operationId": "patchAccountConfig", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountConfigurations" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountConfigurations" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Account Configurations", + "tags": [ + "Account Configurations" + ] + } + }, + "/v2/account/portfolio/history": { + "get": { + "description": "Returns timeseries data about equity and profit/loss (P/L) of the account in requested timespan.", + "operationId": "getAccountPortfolioHistory", + "parameters": [ + { + "description": "The duration of the data in `number` + `unit` format, such as 1D, where `unit` can be D for day, W for week, M for month and A for year. Defaults to 1M.\n\nOnly two of `start`, `end` and `period` can be specified at the same time.\n\nFor intraday timeframes (\\<1D) only 30 days or less can be queried, for 1D resolutions there is no such limit, data is available since the\ncreation of the account.\n", + "in": "query", + "name": "period", + "schema": { + "type": "string" + } + }, + { + "description": "The resolution of time window. 1Min, 5Min, 15Min, 1H, or 1D. If omitted, 1Min for less than 7 days period,\n15Min for less than 30 days, or otherwise 1D.\n\nFor queries with longer than 30 days of `period`, the system only accepts 1D as `timeframe`.\n", + "in": "query", + "name": "timeframe", + "schema": { + "type": "string" + } + }, + { + "description": "For intraday resolutions (<1D) this specifies which timestamps to return data points for:\n\nAllowed values are:\n- **market_hours**\n\n Only timestamps for the core equity trading hours are returned (usually 9:30am to 4:00pm, trading days only)\n\n- **extended_hours**\n\n Returns timestamps for the whole session including extended hours (usually 4:00am to 8:00pm, trading days only)\n\n- **continuous**\n\n Returns price data points 24/7 (for off-session times too). To calculate the equity values we are using the following prices:\n\n Between 4:00am and 10:00pm on trading days the valuation will be calculated based on the last trade (extended hours and normal hours respectively).\n\n After 10:00pm, until the next session open the equities will be valued at their official closing price on the primary exchange.\n", + "in": "query", + "name": "intraday_reporting", + "schema": { + "default": "market_hours", + "enum": [ + "market_hours", + "extended_hours", + "continuous" + ], + "type": "string" + } + }, + { + "description": "The timestamp the data is returned starting from in RFC3339 format (including timezone specification). Defaults to `end` minus `period`\n\nIf provided, the `start` value is always normalized to the `America/New_York` timezone and adjusted to the nearest `timeframe` interval, e.g. seconds are always truncated and the time is rounded backwards to the nearest interval of `1Min`, `5Min`, `15Min`, or `1H`.\n\nIf `timeframe=1D` and `start` is not a valid trading date, find the next available trading date. For example, if `start` occurs on Saturday or Sunday after converting to the America/New_York timezone, `start` is adjusted to the first weekday that is not a market holiday (e.g. Monday).\n\nIf `timeframe` is less than `1D` and `intraday_reporting` is not `continuous`, `start` always reflects the beginning of a market session. If `start` is between midnight and the end (inclusive) of an active trading day, `start` is set to the beginning of the session on the specified day. Otherwise, if `start` occurs outside of the market session, the next available market date is used.\n\nFor example, when `intraday_reporting=market_hours` and `start=2023-10-19T23:59:59-04:00`, the provided `start` date occurs outside of the regular market session. The effective `start` timestamp is adjusted to the beginning of the next session: `2023-10-20T09:30:00-04:00`\n\n`start` may be be combined with one of `end` or `period`.\n\nProviding all of `start`, `end`, and `period` is invalid.\n", + "in": "query", + "name": "start", + "schema": { + "example": "2021-03-16T18:38:01Z", + "format": "date-time", + "type": "string" + } + }, + { + "description": "`pnl_reset` defines how we are calculating the baseline values for Profit And Loss (pnl) for queries with `timeframe` less than 1D (intraday queries).\n\nThe default behavior for intraday queries is that we reset the pnl value to the previous day's closing equity for each **trading** day.\n\nIn case of crypto (given its continuous nature), this might not be desired: specifying \"no_reset\" disables this behavior and all pnl values\nreturned will be relative to the closing equity of the previous trading day.\n\nFor 1D resolution all PnL values are calculated relative to the `base_value`, we are not resetting the base value.\n", + "in": "query", + "name": "pnl_reset", + "schema": { + "default": "per_day", + "enum": [ + "no_reset", + "per_day" + ], + "type": "string" + } + }, + { + "description": "The timestamp the data is returned up to in RFC3339 format (including timezone specification). Defaults to the current time.\n\nIf provided, the `end` value is always normalized to the `America/New_York` timezone and adjusted to the nearest `timeframe` interval, e.g. seconds are always truncated and the time is rounded backwards to the nearest interval of `1Min`, `5Min`, `15Min`, or `1H`.\n\nWhen `intraday_reporting` is either `market_hours` or `extended_hours`, the `end` value is adjusted to not occur after session close on the specified day. For example if the `intraday_reporting` is `extended_hours`, and the timestamp specified is `2023-10-19T21:33:00-04:00`, `end` is adjusted to `2023-10-19T20:00:00-04:00`.\n\n`end` may be combined with `start` or `period`.\n\nProviding all of `start`, `end`, and `period` is invalid.\n", + "in": "query", + "name": "end", + "schema": { + "example": "2021-03-16T18:38:01Z", + "format": "date-time", + "type": "string" + } + }, + { + "description": "**deprecated**: Users are strongly advised to **rely on the `intraday_reporting` query parameter** for better control\nof the reporting range.\n\nIf true, include extended hours in the result. This is effective only for timeframe less than 1D.\n", + "in": "query", + "name": "extended_hours", + "schema": { + "type": "string" + } + }, + { + "description": "The cashflow activities to include in the report. One of 'ALL', 'NONE', or a comma-separated list of activity types.", + "examples": { + "all": { + "value": "ALL" + }, + "cash_transfers": { + "summary": "Include cash movements.", + "value": "JNLC,CSD,CSW" + }, + "none": { + "value": "NONE" + } + }, + "in": "query", + "name": "cashflow_types", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "example-cashflows": { + "value": { + "base_value": 8413.04, + "base_value_asof": "2026-04-06", + "cashflow": { + "CSD": [ + 9.93, + 10.13, + 10.16, + 0 + ], + "DIV": [ + 0, + 0, + 0.63, + 0 + ] + }, + "equity": [ + 8425.21, + 8639.77, + 8766.1, + 8835.31 + ], + "profit_loss": [ + 12.17, + 214.56, + 126.33, + 69.21 + ], + "profit_loss_pct": [ + 0.0014, + 0.0255, + 0.0146, + 0.0079 + ], + "timeframe": "1D", + "timestamp": [ + 1775606400, + 1775692800, + 1775779200, + 1775865600 + ] + } + }, + "example-intraday-query-15min-1d": { + "value": { + "base_value": 2774.16, + "base_value_asof": "2023-10-18", + "cashflow": { + "CSD": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 100, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + }, + "equity": [ + 2773.79, + 2769.04, + 2768.65, + 2765.11, + 2763.03, + 2763.17, + 2763.17, + 2763.47, + 2763.91, + 2768.13, + 2774.98, + 2757.94, + 2757.65, + 2774.54, + 2775.58, + 2775.28, + 2767.9, + 2762.26, + 2762.56, + 2756.99, + 2756.84, + 2752.43, + 2752.13, + 2748.44, + 2751.23, + 2747.54, + 2748.74 + ], + "profit_loss": [ + -0.37, + -5.12, + -5.51, + -9.05, + -11.13, + -10.99, + -10.99, + -10.69, + -10.25, + -6.03, + 0.82, + -16.22, + -16.51, + 0.38, + 1.42, + 1.12, + -6.26, + -11.9, + -11.6, + -17.17, + -17.32, + -21.73, + -22.03, + -25.72, + -22.93, + -26.62, + -25.42 + ], + "profit_loss_pct": [ + -0.0001, + -0.0018, + -0.002, + -0.0033, + -0.004, + -0.004, + -0.004, + -0.0039, + -0.0037, + -0.0022, + 0.0003, + -0.0058, + -0.006, + 0.0001, + 0.0005, + 0.0004, + -0.0023, + -0.0043, + -0.0042, + -0.0062, + -0.0062, + -0.0078, + -0.0079, + -0.0093, + -0.0083, + -0.0096, + -0.0092 + ], + "timeframe": "15Min", + "timestamp": [ + 1697722200, + 1697723100, + 1697724000, + 1697724900, + 1697725800, + 1697726700, + 1697727600, + 1697728500, + 1697729400, + 1697730300, + 1697731200, + 1697732100, + 1697733000, + 1697733900, + 1697734800, + 1697735700, + 1697736600, + 1697737500, + 1697738400, + 1697739300, + 1697740200, + 1697741100, + 1697742000, + 1697742900, + 1697743800, + 1697744700, + 1697745600 + ] + } + }, + "example-query-1d-7d": { + "value": { + "base_value": 2784.79, + "cashflow": { + "CSD": [ + 0, + 0, + 100, + 0, + 0 + ] + }, + "equity": [ + 2784.79, + 2794.79, + 2805.46, + 2774.16, + 2748.73 + ], + "profit_loss": [ + 0, + 10.0022, + 10.6692, + -31.2996, + -25.4232 + ], + "profit_loss_pct": [ + 0, + 0.0035, + 0.0074, + -0.0038, + -0.0129 + ], + "timeframe": "1D", + "timestamp": [ + 1697241600, + 1697500800, + 1697587200, + 1697673600, + 1697760000 + ] + } + } + }, + "schema": { + "$ref": "#/components/schemas/PortfolioHistory" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Get Account Portfolio History", + "tags": [ + "Portfolio History" + ] + } + }, + "/v2/assets": { + "get": { + "description": "The assets API serves as the master list of assets available for trade and data consumption from Alpaca. Assets are sorted by asset class, exchange and symbol.", + "operationId": "get-v2-assets", + "parameters": [ + { + "description": "e.g. \"active\". By default, all statuses are included.", + "in": "query", + "name": "status", + "schema": { + "type": "string" + } + }, + { + "description": "Defaults to us_equity.", + "in": "query", + "name": "asset_class", + "schema": { + "type": "string" + } + }, + { + "description": "Optional AMEX, ARCA, BATS, NYSE, NASDAQ, NYSEARCA, OTC or CRYPTO", + "in": "query", + "name": "exchange", + "schema": { + "type": "string" + } + }, + { + "description": "Comma separated values to query for more than one attribute. Assets which have any of the given attributes will be included.\n\nSupported values:\n- `ptp_no_exception`: Asset is a Publicly Traded Partnership (PTP) without a qualified notice; non-U.S. customers may incur 10% withholding on gross proceeds as per IRS guidance, and are blocked from being purchased by default.\n- `ptp_with_exception`: Users can open positions in these PTPs without general restrictions.\n- `ipo`: Accepting limit orders only before the stock begins trading on the secondary market.\n- `has_options`: The underlying equity has listed options available on the platform. Note: if the equity had inactive/expired contracts in the past, this will still show up.\n- `options_late_close`: Indicates the underlying asset's options contracts close at 4:15pm ET instead of the standard 4:00pm ET.\n- `fractional_eh_enabled`: Indicates the asset accepts fractional orders during extended hours sessions (pre-market, post-market, and overnight if enabled).\n- `overnight_tradable`: Asset is eligible for overnight (24x5) trading in supported venues on the platform.\n- `overnight_halted`: Asset is eligible for overnight trading but is currently halted/blocked for overnight sessions due to risk, corporate action, compliance, or venue constraints.", + "explode": false, + "in": "query", + "name": "attributes", + "schema": { + "default": [], + "example": [ + "ptp_no_exception", + "ipo" + ], + "items": { + "$ref": "#/components/schemas/AssetAttribute" + }, + "type": "array" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Assets" + }, + "type": "array" + } + } + }, + "description": "An array of asset objects" + } + }, + "summary": "Get Assets", + "tags": [ + "Assets" + ] + } + }, + "/v2/assets/{symbol_or_asset_id}": { + "get": { + "description": "Get the asset model for a given symbol or asset_id. The symbol or asset_id should be passed in as a path parameter.\n\n**Note**: For crypto, the symbol has to follow old symbology, e.g. BTCUSD.\n\n**Note**: For coin pairs, the symbol should be separated by a slash (/), e.g. BTC/USDT. Since the slash is a special character in HTTP, use the URL encoded version instead, e.g. /v2/assets/BTC%2FUSDT", + "operationId": "get-v2-assets-symbol_or_asset_id", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Assets" + } + } + }, + "description": "An Asset object" + }, + "404": { + "description": "Not Found" + } + }, + "summary": "Get an Asset by ID or Symbol", + "tags": [ + "Assets" + ] + }, + "parameters": [ + { + "description": "symbol or assetId. CUSIP is also accepted for US equities.", + "in": "path", + "name": "symbol_or_asset_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v2/calendar": { + "get": { + "description": "The calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results. In addition to the dates, the response also contains the specific open and close times for the market days, taking into account early closures.\n", + "operationId": "LegacyCalendar", + "parameters": [ + { + "$ref": "#/components/parameters/legacy_start" + }, + { + "$ref": "#/components/parameters/legacy_end" + }, + { + "$ref": "#/components/parameters/legacy_date_type" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/legacy_public_calendar_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get US Market Calendar", + "tags": [ + "Calendar" + ] + } + }, + "/v2/clock": { + "get": { + "description": "The clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close.\n", + "operationId": "LegacyClock", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/legacy_clock" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get US Market Clock", + "tags": [ + "Clock" + ] + } + }, + "/v2/corporate_actions/announcements": { + "get": { + "deprecated": true, + "description": "This endpoint is deprecated, please use [the new corporate actions endpoint](https://docs.alpaca.markets/reference/corporateactions-1) instead.", + "operationId": "get-v2-corporate_actions-announcements", + "parameters": [ + { + "description": "A comma-delimited list of corporate action types.", + "explode": false, + "in": "query", + "name": "ca_types", + "required": true, + "schema": { + "items": { + "$ref": "#/components/schemas/CorporateActionCaType" + }, + "type": "array" + }, + "style": "form" + }, + { + "description": "The start (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days.", + "in": "query", + "name": "since", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The end (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days.", + "in": "query", + "name": "until", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The symbol of the company initiating the announcement.", + "in": "query", + "name": "symbol", + "schema": { + "type": "string" + } + }, + { + "description": "The CUSIP of the company initiating the announcement.", + "in": "query", + "name": "cusip", + "schema": { + "type": "string" + } + }, + { + "description": "declaration_date, ex_date, record_date, or payable_date", + "in": "query", + "name": "date_type", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Example 1": { + "value": [ + { + "ca_sub_type": "DIV", + "ca_type": "Dividend", + "cash": "0.018", + "corporate_actions_id": "F58684224_XY37", + "declaration_date": "2021-01-05", + "expiration_date": "2021-01-12", + "id": "be3c368a-4c7c-4384-808e-f02c9f5a8afe", + "initiating_original_cusip": "55275E101", + "initiating_symbol": "MLLAX", + "new_rate": "1", + "old_rate": "1", + "payable_date": "2021-01-14", + "record_date": "2021-01-13", + "target_original_cusip": "55275E101", + "target_symbol": "MLLAX" + }, + { + "ca_sub_type": "cash", + "ca_type": "Dividend", + "cash": "0.145", + "corporate_action_id": "48251W104_AD21", + "declaration_date": "2021-11-01", + "ex_date": "2021-11-12", + "initiating_original_cusip": "G52830109", + "initiating_symbol": "KKR", + "new_rate": "1", + "old_rate": "1", + "payable_date": "2021-11-30", + "record_date": "2021-11-15", + "target_original_cusip": "G52830109", + "target_symbol": "KKR" + } + ] + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/CorporateAnnouncement" + }, + "type": "array" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve Announcements", + "tags": [ + "Corporate Actions" + ] + } + }, + "/v2/corporate_actions/announcements/{id}": { + "get": { + "deprecated": true, + "description": "This endpoint is deprecated, please use [the new corporate actions endpoint](https://docs.alpaca.markets/reference/corporateactions-1) instead.", + "operationId": "get-v2-corporate_actions-announcements-id", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CorporateAnnouncement" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieve a Specific Announcement", + "tags": [ + "Corporate Actions" + ] + }, + "parameters": [ + { + "description": "The corporate announcement's id", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v2/options/contracts": { + "get": { + "description": "This endpoint allows you to retrieve a list of option contracts based on various filtering criteria.\nBy default only active contracts that expire before the upcoming weekend are returned.\n", + "operationId": "get-options-contracts", + "parameters": [ + { + "description": "Filter contracts by one or more underlying symbols.", + "example": "AAPL,SPY", + "in": "query", + "name": "underlying_symbols", + "schema": { + "type": "string" + } + }, + { + "description": "Include deliverables array in the response.", + "example": true, + "in": "query", + "name": "show_deliverables", + "schema": { + "type": "boolean" + } + }, + { + "description": "Filter contracts by status (active/inactive). By default only active contracts are returned.", + "example": "active", + "in": "query", + "name": "status", + "schema": { + "enum": [ + "active", + "inactive" + ], + "type": "string" + } + }, + { + "description": "Filter contracts by the exact expiration date (format: YYYY-MM-DD).", + "example": "2025-06-20", + "in": "query", + "name": "expiration_date", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts with expiration date greater than or equal to the specified date.", + "example": "2025-06-20", + "in": "query", + "name": "expiration_date_gte", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts with expiration date less than or equal to the specified date. By default this is set to the next weekend.", + "example": "2025-06-20", + "in": "query", + "name": "expiration_date_lte", + "schema": { + "format": "date", + "type": "string" + } + }, + { + "description": "Filter contracts by the root symbol.", + "example": "AAPL", + "in": "query", + "name": "root_symbol", + "schema": { + "type": "string" + } + }, + { + "description": "Filter contracts by the type (call/put).", + "example": "call", + "in": "query", + "name": "type", + "schema": { + "$ref": "#/components/schemas/OptionContractType" + } + }, + { + "description": "Filter contracts by the style (american/european).", + "example": "american", + "in": "query", + "name": "style", + "schema": { + "$ref": "#/components/schemas/OptionContractStyle" + } + }, + { + "description": "Filter contracts with strike price greater than or equal to the specified value.", + "example": 50, + "in": "query", + "name": "strike_price_gte", + "schema": { + "type": "number" + } + }, + { + "description": "Filter contracts with strike price less than or equal to the specified value.", + "example": 100, + "in": "query", + "name": "strike_price_lte", + "schema": { + "type": "number" + } + }, + { + "$ref": "#/components/parameters/PageToken" + }, + { + "description": "The number of contracts to limit per page (default=100, max=10000).", + "example": 100, + "in": "query", + "name": "limit", + "schema": { + "type": "integer" + } + }, + { + "description": "The ppind (Penny Program Indicator) field indicates whether an option contract is eligible for penny price increments,\nwith `true` meaning it is part of the Penny Program and `false` meaning it is not.", + "example": true, + "in": "query", + "name": "ppind", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OptionContractsResponse" + } + } + }, + "description": "Successful Response." + } + }, + "summary": "Get Option Contracts", + "tags": [ + "Assets" + ] + } + }, + "/v2/options/contracts/{symbol_or_id}": { + "get": { + "description": "Get an option contract by symbol or contract ID. The symbol or id should be passed in as a path parameter.", + "operationId": "get-option-contract-symbol_or_id", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OptionContract" + } + } + }, + "description": "An option contract" + }, + "404": { + "content": { + "application/json": { + "examples": { + "Contract Not Found": { + "value": { + "code": 40410000, + "message": "option contract TSLA231110C00021000 not found" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Not Found" + } + }, + "summary": "Get an option contract by ID or Symbol", + "tags": [ + "Assets" + ] + }, + "parameters": [ + { + "description": "symbol or contract ID", + "in": "path", + "name": "symbol_or_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v2/orders": { + "delete": { + "description": "Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.", + "operationId": "deleteAllOrders", + "responses": { + "207": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/CanceledOrderResponse" + }, + "type": "array" + } + } + }, + "description": "Multi-Status with body.\n\nan array of objects that include the order id and http status code for each status request." + }, + "500": { + "description": "Failed to cancel order." + } + }, + "summary": "Delete All Orders", + "tags": [ + "Orders" + ] + }, + "get": { + "description": "Retrieves a list of orders for the account, filtered by the supplied query parameters.", + "operationId": "getAllOrders", + "parameters": [ + { + "description": "Order status to be queried. open, closed or all. Defaults to open.", + "in": "query", + "name": "status", + "schema": { + "enum": [ + "open", + "closed", + "all" + ], + "example": "open", + "type": "string" + } + }, + { + "description": "The maximum number of orders in response. Defaults to 50 and max is 500.", + "in": "query", + "name": "limit", + "schema": { + "type": "integer" + } + }, + { + "description": "The response will include only ones submitted after this timestamp (exclusive.)", + "in": "query", + "name": "after", + "schema": { + "type": "string" + } + }, + { + "description": "The response will include only ones submitted until this timestamp (exclusive.)", + "in": "query", + "name": "until", + "schema": { + "type": "string" + } + }, + { + "description": "The chronological order of response based on the submission time. asc or desc. Defaults to desc.", + "in": "query", + "name": "direction", + "schema": { + "enum": [ + "asc", + "desc" + ], + "type": "string" + } + }, + { + "description": "If true, the result will roll up multi-leg orders under the legs field of primary order.", + "in": "query", + "name": "nested", + "schema": { + "type": "boolean" + } + }, + { + "description": "A comma-separated list of symbols to filter by (ex. \"AAPL,TSLA,MSFT\"). A currency pair is required for crypto orders (ex. \"BTCUSD,BCHUSD,LTCUSD,ETCUSD\").", + "in": "query", + "name": "symbols", + "schema": { + "type": "string" + } + }, + { + "description": "Filters down to orders that have a matching side field set.", + "in": "query", + "name": "side", + "schema": { + "type": "string" + } + }, + { + "description": "A comma-separated list of asset classes, the response will include only orders in the specified asset classes. By specifying `us_option` as the class, you can query option orders by underlying symbol using the symbols parameter.", + "in": "query", + "name": "asset_class", + "schema": { + "items": { + "enum": [ + "us_equity", + "us_option", + "crypto", + "crypto_perp", + "treasury", + "corporate", + "global_equity", + "us_index", + "us_equity_chain", + "ipo", + "all" + ], + "type": "string" + }, + "type": "array" + } + }, + { + "description": "Return orders submitted before the order with this ID (exclusive).\nMutually exclusive with `after_order_id`. Do not combine with `after`/`until`.\n", + "in": "query", + "name": "before_order_id", + "schema": { + "type": "string" + } + }, + { + "description": "Return orders submitted after the order with this ID (exclusive).\nMutually exclusive with `before_order_id`. Do not combine with `after`/`until`.\n", + "in": "query", + "name": "after_order_id", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Crypto": { + "$ref": "#/components/examples/CryptoOrderResponse" + }, + "Equity": { + "$ref": "#/components/examples/EquityOrderResponse" + }, + "IPO": { + "$ref": "#/components/examples/IPOOrderResponse" + }, + "MultilegOptions": { + "$ref": "#/components/examples/MultilegOptionsOrderResponse" + }, + "Options": { + "$ref": "#/components/examples/OptionOrderResponse" + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/Order" + }, + "type": "array" + } + } + }, + "description": "Successful response\n\nAn array of Order objects" + } + }, + "summary": "Get All Orders", + "tags": [ + "Orders" + ] + }, + "post": { + "description": "Places a new order for the given account. An order request may be rejected if the account is not authorized for trading, or if the tradable balance is insufficient to fill the order.", + "operationId": "postOrder", + "requestBody": { + "content": { + "application/json": { + "examples": { + "Crypto": { + "summary": "Buy a crypto coin", + "value": { + "limit_price": "2100", + "qty": "0.02", + "side": "buy", + "symbol": "ETH/USD", + "time_in_force": "gtc", + "type": "limit" + } + }, + "Equity": { + "summary": "Buy an equity stock", + "value": { + "limit_price": "150", + "qty": "2", + "side": "buy", + "symbol": "AAPL", + "time_in_force": "gtc", + "type": "limit" + } + }, + "IPO": { + "summary": "Submit an IPO indication of interest", + "value": { + "notional": "500", + "side": "buy", + "symbol": "FI111225", + "time_in_force": "gtc", + "type": "market" + } + }, + "MultilegOptions": { + "summary": "Option Call spread", + "value": { + "legs": [ + { + "position_intent": "buy_to_open", + "ratio_qty": "3", + "side": "buy", + "symbol": "AAPL241213C00250000" + }, + { + "position_intent": "sell_to_open", + "ratio_qty": "1", + "side": "sell", + "symbol": "AAPL241213C00260000" + } + ], + "limit_price": "10", + "order_class": "mleg", + "qty": "3", + "time_in_force": "day", + "type": "limit" + } + }, + "Options": { + "summary": "Buy an option contract", + "value": { + "limit_price": "10", + "qty": "2", + "side": "buy", + "symbol": "AAPL250620C00100000", + "time_in_force": "day", + "type": "limit" + } + } + }, + "schema": { + "$ref": "#/components/schemas/CreateOrderRequest" + } + } + }, + "description": "", + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Crypto": { + "$ref": "#/components/examples/CryptoOrderResponse" + }, + "Equity": { + "$ref": "#/components/examples/EquityOrderResponse" + }, + "IPO": { + "$ref": "#/components/examples/IPOOrderResponse" + }, + "MultilegOptions": { + "$ref": "#/components/examples/MultilegOptionsOrderResponse" + }, + "Options": { + "$ref": "#/components/examples/OptionOrderResponse" + } + }, + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "Successful response" + }, + "403": { + "description": "Forbidden\n\nBuying power or shares is not sufficient." + }, + "422": { + "description": "Unprocessable\n\nInput parameters are not recognized." + } + }, + "summary": "Create an Order", + "tags": [ + "Orders" + ] + } + }, + "/v2/orders/{order_id}": { + "delete": { + "description": "Attempts to cancel an Open Order. If the order is no longer cancelable, the request will be rejected with status 422; otherwise accepted with return status 204.", + "operationId": "deleteOrderByOrderID", + "responses": { + "204": { + "description": "No Content" + }, + "422": { + "description": "The order status is not cancelable." + } + }, + "summary": "Delete Order by ID", + "tags": [ + "Orders" + ] + }, + "get": { + "description": "Retrieves a single order for the given order_id.", + "operationId": "getOrderByOrderID", + "parameters": [ + { + "description": "If true, the result will roll up multi-leg orders under the legs field of primary order.", + "in": "query", + "name": "nested", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Crypto": { + "$ref": "#/components/examples/CryptoOrderResponse" + }, + "Equity": { + "$ref": "#/components/examples/EquityOrderResponse" + }, + "IPO": { + "$ref": "#/components/examples/IPOOrderResponse" + }, + "MultilegOptions": { + "$ref": "#/components/examples/MultilegOptionsOrderResponse" + }, + "Options": { + "$ref": "#/components/examples/OptionOrderResponse" + } + }, + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Get Order by ID", + "tags": [ + "Orders" + ] + }, + "parameters": [ + { + "description": "order id", + "in": "path", + "name": "order_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "patch": { + "description": "Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order.\n\nA success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel.\n\nWhile an order is being replaced, buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order.\n\nNote: Order cannot be replaced when the status is `accepted`, `pending_new`, `pending_cancel` or `pending_replace`.\n\nNote: Notional orders for non-IPO asset classes cannot be replaced. Any attempt to modify a non-IPO notional order via this endpoint will be rejected; cancel it and submit a new one instead.\n\nNote: IPO indications of interest (`asset_class: \"ipo\"`) **are** notional and **can** be replaced via this endpoint by providing a new `notional` value. `qty` and `notional` are mutually exclusive on a single replace request.\n", + "operationId": "patchOrderByOrderId", + "requestBody": { + "content": { + "application/json": { + "examples": { + "Equity": { + "summary": "Increase qty and limit price on an equity order", + "value": { + "limit_price": "155", + "qty": "4", + "time_in_force": "gtc" + } + }, + "IPO": { + "summary": "Update notional on an IPO indication of interest", + "value": { + "notional": "750" + } + }, + "Options": { + "summary": "Adjust an option order's limit price", + "value": { + "limit_price": "11.25", + "time_in_force": "day" + } + } + }, + "schema": { + "$ref": "#/components/schemas/PatchOrderRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "Equity": { + "$ref": "#/components/examples/EquityOrderResponse" + }, + "IPO": { + "$ref": "#/components/examples/IPOOrderResponse" + }, + "Options": { + "$ref": "#/components/examples/OptionOrderResponse" + } + }, + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "Successful response\n\nThe new Order object with the new order ID." + } + }, + "summary": "Replace Order by ID", + "tags": [ + "Orders" + ] + } + }, + "/v2/orders:by_client_order_id": { + "get": { + "description": "Retrieves a single order specified by the client order ID.", + "operationId": "getOrderByClientOrderId", + "parameters": [ + { + "description": "The client-assigned order ID.", + "in": "query", + "name": "client_order_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "Successfully retrieved the order matching the client_order_id." + } + }, + "summary": "Get Order by Client Order ID", + "tags": [ + "Orders" + ] + } + }, + "/v2/positions": { + "delete": { + "description": "Closes (liquidates) all of the account's open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.", + "operationId": "deleteAllOpenPositions", + "parameters": [ + { + "description": "If true is specified, cancel all open orders before liquidating all positions.", + "in": "query", + "name": "cancel_orders", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "207": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/PositionClosedReponse" + }, + "type": "array" + } + } + }, + "description": "Multi-Status with body.\n\nan array of PositionClosed responses" + }, + "500": { + "description": "Failed to liquidate" + } + }, + "summary": "Close All Positions", + "tags": [ + "Positions" + ] + }, + "get": { + "description": "The positions API provides information about an account's current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API\n\nRetrieves a list of the account's open positions", + "operationId": "getAllOpenPositions", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Position" + }, + "type": "array" + } + } + }, + "description": "Successful response" + } + }, + "summary": "All Open Positions", + "tags": [ + "Positions" + ] + } + }, + "/v2/positions/{symbol_or_asset_id}": { + "delete": { + "description": "Closes (liquidates) the account's open position for the given symbol. Works for both long and short positions.", + "operationId": "deleteOpenPosition", + "parameters": [ + { + "description": "the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage", + "in": "query", + "name": "qty", + "schema": { + "type": "number" + } + }, + { + "description": "percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty", + "in": "query", + "name": "percentage", + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "Successful response\n\nReturns the order created to close out this position" + } + }, + "summary": "Close a Position", + "tags": [ + "Positions" + ] + }, + "get": { + "description": "Retrieves the account's open position for the given symbol or assetId.", + "operationId": "getOpenPosition", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Get an Open Position", + "tags": [ + "Positions" + ] + }, + "parameters": [ + { + "description": "symbol or assetId", + "in": "path", + "name": "symbol_or_asset_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v2/positions/{symbol_or_contract_id}/do-not-exercise": { + "post": { + "description": "This endpoint enables users to submit a do-not-exercise (DNE) instruction for a held option contract, preventing automatic exercise at expiry.\nBy default, Alpaca will automatically exercise in-the-money (ITM) contracts at expiry. This endpoint allows users to override that behavior.\nTo override this behavior and submit an exercise instruction, please contact our support team.", + "operationId": "optionDoNotExercise", + "parameters": [ + { + "description": "Option contract symbol or ID.", + "in": "path", + "name": "symbol_or_contract_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful Response\n\nDo-not-exercise instruction successfully submitted." + }, + "403": { + "content": { + "application/json": { + "examples": { + "No Available Position": { + "value": { + "code": 40310000, + "message": "no available position for the specified contract" + } + }, + "Short Position": { + "value": { + "code": 40310001, + "message": "cannot submit DNE for short position" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Forbidden\n\nAvailable position quantity is not sufficient or no position found." + }, + "422": { + "content": { + "application/json": { + "examples": { + "Invalid Symbol": { + "value": { + "code": 42210000, + "message": "invalid symbol" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Invalid Parameters.\n\nOne or more parameters provided are invalid." + } + }, + "summary": "Do Not Exercise an Options Position", + "tags": [ + "Positions" + ] + } + }, + "/v2/positions/{symbol_or_contract_id}/exercise": { + "post": { + "description": "This endpoint enables users to exercise a held option contract, converting it into the underlying asset based on the specified terms.\nAll available held shares of this option contract will be exercised.\nBy default, Alpaca will automatically exercise in-the-money (ITM) contracts at expiry.\nExercise requests will be processed immediately once received. Exercise requests submitted between market close and midnight will be rejected to avoid any confusion about when the exercise will settle.\nTo cancel an exercise request or to submit a Do-not-exercise (DNE) instruction, you can use the do-not-exercise endpoint or contact our support team.", + "operationId": "optionExercise", + "parameters": [ + { + "description": "Option contract symbol or ID.", + "in": "path", + "name": "symbol_or_contract_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successful Response\n\nExercise instruction successfully submitted." + }, + "403": { + "content": { + "application/json": { + "examples": { + "No Available Position": { + "value": { + "code": 40310000, + "message": "no available position for the specified contract" + } + }, + "Short Position": { + "value": { + "code": 40310001, + "message": "cannot exercise short position" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Forbidden\n\nAvailable position quantity is not sufficient." + }, + "422": { + "content": { + "application/json": { + "examples": { + "Invalid Symbol": { + "value": { + "code": 42210000, + "message": "invalid symbol" + } + } + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Invalid Parameters.\n\nOne or more parameters provided are invalid." + } + }, + "summary": "Exercise an Options Position", + "tags": [ + "Positions" + ] + } + }, + "/v2/tokenization/mint": { + "post": { + "description": "This endpoint is used by an Authorized Participant to request the minting of a tokenized asset.\n\n**Idempotency**: When the `Idempotency-Key` header is supplied, this endpoint is\nidempotent. Multiple requests with the same key and identical request body will\ncreate only one mint request. A subsequent request returns the previously created\nrequest with the same response (no duplicate is created). If the same key is used\nwith a different request body, the API returns `422 Unprocessable Entity`.\n\n**Recommended for production**: Always supply `Idempotency-Key` when requesting a\nmint. This allows safe retries on timeouts, network errors, or 5xx responses\nwithout risking duplicate requests. Use a client-generated unique value (e.g. UUID).", + "operationId": "postTokenizationMint", + "parameters": [ + { + "$ref": "#/components/parameters/LegacyIdempotencyKey" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenizationMintRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TokenizationMintResponse" + } + } + }, + "description": "Successfully requested minting of a tokenized asset." + }, + "400": { + "content": { + "application/json": { + "example": { + "code": 40010000, + "message": "failed to decode request body" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Bad request (e.g. malformed input, insufficient position, or account not authorized to mint). Also returned when the `Idempotency-Key` header is malformed, or when replaying a request that was originally rejected." + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "issuer is required, network is required" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "One or more request parameters are missing or invalid, or the same `Idempotency-Key` was reused with a different request body." + } + }, + "summary": "Mint a Tokenized Asset", + "tags": [ + "Tokenization" + ] + } + }, + "/v2/tokenization/requests": { + "get": { + "description": "An Authorized Participant can use this endpoint to list the tokenization requests performed on the Instant Tokenization Network (ITN).", + "operationId": "getTokenizationRequests", + "parameters": [ + { + "description": "Tokenization request type to be queried", + "example": "mint", + "in": "query", + "name": "type", + "schema": { + "$ref": "#/components/schemas/TokenizationRequestType" + } + }, + { + "description": "Tokenization request status to be queried", + "example": "pending", + "in": "query", + "name": "status", + "schema": { + "$ref": "#/components/schemas/TokenizationRequestStatus" + } + }, + { + "description": "Underlying symbol of the tokenization requests to be queried", + "in": "query", + "name": "underlying_symbol", + "schema": { + "type": "string" + } + }, + { + "description": "Issuer of the tokenization requests to be queried", + "in": "query", + "name": "issuer", + "schema": { + "$ref": "#/components/schemas/TokenizationIssuer" + } + }, + { + "description": "Network of the tokenization requests to be queried", + "in": "query", + "name": "network", + "schema": { + "$ref": "#/components/schemas/TokenizationNetwork" + } + }, + { + "description": "The response will include only requests created after this timestamp (exclusive)", + "in": "query", + "name": "after", + "schema": { + "example": "2025-09-30T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + }, + { + "description": "The response will include only requests created before this timestamp (exclusive)", + "in": "query", + "name": "before", + "schema": { + "example": "2025-09-30T18:38:01.942282Z", + "format": "date-time", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/TokenizationRequest" + }, + "type": "array" + } + } + }, + "description": "Successful response\n\nA list of tokenization requests" + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "failed to parse after" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "One or more request parameters are missing or invalid." + } + }, + "summary": "List Tokenization Requests", + "tags": [ + "Tokenization" + ] + } + }, + "/v2/tokenization/requests/{tokenization_request_id}": { + "get": { + "description": "An Authorized Participant can use this endpoint to retrieve a single tokenization request, mint or redeem, by its `tokenization_request_id`.", + "operationId": "getTokenizationRequest", + "parameters": [ + { + "description": "Unique identifier of the tokenization request, as returned by the mint endpoint or the list-requests endpoint.", + "in": "path", + "name": "tokenization_request_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "created_at": "2025-11-04T18:38:01.942282Z", + "fees": "0.5", + "issuer": "xstocks", + "network": "solana", + "qty": "1.0", + "status": "completed", + "token_symbol": "TSLAx", + "tokenization_request_id": "5b1d6a3e-7f0a-4d2c-b8e1-9e6f1c0d2c4a", + "tx_hash": "5J7ZxK4QwR3vH2pY1aB6sN8cM9tD0fA2eXyVwUjL3kPqR4mZcF7nB1tA8sH6dG2pE", + "type": "mint", + "underlying_symbol": "TSLA", + "updated_at": "2025-11-04T18:38:42.117004Z", + "wallet_address": "5dXY1aH2tQpV3wXmJg6Z7c8B4nKvF9bA1pQrSt2uVwYxXz" + }, + "schema": { + "$ref": "#/components/schemas/TokenizationRequest" + } + } + }, + "description": "Successful response" + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "404": { + "content": { + "application/json": { + "example": { + "code": 40410000, + "message": "tokenization request not found" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "No tokenization request with the supplied `tokenization_request_id` exists for the calling account." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "tokenization_request_id is not a valid UUID" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The `tokenization_request_id` path parameter is not a valid UUID." + } + }, + "summary": "Get Tokenization Request by ID", + "tags": [ + "Tokenization" + ] + } + }, + "/v2/tokenization/requests:by_client_request_id": { + "get": { + "description": "An Authorized Participant can use this endpoint to retrieve a single mint tokenization request by their own `client_request_id` -- the AP-supplied label originally passed on the mint request. If the AP has reused a `client_request_id` across multiple requests, the most recently created request is returned.", + "operationId": "getTokenizationRequestByClientRequestID", + "parameters": [ + { + "description": "AP-supplied request identifier originally passed on the mint request, echoed back on the tokenization-request response.", + "in": "query", + "name": "client_request_id", + "required": true, + "schema": { + "example": "ap-request-2025-11-04-001", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "created_at": "2025-11-04T18:38:01.942282Z", + "fees": "0.5", + "issuer": "xstocks", + "network": "solana", + "qty": "1.0", + "status": "completed", + "token_symbol": "TSLAx", + "tokenization_request_id": "5b1d6a3e-7f0a-4d2c-b8e1-9e6f1c0d2c4a", + "tx_hash": "5J7ZxK4QwR3vH2pY1aB6sN8cM9tD0fA2eXyVwUjL3kPqR4mZcF7nB1tA8sH6dG2pE", + "type": "mint", + "underlying_symbol": "TSLA", + "updated_at": "2025-11-04T18:38:42.117004Z", + "wallet_address": "5dXY1aH2tQpV3wXmJg6Z7c8B4nKvF9bA1pQrSt2uVwYxXz" + }, + "schema": { + "$ref": "#/components/schemas/TokenizationRequest" + } + } + }, + "description": "Successful response" + }, + "401": { + "content": { + "application/json": { + "example": { + "code": 40110000, + "message": "unauthorized" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Authentication credentials are missing or invalid." + }, + "403": { + "content": { + "application/json": { + "example": { + "code": 40310000, + "message": "forbidden" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Caller is not authorized to perform this operation." + }, + "404": { + "content": { + "application/json": { + "example": { + "code": 40410000, + "message": "tokenization request not found" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "No tokenization request with the supplied `client_request_id` exists for the calling account." + }, + "422": { + "content": { + "application/json": { + "example": { + "code": 42210001, + "message": "client_request_id query parameter is required" + }, + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The `client_request_id` query parameter is missing." + } + }, + "summary": "Get Tokenization Request by `client_request_id`", + "tags": [ + "Tokenization" + ] + } + }, + "/v2/wallets": { + "get": { + "description": "Lists wallets for the account given in the path parameter. If an asset is specified and no wallet for the account and asset pair exists one will be created. If no asset is specified only existing wallets will be listed for the account. An account may have at most one wallet per asset.", + "operationId": "listCryptoFundingWallets", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CryptoWallet" + } + } + }, + "description": "A single wallet object if an asset is specified or an array of wallet objects if no asset is specified" + } + }, + "summary": "Retrieve Crypto Funding Wallets", + "tags": [ + "Crypto Funding" + ] + }, + "parameters": [ + { + "description": "Filter by crypto asset symbol, e.g. BTC, ETH, USDT. If specified and no wallet exists, one will be created.", + "in": "query", + "name": "asset", + "schema": { + "type": "string" + } + }, + { + "description": "Optional chain identifier. Use to request wallets for a specific chain when asset is a multi-chain crypto asset. If not specified, network is considered.", + "in": "query", + "name": "chain", + "schema": { + "$ref": "#/components/schemas/CryptoChain" + } + }, + { + "description": "Deprecated. Use chain instead. Optional network identifier which is used to request wallets for a specific network when asset is a multi-chain crypto asset. When both 'chain' and 'network' are specified, 'chain' will take precedence and 'network' will be ignored. If 'chain' and 'network' are not specified, the default 'network' (ethereum) will be used.", + "in": "query", + "name": "network", + "schema": { + "deprecated": true, + "enum": [ + "ethereum", + "solana" + ], + "type": "string" + } + } + ] + }, + "/v2/wallets/fees/estimate": { + "get": { + "description": "Returns the estimated on-chain network (gas) fee for a proposed crypto withdrawal at current chain conditions. Pass the `asset`, `from_address`, `to_address`, and `amount` you intend to send; the response reports the network fee that would be charged for the corresponding transaction.", + "operationId": "getCryptoTransferEstimate", + "parameters": [ + { + "description": "The asset for the proposed transaction", + "in": "query", + "name": "asset", + "schema": { + "type": "string" + } + }, + { + "description": "The originating address of the proposed transaction", + "in": "query", + "name": "from_address", + "schema": { + "type": "string" + } + }, + { + "description": "The destination address of the proposed transaction", + "in": "query", + "name": "to_address", + "schema": { + "type": "string" + } + }, + { + "description": "The amount, denoted in the specified asset, of the proposed transaction", + "in": "query", + "name": "amount", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WalletFeeEstimateResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Returns the estimated gas fee for a proposed transaction.", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v2/wallets/transfers": { + "get": { + "description": "Returns an array of all transfers associated with the given account across all wallets.", + "operationId": "listCryptoFundingTransfers", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CryptoTransfer" + } + } + }, + "description": "An array of transfer objects" + } + }, + "summary": "Retrieve Crypto Funding Transfers", + "tags": [ + "Crypto Funding" + ] + }, + "post": { + "deprecated": true, + "description": "Creates a withdrawal request. Note that outgoing withdrawals must be sent to a whitelisted address and you must whitelist addresses at least 24 hours in advance. If you attempt to withdraw funds to a non-whitelisted address then the transfer will be rejected.", + "operationId": "createCryptoTransferForAccount", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCryptoTransferRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CryptoTransfer" + } + } + }, + "description": "Successfully requested a transfer." + }, + "400": { + "content": { + "application/json": { + "examples": { + "TravelRuleValidationError": { + "$ref": "#/components/examples/TravelRuleValidationError" + }, + "WalletError": { + "value": { + "message": "asset cannot be empty" + } + } + }, + "schema": { + "$ref": "#/components/schemas/TravelRuleErrorResponse" + } + } + }, + "description": "The request or travel rule information is invalid." + } + }, + "summary": "Request a New Withdrawal", + "tags": [ + "Crypto Funding" + ], + "x-deprecation": { + "reason": "This endpoint is deprecated. Use the Alpaca web application to initiate withdrawals.", + "since": "2026-07-09", + "sunset": "2026-10-09" + } + } + }, + "/v2/wallets/transfers/{transfer_id}": { + "get": { + "description": "Returns a specific wallet transfer by passing into the query the transfer_id.", + "operationId": "getCryptoFundingTransfer", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CryptoTransfer" + } + } + }, + "description": "A single crypto transfer object" + } + }, + "summary": "Retrieve a Crypto Funding Transfer", + "tags": [ + "Crypto Funding" + ] + }, + "parameters": [ + { + "description": "The crypto transfer to retrieve", + "in": "path", + "name": "transfer_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v2/wallets/travel-rule/vasps": { + "get": { + "description": "Search for Virtual Asset Service Providers, or crypto exchanges, on Notabene's network.\nThis endpoint can be used to find the VASP DID for your beneficiary's exchange when submitting\ntravel rule information for your whitelisted wallets. Use the `q` parameter to search for exchanges.", + "operationId": "searchVASPs", + "parameters": [ + { + "description": "General search query string.", + "in": "query", + "name": "q", + "schema": { + "type": "string" + } + }, + { + "description": "Filter by VASP email domain.", + "in": "query", + "name": "emailDomain", + "schema": { + "type": "string" + } + }, + { + "description": "Filter by Chainalysis-specific VASP name.", + "in": "query", + "name": "chainalysisName", + "schema": { + "type": "string" + } + }, + { + "description": "Specify which fields to return (comma-separated).", + "in": "query", + "name": "fields", + "schema": { + "type": "string" + } + }, + { + "description": "The zero-based page number to retrieve.", + "in": "query", + "name": "page", + "schema": { + "default": 0, + "minimum": 0, + "type": "integer" + } + }, + { + "description": "Number of items per page.", + "in": "query", + "name": "per_page", + "schema": { + "default": 10, + "maximum": 100, + "minimum": 1, + "type": "integer" + } + }, + { + "description": "Field-based sort expression, such as name:ASC. Multiple expressions may be comma-separated. Defaults to name:ASC.", + "in": "query", + "name": "order", + "schema": { + "default": "name:ASC", + "example": "name:ASC", + "pattern": "^([ A-Za-z]+(:(ASC|DESC))?(:NULLS (FIRST|LAST))?(,?))+$", + "type": "string" + } + }, + { + "description": "Whether to include child/subsidiary entities.", + "in": "query", + "name": "includeSubsidiaryVASPs", + "schema": { + "default": false, + "type": "boolean" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "page": 1, + "pages": 1, + "total": 1, + "vasps": [ + { + "country": "US", + "did": "did:ethr:0xf1c002f9e7ca88018d6dcf1e86403fb2f5f055f4", + "id": "vasp-1", + "name": "Example Exchange" + } + ] + }, + "schema": { + "$ref": "#/components/schemas/SearchVASPsResponse" + } + } + }, + "description": "Successful request. Returns an array of VASPs or an empty list if no matches found." + } + }, + "summary": "Search for VASPs", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v2/wallets/whitelists": { + "get": { + "description": "Returns the list of whitelisted withdrawal addresses for your account.", + "operationId": "listWhitelistedAddress", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WhitelistedAddress" + } + } + }, + "description": "An array of whitelisted objects" + } + }, + "summary": "An array of whitelisted addresses", + "tags": [ + "Crypto Funding" + ] + }, + "post": { + "description": "Submits a new whitelisted withdrawal address for your account. The chain is derived from the supplied asset symbol and address, and the same address cannot be whitelisted twice on the same chain.\n\nWhere travel rule reporting applies to your account, supply travel rule information for the destination wallet. Use the `Search VASPs` endpoint to find the VASP DID for the destination exchange. For a self-hosted wallet, set `beneficiary_is_self_hosted` to true. If the exchange is not in the directory, provide its information in `beneficiary_manual_entry`.\n\nNote that whitelisted addresses must wait at least 24 hours before they can be used as a withdrawal destination.", + "operationId": "createWhitelistedAddress", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateWhitelistedAddressRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WhitelistedAddress" + } + } + }, + "description": "Successfully requested a whitelisted address" + }, + "400": { + "content": { + "application/json": { + "examples": { + "TravelRuleValidationError": { + "$ref": "#/components/examples/TravelRuleValidationError" + }, + "WalletError": { + "value": { + "message": "asset cannot be empty" + } + } + }, + "schema": { + "$ref": "#/components/schemas/TravelRuleErrorResponse" + } + } + }, + "description": "The request or travel rule information is invalid." + } + }, + "summary": "Request a new whitelisted address", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v2/wallets/whitelists/{whitelisted_address_id}": { + "delete": { + "description": "Deletes a whitelisted withdrawal address by ID. Subsequent withdrawals targeting the deleted address will be rejected.", + "operationId": "deleteWhitelistedAddress", + "responses": { + "200": { + "description": "Successfully deleted a whitelisted address" + } + }, + "summary": "Delete a whitelisted address", + "tags": [ + "Crypto Funding" + ] + }, + "parameters": [ + { + "description": "The whitelisted address to delete", + "in": "path", + "name": "whitelisted_address_id", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v2/wallets/whitelists/{whitelisted_address_id}/travel-rule-info": { + "parameters": [ + { + "description": "The whitelisted address update travel rule information for", + "in": "path", + "name": "whitelisted_address_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "patch": { + "description": "You are required to supply travel rule information for the crypto wallets you're withdrawing to.\n\nIt is preferred that you use the `Search VASPs` endpoint to find the VASP DID for the exchange you are withdrawing to,\notherwise, if it's a self-hosted wallet, please set `beneficiary_is_self_hosted` to true.\n\nIf the exchange cannot be found in our directory, please supply the information manually using the `beneficiary_manual_entry` object.", + "operationId": "updateWhitelistedAddressTravelRuleInfo", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateWhitelistedAddressTravelRuleInfoRequest" + } + } + }, + "description": "Travel rule information to associate with the whitelisted address.", + "required": true + }, + "responses": { + "200": { + "description": "Successfully updated travel rule information" + }, + "400": { + "content": { + "application/json": { + "examples": { + "TravelRuleValidationError": { + "$ref": "#/components/examples/TravelRuleValidationError" + }, + "WalletError": { + "value": { + "message": "travel_rule_info is missing" + } + } + }, + "schema": { + "$ref": "#/components/schemas/TravelRuleErrorResponse" + } + } + }, + "description": "The request or travel rule information is invalid." + } + }, + "summary": "Update travel rule information for a whitelisted wallet", + "tags": [ + "Crypto Funding" + ] + } + }, + "/v2/watchlists": { + "get": { + "description": "Returns the list of watchlists registered under the account.", + "operationId": "getWatchlists", + "responses": { + "200": { + "content": { + "application/json": { + "examples": { + "example-1": { + "value": [ + { + "account_id": "abe25343-a7ba-4255-bdeb-f7e013e9ee5d", + "created_at": "2022-01-31T21:49:05.14628Z", + "id": "3174d6df-7726-44b4-a5bd-7fda5ae6e009", + "name": "Primary Watchlist", + "updated_at": "2022-01-31T21:49:05.14628Z" + } + ] + } + }, + "schema": { + "items": { + "$ref": "#/components/schemas/WatchlistWithoutAsset" + }, + "type": "array" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Get All Watchlists", + "tags": [ + "Watchlists" + ] + }, + "post": { + "description": "Create a new watchlist with initial set of assets.", + "operationId": "postWatchlist", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateWatchlistRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Create Watchlist", + "tags": [ + "Watchlists" + ] + } + }, + "/v2/watchlists/{watchlist_id}": { + "delete": { + "description": "Delete a watchlist. This is a permanent deletion.", + "operationId": "deleteWatchlistById", + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Watchlist not found" + } + }, + "summary": "Delete Watchlist By Id", + "tags": [ + "Watchlists" + ] + }, + "get": { + "description": "Returns a watchlist identified by the ID.", + "operationId": "getWatchlistById", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Get Watchlist by ID", + "tags": [ + "Watchlists" + ] + }, + "parameters": [ + { + "description": "watchlist id", + "in": "path", + "name": "watchlist_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "post": { + "description": "Append an asset for the symbol to the end of watchlist asset list", + "operationId": "addAssetToWatchlist", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AddAssetToWatchlistRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Add Asset to Watchlist", + "tags": [ + "Watchlists" + ] + }, + "put": { + "description": "Update the name and/or content of watchlist", + "operationId": "updateWatchlistById", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateWatchlistRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Update Watchlist By Id", + "tags": [ + "Watchlists" + ] + } + }, + "/v2/watchlists/{watchlist_id}/{symbol}": { + "delete": { + "description": "Delete one entry for an asset by symbol name", + "operationId": "removeAssetFromWatchlist", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Returns the updated watchlist" + } + }, + "summary": "Delete Symbol from Watchlist", + "tags": [ + "Watchlists" + ] + }, + "parameters": [ + { + "description": "Watchlist ID", + "in": "path", + "name": "watchlist_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "symbol name to remove from the watchlist content", + "in": "path", + "name": "symbol", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, + "/v2/watchlists:by_name": { + "delete": { + "description": "Delete a watchlist. This is a permanent deletion.", + "operationId": "deleteWatchlistByName", + "parameters": [ + { + "description": "name of the watchlist", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + }, + "summary": "Delete Watchlist By Name", + "tags": [ + "Watchlists" + ] + }, + "get": { + "description": "You can also call GET, PUT, POST and DELETE with watchlist name with another endpoint /v2/watchlists:by_name and query parameter name=, instead of /v2/watchlists/{watchlist_id} endpoints\n\nReturns a watchlist by name", + "operationId": "getWatchlistByName", + "parameters": [ + { + "description": "name of the watchlist", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Get Watchlist by Name", + "tags": [ + "Watchlists" + ] + }, + "post": { + "description": "Append an asset for the symbol to the end of watchlist asset list", + "operationId": "addAssetToWatchlistByName", + "parameters": [ + { + "description": "name of the watchlist", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AddAssetToWatchlistRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Add Asset to Watchlist By Name", + "tags": [ + "Watchlists" + ] + }, + "put": { + "description": "Update the name and/or content of watchlist", + "operationId": "updateWatchlistByName", + "parameters": [ + { + "description": "name of the watchlist", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateWatchlistRequest" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Watchlist" + } + } + }, + "description": "Successful response" + } + }, + "summary": "Update Watchlist By Name", + "tags": [ + "Watchlists" + ] + } + }, + "/v3/calendar/{market}": { + "get": { + "description": "This endpoint returns the market calendar.", + "operationId": "Calendar", + "parameters": [ + { + "$ref": "#/components/parameters/market" + }, + { + "$ref": "#/components/parameters/start" + }, + { + "$ref": "#/components/parameters/end" + }, + { + "$ref": "#/components/parameters/timezone" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/public_calendar_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get Market Calendar", + "tags": [ + "Calendar" + ] + } + }, + "/v3/clock": { + "get": { + "description": "This API serves information about multiple markets: the current time, if it's a market day, the current phase of the market, etc.\n", + "operationId": "Clock", + "parameters": [ + { + "$ref": "#/components/parameters/markets" + }, + { + "$ref": "#/components/parameters/time" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/clock_resp" + } + } + }, + "description": "OK", + "headers": { + "X-RateLimit-Limit": { + "$ref": "#/components/headers/ratelimit_limit" + }, + "X-RateLimit-Remaining": { + "$ref": "#/components/headers/ratelimit_remaining" + }, + "X-RateLimit-Reset": { + "$ref": "#/components/headers/ratelimit_reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "429": { + "$ref": "#/components/responses/429" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "summary": "Get Market Clock", + "tags": [ + "Clock" + ] + } + } + }, + "security": [ + { + "API_Key": [], + "API_Secret": [] + } + ], + "servers": [ + { + "description": "Paper", + "url": "https://paper-api.alpaca.markets" + }, + { + "description": "Live", + "url": "https://api.alpaca.markets" + } + ], + "tags": [ + { + "name": "Accounts" + }, + { + "name": "Assets" + }, + { + "name": "Corporate Actions" + }, + { + "name": "Orders" + }, + { + "name": "Positions" + }, + { + "name": "Portfolio History" + }, + { + "name": "Watchlists" + }, + { + "name": "Account Configurations" + }, + { + "name": "Account Activities" + }, + { + "name": "Calendar" + }, + { + "name": "Clock" + }, + { + "name": "Crypto Funding" + }, + { + "description": "Request minting of tokenized assets and list tokenization requests on the Instant Tokenization Network (ITN).", + "name": "Tokenization" + }, + { + "description": "Endpoints for locate requests and quotes.", + "name": "Locates" + }, + { + "name": "Events" + } + ], + "x-readme": { + "explorer-enabled": true, + "proxy-enabled": false + } +} diff --git a/schemaJson2Pojo.gradle b/schemaJson2Pojo.gradle deleted file mode 100644 index d238941a..00000000 --- a/schemaJson2Pojo.gradle +++ /dev/null @@ -1,200 +0,0 @@ -/* - * This build file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java project to get you started. - * For more details take a look at the Java Quickstart chapter in the Gradle - * user guide available at https://docs.gradle.org/3.4.1/userguide/tutorial_java_projects.html - */ - -buildscript { - repositories { - mavenCentral() - jcenter() - } - - dependencies { - // this plugin - classpath 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:1.0.0' - // add additional dependencies here if you wish to reference instead of generate them (see example directory) - } -} - - -// Apply the java plugin to add support for Java -apply plugin: 'java' - -apply plugin: 'jsonschema2pojo' - - -// In this section you declare where to find the dependencies of your project -repositories { - // Use jcenter for resolving your dependencies. - // You can declare any Maven/Ivy/file repository here. - maven { url "https://repo.maven.apache.org/maven2" } - jcenter() - //maven { url "http://mvnrepository.com/artifact" } -} - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 -[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' - - -// Each configuration is set to the default value -jsonSchema2Pojo { - - // Whether to allow 'additional' properties to be supported in classes by adding a map to - // hold these. This is true by default, meaning that the schema rule 'additionalProperties' - // controls whether the map is added. Set this to false to globabally disable additional properties. - includeAdditionalProperties = true - - // Whether to generate builder-style methods of the form withXxx(value) (that return this), - // alongside the standard, void-return setters. - generateBuilders = false - - // Whether to use primitives (long, double, boolean) instead of wrapper types where possible - // when generating bean properties (has the side-effect of making those properties non-null). - usePrimitives = true - - // Location of the JSON Schema file(s). This may refer to a single file or a directory of files. - source = files(project.properties.get("source")) - - // Target directory for generated Java source files. The plugin will add this directory to the - // java source set so the compiler will find and compile the newly generated source files. - targetDirectory = file(project.properties.get("targetDirectory")) - - // Package name used for generated Java classes (for types where a fully qualified name has not - // been supplied in the schema using the 'javaType' property). - targetPackage = project.properties.get("targetPackage", "io.github.mainstringargs.domain") - - // The characters that should be considered as word delimiters when creating Java Bean property - // names from JSON property names. If blank or not set, JSON properties will be considered to - // contain a single word when creating Java Bean property names. - propertyWordDelimiters = ['-', '_'] - - // Whether to use the java type long (or Long) instead of int (or Integer) when representing the - // JSON Schema type 'integer'. - useLongIntegers = true - - // Whether to use the java type BigInteger when representing the JSON Schema type 'integer'. Note - // that this configuration overrides useLongIntegers - useBigIntegers = false - - // Whether to use the java type double (or Double) instead of float (or Float) when representing - // the JSON Schema type 'number'. - useDoubleNumbers = false - - // Whether to use the java type BigDecimal when representing the JSON Schema type 'number'. Note - // that this configuration overrides useDoubleNumbers - useBigDecimals = false - - // Whether to include hashCode and equals methods in generated Java types. - includeHashcodeAndEquals = true - - // Whether to include a toString method in generated Java types. - includeToString = true - - // The style of annotations to use in the generated Java types. Supported values: - // - jackson (alias of jackson2) - // - jackson2 (apply annotations from the Jackson 2.x library) - // - jackson1 (apply annotations from the Jackson 1.x library) - // - gson (apply annotations from the Gson library) - // - moshi1 (apply annotations from the Moshi 1.x library) - // - none (apply no annotations at all) - annotationStyle = 'gson' - - // A fully qualified class name, referring to a custom annotator class that implements - // org.jsonschema2pojo.Annotator and will be used in addition to the one chosen - // by annotationStyle. If you want to use the custom annotator alone, set annotationStyle to none. - customAnnotator = 'org.jsonschema2pojo.NoopAnnotator' - - // Whether to include JSR-303/349 annotations (for schema rules like minimum, maximum, etc) in - // generated Java types. Schema rules and the annotation they produce: - // - maximum = @DecimalMax - // - minimum = @DecimalMin - // - minItems,maxItems = @Size - // - minLength,maxLength = @Size - // - pattern = @Pattern - // - required = @NotNull - // Any Java fields which are an object or array of objects will be annotated with @Valid to - // support validation of an entire document tree. - includeJsr303Annotations = false - - // The type of input documents that will be read. Supported values: - // - jsonschema (schema documents, containing formal rules that describe the structure of JSON data) - // - json (documents that represent an example of the kind of JSON data that the generated Java types - // will be mapped to) - // - yamlschema (JSON schema documents, represented as YAML) - // - yaml (documents that represent an example of the kind of YAML (or JSON) data that the generated Java types - // will be mapped to) - sourceType = 'jsonschema' - - // Whether to empty the target directory before generation occurs, to clear out all source files - // that have been generated previously. Be warned, when activated this option - // will cause jsonschema2pojo to indiscriminately delete the entire contents of the target - // directory (all files and folders) before it begins generating sources. - removeOldOutput = false - - // The character encoding that should be used when writing the generated Java source files - outputEncoding = 'UTF-8' - - // Whether to use {@link org.joda.time.DateTime} instead of {@link java.util.Date} when adding - // date type fields to generated Java types. - useJodaDates = false - - // Whether to add JsonFormat annotations when using Jackson 2 that cause format "date", "time", and "date-time" - // fields to be formatted as yyyy-MM-dd, HH:mm:ss.SSS and yyyy-MM-dd'T'HH:mm:ss.SSSZ respectively. To customize these - // patterns, use customDatePattern, customTimePattern, and customDateTimePattern config options or add these inside a - // schema to affect an individual field - formatDateTimes = true - formatDates = true - formatTimes = true - - //2018-10-05T05:48:59Z - customDateTimePattern = "yyyy-MM-ddTHH:mm:ssZ" - - // Whether to initialize Set and List fields as empty collections, or leave them as null. - initializeCollections = true - - // Whether to add a prefix to generated classes. - classNamePrefix = "" - - // Whether to add a suffix to generated classes. - classNameSuffix = "" - - // An array of strings that should be considered as file extensions and therefore not included in class names. - fileExtensions = [] as String[] - - // Whether to generate constructors or not. - includeConstructors = true - - // **EXPERIMENTAL** Whether to make the generated types Parcelable for Android - parcelable = false - - // Whether to make the generated types Serializable - serializable = true - - // Whether to include getters or to omit these accessor methods and create public fields instead. - includeGetters = true - - // Whether to include setters or to omit these accessor methods and create public fields instead. - includeSetters = true - - // Whether to include dynamic getters, setters, and builders or to omit these methods. - includeDynamicAccessors = false - - // Whether to include dynamic getters or to omit these methods. - includeDynamicGetters = false - - // Whether to include dynamic setters or to omit these methods. - includeDynamicSetters = false - - // Whether to include dynamic builders or to omit these methods. - includeDynamicBuilders = false - - // What type to use instead of string when adding string properties of format "date" to Java types - dateType = "java.time.LocalDate" - - // What type to use instead of string when adding string properties of format "date-time" to Java types - dateTimeType = "java.time.LocalDateTime" -} diff --git a/schema_json/alpaca/account/account.json b/schema_json/alpaca/account/account.json deleted file mode 100644 index b4423179..00000000 --- a/schema_json/alpaca/account/account.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/account/", - "properties": { - "id": { - "existingJavaType": "java.lang.String", - "title": "Account ID." - }, - "account_number": { - "existingJavaType": "java.lang.String", - "title": "Account number." - }, - "status": { - "existingJavaType": "io.github.mainstringargs.alpaca.enums.AccountStatus", - "title": "See Account Status" - }, - "currency": { - "existingJavaType": "java.lang.String", - "title": "“USD”" - }, - "cash": { - "existingJavaType": "java.lang.String", - "title": "Cash balance" - }, - "portfolio_value": { - "existingJavaType": "java.lang.String", - "title": "Total value of cash + holding positions (This field is deprecated. It is equivalent to the equity field.)" - }, - "pattern_day_trader": { - "existingJavaType": "java.lang.Boolean", - "title": "Whether or not the account has been flagged as a pattern day trader" - }, - "trade_suspended_by_user": { - "existingJavaType": "java.lang.Boolean", - "title": "User setting. If true, the account is not allowed to place orders." - }, - "trading_blocked": { - "existingJavaType": "java.lang.Boolean", - "title": "If true, the account is not allowed to place orders." - }, - "transfers_blocked": { - "existingJavaType": "java.lang.Boolean", - "title": "If true, the account is not allowed to request money transfers." - }, - "account_blocked": { - "existingJavaType": "java.lang.Boolean", - "title": "If true, the account activity by user is prohibited." - }, - "created_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Timestamp this account was created at" - }, - "shorting_enabled": { - "existingJavaType": "java.lang.Boolean", - "title": "Flag to denote whether or not the account is permitted to short" - }, - "long_market_value": { - "existingJavaType": "java.lang.String", - "title": "Real-time MtM value of all long positions held in the account" - }, - "short_market_value": { - "existingJavaType": "java.lang.String", - "title": "Real-time MtM value of all short positions held in the account" - }, - "equity": { - "existingJavaType": "java.lang.String", - "title": "Cash + long_market_value + short_market_value" - }, - "last_equity": { - "existingJavaType": "java.lang.String", - "title": "Equity as of previous trading day at 16:00:00 ET" - }, - "multiplier": { - "existingJavaType": "java.lang.String", - "title": "Buying power multiplier that represents account margin classification; valid values 1 (standard limited margin account with 1x buying power), 2 (reg T margin account with 2x intraday and overnight buying power; this is the default for all non-PDT accounts with $2,000 or more equity), 4 (PDT account with 4x intraday buying power and 2x reg T overnight buying power)" - }, - "buying_power": { - "existingJavaType": "java.lang.String", - "title": "Current available $ buying power; If multiplier = 4, this is your daytrade buying power which is calculated as (last_equity - (last) maintenance_margin) * 4; If multiplier = 2, buying_power = max(equity – initial_margin,0) * 2; If multiplier = 1, buying_power = cash" - }, - "initial_margin": { - "existingJavaType": "java.lang.String", - "title": "Reg T initial margin requirement (continuously updated value)" - }, - "maintenance_margin": { - "existingJavaType": "java.lang.String", - "title": "Maintenance margin requirement (continuously updated value)" - }, - "sma": { - "existingJavaType": "java.lang.String", - "title": "Value of special memorandum account (will be used at a later date to provide additional buying_power)" - }, - "daytrade_count": { - "existingJavaType": "java.lang.Integer", - "title": "The current number of daytrades that have been made in the last 5 trading days (inclusive of today)" - }, - "last_maintenance_margin": { - "existingJavaType": "java.lang.String", - "title": "Your maintenance margin requirement on the previous trading day" - }, - "daytrading_buying_power": { - "existingJavaType": "java.lang.String", - "title": "Your buying power for day trades (continuously updated value)" - }, - "regt_buying_power": { - "existingJavaType": "java.lang.String", - "title": "Your buying power under Regulation T (your excess equity - equity minus margin value - times your margin multiplier)" - } - } -} diff --git a/schema_json/alpaca/account_activities/account_activity.json b/schema_json/alpaca/account_activities/account_activity.json deleted file mode 100644 index 1a180f27..00000000 --- a/schema_json/alpaca/account_activities/account_activity.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/account-activities/" -} diff --git a/schema_json/alpaca/account_activities/non_trade_activity.json b/schema_json/alpaca/account_activities/non_trade_activity.json deleted file mode 100644 index 17b43c6b..00000000 --- a/schema_json/alpaca/account_activities/non_trade_activity.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/account-activities/", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.accountactivities.AccountActivity" - }, - "properties": { - "activity_type": { - "existingJavaType": "java.lang.String", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/account-activities/#activity-types for a list of possible values." - }, - "id": { - "existingJavaType": "java.lang.String", - "title": "An ID for the activity, always in “::” format. Can be sent as page_token in requests to facilitate the paging of results." - }, - "date": { - "existingJavaType": "java.lang.String", - "title": "The date on which the activity occurred or on which the transaction associated with the activity settled." - }, - "net_amount": { - "existingJavaType": "java.lang.String", - "title": "The net amount of money (positive or negative) associated with the activity." - }, - "symbol": { - "existingJavaType": "java.lang.String", - "title": "The symbol of the security involved with the activity. Not present for all activity types." - }, - "qty": { - "existingJavaType": "java.lang.String", - "title": "For dividend activities, the number of shares that contributed to the payment. Not present for other activity types." - }, - "per_share_amount": { - "existingJavaType": "java.lang.String", - "title": "For dividend activities, the average amount paid per share. Not present for other activity types." - }, - "description": { - "existingJavaType": "java.lang.String", - "title": "For Transaction records (TRANS,CSR,CSD) a description field is present (even if the docs don't mention it!" - } - } -} diff --git a/schema_json/alpaca/account_activities/trade_activity.json b/schema_json/alpaca/account_activities/trade_activity.json deleted file mode 100644 index 99b52cee..00000000 --- a/schema_json/alpaca/account_activities/trade_activity.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/account-activities/", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.accountactivities.AccountActivity" - }, - "properties": { - "activity_type": { - "existingJavaType": "java.lang.String", - "title": "FILL" - }, - "id": { - "existingJavaType": "java.lang.String", - "title": "An id for the activity. Always in “::” format. Can be sent as page_token in requests to facilitate the paging of results." - }, - "cum_qty": { - "existingJavaType": "java.lang.String", - "title": "The cumulative quantity of shares involved in the execution." - }, - "leaves_qty": { - "existingJavaType": "java.lang.String", - "title": "For partially_filled orders, the quantity of shares that are left to be filled." - }, - "price": { - "existingJavaType": "java.lang.String", - "title": "The per-share price that the trade was executed at." - }, - "qty": { - "existingJavaType": "java.lang.String", - "title": "The number of shares involved in the trade execution." - }, - "side": { - "existingJavaType": "java.lang.String", - "title": "Buy or sell" - }, - "symbol": { - "existingJavaType": "java.lang.String", - "title": "The symbol of the security being traded." - }, - "transaction_time": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "The time at which the execution occurred." - }, - "order_id": { - "existingJavaType": "java.lang.String", - "title": "The id for the order that filled. Always in GUID format." - }, - "type": { - "existingJavaType": "java.lang.String", - "title": "fill or partial_fill" - } - } -} diff --git a/schema_json/alpaca/account_configuration/account_configuration.json b/schema_json/alpaca/account_configuration/account_configuration.json deleted file mode 100644 index 1f80585b..00000000 --- a/schema_json/alpaca/account_configuration/account_configuration.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/account-configuration/", - "properties": { - "dtbp_check": { - "existingJavaType": "java.lang.String", - "title": "Both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks." - }, - "trade_confirm_email": { - "existingJavaType": "java.lang.String", - "title": "all or none. If none, emails for order fills are not sent." - }, - "suspend_trade": { - "existingJavaType": "java.lang.Boolean", - "title": "If true, new orders are blocked." - }, - "no_shorting": { - "existingJavaType": "java.lang.Boolean", - "title": "If true, account becomes long-only mode." - } - } -} diff --git a/schema_json/alpaca/asset/asset.json b/schema_json/alpaca/asset/asset.json deleted file mode 100644 index c1e4b05d..00000000 --- a/schema_json/alpaca/asset/asset.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/assets/", - "properties": { - "id": { - "existingJavaType": "java.lang.String", - "title": "Asset ID." - }, - "class": { - "existingJavaType": "java.lang.String", - "title": "“us_equity”" - }, - "exchange": { - "existingJavaType": "java.lang.String", - "title": "AMEX, ARCA, BATS, NYSE, NASDAQ or NYSEARCA" - }, - "symbol": { - "existingJavaType": "java.lang.String", - "title": "symbol" - }, - "status": { - "existingJavaType": "java.lang.String", - "title": "active or inactive" - }, - "tradable": { - "existingJavaType": "java.lang.Boolean", - "title": "Asset is tradable on Alpaca or not." - }, - "marginable": { - "existingJavaType": "java.lang.Boolean", - "title": "Asset is marginable or not." - }, - "shortable": { - "existingJavaType": "java.lang.Boolean", - "title": "Asset is shortable or not." - }, - "easy_to_borrow": { - "existingJavaType": "java.lang.Boolean", - "title": "Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way to check whether the name is currently available to short at Alpaca)." - } - } -} diff --git a/schema_json/alpaca/bar/bar.json b/schema_json/alpaca/bar/bar.json deleted file mode 100644 index 682776c8..00000000 --- a/schema_json/alpaca/bar/bar.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/market-data/bars/", - "properties": { - "t": { - "existingJavaType": "java.lang.Long", - "title": "The beginning time of this bar as a Unix epoch in seconds" - }, - "o": { - "existingJavaType": "java.lang.Double", - "title": "Open price" - }, - "h": { - "existingJavaType": "java.lang.Double", - "title": "High price" - }, - "l": { - "existingJavaType": "java.lang.Double", - "title": "Low price" - }, - "c": { - "existingJavaType": "java.lang.Double", - "title": "Close price" - }, - "v": { - "existingJavaType": "java.lang.Double", - "title": "Volume" - } - } -} diff --git a/schema_json/alpaca/calendar/calendar.json b/schema_json/alpaca/calendar/calendar.json deleted file mode 100644 index df9098a6..00000000 --- a/schema_json/alpaca/calendar/calendar.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/calendar/", - "properties": { - "date": { - "existingJavaType": "java.lang.String", - "title": "Date string in “%Y-%m-%d” format" - }, - "open": { - "existingJavaType": "java.lang.String", - "title": "The time the market opens at on this date in “%H:%M” format" - }, - "close": { - "existingJavaType": "java.lang.String", - "title": "The time the market closes at on this date in “%H:%M” format" - } - } -} diff --git a/schema_json/alpaca/clock/clock.json b/schema_json/alpaca/clock/clock.json deleted file mode 100644 index 88579382..00000000 --- a/schema_json/alpaca/clock/clock.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/clock/", - "properties": { - "timestamp": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Current timestamp" - }, - "is_open": { - "existingJavaType": "java.lang.Boolean", - "title": "Whether or not the market is open" - }, - "next_open": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Next market open timestamp" - }, - "next_close": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Next market close timestamp" - } - } -} diff --git a/schema_json/alpaca/order/cancelled_order.json b/schema_json/alpaca/order/cancelled_order.json deleted file mode 100644 index 531be7c9..00000000 --- a/schema_json/alpaca/order/cancelled_order.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/orders/", - "properties": { - "id": { - "existingJavaType": "java.lang.String", - "title": "Order ID" - }, - "status": { - "existingJavaType": "java.lang.Integer", - "title": "The HTTP status code of the cancel status" - }, - "body": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.order.Order", - "title": "The cancelled order" - } - } -} diff --git a/schema_json/alpaca/order/order.json b/schema_json/alpaca/order/order.json deleted file mode 100644 index 16f377e0..00000000 --- a/schema_json/alpaca/order/order.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/orders/", - "properties": { - "id": { - "existingJavaType": "java.lang.String", - "title": "Order ID" - }, - "client_order_id": { - "existingJavaType": "java.lang.String", - "title": "Client unique order ID" - }, - "created_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Created at" - }, - "updated_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Updated at" - }, - "submitted_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Submitted at" - }, - "filled_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Filled at" - }, - "expired_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Expired at" - }, - "canceled_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Canceled at" - }, - "failed_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Failed at" - }, - "replaced_at": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Replaced at" - }, - "replaced_by": { - "existingJavaType": "java.lang.String", - "title": "The order ID that this order was replaced by" - }, - "replaces": { - "existingJavaType": "java.lang.String", - "title": "The order ID that this order replaces" - }, - "asset_id": { - "existingJavaType": "java.lang.String", - "title": "Asset ID" - }, - "symbol": { - "existingJavaType": "java.lang.String", - "title": "Asset symbol" - }, - "asset_class": { - "existingJavaType": "java.lang.String", - "title": "Asset class" - }, - "qty": { - "existingJavaType": "java.lang.String", - "title": "Ordered quantity" - }, - "filled_qty": { - "existingJavaType": "java.lang.String", - "title": "Filled quantity" - }, - "type": { - "existingJavaType": "java.lang.String", - "title": "Valid values: market, limit, stop, stop_limit" - }, - "side": { - "existingJavaType": "java.lang.String", - "title": "Valid values: buy, sell" - }, - "time_in_force": { - "existingJavaType": "java.lang.String", - "title": "See Orders page" - }, - "limit_price": { - "existingJavaType": "java.lang.String", - "title": "Limit price" - }, - "stop_price": { - "existingJavaType": "java.lang.String", - "title": "Stop price" - }, - "filled_avg_price": { - "existingJavaType": "java.lang.String", - "title": "Stop price" - }, - "status": { - "existingJavaType": "java.lang.String", - "title": "See Orders page" - }, - "extended_hours": { - "existingJavaType": "java.lang.Boolean", - "title": "If true, eligible for execution outside regular trading hours." - }, - "legs": { - "existingJavaType": "java.util.ArrayList", - "title": "When querying non-simple order_class orders in a nested style, an array of Order entities associated with this order is returned. Otherwise, null." - } - } -} diff --git a/schema_json/alpaca/portfolio_history/portfolio_history.json b/schema_json/alpaca/portfolio_history/portfolio_history.json deleted file mode 100644 index b39982c3..00000000 --- a/schema_json/alpaca/portfolio_history/portfolio_history.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/portfolio-history/", - "properties": { - "timestamp": { - "existingJavaType": "java.util.ArrayList", - "title": "Time of each data element, left-labeled (the beginning of time window)" - }, - "equity": { - "existingJavaType": "java.util.ArrayList", - "title": "Equity value of the account in dollar amount as of the end of each time window" - }, - "profit_loss": { - "existingJavaType": "java.util.ArrayList", - "title": "Profit/loss in dollar from the base value" - }, - "profit_loss_pct": { - "existingJavaType": "java.util.ArrayList", - "title": "Profit/loss in percentage from the base value" - }, - "base_value": { - "existingJavaType": "java.lang.Double", - "title": "Basis in dollar of the profit loss calculation" - }, - "timeframe": { - "existingJavaType": "io.github.mainstringargs.alpaca.enums.PortfolioTimeFrame", - "title": "Time window size of each data element" - } - } -} diff --git a/schema_json/alpaca/position/close_position_order.json b/schema_json/alpaca/position/close_position_order.json deleted file mode 100644 index 0731f66d..00000000 --- a/schema_json/alpaca/position/close_position_order.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "object", - "title": "See https://alpaca.markets/docs/api-documentation/api-v2/positions/", - "properties": { - "symbol": { - "existingJavaType": "java.lang.String", - "title": "The symbol" - }, - "status": { - "existingJavaType": "java.lang.Integer", - "title": "The HTTP status code of the position-closing order status" - }, - "body": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.order.Order", - "title": "The position-closing order" - } - } -} diff --git a/schema_json/alpaca/position/position.json b/schema_json/alpaca/position/position.json deleted file mode 100644 index 254678d3..00000000 --- a/schema_json/alpaca/position/position.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "type": "object", - "title": "See https://alpaca.markets/docs/api-documentation/api-v2/positions/", - "properties": { - "asset_id": { - "existingJavaType": "java.lang.String", - "title": "Asset ID" - }, - "symbol": { - "existingJavaType": "java.lang.String", - "title": "Symbol name of the asset" - }, - "exchange": { - "existingJavaType": "java.lang.String", - "title": "Exchange name of the asset" - }, - "asset_class": { - "existingJavaType": "java.lang.String", - "title": "Asset class name" - }, - "avg_entry_price": { - "existingJavaType": "java.lang.String", - "title": "Average entry price of the position" - }, - "qty": { - "existingJavaType": "java.lang.String", - "title": "The number of shares" - }, - "side": { - "existingJavaType": "java.lang.String", - "title": "“long”" - }, - "market_value": { - "existingJavaType": "java.lang.String", - "title": "Total dollar amount of the position" - }, - "cost_basis": { - "existingJavaType": "java.lang.String", - "title": "Total cost basis in dollar" - }, - "unrealized_pl": { - "existingJavaType": "java.lang.String", - "title": "Unrealized profit/loss in dollars" - }, - "unrealized_plpc": { - "existingJavaType": "java.lang.String", - "title": "Unrealized profit/loss percent (by a factor of 1)" - }, - "unrealized_intraday_pl": { - "existingJavaType": "java.lang.String", - "title": "Unrealized profit/loss in dollars for the day" - }, - "unrealized_intraday_plpc": { - "existingJavaType": "java.lang.String", - "title": "Unrealized profit/loss percent (by a factor of 1)" - }, - "current_price": { - "existingJavaType": "java.lang.String", - "title": "Current asset price per share" - }, - "lastday_price": { - "existingJavaType": "java.lang.String", - "title": "Last day’s asset price per share based on the closing value of the last trading day" - }, - "change_today": { - "existingJavaType": "java.lang.String", - "title": "Percent change from last day price (by a factor of 1)" - } - } -} diff --git a/schema_json/alpaca/watchlist/watchlist.json b/schema_json/alpaca/watchlist/watchlist.json deleted file mode 100644 index 9976aac0..00000000 --- a/schema_json/alpaca/watchlist/watchlist.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/watchlist/", - "properties": { - "id": { - "existingJavaType": "java.lang.String", - "title": "Watchlist ID" - }, - "created_at": { - "existingJavaType": "java.lang.String", - "title": "Created at" - }, - "updated_at": { - "existingJavaType": "java.lang.String", - "title": "Updated at" - }, - "name": { - "existingJavaType": "java.lang.String", - "title": "User-defined watchlist name (up to 64 characters)" - }, - "account_id": { - "existingJavaType": "java.lang.String", - "title": "Account ID" - }, - "assets": { - "existingJavaType": "java.util.ArrayList", - "title": "The content of this watchlist, in the order as registered by the client" - } - } -} diff --git a/schema_json/alpaca/websocket/account/account_update.json b/schema_json/alpaca/websocket/account/account_update.json deleted file mode 100644 index 83fb89d7..00000000 --- a/schema_json/alpaca/websocket/account/account_update.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.account.Account" - }, - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/" -} diff --git a/schema_json/alpaca/websocket/account/account_update_message.json b/schema_json/alpaca/websocket/account/account_update_message.json deleted file mode 100644 index 0a68a12c..00000000 --- a/schema_json/alpaca/websocket/account/account_update_message.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.websocket.AlpacaStreamMessage" - }, - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/", - "properties": { - "data": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.websocket.account.AccountUpdate" - } - } -} diff --git a/schema_json/alpaca/websocket/alpaca_stream_message.json b/schema_json/alpaca/websocket/alpaca_stream_message.json deleted file mode 100644 index d1d0cca4..00000000 --- a/schema_json/alpaca/websocket/alpaca_stream_message.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "object", - "javaInterfaces": [ - "io.github.mainstringargs.abstracts.websocket.message.StreamMessage" - ], - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/", - "properties": { - "stream": { - "existingJavaType": "io.github.mainstringargs.alpaca.websocket.message.AlpacaStreamMessageType", - "title": "The stream type" - } - } -} diff --git a/schema_json/alpaca/websocket/authorization/authorization_data.json b/schema_json/alpaca/websocket/authorization/authorization_data.json deleted file mode 100644 index f91b1e08..00000000 --- a/schema_json/alpaca/websocket/authorization/authorization_data.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "The status." - }, - "action": { - "existingJavaType": "java.lang.String", - "title": "The desired action." - } - } -} diff --git a/schema_json/alpaca/websocket/authorization/authorization_message.json b/schema_json/alpaca/websocket/authorization/authorization_message.json deleted file mode 100644 index 04e7e88a..00000000 --- a/schema_json/alpaca/websocket/authorization/authorization_message.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.websocket.AlpacaStreamMessage" - }, - "properties": { - "data": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.websocket.authorization.AuthorizationData", - "title": "The data" - } - } -} diff --git a/schema_json/alpaca/websocket/listening/listening_data.json b/schema_json/alpaca/websocket/listening/listening_data.json deleted file mode 100644 index 2a8a2594..00000000 --- a/schema_json/alpaca/websocket/listening/listening_data.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/", - "properties": { - "streams": { - "existingJavaType": "java.util.ArrayList" - } - } -} diff --git a/schema_json/alpaca/websocket/listening/listening_message.json b/schema_json/alpaca/websocket/listening/listening_message.json deleted file mode 100644 index 013a80fb..00000000 --- a/schema_json/alpaca/websocket/listening/listening_message.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.websocket.AlpacaStreamMessage" - }, - "properties": { - "data": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.websocket.listening.ListeningData", - "title": "The data" - } - } -} diff --git a/schema_json/alpaca/websocket/trade/trade_update.json b/schema_json/alpaca/websocket/trade/trade_update.json deleted file mode 100644 index 694a4bcd..00000000 --- a/schema_json/alpaca/websocket/trade/trade_update.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "object", - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/", - "properties": { - "event": { - "existingJavaType": "java.lang.String", - "title": "The event type" - }, - "price": { - "existingJavaType": "java.lang.String", - "title": "The Price" - }, - "timestamp": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "The timestamp" - }, - "position_qty": { - "existingJavaType": "java.lang.String", - "title": "The position quantity" - }, - "order": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.order.Order", - "title": "The Order" - } - } -} diff --git a/schema_json/alpaca/websocket/trade/trade_update_message.json b/schema_json/alpaca/websocket/trade/trade_update_message.json deleted file mode 100644 index 7a7498ce..00000000 --- a/schema_json/alpaca/websocket/trade/trade_update_message.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.websocket.AlpacaStreamMessage" - }, - "title": "See https://docs.alpaca.markets/api-documentation/api-v2/streaming/", - "properties": { - "data": { - "existingJavaType": "io.github.mainstringargs.domain.alpaca.websocket.trade.TradeUpdate" - } - } -} diff --git a/schema_json/polygon/aggregates/aggregate.json b/schema_json/polygon/aggregates/aggregate.json deleted file mode 100644 index 0014d8db..00000000 --- a/schema_json/polygon/aggregates/aggregate.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_aggs_ticker_ticker_range_multiplier_timespan_from_to", - "properties": { - "T": { - "existingJavaType": "java.lang.String", - "javaName": "ticker", - "title": "Ticker symbol" - }, - "v": { - "existingJavaType": "java.lang.Long", - "title": "Volume" - }, - "o": { - "existingJavaType": "java.lang.Double", - "title": "Open" - }, - "c": { - "existingJavaType": "java.lang.Double", - "title": "Close" - }, - "h": { - "existingJavaType": "java.lang.Double", - "title": "High" - }, - "l": { - "existingJavaType": "java.lang.Double", - "title": "Low" - }, - "t": { - "existingJavaType": "java.lang.Long", - "title": "Unix Msec Timestamp ( Start of Aggregate window )" - }, - "n": { - "existingJavaType": "java.lang.Integer", - "title": "Number of items in aggregate window" - } - } -} diff --git a/schema_json/polygon/aggregates/aggregates_response.json b/schema_json/polygon/aggregates/aggregates_response.json deleted file mode 100644 index f8924c96..00000000 --- a/schema_json/polygon/aggregates/aggregates_response.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_aggs_ticker_ticker_range_multiplier_timespan_from_to", - "properties": { - "ticker": { - "existingJavaType": "java.lang.String", - "title": "Ticker symbol requested" - }, - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of the response" - }, - "adjusted": { - "existingJavaType": "java.lang.Boolean", - "title": "If this response was adjusted for splits" - }, - "queryCount": { - "existingJavaType": "java.lang.Double", - "title": "Number of aggregate ( min or day ) used to generate the response" - }, - "resultsCount": { - "existingJavaType": "java.lang.Double", - "title": "Total number of results generated" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "results" - } - } -} diff --git a/schema_json/polygon/conditions_mapping/conditions_mapping.json b/schema_json/polygon/conditions_mapping/conditions_mapping.json deleted file mode 100644 index 00044e61..00000000 --- a/schema_json/polygon/conditions_mapping/conditions_mapping.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v1_meta_conditions_ticktype", - "extends": { - "existingJavaType": "java.util.HashMap" - } -} diff --git a/schema_json/polygon/daily_open_close/daily_open_close_response.json b/schema_json/polygon/daily_open_close/daily_open_close_response.json deleted file mode 100644 index 972e9e32..00000000 --- a/schema_json/polygon/daily_open_close/daily_open_close_response.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v1_open_close_symbol_date", - "properties": { - "symbol": { - "existingJavaType": "java.lang.String", - "title": "Symbol that was evaluated from the request" - }, - "open": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.dailyopenclose.DailyOpenCloseTrade", - "title": "open" - }, - "close": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.dailyopenclose.DailyOpenCloseTrade", - "title": "close" - }, - "afterHours": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.dailyopenclose.DailyOpenCloseTrade", - "title": "afterHours" - } - } -} diff --git a/schema_json/polygon/daily_open_close/daily_open_close_trade.json b/schema_json/polygon/daily_open_close/daily_open_close_trade.json deleted file mode 100644 index f4e650e9..00000000 --- a/schema_json/polygon/daily_open_close/daily_open_close_trade.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v1_open_close_symbol_date", - "properties": { - "condition1": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 1 of this trade" - }, - "condition2": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 2 of this trade" - }, - "condition3": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 3 of this trade" - }, - "condition4": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 4 of this trade" - }, - "exchange": { - "existingJavaType": "java.lang.Integer", - "title": "The exchange this trade happened on" - }, - "price": { - "existingJavaType": "java.lang.Double", - "title": "Price of the trade" - }, - "size": { - "existingJavaType": "java.lang.Integer", - "title": "Size of the trade" - }, - "timestamp": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Timestamp of this trade" - } - } -} diff --git a/schema_json/polygon/exchanges/exchange.json b/schema_json/polygon/exchanges/exchange.json deleted file mode 100644 index 37ed8d63..00000000 --- a/schema_json/polygon/exchanges/exchange.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v1_meta_exchanges", - "properties": { - "id": { - "existingJavaType": "java.lang.Integer", - "title": "ID of the exchange" - }, - "type": { - "existingJavaType": "java.lang.String", - "title": "The type of exchange this is.
- TRF = Trade Reporting Facility
- exchange = Reporting exchange on the tape
Can be TRF or exchange" - }, - "market": { - "existingJavaType": "java.lang.String", - "title": "Market data type this exchange contains. Can be equities or indices" - }, - "mic": { - "existingJavaType": "java.lang.String", - "title": "Market Identification Code" - }, - "name": { - "existingJavaType": "java.lang.String", - "title": "Name of the exchange" - }, - "tape": { - "existingJavaType": "java.lang.String", - "title": "Tape id of the exchange" - } - } -} diff --git a/schema_json/polygon/grouped_daily/grouped_daily_response.json b/schema_json/polygon/grouped_daily/grouped_daily_response.json deleted file mode 100644 index 6a39aa9d..00000000 --- a/schema_json/polygon/grouped_daily/grouped_daily_response.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_aggs_grouped_locale_locale_market_market_date", - "properties": { - "ticker": { - "existingJavaType": "java.lang.String", - "title": "Ticker symbol requested" - }, - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of the response" - }, - "adjusted": { - "existingJavaType": "java.lang.Boolean", - "title": "If this response was adjusted for splits" - }, - "queryCount": { - "existingJavaType": "java.lang.Integer", - "title": "Number of aggregate ( min or day ) used to generate the response" - }, - "resultsCount": { - "existingJavaType": "java.lang.Integer", - "title": "Total number of results generated" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "Results" - } - } -} - diff --git a/schema_json/polygon/historic_quotes/historic_quote.json b/schema_json/polygon/historic_quotes/historic_quote.json deleted file mode 100644 index fc1b56f7..00000000 --- a/schema_json/polygon/historic_quotes/historic_quote.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_nbbo_ticker_date", - "properties": { - "T": { - "existingJavaType": "java.lang.String", - "javaName": "ticker", - "title": "Ticker of the object" - }, - "t": { - "existingJavaType": "java.lang.Long", - "title": "Nanosecond accuracy SIP Unix Timestamp" - }, - "y": { - "existingJavaType": "java.lang.Long", - "title": "Nanosecond accuracy Participant/Exchange Unix Timestamp" - }, - "f": { - "existingJavaType": "java.lang.Long", - "title": "Nanosecond accuracy TRF(Trade Reporting Facility) Unix Timestamp" - }, - "q": { - "existingJavaType": "java.lang.Integer", - "title": "Sequence Number" - }, - "c": { - "existingJavaType": "java.util.ArrayList", - "title": "Conditions" - }, - "i": { - "existingJavaType": "java.util.ArrayList", - "title": "Indicators" - }, - "p": { - "existingJavaType": "java.lang.Double", - "javaName": "bp", - "title": "BID Price" - }, - "x": { - "existingJavaType": "java.lang.Integer", - "javaName": "bx", - "title": "BID Exchange ID" - }, - "s": { - "existingJavaType": "java.lang.Integer", - "javaName": "bs", - "title": "BID Size ( In round lots )" - }, - "P": { - "existingJavaType": "java.lang.Double", - "javaName": "ap", - "title": "ASK Price" - }, - "X": { - "existingJavaType": "java.lang.Integer", - "javaName": "ax", - "title": "ASK Exchange ID" - }, - "S": { - "existingJavaType": "java.lang.Integer", - "javaName": "as", - "title": "ASK Size ( In round lots )" - }, - "z": { - "existingJavaType": "java.lang.Integer", - "title": "Tape where trade occured. ( 1,2 = CTA, 3 = UTP )" - } - } -} diff --git a/schema_json/polygon/historic_quotes/historic_quotes_response.json b/schema_json/polygon/historic_quotes/historic_quotes_response.json deleted file mode 100644 index 62a6026a..00000000 --- a/schema_json/polygon/historic_quotes/historic_quotes_response.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_nbbo_ticker_date", - "properties": { - "results_count": { - "existingJavaType": "java.lang.Integer", - "title": "Total number of results in this response" - }, - "db_latency": { - "existingJavaType": "java.lang.Integer", - "title": "Milliseconds of latency for the query results from DB" - }, - "success": { - "existingJavaType": "java.lang.Boolean", - "title": "If this query was executed successfully" - }, - "ticker": { - "existingJavaType": "java.lang.String", - "title": "Ticker symbol that was evaluated from the request" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "results" - } - } -} diff --git a/schema_json/polygon/historic_trades/historic_trade.json b/schema_json/polygon/historic_trades/historic_trade.json deleted file mode 100644 index 50ee0066..00000000 --- a/schema_json/polygon/historic_trades/historic_trade.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_trades_ticker_date", - "properties": { - "T": { - "existingJavaType": "java.lang.String", - "javaName": "ticker", - "title": "Ticker of the object" - }, - "t": { - "existingJavaType": "java.lang.Long", - "title": "Nanosecond accuracy SIP Unix Timestamp" - }, - "y": { - "existingJavaType": "java.lang.Long", - "title": "Nanosecond accuracy Participant/Exchange Unix Timestamp" - }, - "f": { - "existingJavaType": "java.lang.Long", - "title": "Nanosecond accuracy TRF(Trade Reporting Facility) Unix Timestamp" - }, - "q": { - "existingJavaType": "java.lang.Integer", - "title": "Sequence Number" - }, - "i": { - "existingJavaType": "java.lang.String", - "title": "Trade ID" - }, - "x": { - "existingJavaType": "java.lang.Integer", - "title": "Exchange ID" - }, - "s": { - "existingJavaType": "java.lang.Integer", - "title": "Size/Volume of the trade" - }, - "c": { - "existingJavaType": "java.util.ArrayList", - "title": "Conditions" - }, - "p": { - "existingJavaType": "java.lang.Double", - "title": "Price of the trade" - }, - "z": { - "existingJavaType": "java.lang.Integer", - "title": "Tape where trade occured. ( 1,2 = CTA, 3 = UTP )" - } - } -} diff --git a/schema_json/polygon/historic_trades/historic_trades_response.json b/schema_json/polygon/historic_trades/historic_trades_response.json deleted file mode 100644 index d37da34b..00000000 --- a/schema_json/polygon/historic_trades/historic_trades_response.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_trades_ticker_date", - "properties": { - "results_count": { - "existingJavaType": "java.lang.Integer", - "title": "Total number of results in this response" - }, - "db_latency": { - "existingJavaType": "java.lang.Integer", - "title": "Milliseconds of latency for the query results from DB" - }, - "success": { - "existingJavaType": "java.lang.Boolean", - "title": "If this query was executed successfully" - }, - "ticker": { - "existingJavaType": "java.lang.String", - "title": "Ticker symbol that was evaluated from the request" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "results" - } - } -} diff --git a/schema_json/polygon/last_quote/last_quote.json b/schema_json/polygon/last_quote/last_quote.json deleted file mode 100644 index 17dd795b..00000000 --- a/schema_json/polygon/last_quote/last_quote.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v1_last_quote_stocks_symbol", - "properties": { - "askprice": { - "existingJavaType": "java.lang.Double", - "title": "Ask Price" - }, - "asksize": { - "existingJavaType": "java.lang.Long", - "title": "Ask Size" - }, - "askexchange": { - "existingJavaType": "java.lang.Integer", - "title": "Exchange the ask happened on" - }, - "bidprice": { - "existingJavaType": "java.lang.Double", - "title": "Bid Price" - }, - "bidsize": { - "existingJavaType": "java.lang.Long", - "title": "Bid Size" - }, - "bidexchange": { - "existingJavaType": "java.lang.Integer", - "title": "Exchange the bid happened on" - }, - "timestamp": { - "existingJavaType": "java.lang.Long", - "title": "Timestamp of this trade" - } - } -} diff --git a/schema_json/polygon/last_quote/last_quote_response.json b/schema_json/polygon/last_quote/last_quote_response.json deleted file mode 100644 index 20ce7727..00000000 --- a/schema_json/polygon/last_quote/last_quote_response.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v1_last_quote_stocks_symbol", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of this requests response" - }, - "symbol": { - "existingJavaType": "java.lang.String", - "title": "Symbol that was evaluated from the request" - }, - "last": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.lastquote.LastQuote", - "title": "last" - } - } -} diff --git a/schema_json/polygon/last_trade/last_trade.json b/schema_json/polygon/last_trade/last_trade.json deleted file mode 100644 index 12e63250..00000000 --- a/schema_json/polygon/last_trade/last_trade.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v1_last_stocks_symbol", - "properties": { - "price": { - "existingJavaType": "java.lang.Double", - "title": "Price of the trade" - }, - "size": { - "existingJavaType": "java.lang.Long", - "title": "Size of this trade" - }, - "exchange": { - "existingJavaType": "java.lang.Integer", - "title": "Exchange this trade happened on" - }, - "cond1": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 1 of the trade" - }, - "cond2": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 2 of the trade" - }, - "cond3": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 3 of the trade" - }, - "cond4": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 4 of the trade" - }, - "timestamp": { - "existingJavaType": "java.lang.Long", - "title": "Timestamp of this trade" - } - } -} diff --git a/schema_json/polygon/last_trade/last_trade_response.json b/schema_json/polygon/last_trade/last_trade_response.json deleted file mode 100644 index c86bb30d..00000000 --- a/schema_json/polygon/last_trade/last_trade_response.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v1_last_stocks_symbol", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of this requests response" - }, - "symbol": { - "existingJavaType": "java.lang.String", - "title": "Symbol that was evaluated from the request" - }, - "last": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.lasttrade.LastTrade", - "title": "last" - } - } -} diff --git a/schema_json/polygon/locales/locale.json b/schema_json/polygon/locales/locale.json deleted file mode 100644 index a8912865..00000000 --- a/schema_json/polygon/locales/locale.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_locales", - "properties": { - "locale": { - "existingJavaType": "java.lang.String", - "title": "Locale" - }, - "name": { - "existingJavaType": "java.lang.String", - "title": "Name" - } - } -} diff --git a/schema_json/polygon/locales/locales_response.json b/schema_json/polygon/locales/locales_response.json deleted file mode 100644 index 6be63576..00000000 --- a/schema_json/polygon/locales/locales_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_locales", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "Results" - } - } -} diff --git a/schema_json/polygon/market_holidays/market_holiday.json b/schema_json/polygon/market_holidays/market_holiday.json deleted file mode 100644 index 173e3405..00000000 --- a/schema_json/polygon/market_holidays/market_holiday.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v1_marketstatus_upcoming", - "properties": { - "exchange": { - "existingJavaType": "java.lang.String", - "title": "Which market this record is for. Can be NYSE, NASDAQ or OTC" - }, - "name": { - "existingJavaType": "java.lang.String", - "title": "Human readable description of the holiday" - }, - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of the market on this holiday. Can be closed, early-close, late-close, early-open or late-open" - }, - "date": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Date of this holiday" - }, - "open": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Market open time on this holiday ( if it's not closed )" - }, - "close": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Market close time on this holiday ( if it's not closed )" - } - } -} diff --git a/schema_json/polygon/market_status/market_status.json b/schema_json/polygon/market_status/market_status.json deleted file mode 100644 index 2fccfb87..00000000 --- a/schema_json/polygon/market_status/market_status.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v1_marketstatus_now", - "properties": { - "market": { - "existingJavaType": "java.lang.String", - "title": "Status of the market as a whole. Can be open, closed or extended-hours" - }, - "serverTime": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Current time of the server" - }, - "exchanges": { - "existingJavaType": "java.util.HashMap", - "title": "exchanges" - }, - "currencies": { - "existingJavaType": "java.util.HashMap", - "title": "currencies" - } - } -} diff --git a/schema_json/polygon/markets/market.json b/schema_json/polygon/markets/market.json deleted file mode 100644 index 126bea59..00000000 --- a/schema_json/polygon/markets/market.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_markets", - "properties": { - "market": { - "existingJavaType": "java.lang.String", - "title": "Market" - }, - "desc": { - "existingJavaType": "java.lang.String", - "title": "Description" - } - } -} diff --git a/schema_json/polygon/markets/markets_response.json b/schema_json/polygon/markets/markets_response.json deleted file mode 100644 index 619a5031..00000000 --- a/schema_json/polygon/markets/markets_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_markets", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "Results" - } - } -} diff --git a/schema_json/polygon/previous_close/previous_close_response.json b/schema_json/polygon/previous_close/previous_close_response.json deleted file mode 100644 index da57b1a1..00000000 --- a/schema_json/polygon/previous_close/previous_close_response.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_aggs_ticker_ticker_prev", - "properties": { - "ticker": { - "existingJavaType": "java.lang.String", - "title": "Ticker symbol requested" - }, - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of the response" - }, - "adjusted": { - "existingJavaType": "java.lang.Boolean", - "title": "If this response was adjusted for splits" - }, - "queryCount": { - "existingJavaType": "java.lang.Integer", - "title": "Number of aggregate ( min or day ) used to generate the response" - }, - "resultsCount": { - "existingJavaType": "java.lang.Integer", - "title": "Total number of results generated" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "Results" - } - } -} - diff --git a/schema_json/polygon/snapshot/snapshot_all_tickers_response.json b/schema_json/polygon/snapshot/snapshot_all_tickers_response.json deleted file mode 100644 index 42b1c494..00000000 --- a/schema_json/polygon/snapshot/snapshot_all_tickers_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_snapshot_locale_us_markets_stocks_tickers", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of this requests response" - }, - "tickers": { - "existingJavaType": "java.util.ArrayList", - "title": "tickers" - } - } -} diff --git a/schema_json/polygon/snapshot/snapshot_gainers_losers_response.json b/schema_json/polygon/snapshot/snapshot_gainers_losers_response.json deleted file mode 100644 index dae0184a..00000000 --- a/schema_json/polygon/snapshot/snapshot_gainers_losers_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_snapshot_locale_us_markets_stocks_direction", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of this requests response" - }, - "tickers": { - "existingJavaType": "java.util.ArrayList", - "title": "tickers" - } - } -} diff --git a/schema_json/polygon/snapshot/snapshot_single_ticker_response.json b/schema_json/polygon/snapshot/snapshot_single_ticker_response.json deleted file mode 100644 index 389c9f15..00000000 --- a/schema_json/polygon/snapshot/snapshot_single_ticker_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_snapshot_locale_us_markets_stocks_tickers_ticker", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of this requests response" - }, - "ticker": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.snapshot.ticker.SnapshotTicker", - "title": "tickers" - } - } -} diff --git a/schema_json/polygon/snapshot/snapshot_ticker_book.json b/schema_json/polygon/snapshot/snapshot_ticker_book.json deleted file mode 100644 index d9f795ce..00000000 --- a/schema_json/polygon/snapshot/snapshot_ticker_book.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See (documentation not yet public)", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status of this requests response" - }, - "data": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.snapshot.ticker.book.BookData", - "title": "The book data" - } - } -} diff --git a/schema_json/polygon/snapshot/ticker/book/book_data.json b/schema_json/polygon/snapshot/ticker/book/book_data.json deleted file mode 100644 index 0fbc7d1c..00000000 --- a/schema_json/polygon/snapshot/ticker/book/book_data.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "type": "object", - "title": "See (documentation not yet public)", - "properties": { - "ticker": { - "existingJavaType": "java.lang.String", - "title": "The ticker" - }, - "bids": { - "existingJavaType": "java.util.ArrayList", - "title": "The bids on the book" - }, - "asks": { - "existingJavaType": "java.util.ArrayList", - "title": "The asks on the book" - }, - "bidCount": { - "existingJavaType": "java.lang.Integer", - "title": "The volume of bids on the book" - }, - "askCount": { - "existingJavaType": "java.lang.Integer", - "title": "The volume of asks on the book" - }, - "spread": { - "existingJavaType": "java.lang.Double", - "title": "The spread" - }, - "updated": { - "existingJavaType": "java.lang.Long", - "title": "Updated timestamp" - } - } -} diff --git a/schema_json/polygon/snapshot/ticker/book/book_order.json b/schema_json/polygon/snapshot/ticker/book/book_order.json deleted file mode 100644 index baf1a054..00000000 --- a/schema_json/polygon/snapshot/ticker/book/book_order.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See (documentation not yet public)", - "properties": { - "p": { - "existingJavaType": "java.lang.Double", - "title": "The price" - }, - "x": { - "existingJavaType": "java.util.HashMap", - "title": "The map of an exchange ID to its order volume" - } - } -} diff --git a/schema_json/polygon/snapshot/ticker/last_quote.json b/schema_json/polygon/snapshot/ticker/last_quote.json deleted file mode 100644 index 7e89f5b7..00000000 --- a/schema_json/polygon/snapshot/ticker/last_quote.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_snapshot_locale_us_markets_stocks_tickers", - "properties": { - "p": { - "javaName": "bp", - "existingJavaType": "java.lang.Double", - "title": "Bid Price" - }, - "s": { - "javaName": "bs", - "existingJavaType": "java.lang.Integer", - "title": "Bid size in lots" - }, - "P": { - "javaName": "ap", - "existingJavaType": "java.lang.Double", - "title": "Ask Price" - }, - "S": { - "javaName": "as", - "existingJavaType": "java.lang.Integer", - "title": "Ask size in lots" - }, - "t": { - "existingJavaType": "java.lang.Long", - "title": "Last Updated timestamp ( Nanosecond Timestamp )" - } - } -} diff --git a/schema_json/polygon/snapshot/ticker/last_trade.json b/schema_json/polygon/snapshot/ticker/last_trade.json deleted file mode 100644 index c9c63ed4..00000000 --- a/schema_json/polygon/snapshot/ticker/last_trade.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_snapshot_locale_us_markets_stocks_tickers", - "properties": { - "c1": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 1 of this trade" - }, - "c2": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 2 of this trade" - }, - "c3": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 3 of this trade" - }, - "c4": { - "existingJavaType": "java.lang.Integer", - "title": "Condition 4 of this trade" - }, - "e": { - "existingJavaType": "java.lang.Integer", - "title": "The exchange this trade happened on" - }, - "p": { - "existingJavaType": "java.lang.Double", - "title": "Price of the trade" - }, - "s": { - "existingJavaType": "java.lang.Integer", - "title": "Size of the trade" - }, - "t": { - "existingJavaType": "java.lang.Long", - "title": "Timestamp of this trade" - } - } -} diff --git a/schema_json/polygon/snapshot/ticker/snapshot_ticker.json b/schema_json/polygon/snapshot/ticker/snapshot_ticker.json deleted file mode 100644 index 0b9f7d68..00000000 --- a/schema_json/polygon/snapshot/ticker/snapshot_ticker.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_snapshot_locale_us_markets_stocks_tickers", - "properties": { - "ticker": { - "existingJavaType": "java.lang.String", - "title": "Ticker of the object" - }, - "day": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.snapshot.ticker.TickerCandle", - "title": "day" - }, - "lastTrade": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.snapshot.ticker.LastTrade", - "title": "lastTrade" - }, - "lastQuote": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.snapshot.ticker.LastQuote", - "title": "lastQuote" - }, - "min": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.snapshot.ticker.TickerCandle", - "title": "min" - }, - "prevDay": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.snapshot.ticker.TickerCandle", - "title": "prevDay" - }, - "todaysChange": { - "existingJavaType": "java.lang.Double", - "title": "Value of the change from previous day" - }, - "todaysChangePerc": { - "existingJavaType": "java.lang.Double", - "title": "Percentage change since previous day" - }, - "updated": { - "existingJavaType": "java.lang.Long", - "title": "Last Updated timestamp" - } - } -} diff --git a/schema_json/polygon/snapshot/ticker/ticker_candle.json b/schema_json/polygon/snapshot/ticker/ticker_candle.json deleted file mode 100644 index 4a0b63a8..00000000 --- a/schema_json/polygon/snapshot/ticker/ticker_candle.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Stocks--Equities/get_v2_snapshot_locale_us_markets_stocks_tickers", - "properties": { - "c": { - "existingJavaType": "java.lang.Double", - "title": "Close price" - }, - "h": { - "existingJavaType": "java.lang.Double", - "title": "High price" - }, - "l": { - "existingJavaType": "java.lang.Double", - "title": "Low price" - }, - "o": { - "existingJavaType": "java.lang.Double", - "title": "Open price" - }, - "v": { - "existingJavaType": "java.lang.Double", - "title": "Volume" - } - } -} diff --git a/schema_json/polygon/stock_dividends/stock_dividend.json b/schema_json/polygon/stock_dividends/stock_dividend.json deleted file mode 100644 index 89f6a893..00000000 --- a/schema_json/polygon/stock_dividends/stock_dividend.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_dividends_symbol", - "properties": { - "symbol": { - "existingJavaType": "java.lang.String", - "title": "symbol" - }, - "type": { - "existingJavaType": "java.lang.String", - "title": "Refers to the dividend payment type
- Dividend income
- Interest income
- Stock dividend
- Short term capital gain
- Medium term capital gain
- Long term capital gain
- Unspecified term capital gain
" - }, - "exDate": { - "existingJavaType": "java.lang.String", - "title": "Execution date of the trade" - }, - "paymentDate": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Payment date of the trade" - }, - "recordDate": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Record date of the trade" - }, - "declaredDate": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Declared date of the trade" - }, - "amount": { - "existingJavaType": "java.lang.Double", - "title": "Amount of the dividend" - }, - "qualified": { - "existingJavaType": "java.lang.String", - "title": "Refers to the dividend income type
- P = Partially qualified income
- Q = Qualified income
- N = Unqualified income
- null = N/A or unknown
Can be P, Q, N or null" - }, - "flag": { - "existingJavaType": "java.lang.String", - "title": "Refers to the dividend flag, if set
FI = Final dividend, div ends or instrument ends
LI = Liquidation, instrument liquidates
PR = Proceeds of a sale of rights or shares
RE = Redemption of rights
AC = Accrued dividend
AR = Payment in arrears
AD = Additional payment
EX = Extra payment
SP = Special dividend
YE = Year end
UR = Unknown rate
SU = Regular dividend is suspended" - } - } -} diff --git a/schema_json/polygon/stock_dividends/stock_dividends_response.json b/schema_json/polygon/stock_dividends/stock_dividends_response.json deleted file mode 100644 index b9f7fe26..00000000 --- a/schema_json/polygon/stock_dividends/stock_dividends_response.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_dividends_symbol", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status" - }, - "count": { - "existingJavaType": "java.lang.Integer", - "title": "Count" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "Results" - } - } -} diff --git a/schema_json/polygon/stock_financials/stock_financials.json b/schema_json/polygon/stock_financials/stock_financials.json deleted file mode 100644 index fbf25368..00000000 --- a/schema_json/polygon/stock_financials/stock_financials.json +++ /dev/null @@ -1,446 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_financials_symbol", - "properties": { - "ticker": { - "existingJavaType": "java.lang.String", - "title": "ticker" - }, - "period": { - "existingJavaType": "java.lang.String", - "title": "Reporting period. Can be Q, T, QA, TA, Y or YA" - }, - "calendarDate": { - "existingJavaType": "java.lang.String", - "title": "calendarDate" - }, - "reportPeriod": { - "existingJavaType": "java.lang.String", - "title": "reportPeriod" - }, - "updated": { - "existingJavaType": "java.lang.String", - "title": "updated" - }, - "accumulatedOtherComprehensiveIncome": { - "existingJavaType": "java.lang.Double", - "title": "accumulatedOtherComprehensiveIncome" - }, - "assets": { - "existingJavaType": "java.lang.Double", - "title": "assets" - }, - "assetsAverage": { - "existingJavaType": "java.lang.Double", - "title": "assetsAverage" - }, - "assetsCurrent": { - "existingJavaType": "java.lang.Double", - "title": "assetsCurrent" - }, - "assetTurnover": { - "existingJavaType": "java.lang.Double", - "title": "assetTurnover" - }, - "assetsNonCurrent": { - "existingJavaType": "java.lang.Double", - "title": "assetsNonCurrent" - }, - "bookValuePerShare": { - "existingJavaType": "java.lang.Double", - "title": "bookValuePerShare" - }, - "capitalExpenditure": { - "existingJavaType": "java.lang.Double", - "title": "capitalExpenditure" - }, - "cashAndEquivalents": { - "existingJavaType": "java.lang.Double", - "title": "cashAndEquivalents" - }, - "cashAndEquivalentsUSD": { - "existingJavaType": "java.lang.Double", - "title": "cashAndEquivalentsUSD" - }, - "costOfRevenue": { - "existingJavaType": "java.lang.Double", - "title": "costOfRevenue" - }, - "consolidatedIncome": { - "existingJavaType": "java.lang.Double", - "title": "consolidatedIncome" - }, - "currentRatio": { - "existingJavaType": "java.lang.Double", - "title": "currentRatio" - }, - "debtToEquityRatio": { - "existingJavaType": "java.lang.Double", - "title": "debtToEquityRatio" - }, - "debt": { - "existingJavaType": "java.lang.Double", - "title": "debt" - }, - "debtCurrent": { - "existingJavaType": "java.lang.Double", - "title": "debtCurrent" - }, - "debtNonCurrent": { - "existingJavaType": "java.lang.Double", - "title": "debtNonCurrent" - }, - "debtUSD": { - "existingJavaType": "java.lang.Double", - "title": "debtUSD" - }, - "deferredRevenue": { - "existingJavaType": "java.lang.Double", - "title": "deferredRevenue" - }, - "depreciationAmortizationAndAccretion": { - "existingJavaType": "java.lang.Double", - "title": "depreciationAmortizationAndAccretion" - }, - "deposits": { - "existingJavaType": "java.lang.Double", - "title": "deposits" - }, - "dividendYield": { - "existingJavaType": "java.lang.Double", - "title": "dividendYield" - }, - "dividendsPerBasicCommonShare": { - "existingJavaType": "java.lang.Double", - "title": "dividendsPerBasicCommonShare" - }, - "earningBeforeInterestTaxes": { - "existingJavaType": "java.lang.Double", - "title": "earningBeforeInterestTaxes" - }, - "earningsBeforeInterestTaxesDepreciationAmortization": { - "existingJavaType": "java.lang.Double", - "title": "earningsBeforeInterestTaxesDepreciationAmortization" - }, - "EBITDAMargin": { - "existingJavaType": "java.lang.Double", - "title": "EBITDAMargin" - }, - "earningsBeforeInterestTaxesDepreciationAmortizationUSD": { - "existingJavaType": "java.lang.Double", - "title": "earningsBeforeInterestTaxesDepreciationAmortizationUSD" - }, - "earningBeforeInterestTaxesUSD": { - "existingJavaType": "java.lang.Double", - "title": "earningBeforeInterestTaxesUSD" - }, - "earningsBeforeTax": { - "existingJavaType": "java.lang.Double", - "title": "earningsBeforeTax" - }, - "earningsPerBasicShare": { - "existingJavaType": "java.lang.Double", - "title": "earningsPerBasicShare" - }, - "earningsPerDilutedShare": { - "existingJavaType": "java.lang.Double", - "title": "earningsPerDilutedShare" - }, - "earningsPerBasicShareUSD": { - "existingJavaType": "java.lang.Double", - "title": "earningsPerBasicShareUSD" - }, - "shareholdersEquity": { - "existingJavaType": "java.lang.Double", - "title": "shareholdersEquity" - }, - "averageEquity": { - "existingJavaType": "java.lang.Double", - "title": "averageEquity" - }, - "shareholdersEquityUSD": { - "existingJavaType": "java.lang.Double", - "title": "shareholdersEquityUSD" - }, - "enterpriseValue": { - "existingJavaType": "java.lang.Double", - "title": "enterpriseValue" - }, - "enterpriseValueOverEBIT": { - "existingJavaType": "java.lang.Double", - "title": "enterpriseValueOverEBIT" - }, - "enterpriseValueOverEBITDA": { - "existingJavaType": "java.lang.Double", - "title": "enterpriseValueOverEBITDA" - }, - "freeCashFlow": { - "existingJavaType": "java.lang.Double", - "title": "freeCashFlow" - }, - "freeCashFlowPerShare": { - "existingJavaType": "java.lang.Double", - "title": "freeCashFlowPerShare" - }, - "foreignCurrencyUSDExchangeRate": { - "existingJavaType": "java.lang.Double", - "title": "foreignCurrencyUSDExchangeRate" - }, - "grossProfit": { - "existingJavaType": "java.lang.Double", - "title": "grossProfit" - }, - "grossMargin": { - "existingJavaType": "java.lang.Double", - "title": "grossMargin" - }, - "goodwillAndIntangibleAssets": { - "existingJavaType": "java.lang.Double", - "title": "goodwillAndIntangibleAssets" - }, - "interestExpense": { - "existingJavaType": "java.lang.Double", - "title": "interestExpense" - }, - "investedCapital": { - "existingJavaType": "java.lang.Double", - "title": "investedCapital" - }, - "investedCapitalAverage": { - "existingJavaType": "java.lang.Double", - "title": "investedCapitalAverage" - }, - "inventory": { - "existingJavaType": "java.lang.Double", - "title": "inventory" - }, - "investments": { - "existingJavaType": "java.lang.Double", - "title": "investments" - }, - "investmentsCurrent": { - "existingJavaType": "java.lang.Double", - "title": "investmentsCurrent" - }, - "investmentsNonCurrent": { - "existingJavaType": "java.lang.Double", - "title": "investmentsNonCurrent" - }, - "totalLiabilities": { - "existingJavaType": "java.lang.Double", - "title": "totalLiabilities" - }, - "currentLiabilities": { - "existingJavaType": "java.lang.Double", - "title": "currentLiabilities" - }, - "liabilitiesNonCurrent": { - "existingJavaType": "java.lang.Double", - "title": "liabilitiesNonCurrent" - }, - "marketCapitalization": { - "existingJavaType": "java.lang.Double", - "title": "marketCapitalization" - }, - "netCashFlow": { - "existingJavaType": "java.lang.Double", - "title": "netCashFlow" - }, - "netCashFlowBusinessAcquisitionsDisposals": { - "existingJavaType": "java.lang.Double", - "title": "netCashFlowBusinessAcquisitionsDisposals" - }, - "issuanceEquityShares": { - "existingJavaType": "java.lang.Double", - "title": "issuanceEquityShares" - }, - "issuanceDebtSecurities": { - "existingJavaType": "java.lang.Double", - "title": "issuanceDebtSecurities" - }, - "paymentDividendsOtherCashDistributions": { - "existingJavaType": "java.lang.Double", - "title": "paymentDividendsOtherCashDistributions" - }, - "netCashFlowFromFinancing": { - "existingJavaType": "java.lang.Double", - "title": "netCashFlowFromFinancing" - }, - "netCashFlowFromInvesting": { - "existingJavaType": "java.lang.Double", - "title": "netCashFlowFromInvesting" - }, - "netCashFlowInvestmentAcquisitionsDisposals": { - "existingJavaType": "java.lang.Double", - "title": "netCashFlowInvestmentAcquisitionsDisposals" - }, - "netCashFlowFromOperations": { - "existingJavaType": "java.lang.Double", - "title": "netCashFlowFromOperations" - }, - "effectOfExchangeRateChangesOnCash": { - "existingJavaType": "java.lang.Double", - "title": "effectOfExchangeRateChangesOnCash" - }, - "netIncome": { - "existingJavaType": "java.lang.Double", - "title": "netIncome" - }, - "netIncomeCommonStock": { - "existingJavaType": "java.lang.Double", - "title": "netIncomeCommonStock" - }, - "netIncomeCommonStockUSD": { - "existingJavaType": "java.lang.Double", - "title": "netIncomeCommonStockUSD" - }, - "netLossIncomeFromDiscontinuedOperations": { - "existingJavaType": "java.lang.Double", - "title": "netLossIncomeFromDiscontinuedOperations" - }, - "netIncomeToNonControllingInterests": { - "existingJavaType": "java.lang.Double", - "title": "netIncomeToNonControllingInterests" - }, - "profitMargin": { - "existingJavaType": "java.lang.Double", - "title": "profitMargin" - }, - "operatingExpenses": { - "existingJavaType": "java.lang.Double", - "title": "operatingExpenses" - }, - "operatingIncome": { - "existingJavaType": "java.lang.Double", - "title": "operatingIncome" - }, - "tradeAndNonTradePayables": { - "existingJavaType": "java.lang.Double", - "title": "tradeAndNonTradePayables" - }, - "payoutRatio": { - "existingJavaType": "java.lang.Double", - "title": "payoutRatio" - }, - "priceToBookValue": { - "existingJavaType": "java.lang.Double", - "title": "priceToBookValue" - }, - "priceEarnings": { - "existingJavaType": "java.lang.Double", - "title": "priceEarnings" - }, - "priceToEarningsRatio": { - "existingJavaType": "java.lang.Double", - "title": "priceToEarningsRatio" - }, - "propertyPlantEquipmentNet": { - "existingJavaType": "java.lang.Double", - "title": "propertyPlantEquipmentNet" - }, - "preferredDividendsIncomeStatementImpact": { - "existingJavaType": "java.lang.Double", - "title": "preferredDividendsIncomeStatementImpact" - }, - "sharePriceAdjustedClose": { - "existingJavaType": "java.lang.Double", - "title": "sharePriceAdjustedClose" - }, - "priceSales": { - "existingJavaType": "java.lang.Double", - "title": "priceSales" - }, - "priceToSalesRatio": { - "existingJavaType": "java.lang.Double", - "title": "priceToSalesRatio" - }, - "tradeAndNonTradeReceivables": { - "existingJavaType": "java.lang.Double", - "title": "tradeAndNonTradeReceivables" - }, - "accumulatedRetainedEarningsDeficit": { - "existingJavaType": "java.lang.Double", - "title": "accumulatedRetainedEarningsDeficit" - }, - "revenues": { - "existingJavaType": "java.lang.Double", - "title": "revenues" - }, - "revenuesUSD": { - "existingJavaType": "java.lang.Double", - "title": "revenuesUSD" - }, - "researchAndDevelopmentExpense": { - "existingJavaType": "java.lang.Double", - "title": "researchAndDevelopmentExpense" - }, - "returnOnAverageAssets": { - "existingJavaType": "java.lang.Double", - "title": "returnOnAverageAssets" - }, - "returnOnAverageEquity": { - "existingJavaType": "java.lang.Double", - "title": "returnOnAverageEquity" - }, - "returnOnInvestedCapital": { - "existingJavaType": "java.lang.Double", - "title": "returnOnInvestedCapital" - }, - "returnOnSales": { - "existingJavaType": "java.lang.Double", - "title": "returnOnSales" - }, - "shareBasedCompensation": { - "existingJavaType": "java.lang.Double", - "title": "shareBasedCompensation" - }, - "sellingGeneralAndAdministrativeExpense": { - "existingJavaType": "java.lang.Double", - "title": "sellingGeneralAndAdministrativeExpense" - }, - "shareFactor": { - "existingJavaType": "java.lang.Double", - "title": "shareFactor" - }, - "shares": { - "existingJavaType": "java.lang.Double", - "title": "shares" - }, - "weightedAverageShares": { - "existingJavaType": "java.lang.Double", - "title": "weightedAverageShares" - }, - "weightedAverageSharesDiluted": { - "existingJavaType": "java.lang.Double", - "title": "weightedAverageSharesDiluted" - }, - "salesPerShare": { - "existingJavaType": "java.lang.Double", - "title": "salesPerShare" - }, - "tangibleAssetValue": { - "existingJavaType": "java.lang.Double", - "title": "tangibleAssetValue" - }, - "taxAssets": { - "existingJavaType": "java.lang.Double", - "title": "taxAssets" - }, - "incomeTaxExpense": { - "existingJavaType": "java.lang.Double", - "title": "incomeTaxExpense" - }, - "taxLiabilities": { - "existingJavaType": "java.lang.Double", - "title": "taxLiabilities" - }, - "tangibleAssetsBookValuePerShare": { - "existingJavaType": "java.lang.Double", - "title": "tangibleAssetsBookValuePerShare" - }, - "workingCapital": { - "existingJavaType": "java.lang.Double", - "title": "workingCapital" - } - } -} diff --git a/schema_json/polygon/stock_financials/stock_financials_response.json b/schema_json/polygon/stock_financials/stock_financials_response.json deleted file mode 100644 index 725cfffd..00000000 --- a/schema_json/polygon/stock_financials/stock_financials_response.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_financials_symbol", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status" - }, - "count": { - "existingJavaType": "java.lang.Integer", - "title": "Count" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "Results" - } - } -} diff --git a/schema_json/polygon/stock_splits/stock_split.json b/schema_json/polygon/stock_splits/stock_split.json deleted file mode 100644 index 78783882..00000000 --- a/schema_json/polygon/stock_splits/stock_split.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_splits_symbol", - "properties": { - "ticker": { - "existingJavaType": "java.lang.String", - "title": "ticker" - }, - "exDate": { - "existingJavaType": "java.lang.String", - "title": "Execution date of the split" - }, - "paymentDate": { - "existingJavaType": "java.lang.String", - "title": "Payment date of the split" - }, - "recordDate": { - "existingJavaType": "java.lang.String", - "title": "Payment date of the split" - }, - "declaredDate": { - "existingJavaType": "java.lang.String", - "title": "Payment date of the split" - }, - "ratio": { - "existingJavaType": "java.lang.Double", - "title": "refers to the split ratio. The split ratio is an inverse of the number of shares that a holder of the stock would have after the split divided by the number of shares that the holder had before. For example: Split ratio of .5 = 2 for 1 split." - }, - "tofactor": { - "existingJavaType": "java.lang.Double", - "title": "To factor of the split. Used to calculate the split ratio forfactor/tofactor = ratio (eg ½ = 0.5)" - }, - "forfactor": { - "existingJavaType": "java.lang.Double", - "title": "For factor of the split. Used to calculate the split ratio forfactor/tofactor = ratio (eg ½ = 0.5)" - } - } -} diff --git a/schema_json/polygon/stock_splits/stock_splits_response.json b/schema_json/polygon/stock_splits/stock_splits_response.json deleted file mode 100644 index ffdf5926..00000000 --- a/schema_json/polygon/stock_splits/stock_splits_response.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_splits_symbol", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status" - }, - "count": { - "existingJavaType": "java.lang.Integer", - "title": "Count" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "Results" - } - } -} diff --git a/schema_json/polygon/ticker_details/ticker_details.json b/schema_json/polygon/ticker_details/ticker_details.json deleted file mode 100644 index 6a232691..00000000 --- a/schema_json/polygon/ticker_details/ticker_details.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v1_meta_symbols_symbol_company", - "properties": { - "logo": { - "existingJavaType": "java.lang.String", - "title": "URL of the entities logo." - }, - "exchange": { - "existingJavaType": "java.lang.String", - "title": "Symbols primary exchange" - }, - "name": { - "existingJavaType": "java.lang.String", - "title": "Name of the company/entity" - }, - "symbol": { - "existingJavaType": "java.lang.String", - "title": "symbol" - }, - "listdate": { - "existingJavaType": "java.lang.String", - "title": "Date this symbol was listed on the exchange." - }, - "cik": { - "existingJavaType": "java.lang.String", - "title": "Official CIK guid used for SEC database / filings." - }, - "bloomberg": { - "existingJavaType": "java.lang.String", - "title": "Bloomberg guid for this symbol" - }, - "figi": { - "existingJavaType": "java.lang.String", - "title": "guid for the OpenFigi project ( https://openfigi.com/ )" - }, - "lei": { - "existingJavaType": "java.lang.String", - "title": "Legal Entity Identifier (LEI) guid for symbol ( https://en.wikipedia.org/wiki/Legal_Entity_Identifier )" - }, - "sic": { - "existingJavaType": "java.lang.Integer", - "title": "Standard Industrial Classification (SIC) id for symbol ( https://en.wikipedia.org/wiki/Standard_Industrial_Classification )" - }, - "country": { - "existingJavaType": "java.lang.String", - "title": "Country in which this company is registered" - }, - "industry": { - "existingJavaType": "java.lang.String", - "title": "Industry this company operates in" - }, - "sector": { - "existingJavaType": "java.lang.String", - "title": "Sector of the indsutry in which this symbol operates in" - }, - "marketcap": { - "existingJavaType": "java.lang.Double", - "title": "Current market cap for this company" - }, - "employees": { - "existingJavaType": "java.lang.Integer", - "title": "Approximate number of employees" - }, - "phone": { - "existingJavaType": "java.lang.String", - "title": "Phone number for this company. Usually corporate contact number." - }, - "ceo": { - "existingJavaType": "java.lang.String", - "title": "Name of the companies current CEO" - }, - "url": { - "existingJavaType": "java.lang.String", - "title": "URL of the companies website" - }, - "title": { - "existingJavaType": "java.lang.String", - "title": "A description of the company and what they do/offer" - }, - "similar": { - "existingJavaType": "java.util.ArrayList", - "title": "similar" - }, - "tags": { - "existingJavaType": "java.util.ArrayList", - "title": "tags" - }, - "updated": { - "existingJavaType": "java.lang.String", - "title": "Last time this company record was updated." - } - } -} diff --git a/schema_json/polygon/ticker_news/ticker_news.json b/schema_json/polygon/ticker_news/ticker_news.json deleted file mode 100644 index 773741a0..00000000 --- a/schema_json/polygon/ticker_news/ticker_news.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v1_meta_symbols_symbol_news", - "properties": { - "symbols": { - "existingJavaType": "java.util.ArrayList", - "title": "symbols" - }, - "title": { - "existingJavaType": "java.lang.String", - "title": "Name of the article" - }, - "url": { - "existingJavaType": "java.lang.String", - "title": "URL of this article" - }, - "source": { - "existingJavaType": "java.lang.String", - "title": "Source of this article" - }, - "summary": { - "existingJavaType": "java.lang.String", - "title": "Short summary of the article" - }, - "image": { - "existingJavaType": "java.lang.String", - "title": "URL of the image for this article, if found" - }, - "timestamp": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Timestamp of the article" - }, - "keywords": { - "existingJavaType": "java.util.ArrayList", - "title": "keywords" - } - } -} diff --git a/schema_json/polygon/ticker_types/ticker_types.json b/schema_json/polygon/ticker_types/ticker_types.json deleted file mode 100644 index a9571c6d..00000000 --- a/schema_json/polygon/ticker_types/ticker_types.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_types", - "properties": { - "types": { - "existingJavaType": "java.util.HashMap", - "title": "Types" - }, - "indexTypes": { - "existingJavaType": "java.util.HashMap", - "title": "Index Types" - } - } -} diff --git a/schema_json/polygon/ticker_types/ticket_types_response.json b/schema_json/polygon/ticker_types/ticket_types_response.json deleted file mode 100644 index 4a9c0694..00000000 --- a/schema_json/polygon/ticker_types/ticket_types_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_types", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status" - }, - "results": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.tickertypes.TickerTypes", - "title": "Results" - } - } -} diff --git a/schema_json/polygon/tickers/ticker/forex_ticker.json b/schema_json/polygon/tickers/ticker/forex_ticker.json deleted file mode 100644 index 07fc2871..00000000 --- a/schema_json/polygon/tickers/ticker/forex_ticker.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_tickers", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.tickers.ticker.Ticker" - }, - "properties": { - "attrs": { - "existingJavaType": "java.util.HashMap", - "title": "Attributes" - } - } -} diff --git a/schema_json/polygon/tickers/ticker/stock_ticker.json b/schema_json/polygon/tickers/ticker/stock_ticker.json deleted file mode 100644 index 5e940bbe..00000000 --- a/schema_json/polygon/tickers/ticker/stock_ticker.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_tickers", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.tickers.ticker.Ticker" - }, - "properties": { - "type": { - "existingJavaType": "java.lang.String", - "title": "Type of symbol this is. See symbol types." - }, - "codes": { - "existingJavaType": "java.util.HashMap", - "title": "Codes" - } - } -} diff --git a/schema_json/polygon/tickers/ticker/ticker.json b/schema_json/polygon/tickers/ticker/ticker.json deleted file mode 100644 index f2ab579e..00000000 --- a/schema_json/polygon/tickers/ticker/ticker.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_tickers", - "properties": { - "ticker": { - "existingJavaType": "java.lang.String", - "title": "Ticker" - }, - "name": { - "existingJavaType": "java.lang.String", - "title": "Name of the item." - }, - "market": { - "existingJavaType": "java.lang.String", - "title": "Market" - }, - "locale": { - "existingJavaType": "java.lang.String", - "title": "Locale" - }, - "currency": { - "existingJavaType": "java.lang.String", - "title": "Currency" - }, - "active": { - "existingJavaType": "java.lang.Boolean", - "title": "Active" - }, - "primaryExch": { - "existingJavaType": "java.lang.String", - "title": "Primary Exchange" - }, - "updated": { - "existingJavaType": "java.time.ZonedDateTime", - "title": "Last time this company record was updated." - }, - "url": { - "existingJavaType": "java.lang.String", - "title": "URL of this symbol. Use this to get this symbols endpoints." - } - } -} diff --git a/schema_json/polygon/tickers/tickers_response.json b/schema_json/polygon/tickers/tickers_response.json deleted file mode 100644 index a887d3e4..00000000 --- a/schema_json/polygon/tickers/tickers_response.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "object", - "title": "See https://polygon.io/docs/#!/Reference/get_v2_reference_tickers", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "Status" - }, - "page": { - "existingJavaType": "java.lang.Integer", - "title": "Page" - }, - "perPage": { - "existingJavaType": "java.lang.Integer", - "title": "Per Page" - }, - "count": { - "existingJavaType": "java.lang.Integer", - "title": "Count" - }, - "results": { - "existingJavaType": "java.util.ArrayList", - "title": "Results" - } - } -} diff --git a/schema_json/polygon/websocket/aggregate/aggregate_message.json b/schema_json/polygon/websocket/aggregate/aggregate_message.json deleted file mode 100644 index cf055d6b..00000000 --- a/schema_json/polygon/websocket/aggregate/aggregate_message.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.websocket.PolygonStreamMessage" - }, - "title": "See https://polygon.io/sockets", - "properties": { - "v": { - "existingJavaType": "java.lang.Long", - "title": "Tick Volume" - }, - "av": { - "existingJavaType": "java.lang.Long", - "title": "Accumulated Volume ( Today )" - }, - "op": { - "existingJavaType": "java.lang.Double", - "title": "Today's official opening price" - }, - "vw": { - "existingJavaType": "java.lang.Double", - "title": "VWAP (Volume Weighted Average Price)" - }, - "o": { - "existingJavaType": "java.lang.Double", - "title": "Tick Open Price" - }, - "c": { - "existingJavaType": "java.lang.Double", - "title": "Tick Close Price" - }, - "h": { - "existingJavaType": "java.lang.Double", - "title": "Tick High Price" - }, - "l": { - "existingJavaType": "java.lang.Double", - "title": "Tick Low Price" - }, - "a": { - "existingJavaType": "java.lang.Double", - "title": "Tick Average / VWAP Price" - }, - "s": { - "existingJavaType": "java.lang.Long", - "title": "Tick Start Timestamp ( Unix MS )" - }, - "e": { - "existingJavaType": "java.lang.Long", - "title": "Tick End Timestamp ( Unix MS )" - } - } -} diff --git a/schema_json/polygon/websocket/aggregate/aggregate_per_minute_message.json b/schema_json/polygon/websocket/aggregate/aggregate_per_minute_message.json deleted file mode 100644 index 41bdde93..00000000 --- a/schema_json/polygon/websocket/aggregate/aggregate_per_minute_message.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.websocket.aggregate.AggregateMessage" - }, - "title": "See https://polygon.io/sockets" -} diff --git a/schema_json/polygon/websocket/aggregate/aggregate_per_second_message.json b/schema_json/polygon/websocket/aggregate/aggregate_per_second_message.json deleted file mode 100644 index 41bdde93..00000000 --- a/schema_json/polygon/websocket/aggregate/aggregate_per_second_message.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.websocket.aggregate.AggregateMessage" - }, - "title": "See https://polygon.io/sockets" -} diff --git a/schema_json/polygon/websocket/polygon_stream_message.json b/schema_json/polygon/websocket/polygon_stream_message.json deleted file mode 100644 index ee06b470..00000000 --- a/schema_json/polygon/websocket/polygon_stream_message.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "object", - "javaInterfaces": [ - "io.github.mainstringargs.abstracts.websocket.message.StreamMessage" - ], - "title": "See https://polygon.io/sockets", - "properties": { - "ev": { - "existingJavaType": "io.github.mainstringargs.polygon.websocket.message.PolygonStreamMessageType", - "title": "The event type" - }, - "sym": { - "existingJavaType": "java.lang.String", - "title": "Symbol Ticker" - } - } -} diff --git a/schema_json/polygon/websocket/quote/quote_message.json b/schema_json/polygon/websocket/quote/quote_message.json deleted file mode 100644 index 487c79cb..00000000 --- a/schema_json/polygon/websocket/quote/quote_message.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.websocket.PolygonStreamMessage" - }, - "title": "See https://polygon.io/sockets", - "properties": { - "bx": { - "existingJavaType": "java.lang.String", - "title": "Bix Exchange ID" - }, - "bp": { - "existingJavaType": "java.lang.Double", - "title": "Bid Price" - }, - "bs": { - "existingJavaType": "java.lang.Integer", - "title": "Bid Size" - }, - "ax": { - "existingJavaType": "java.lang.String", - "title": "Ask Exchange ID" - }, - "ap": { - "existingJavaType": "java.lang.Double", - "title": "Ask Price" - }, - "as": { - "existingJavaType": "java.lang.Integer", - "title": "Ask Size" - }, - "c": { - "existingJavaType": "java.lang.Integer", - "title": "Quote Condition" - }, - "t": { - "existingJavaType": "java.lang.Long", - "title": "Quote Timestamp ( Unix MS )" - } - } -} diff --git a/schema_json/polygon/websocket/status/status_message.json b/schema_json/polygon/websocket/status/status_message.json deleted file mode 100644 index 1311a5df..00000000 --- a/schema_json/polygon/websocket/status/status_message.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.websocket.PolygonStreamMessage" - }, - "title": "See https://polygon.io/sockets", - "properties": { - "status": { - "existingJavaType": "java.lang.String", - "title": "The status" - }, - "message": { - "existingJavaType": "java.lang.String", - "title": "The message" - } - } -} diff --git a/schema_json/polygon/websocket/trade/trade_message.json b/schema_json/polygon/websocket/trade/trade_message.json deleted file mode 100644 index bede5ac3..00000000 --- a/schema_json/polygon/websocket/trade/trade_message.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "type": "object", - "extends": { - "existingJavaType": "io.github.mainstringargs.domain.polygon.websocket.PolygonStreamMessage" - }, - "title": "See https://polygon.io/sockets", - "properties": { - "x": { - "existingJavaType": "java.lang.String", - "title": "Exchange ID" - }, - "i": { - "existingJavaType": "java.lang.String", - "title": "Trade ID" - }, - "z": { - "existingJavaType": "java.lang.Integer", - "title": "Tape ( 1=A 2=B 3=C)" - }, - "p": { - "existingJavaType": "java.lang.Double", - "title": "Price" - }, - "s": { - "existingJavaType": "java.lang.Integer", - "title": "Trade Size" - }, - "c": { - "existingJavaType": "java.util.ArrayList", - "title": "Trade Conditions" - }, - "t": { - "existingJavaType": "java.lang.Long", - "title": "Trade Timestamp ( Unix MS )" - } - } -} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 3443d148..00000000 --- a/settings.gradle +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This settings file was generated by the Gradle 'init' task. - * - * The settings file is used to specify which projects to include in your build. - * In a single project build this file can be empty or even removed. - * - * Detailed information about configuring a multi-project build in Gradle can be found - * in the user guide at https://docs.gradle.org/3.4.1/userguide/multi_project_builds.html - */ - -/* -// To declare projects as part of a multi-project build use the 'include' method -include 'shared' -include 'api' -include 'services:webservice' -*/ - -rootProject.name = 'alpaca-java' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..3685ed2b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,5 @@ +rootProject.name = "alpaca-java" +include("module:common") +include("module:market-data") +include("module:trading") +include("module:broker") diff --git a/src/main/java/io/github/mainstringargs/abstracts/enums/APIName.java b/src/main/java/io/github/mainstringargs/abstracts/enums/APIName.java deleted file mode 100644 index 89f2ac69..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/enums/APIName.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.github.mainstringargs.abstracts.enums; - -public interface APIName { - - /** - * Gets the API name. - * - * @return the API name - */ - String getAPIName(); -} diff --git a/src/main/java/io/github/mainstringargs/abstracts/rest/AbstractRequest.java b/src/main/java/io/github/mainstringargs/abstracts/rest/AbstractRequest.java deleted file mode 100644 index 9c8fb844..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/rest/AbstractRequest.java +++ /dev/null @@ -1,308 +0,0 @@ -package io.github.mainstringargs.abstracts.rest; - -import com.google.gson.JsonElement; -import com.google.gson.stream.JsonReader; -import com.mashape.unirest.http.HttpResponse; -import com.mashape.unirest.http.Unirest; -import com.mashape.unirest.http.exceptions.UnirestException; -import com.mashape.unirest.request.GetRequest; -import com.mashape.unirest.request.HttpRequestWithBody; -import io.github.mainstringargs.util.gson.GsonUtil; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -/** - * The type Abstract request. - */ -public abstract class AbstractRequest { - - /** The logger. */ - private static final Logger LOGGER = LogManager.getLogger(AbstractRequest.class); - - /** The headers. */ - protected final Map headers = new HashMap<>(); - - /** - * Invoke get. - * - * @param abstractRequestBuilder the abstract request builder - * - * @return the http response - */ - public HttpResponse invokeGet(AbstractRequestBuilder abstractRequestBuilder) { - try { - String url = abstractRequestBuilder.getURL(); - - LOGGER.debug("GET URL " + url); - - GetRequest request = Unirest.get(url); - - if (!headers.isEmpty()) { - request.headers(headers); - - LOGGER.debug("GET Headers: " + headers); - } - - return request.asBinary(); - } catch (UnirestException e) { - LOGGER.error("UnirestException", e); - } - - return null; - } - - /** - * Invoke head. - * - * @param abstractRequestBuilder the abstract request builder - * - * @return the http response - */ - public HttpResponse invokeHead(AbstractRequestBuilder abstractRequestBuilder) { - try { - String url = abstractRequestBuilder.getURL(); - - LOGGER.debug("HEAD URL " + url); - - GetRequest request = Unirest.head(url); - - if (!headers.isEmpty()) { - request.headers(headers); - - LOGGER.debug("HEAD Headers: " + headers); - } - - return request.asBinary(); - } catch (UnirestException e) { - LOGGER.error("UnirestException", e); - } - - return null; - } - - /** - * Invoke post. - * - * @param abstractRequestBuilder the abstract request builder - * - * @return the http response - */ - public HttpResponse invokePost(AbstractRequestBuilder abstractRequestBuilder) { - try { - String url = abstractRequestBuilder.getURL(); - - LOGGER.debug("POST URL: " + url); - - HttpRequestWithBody request = Unirest.post(url); - - if (!headers.isEmpty()) { - request.headers(headers); - - LOGGER.debug("POST Headers: " + headers); - } - - String body = abstractRequestBuilder.getBody(); - if (body != null) { - request.body(body); - - LOGGER.debug("POST Body: " + body); - } - - return request.asBinary(); - } catch (UnirestException e) { - LOGGER.error("UnirestException", e); - } - - return null; - } - - /** - * Invoke patch. - * - * @param abstractRequestBuilder the abstract request builder - * - * @return the http response - */ - public HttpResponse invokePatch(AbstractRequestBuilder abstractRequestBuilder) { - try { - String url = abstractRequestBuilder.getURL(); - - LOGGER.debug("PATCH URL " + url); - - HttpRequestWithBody request = Unirest.patch(url); - - if (!headers.isEmpty()) { - request.headers(headers); - - LOGGER.debug("PATCH Headers: " + headers); - } - - String body = abstractRequestBuilder.getBody(); - if (body != null) { - request.body(body); - - LOGGER.debug("PATCH Body: " + body); - } - - return request.asBinary(); - } catch (UnirestException e) { - LOGGER.error("UnirestException", e); - } - - return null; - } - - /** - * Invoke put http response. - * - * @param abstractRequestBuilder the abstract request builder - * - * @return the http response - */ - public HttpResponse invokePut(AbstractRequestBuilder abstractRequestBuilder) { - try { - String url = abstractRequestBuilder.getURL(); - - LOGGER.debug("PUT URL " + url); - - HttpRequestWithBody request = Unirest.put(url); - - if (!headers.isEmpty()) { - request.headers(headers); - - LOGGER.debug("PUT Headers: " + headers); - } - - String body = abstractRequestBuilder.getBody(); - if (body != null) { - request.body(body); - - LOGGER.debug("PUT Body: " + body); - } - - return request.asBinary(); - } catch (UnirestException e) { - LOGGER.error("UnirestException", e); - } - - return null; - } - - /** - * Invoke delete. - * - * @param abstractRequestBuilder the abstract request builder - * - * @return the http response - */ - public HttpResponse invokeDelete(AbstractRequestBuilder abstractRequestBuilder) { - try { - String url = abstractRequestBuilder.getURL(); - - LOGGER.debug("DELETE URL " + url); - - HttpRequestWithBody request = Unirest.delete(url); - - if (!headers.isEmpty()) { - request.headers(headers); - - LOGGER.debug("DELETE Headers: " + headers); - } - - String body = abstractRequestBuilder.getBody(); - if (body != null) { - request.body(body); - - LOGGER.debug("DELETE Body: " + body); - } - - return request.asBinary(); - } catch (UnirestException e) { - LOGGER.error("UnirestException", e); - } - - return null; - } - - /** - * Invoke options. - * - * @param abstractRequestBuilder the abstract request builder - * - * @return the http response - */ - public HttpResponse invokeOptions(AbstractRequestBuilder abstractRequestBuilder) { - try { - String url = abstractRequestBuilder.getURL(); - - LOGGER.debug("OPTIONS URL " + url); - - HttpRequestWithBody request = Unirest.options(url); - - if (!headers.isEmpty()) { - request.headers(headers); - - LOGGER.debug("OPTIONS Headers: " + headers); - } - - String body = abstractRequestBuilder.getBody(); - if (body != null) { - request.body(body); - - LOGGER.debug("OPTIONS Body: " + body); - } - - return request.asBinary(); - } catch (UnirestException e) { - LOGGER.error("UnirestException", e); - } - - return null; - } - - /** - * Gets the response object. - * - * @param the generic type - * @param httpResponse the http response - * @param type the type - * - * @return the response object - */ - public T getResponseObject(HttpResponse httpResponse, Type type) { - T responseObjectFromJson = null; - - try (JsonReader jsonReader = new JsonReader(new InputStreamReader(httpResponse.getRawBody()))) { - responseObjectFromJson = GsonUtil.GSON.fromJson(jsonReader, type); - } catch (Exception e) { - LOGGER.error("Exception", e); - } - - return responseObjectFromJson; - } - - /** - * Gets response json. - * - * @param httpResponse the http response - * - * @return the response json - */ - public JsonElement getResponseJSON(HttpResponse httpResponse) { - JsonElement responseJsonElement = null; - - try (JsonReader jsonReader = new JsonReader(new InputStreamReader(httpResponse.getRawBody()))) { - responseJsonElement = GsonUtil.JSON_PARSER.parse(jsonReader); - } catch (Exception e) { - LOGGER.error("Exception", e); - } - - return responseJsonElement; - } -} diff --git a/src/main/java/io/github/mainstringargs/abstracts/rest/AbstractRequestBuilder.java b/src/main/java/io/github/mainstringargs/abstracts/rest/AbstractRequestBuilder.java deleted file mode 100644 index 489fa253..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/rest/AbstractRequestBuilder.java +++ /dev/null @@ -1,142 +0,0 @@ -package io.github.mainstringargs.abstracts.rest; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * The type Abstract request builder. - */ -public abstract class AbstractRequestBuilder { - - /** The Constant URL_SEPARATOR. */ - private final static String URL_SEPARATOR = "/"; - - /** The appended endpoints. */ - private final List appendedEndpoints = new ArrayList<>(); - - /** The url parameters. */ - private final Map urlParameters = new LinkedHashMap<>(); - - /** The Body json object. */ - private final JsonObject bodyJsonObject = new JsonObject(); - - /** The base url. */ - private final String baseUrl; - - /** The custom body. */ - private String customBody; - - /** - * Instantiates a new abstract request builder. - * - * @param baseUrl the base url - */ - public AbstractRequestBuilder(String baseUrl) { - this.baseUrl = baseUrl; - } - - /** - * Append endpoint. - * - * @param endpoint the endpoint - */ - public void appendEndpoint(String endpoint) { - if (endpoint != null) { - appendedEndpoints.add(endpoint); - } - } - - /** - * Append URL parameter. - * - * @param urlKey the url key - * @param urlValue the url value - */ - public void appendURLParameter(String urlKey, String urlValue) { - if (urlValue != null) { - urlParameters.put(urlKey, urlValue); - } - } - - /** - * Append json body property. - * - * @param bodyKey the body key - * @param bodyValue the body value - */ - public void appendJSONBodyProperty(String bodyKey, String bodyValue) { - if (bodyValue != null) { - bodyJsonObject.addProperty(bodyKey, bodyValue); - } - } - - /** - * Append body json property. - * - * @param bodyKey the body key - * @param bodyValue the body value - */ - public void appendJSONBodyJSONProperty(String bodyKey, JsonElement bodyValue) { - if (bodyValue != null) { - bodyJsonObject.add(bodyKey, bodyValue); - } - } - - /** - * Gets the url. - * - * @return the url - */ - public String getURL() { - StringBuilder builder = new StringBuilder(baseUrl); - - for (String appendedEndpoint : appendedEndpoints) { - builder.append(URL_SEPARATOR); - builder.append(appendedEndpoint); - } - - if (!urlParameters.isEmpty()) { - builder.append('?'); - - for (Map.Entry entry : urlParameters.entrySet()) { - builder.append(entry.getKey().trim()); - builder.append('='); - builder.append(entry.getValue().trim()); - builder.append('&'); - } - // removes last & - builder.deleteCharAt(builder.length() - 1); - } - - return builder.toString(); - } - - /** - * Gets the body. - * - * @return the body - */ - public String getBody() { - if (customBody != null) { - return customBody; - } else if (bodyJsonObject.size() > 0) { - return bodyJsonObject.toString(); - } else { - return null; - } - } - - /** - * Sets custom body. - * - * @param customBody the custom body - */ - public void setCustomBody(String customBody) { - this.customBody = customBody; - } -} diff --git a/src/main/java/io/github/mainstringargs/abstracts/rest/exception/AbstractAPIRequestException.java b/src/main/java/io/github/mainstringargs/abstracts/rest/exception/AbstractAPIRequestException.java deleted file mode 100644 index 4dfda189..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/rest/exception/AbstractAPIRequestException.java +++ /dev/null @@ -1,153 +0,0 @@ -package io.github.mainstringargs.abstracts.rest.exception; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.mashape.unirest.http.HttpResponse; -import io.github.mainstringargs.util.gson.GsonUtil; - -import java.io.InputStream; -import java.io.InputStreamReader; - -/** - * The type Abstract API request exception. - */ -public abstract class AbstractAPIRequestException extends Exception { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - /** The constant CODE_KEY. */ - protected static final String CODE_KEY = "code"; - - /** The constant MESSAGE_KEY. */ - protected static final String MESSAGE_KEY = "message"; - - /** The Api name. */ - protected final String apiName; - - /** The Http response. */ - protected HttpResponse httpResponse; - - /** The Request code. */ - protected int requestStatusCode; - - /** The Request status text. */ - protected String requestStatusText; - - /** The Api response code. */ - protected int apiResponseCode = -1; - - /** The Api response message. */ - protected String apiResponseMessage; - - /** - * Instantiates a new Abstract api request exception. - * - * @param apiName the api name - * @param httpResponse the http response - */ - public AbstractAPIRequestException(String apiName, HttpResponse httpResponse) { - super(); - - this.apiName = apiName; - this.httpResponse = httpResponse; - - this.requestStatusCode = httpResponse.getStatus(); - this.requestStatusText = httpResponse.getStatusText(); - } - - /** - * Parse the API exception message to populate the following fields: - *

- * {@link AbstractAPIRequestException#requestStatusCode}, {@link AbstractAPIRequestException#requestStatusText}, - * {@link AbstractAPIRequestException#apiResponseCode}, {@link AbstractAPIRequestException#apiResponseMessage} - */ - protected abstract void parseAPIExceptionMessage(); - - /** - * Parse a standard API exception response. - *

- * The following format is parsed: - *

-     *  {
-     *     "code": 40010001,
-     *     "message": "Error message"
-     *  }
-     * 
- */ - protected void parseStandardAPIExceptionResponse() { - JsonElement responseJsonElement = GsonUtil.JSON_PARSER.parse(new InputStreamReader(httpResponse.getBody())); - - if (responseJsonElement instanceof JsonObject) { - JsonObject responseJsonObject = (JsonObject) responseJsonElement; - - if (responseJsonObject.has(CODE_KEY)) { - apiResponseCode = responseJsonObject.get(CODE_KEY).getAsInt(); - } - - if (responseJsonObject.has(MESSAGE_KEY)) { - apiResponseMessage = responseJsonObject.get(MESSAGE_KEY).getAsString(); - } - } - - // Just use the response JSON if the message could not be parsed. - if (apiResponseMessage == null) { - apiResponseMessage = responseJsonElement.toString(); - } - } - - @Override - public String getMessage() { - this.parseAPIExceptionMessage(); - - StringBuilder messageBuilder = new StringBuilder(apiName).append(" API Request Exception! : "); - messageBuilder.append("Status Code = ").append(requestStatusCode); - messageBuilder.append(", Status Text = \"").append(requestStatusText).append("\""); - - if (apiResponseCode != -1) { - messageBuilder.append(", API Response Code = ").append(apiResponseCode); - } - - if (apiResponseMessage != null) { - messageBuilder.append(", API Response Message = \"").append(apiResponseMessage).append("\""); - } - - return messageBuilder.toString(); - } - - /** - * Gets request status code. - * - * @return the request status code - */ - public int getRequestStatusCode() { - return requestStatusCode; - } - - /** - * Gets request status text. - * - * @return the request status text - */ - public String getRequestStatusText() { - return requestStatusText; - } - - /** - * Gets api response code. - * - * @return the api response code - */ - public int getAPIResponseCode() { - return apiResponseCode; - } - - /** - * Gets api response message. - * - * @return the api response message - */ - public String getAPIResponseMessage() { - return apiResponseMessage; - } -} diff --git a/src/main/java/io/github/mainstringargs/abstracts/websocket/client/AbstractWebsocketClientEndpoint.java b/src/main/java/io/github/mainstringargs/abstracts/websocket/client/AbstractWebsocketClientEndpoint.java deleted file mode 100644 index 4a099656..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/websocket/client/AbstractWebsocketClientEndpoint.java +++ /dev/null @@ -1,163 +0,0 @@ -package io.github.mainstringargs.abstracts.websocket.client; - -import io.github.mainstringargs.util.concurrency.ExecutorTracer; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import javax.websocket.CloseReason; -import javax.websocket.ContainerProvider; -import javax.websocket.DeploymentException; -import javax.websocket.Session; -import javax.websocket.WebSocketContainer; -import java.io.IOException; -import java.net.URI; -import java.util.concurrent.ExecutorService; - -/** - * The type Abstract websocket client endpoint. You must annotate a subclass with {@link javax.websocket.ClientEndpoint} - * and the appropriate websocket subprotocols because websocket annotations don't work with inheritance. The subclass - * must also contain separate methods with the following annotations: {@link javax.websocket.OnOpen}, {@link - * javax.websocket.OnClose}, and {@link javax.websocket.OnMessage}. - */ -public abstract class AbstractWebsocketClientEndpoint { - - /** The constant LOGGER. */ - private static final Logger LOGGER = LogManager.getLogger(AbstractWebsocketClientEndpoint.class); - - /** The Websocket client. */ - private WebsocketClient websocketClient; - - /** The Endpoint uri. */ - private final URI endpointURI; - - /** The Executor service. */ - private final ExecutorService executorService; - - /** The User session. */ - private Session userSession; - - /** The Retry attempts. */ - private int retryAttempts = 0; - - /** - * Instantiates a new Abstract websocket client endpoint. - * - * @param websocketClient the websocket client - * @param endpointURI the endpoint uri - * @param messageThreadName the message thread name - */ - public AbstractWebsocketClientEndpoint(WebsocketClient websocketClient, URI endpointURI, - String messageThreadName) { - this.websocketClient = websocketClient; - this.endpointURI = endpointURI; - this.executorService = ExecutorTracer.newSingleThreadExecutor(r -> new Thread(r, messageThreadName)); - } - - /** - * Connect. - * - * @throws DeploymentException the deployment exception - * @throws IOException Signals that an I/O exception has occurred. - */ - public void connect() throws DeploymentException, IOException { - WebSocketContainer container = ContainerProvider.getWebSocketContainer(); - - LOGGER.info("Connecting to " + endpointURI); - - container.connectToServer(this, endpointURI); - } - - /** - * Disconnect. - * - * @throws IOException the io exception - */ - public void disconnect() throws IOException { - if (userSession != null) { - userSession.close(); - } - } - - /** - * On open. - * - * @param userSession the user session - */ - protected void onOpen(Session userSession) { - this.userSession = userSession; - - LOGGER.debug("onOpen " + userSession); - LOGGER.info("Websocket opened"); - - LOGGER.info("Authenticating..."); - websocketClient.sendAuthenticationMessage(); - } - - /** - * On close. - * - * @param userSession the user session - * @param reason the reason - */ - protected void onClose(Session userSession, CloseReason reason) { - this.userSession = null; - - LOGGER.debug("onClose " + userSession); - - if (!reason.getCloseCode().equals(CloseReason.CloseCodes.NORMAL_CLOSURE)) { - if (retryAttempts > 5) { - LOGGER.error("More than 5 attempts to reconnect were made."); - return; - } - - LOGGER.info("Attempting a reconnect in 3 seconds."); - retryAttempts++; - - try { - Thread.sleep(3000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - - LOGGER.info("Reconnecting due to closure " + - CloseReason.CloseCodes.getCloseCode(reason.getCloseCode().getCode())); - - try { - connect(); - } catch (Exception e) { - LOGGER.catching(e); - } - } else { - LOGGER.info("Websocket closed"); - } - } - - /** - * On message. - * - * @param message the message - */ - protected void onMessage(String message) { - executorService.execute(() -> websocketClient.handleWebsocketMessage(message)); - } - - /** - * Send a message. - * - * @param message the message - */ - public void sendMessage(String message) { - LOGGER.debug("sendMessage " + message); - - userSession.getAsyncRemote().sendText(message); - } - - /** - * Gets user session. - * - * @return the user session - */ - public Session getUserSession() { - return userSession; - } -} diff --git a/src/main/java/io/github/mainstringargs/abstracts/websocket/client/WebsocketClient.java b/src/main/java/io/github/mainstringargs/abstracts/websocket/client/WebsocketClient.java deleted file mode 100644 index 78d2644c..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/websocket/client/WebsocketClient.java +++ /dev/null @@ -1,70 +0,0 @@ -package io.github.mainstringargs.abstracts.websocket.client; - -import io.github.mainstringargs.abstracts.websocket.listener.StreamListener; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessage; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessageType; - -/** - * The type Websocket client. - */ -public interface WebsocketClient { - - /** - * Add listener. - * - * @param streamListener the stream listener - */ - void addListener(StreamListener streamListener); - - /** - * Remove listener. - * - * @param streamListener the stream listener - */ - void removeListener(StreamListener streamListener); - - /** - * Connect. - */ - void connect(); - - /** - * Disconnect. - */ - void disconnect(); - - /** - * Send authentication message. - */ - void sendAuthenticationMessage(); - - /** - * Handle websocket message. - * - * @param message the message - */ - void handleWebsocketMessage(String message); - - /** - * Send stream message to listeners. - * - * @param streamMessageType the stream message type - * @param streamMessage the stream message - */ - void sendStreamMessageToListeners(StreamMessageType streamMessageType, StreamMessage streamMessage); - - /** - * Is connected boolean. - * - * @return the boolean - */ - boolean isConnected(); - - /** - * Is authenticated boolean. - * - * @return the boolean - */ - boolean isAuthenticated(); - -} diff --git a/src/main/java/io/github/mainstringargs/abstracts/websocket/listener/StreamListener.java b/src/main/java/io/github/mainstringargs/abstracts/websocket/listener/StreamListener.java deleted file mode 100644 index 0bd0b6ba..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/websocket/listener/StreamListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.mainstringargs.abstracts.websocket.listener; - -import io.github.mainstringargs.abstracts.websocket.message.StreamMessage; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessageType; - -/** - * The type Stream listener. - * - * @param the stream message type type parameter - * @param the stream message type parameter - */ -public interface StreamListener { - - /** - * On stream update. - * - * @param streamMessageType the stream message type - * @param streamMessage the stream message - */ - void onStreamUpdate(T streamMessageType, M streamMessage); -} diff --git a/src/main/java/io/github/mainstringargs/abstracts/websocket/message/StreamMessage.java b/src/main/java/io/github/mainstringargs/abstracts/websocket/message/StreamMessage.java deleted file mode 100644 index c57c48a1..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/websocket/message/StreamMessage.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.mainstringargs.abstracts.websocket.message; - -/** - * The type stream message. - */ -public interface StreamMessage { -} diff --git a/src/main/java/io/github/mainstringargs/abstracts/websocket/message/StreamMessageType.java b/src/main/java/io/github/mainstringargs/abstracts/websocket/message/StreamMessageType.java deleted file mode 100644 index 55c5cd8e..00000000 --- a/src/main/java/io/github/mainstringargs/abstracts/websocket/message/StreamMessageType.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.mainstringargs.abstracts.websocket.message; - -/** - * The type stream message type. - */ -public interface StreamMessageType { -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/AlpacaAPI.java b/src/main/java/io/github/mainstringargs/alpaca/AlpacaAPI.java deleted file mode 100644 index 1acf9e44..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/AlpacaAPI.java +++ /dev/null @@ -1,1581 +0,0 @@ -package io.github.mainstringargs.alpaca; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.reflect.TypeToken; -import com.mashape.unirest.http.HttpResponse; -import io.github.mainstringargs.alpaca.enums.ActivityType; -import io.github.mainstringargs.alpaca.enums.AssetStatus; -import io.github.mainstringargs.alpaca.enums.BarsTimeFrame; -import io.github.mainstringargs.alpaca.enums.Direction; -import io.github.mainstringargs.alpaca.enums.OrderClass; -import io.github.mainstringargs.alpaca.enums.OrderSide; -import io.github.mainstringargs.alpaca.enums.OrderStatus; -import io.github.mainstringargs.alpaca.enums.OrderTimeInForce; -import io.github.mainstringargs.alpaca.enums.OrderType; -import io.github.mainstringargs.alpaca.enums.PortfolioPeriodUnit; -import io.github.mainstringargs.alpaca.enums.PortfolioTimeFrame; -import io.github.mainstringargs.alpaca.properties.AlpacaProperties; -import io.github.mainstringargs.alpaca.rest.AlpacaRequest; -import io.github.mainstringargs.alpaca.rest.AlpacaRequestBuilder; -import io.github.mainstringargs.alpaca.rest.exception.AlpacaAPIRequestException; -import io.github.mainstringargs.alpaca.websocket.client.AlpacaWebsocketClient; -import io.github.mainstringargs.alpaca.websocket.listener.AlpacaStreamListener; -import io.github.mainstringargs.domain.alpaca.account.Account; -import io.github.mainstringargs.domain.alpaca.accountactivities.AccountActivity; -import io.github.mainstringargs.domain.alpaca.accountactivities.NonTradeActivity; -import io.github.mainstringargs.domain.alpaca.accountactivities.TradeActivity; -import io.github.mainstringargs.domain.alpaca.accountconfiguration.AccountConfiguration; -import io.github.mainstringargs.domain.alpaca.asset.Asset; -import io.github.mainstringargs.domain.alpaca.bar.Bar; -import io.github.mainstringargs.domain.alpaca.calendar.Calendar; -import io.github.mainstringargs.domain.alpaca.clock.Clock; -import io.github.mainstringargs.domain.alpaca.order.CancelledOrder; -import io.github.mainstringargs.domain.alpaca.order.Order; -import io.github.mainstringargs.domain.alpaca.portfoliohistory.PortfolioHistory; -import io.github.mainstringargs.domain.alpaca.position.ClosePositionOrder; -import io.github.mainstringargs.domain.alpaca.position.Position; -import io.github.mainstringargs.domain.alpaca.watchlist.Watchlist; -import io.github.mainstringargs.util.gson.GsonUtil; -import io.github.mainstringargs.util.time.TimeUtil; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.InputStream; -import java.lang.reflect.Type; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Map; -import java.util.StringJoiner; -import java.util.stream.Collectors; - -/** - * The Class AlpacaAPI. - */ -public class AlpacaAPI { - - /** The logger. */ - private static Logger LOGGER = LogManager.getLogger(AlpacaAPI.class); - - /** The version. */ - private final String apiVersion; - - /** The key id. */ - private final String keyId; - - /** The base API url. */ - private final String baseAPIURL; - - /** The alpaca request. */ - private final AlpacaRequest alpacaRequest; - - /** The base data url. */ - private final String baseDataUrl; - - /** The alpaca web socket client. */ - private final AlpacaWebsocketClient alpacaWebSocketClient; - - /** - * Instantiates a new Alpaca API using properties specified in alpaca.properties file (or relevant defaults) - */ - public AlpacaAPI() { - this(AlpacaProperties.API_VERSION_VALUE, AlpacaProperties.KEY_ID_VALUE, - AlpacaProperties.SECRET_VALUE, AlpacaProperties.BASE_API_URL_VALUE, - AlpacaProperties.BASE_DATA_URL_VALUE); - - LOGGER.debug(AlpacaProperties.staticToString()); - } - - /** - * Instantiates a new Alpaca API using the specified apiVersion - * - * @param apiVersion the api version - */ - public AlpacaAPI(String apiVersion) { - this(apiVersion, AlpacaProperties.KEY_ID_VALUE, AlpacaProperties.SECRET_VALUE, - AlpacaProperties.BASE_API_URL_VALUE, AlpacaProperties.BASE_DATA_URL_VALUE); - } - - /** - * Instantiates a new Alpaca API using the specified apiVersion, keyId, and secret. - * - * @param keyId the key id - * @param secret the secret - */ - public AlpacaAPI(String apiVersion, String keyId, String secret) { - this(apiVersion, keyId, secret, AlpacaProperties.BASE_API_URL_VALUE, - AlpacaProperties.BASE_DATA_URL_VALUE); - } - - /** - * Instantiates a new Alpaca API using the specified apiVersion, keyId, secret, and baseAPIURL. - * - * @param apiVersion the api version - * @param keyId the key id - * @param secret the secret - * @param baseAPIURL the api account url - */ - public AlpacaAPI(String apiVersion, String keyId, String secret, String baseAPIURL) { - this(apiVersion, keyId, secret, baseAPIURL, AlpacaProperties.BASE_DATA_URL_VALUE); - } - - /** - * Instantiates a new Alpaca API using the specified keyId, secret, baseAPIURL, and baseDataUrl. - * - * @param apiVersion the api version - * @param keyId the key id - * @param secret the secret - * @param baseAPIURL the base api url - * @param baseDataUrl the base data url - */ - public AlpacaAPI(String apiVersion, String keyId, String secret, String baseAPIURL, String baseDataUrl) { - this.apiVersion = apiVersion; - this.keyId = keyId; - this.baseAPIURL = baseAPIURL; - this.baseDataUrl = baseDataUrl; - - alpacaRequest = new AlpacaRequest(keyId, secret); - alpacaWebSocketClient = new AlpacaWebsocketClient(keyId, secret, baseAPIURL); - - LOGGER.debug(this.toString()); - } - - /** - * Returns the account associated with the API key. - * - * @return the account - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Get the Account - */ - public Account getAccount() throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ACCOUNT_ENDPOINT); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Account.class); - } - - /** - * Returns account activity entries for many or for a specific type of activity. - * - * @param date The date for which you want to see activities. - * @param until The response will contain only activities submitted before this date. (Cannot be used with - * date.) - * @param after The response will contain only activities submitted after this date. (Cannot be used with - * date.) - * @param direction asc or desc (default desc if unspecified.) - * @param pageSize The maximum number of entries to return in the response. (See the section on paging above.) - * @param pageToken The ID of the end of your current page of results. (See the section on paging above.) - * @param activityTypes the activity types (null for all activities) - * - * @return the account activities - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Gets the Account - * Activities - */ - public ArrayList getAccountActivities(ZonedDateTime date, ZonedDateTime until, ZonedDateTime after, - Direction direction, Integer pageSize, String pageToken, ActivityType... activityTypes) - throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, AlpacaConstants.VERSION_2_ENDPOINT, - AlpacaConstants.ACCOUNT_ENDPOINT, - AlpacaConstants.ACTIVITIES_ENDPOINT); - - if (activityTypes != null) { // Check if we don't want all activity types - if (activityTypes.length == 1) { // Get one activity - urlBuilder.appendEndpoint(activityTypes[0].getAPIName()); - } else { // Get list of activities - urlBuilder.appendURLParameter("activity_types", Arrays.stream(activityTypes) - .map(ActivityType::getAPIName).collect(Collectors.joining(","))); // Makes comma-separated list - } - } - - if (date != null) { - urlBuilder.appendURLParameter(AlpacaConstants.DATE_PARAMETER, - date.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - if (until != null) { - urlBuilder.appendURLParameter(AlpacaConstants.UNTIL_PARAMETER, - until.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - if (after != null) { - urlBuilder.appendURLParameter(AlpacaConstants.AFTER_PARAMETER, - after.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - if (direction != null) { - urlBuilder.appendURLParameter(AlpacaConstants.DIRECTION_PARAMETER, direction.getAPIName()); - } - - if (pageSize != null) { - urlBuilder.appendURLParameter(AlpacaConstants.PAGE_SIZE_PARAMETER, pageSize.toString()); - } - - if (pageToken != null) { - urlBuilder.appendURLParameter(AlpacaConstants.PAGE_TOKEN_PARAMETER, pageToken); - } - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - JsonElement responseJsonElement = alpacaRequest.getResponseJSON(response); - ArrayList accountActivities = new ArrayList<>(); - - if (responseJsonElement instanceof JsonArray) { - JsonArray responseJsonArray = (JsonArray) responseJsonElement; - - for (JsonElement arrayJsonElement : responseJsonArray) { // Loop through response array - if (arrayJsonElement instanceof JsonObject) { - JsonObject arrayJsonObject = (JsonObject) arrayJsonElement; - - if (GsonUtil.doesGsonPOJOMatch(TradeActivity.class, arrayJsonObject)) { - accountActivities.add(GsonUtil.GSON.fromJson(arrayJsonObject, TradeActivity.class)); - } else if (GsonUtil.doesGsonPOJOMatch(NonTradeActivity.class, arrayJsonObject)) { - accountActivities.add(GsonUtil.GSON.fromJson(arrayJsonObject, NonTradeActivity.class)); - } else { - LOGGER.warn("Received unknown JSON Object in response!"); - } - } else { - throw new IllegalStateException("All array elements must be objects!"); - } - } - return accountActivities; - } else { - throw new IllegalStateException("The response must be an array!"); - } - } - - /** - * Returns the current account configuration values. - * - * @return the account configurations - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Account - * Configuration - */ - public AccountConfiguration getAccountConfiguration() throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ACCOUNT_ENDPOINT, - AlpacaConstants.CONFIGURATIONS_ENDPOINT); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, AccountConfiguration.class); - } - - /** - * Sets account configuration. - * - * @param accountConfiguration the account configuration - * - * @return the updated account configuration - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Account - * Configuration - */ - public AccountConfiguration setAccountConfiguration(AccountConfiguration accountConfiguration) - throws AlpacaAPIRequestException { - Preconditions.checkNotNull(accountConfiguration); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ACCOUNT_ENDPOINT, - AlpacaConstants.CONFIGURATIONS_ENDPOINT); - urlBuilder.setCustomBody(GsonUtil.GSON.toJson(accountConfiguration)); - - HttpResponse response = alpacaRequest.invokePatch(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, AccountConfiguration.class); - } - - /** - * Retrieves a list of orders for the account, filtered by the supplied query parameters. - * - * @param status Order status to be queried. open, closed or all. Defaults to open. - * @param limit The maximum number of orders in response. Defaults to 50 and max is 500. - * @param after The response will include only ones submitted after this timestamp (exclusive.) - * @param until The response will include only ones submitted until this timestamp (exclusive.) - * @param direction The chronological order of response based on the submission time. asc or desc. Defaults to - * desc. - * @param nested If true, the result will roll up multi-leg orders under the legs field of primary order. - * - * @return the orders - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Orders - */ - public ArrayList getOrders(OrderStatus status, Integer limit, ZonedDateTime after, ZonedDateTime until, - Direction direction, Boolean nested) throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ORDERS_ENDPOINT); - - if (status != null) { - urlBuilder.appendURLParameter(AlpacaConstants.STATUS_PARAMETER, status.getAPIName()); - } - - if (limit != null) { - urlBuilder.appendURLParameter(AlpacaConstants.LIMIT_PARAMETER, limit.toString()); - } - - if (after != null) { - urlBuilder.appendURLParameter(AlpacaConstants.AFTER_PARAMETER, - after.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - if (until != null) { - urlBuilder.appendURLParameter(AlpacaConstants.UNTIL_PARAMETER, - until.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - if (direction != null) { - urlBuilder.appendURLParameter(AlpacaConstants.DIRECTION_PARAMETER, direction.getAPIName()); - } - - if (nested != null) { - urlBuilder.appendURLParameter(AlpacaConstants.NESTED_PARAMETER, nested.toString()); - } - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - Type arrayListType = new TypeToken>() {}.getType(); - - return alpacaRequest.getResponseObject(response, arrayListType); - } - - /** - * Places a new order for the given account. An order request may be rejected if the account is not authorized for - * trading, or if the tradable balance is insufficient to fill the order. Note: many of the parameters for this - * method can be set to null if they aren't required for your order type. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param type market, limit, stop, or stop_limit - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param limitPrice required if type is limit or stop_limit - * @param stopPrice required if type is stop or stop_limit - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. - * Only works with type limit and time_in_force day. - * @param clientOrderId A unique identifier for the order. Automatically generated if not sent. - * @param orderClass Simple, bracket, oco, or oto. For details of non-simple order classes, please see - * Bracket Order Overview on the Alpaca Docs. - * @param takeProfitLimitPrice Additional parameter for take-profit leg of advanced orders. Required for bracket - * orders. - * @param stopLossStopPrice Additional parameters for stop-loss leg of advanced orders. Required for bracket - * orders. - * @param stopLossLimitPrice Additional parameters for stop-loss leg of advanced orders. The stop-loss order - * becomes a stop-limit order if specified. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Orders - */ - public Order requestNewOrder(String symbol, Integer quantity, OrderSide side, OrderType type, - OrderTimeInForce timeInForce, Double limitPrice, Double stopPrice, Boolean extendedHours, - String clientOrderId, OrderClass orderClass, Double takeProfitLimitPrice, Double stopLossStopPrice, - Double stopLossLimitPrice) - throws AlpacaAPIRequestException { - Preconditions.checkNotNull(symbol); - Preconditions.checkNotNull(quantity); - Preconditions.checkNotNull(side); - Preconditions.checkNotNull(type); - Preconditions.checkNotNull(timeInForce); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ORDERS_ENDPOINT); - - urlBuilder.appendJSONBodyProperty(AlpacaConstants.SYMBOL_PARAMETER, symbol); - urlBuilder.appendJSONBodyProperty(AlpacaConstants.QTY_PARAMETER, quantity.toString()); - urlBuilder.appendJSONBodyProperty(AlpacaConstants.SIDE_PARAMETER, side.getAPIName()); - urlBuilder.appendJSONBodyProperty(AlpacaConstants.TYPE_PARAMETER, type.getAPIName()); - urlBuilder.appendJSONBodyProperty(AlpacaConstants.TIME_IN_FORCE_PARAMETER, timeInForce.getAPIName()); - - if (limitPrice != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.LIMIT_PRICE_PARAMETER, - TimeUtil.toDecimalFormat(limitPrice)); - } - - if (stopPrice != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.STOP_PRICE_PARAMETER, - TimeUtil.toDecimalFormat(stopPrice)); - } - - if (extendedHours != null) { - urlBuilder.appendJSONBodyJSONProperty(AlpacaConstants.EXTENDED_HOURS_PARAMETER, - new JsonPrimitive(extendedHours)); - } - - if (clientOrderId != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.CLIENT_ORDER_ID_PARAMETER, clientOrderId); - } - - if (orderClass != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.ORDER_CLASS_PARAMETER, orderClass.getAPIName()); - } - - if (takeProfitLimitPrice != null) { - JsonObject takeProfit = new JsonObject(); - takeProfit.addProperty(AlpacaConstants.LIMIT_PRICE_PARAMETER, takeProfitLimitPrice); - - urlBuilder.appendJSONBodyJSONProperty(AlpacaConstants.TAKE_PROFIT_PARAMETER, takeProfit); - } - - if (stopLossStopPrice != null || stopLossLimitPrice != null) { - JsonObject stopLoss = new JsonObject(); - - if (stopLossStopPrice != null) { - stopLoss.addProperty(AlpacaConstants.STOP_PRICE_PARAMETER, stopLossStopPrice); - } - if (stopLossLimitPrice != null) { - stopLoss.addProperty(AlpacaConstants.LIMIT_PRICE_PARAMETER, stopLossLimitPrice); - } - - urlBuilder.appendJSONBodyJSONProperty(AlpacaConstants.STOP_LOSS_PARAMETER, stopLoss); - } - - HttpResponse response = alpacaRequest.invokePost(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Order.class); - } - - /** - * A market order is a request to buy or sell a security at the currently available market price. It provides the - * most likely method of filling an order. Market orders fill nearly instantaneously. This method calls {@link - * #requestNewOrder(String, Integer, OrderSide, OrderType, OrderTimeInForce, Double, Double, Boolean, String, - * OrderClass, Double, Double, Double)} with {@link OrderType#MARKET}. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. Only - * works with type limit and time_in_force day. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewMarketOrder(String symbol, Integer quantity, OrderSide side, OrderTimeInForce timeInForce, - Boolean extendedHours) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.MARKET, timeInForce, null, null, extendedHours, - null, OrderClass.SIMPLE, null, null, null); - } - - /** - * A limit order is an order to buy or sell at a specified price or better. A buy limit order (a limit order to buy) - * is executed at the specified limit price or lower (i.e., better). Conversely, a sell limit order (a limit order - * to sell) is executed at the specified limit price or higher (better). Unlike a market order, you have to specify - * the limit price parameter when submitting your order. This method calls {@link #requestNewOrder(String, Integer, - * OrderSide, OrderType, OrderTimeInForce, Double, Double, Boolean, String, OrderClass, Double, Double, Double)} - * with {@link OrderType#LIMIT}. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param limitPrice required if type is limit or stop_limit - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. Only - * works with type limit and time_in_force day. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewLimitOrder(String symbol, Integer quantity, OrderSide side, OrderTimeInForce timeInForce, - Double limitPrice, Boolean extendedHours) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.LIMIT, timeInForce, limitPrice, null, extendedHours, - null, OrderClass.SIMPLE, null, null, null); - } - - /** - * A stop (market) order is an order to buy or sell a security when its price moves past a particular point, - * ensuring a higher probability of achieving a predetermined entry or exit price. Once the market price crosses the - * specified stop price, the stop order becomes a market order. Alpaca converts buy stop orders into stop limit - * orders with a limit price that is 4% higher than a stop price < $50 (or 2.5% higher than a stop price >= - * $50). Sell stop orders are not converted into stop limit orders. This method calls {@link - * #requestNewOrder(String, Integer, OrderSide, OrderType, OrderTimeInForce, Double, Double, Boolean, String, - * OrderClass, Double, Double, Double)} with {@link OrderType#STOP}. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param stopPrice required if type is stop or stop_limit - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. Only - * works with type limit and time_in_force day. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewStopOrder(String symbol, Integer quantity, OrderSide side, OrderTimeInForce timeInForce, - Double stopPrice, Boolean extendedHours) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.STOP, timeInForce, null, stopPrice, extendedHours, - null, OrderClass.SIMPLE, null, null, null); - } - - /** - * A stop-limit order is a conditional trade over a set time frame that combines the features of a stop order with - * those of a limit order and is used to mitigate risk. The stop-limit order will be executed at a specified limit - * price, or better, after a given stop price has been reached. Once the stop price is reached, the stop-limit order - * becomes a limit order to buy or sell at the limit price or better. This method calls {@link - * #requestNewOrder(String, Integer, OrderSide, OrderType, OrderTimeInForce, Double, Double, Boolean, String, - * OrderClass, Double, Double, Double)} with {@link OrderType#STOP_LIMIT}. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param limitPrice required if type is limit or stop_limit - * @param stopPrice required if type is stop or stop_limit - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. Only - * works with type limit and time_in_force day. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewStopLimitOrder(String symbol, Integer quantity, OrderSide side, OrderTimeInForce timeInForce, - Double limitPrice, Double stopPrice, Boolean extendedHours) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.STOP_LIMIT, timeInForce, limitPrice, stopPrice, - extendedHours, null, OrderClass.SIMPLE, null, null, null); - } - - /** - * A bracket order is a chain of three orders that can be used to manage your position entry and exit. It is a - * common use case of an OTOCO (One Triggers OCO {One Cancels Other}) order. This method calls {@link - * #requestNewOrder(String, Integer, OrderSide, OrderType, OrderTimeInForce, Double, Double, Boolean, String, - * OrderClass, Double, Double, Double)} with {@link OrderType#MARKET} and with parameters for a bracket order. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. - * Only works with type limit and time_in_force day. - * @param takeProfitLimitPrice Additional parameter for take-profit leg of advanced orders. Required for bracket - * orders. - * @param stopLossStopPrice Additional parameters for stop-loss leg of advanced orders. Required for bracket - * orders. - * @param stopLossLimitPrice Additional parameters for stop-loss leg of advanced orders. The stop-loss order - * becomes a stop-limit order if specified. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewMarketBracketOrder(String symbol, Integer quantity, OrderSide side, - OrderTimeInForce timeInForce, Boolean extendedHours, Double takeProfitLimitPrice, Double stopLossStopPrice, - Double stopLossLimitPrice) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.MARKET, timeInForce, null, null, - extendedHours, null, OrderClass.BRACKET, takeProfitLimitPrice, stopLossStopPrice, stopLossLimitPrice); - } - - /** - * A bracket order is a chain of three orders that can be used to manage your position entry and exit. It is a - * common use case of an OTOCO (One Triggers OCO {One Cancels Other}) order. This method calls {@link - * #requestNewOrder(String, Integer, OrderSide, OrderType, OrderTimeInForce, Double, Double, Boolean, String, - * OrderClass, Double, Double, Double)} with {@link OrderType#LIMIT} and with parameters for a bracket order. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param limitPrice required if type is limit or stop_limit - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. - * Only works with type limit and time_in_force day. - * @param takeProfitLimitPrice Additional parameter for take-profit leg of advanced orders. Required for bracket - * orders. - * @param stopLossStopPrice Additional parameters for stop-loss leg of advanced orders. Required for bracket - * orders. - * @param stopLossLimitPrice Additional parameters for stop-loss leg of advanced orders. The stop-loss order - * becomes a stop-limit order if specified. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewLimitBracketOrder(String symbol, Integer quantity, OrderSide side, - OrderTimeInForce timeInForce, Double limitPrice, Boolean extendedHours, Double takeProfitLimitPrice, - Double stopLossStopPrice, Double stopLossLimitPrice) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.LIMIT, timeInForce, limitPrice, null, - extendedHours, null, OrderClass.BRACKET, takeProfitLimitPrice, stopLossStopPrice, stopLossLimitPrice); - } - - /** - * OCO (One-Cancels-Other) is another type of advanced order type. This is a set of two orders with the same side - * (buy/buy or sell/sell) and currently only exit order is supported. In other words, this is the second part of the - * bracket orders where the entry order is already filled, and you can submit the take-profit and stop-loss in one - * order submission. This method calls {@link #requestNewOrder(String, Integer, OrderSide, OrderType, - * OrderTimeInForce, Double, Double, Boolean, String, OrderClass, Double, Double, Double)} with parameters for an - * OCO order type. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. - * Only works with type limit and time_in_force day. - * @param takeProfitLimitPrice Additional parameter for take-profit leg of advanced orders. - * @param stopLossStopPrice Additional parameters for stop-loss leg of advanced orders. - * @param stopLossLimitPrice Additional parameters for stop-loss leg of advanced orders. The stop-loss order - * becomes a stop-limit order if specified. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewOCOOrder(String symbol, Integer quantity, OrderSide side, - OrderTimeInForce timeInForce, Boolean extendedHours, Double takeProfitLimitPrice, - Double stopLossStopPrice, Double stopLossLimitPrice) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.LIMIT, timeInForce, null, null, extendedHours, null, - OrderClass.OCO, takeProfitLimitPrice, stopLossStopPrice, stopLossLimitPrice); - } - - /** - * OTO (One-Triggers-Other) is a variant of bracket order. It takes one of the take-profit or stop-loss order in - * addition to the entry order. This method calls {@link #requestNewOrder(String, Integer, OrderSide, OrderType, - * OrderTimeInForce, Double, Double, Boolean, String, OrderClass, Double, Double, Double)} with {@link - * OrderType#LIMIT} and with parameters for an OTO order type. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. - * Only works with type limit and time_in_force day. - * @param takeProfitLimitPrice Additional parameter for take-profit leg of advanced orders. - * @param stopLossStopPrice Additional parameters for stop-loss leg of advanced orders. - * @param stopLossLimitPrice Additional parameters for stop-loss leg of advanced orders. The stop-loss order - * becomes a stop-limit order if specified. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewOTOMarketOrder(String symbol, Integer quantity, OrderSide side, - OrderTimeInForce timeInForce, Boolean extendedHours, Double takeProfitLimitPrice, - Double stopLossStopPrice, Double stopLossLimitPrice) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.MARKET, timeInForce, null, null, extendedHours, null, - OrderClass.OTO, takeProfitLimitPrice, stopLossStopPrice, stopLossLimitPrice); - } - - /** - * OTO (One-Triggers-Other) is a variant of bracket order. It takes one of the take-profit or stop-loss order in - * addition to the entry order. This method calls {@link #requestNewOrder(String, Integer, OrderSide, OrderType, - * OrderTimeInForce, Double, Double, Boolean, String, OrderClass, Double, Double, Double)} with {@link - * OrderType#LIMIT} and with parameters for an OTO order type. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param limitPrice required if type is limit or stop_limit - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. - * Only works with type limit and time_in_force day. - * @param takeProfitLimitPrice Additional parameter for take-profit leg of advanced orders. - * @param stopLossStopPrice Additional parameters for stop-loss leg of advanced orders. - * @param stopLossLimitPrice Additional parameters for stop-loss leg of advanced orders. The stop-loss order - * becomes a stop-limit order if specified. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewOTOLimitOrder(String symbol, Integer quantity, OrderSide side, - OrderTimeInForce timeInForce, Double limitPrice, Boolean extendedHours, Double takeProfitLimitPrice, - Double stopLossStopPrice, Double stopLossLimitPrice) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.LIMIT, timeInForce, limitPrice, null, extendedHours, - null, OrderClass.OTO, takeProfitLimitPrice, stopLossStopPrice, stopLossLimitPrice); - } - - /** - * OTO (One-Triggers-Other) is a variant of bracket order. It takes one of the take-profit or stop-loss order in - * addition to the entry order. This method calls {@link #requestNewOrder(String, Integer, OrderSide, OrderType, - * OrderTimeInForce, Double, Double, Boolean, String, OrderClass, Double, Double, Double)} with {@link - * OrderType#STOP} and with parameters for an OTO order type. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param stopPrice required if type is stop or stop_limit - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. - * Only works with type limit and time_in_force day. - * @param takeProfitLimitPrice Additional parameter for take-profit leg of advanced orders. - * @param stopLossStopPrice Additional parameters for stop-loss leg of advanced orders. - * @param stopLossLimitPrice Additional parameters for stop-loss leg of advanced orders. The stop-loss order - * becomes a stop-limit order if specified. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewOTOStopOrder(String symbol, Integer quantity, OrderSide side, - OrderTimeInForce timeInForce, Double stopPrice, Boolean extendedHours, Double takeProfitLimitPrice, - Double stopLossStopPrice, Double stopLossLimitPrice) throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.STOP, timeInForce, null, stopPrice, extendedHours, - null, OrderClass.OTO, takeProfitLimitPrice, stopLossStopPrice, stopLossLimitPrice); - } - - /** - * OTO (One-Triggers-Other) is a variant of bracket order. It takes one of the take-profit or stop-loss order in - * addition to the entry order. This method calls {@link #requestNewOrder(String, Integer, OrderSide, OrderType, - * OrderTimeInForce, Double, Double, Boolean, String, OrderClass, Double, Double, Double)} with {@link - * OrderType#STOP_LIMIT} and with parameters for an OTO order type. - * - * @param symbol symbol or asset ID to identify the asset to trade - * @param quantity number of shares to trade - * @param side buy or sell - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param limitPrice required if type is limit or stop_limit - * @param stopPrice required if type is stop or stop_limit - * @param extendedHours (default) false. If true, order will be eligible to execute in premarket/afterhours. - * Only works with type limit and time_in_force day. - * @param takeProfitLimitPrice Additional parameter for take-profit leg of advanced orders. - * @param stopLossStopPrice Additional parameters for stop-loss leg of advanced orders. - * @param stopLossLimitPrice Additional parameters for stop-loss leg of advanced orders. The stop-loss order - * becomes a stop-limit order if specified. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Order Types - */ - public Order requestNewOTOStopLimitOrder(String symbol, Integer quantity, OrderSide side, - OrderTimeInForce timeInForce, Double limitPrice, Double stopPrice, Boolean extendedHours, - Double takeProfitLimitPrice, Double stopLossStopPrice, Double stopLossLimitPrice) - throws AlpacaAPIRequestException { - return requestNewOrder(symbol, quantity, side, OrderType.STOP_LIMIT, timeInForce, limitPrice, stopPrice, - extendedHours, null, OrderClass.OTO, takeProfitLimitPrice, stopLossStopPrice, stopLossLimitPrice); - } - - /** - * Retrieves a single order for the given order_id. - * - * @param orderID Order ID - * @param nested If true, the result will roll up multi-leg orders under the legs field of primary order. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Orders - */ - public Order getOrder(String orderID, Boolean nested) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(orderID); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ORDERS_ENDPOINT, - orderID); - - if (nested != null) { - urlBuilder.appendURLParameter(AlpacaConstants.NESTED_PARAMETER, nested.toString()); - } - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Order.class); - } - - /** - * Retrieves a single order for the given client_order_id. - * - * @param clientOrderId the client order id - * - * @return the order by client id - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Orders - */ - public Order getOrderByClientID(String clientOrderId) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(clientOrderId); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ORDERS_BY_CLIENT_ORDER_ID_ENDPOINT); - urlBuilder.appendURLParameter(AlpacaConstants.CLIENT_ORDER_ID_PARAMETER, clientOrderId); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Order.class); - } - - /** - * Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the - * existing order. The other attributes remain the same as the existing order. - * - * @param orderID Order id - * @param quantity number of shares to trade - * @param timeInForce day, gtc, opg, cls, ioc, fok. Please see Understand Orders for more info. - * @param limitPrice required if type is limit or stop_limit - * @param stopPrice required if type is stop or stop_limit - * @param clientOrderId A unique identifier for the order. Automatically generated if not sent. - * - * @return the order - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Orders - */ - public Order replaceOrder(String orderID, Integer quantity, OrderTimeInForce timeInForce, Double limitPrice, - Double stopPrice, String clientOrderId) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(orderID); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ORDERS_ENDPOINT, - orderID); - - if (quantity != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.QTY_PARAMETER, quantity.toString()); - } - - if (timeInForce != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.TIME_IN_FORCE_PARAMETER, timeInForce.getAPIName()); - } - - if (limitPrice != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.LIMIT_PRICE_PARAMETER, - TimeUtil.toDecimalFormat(limitPrice)); - } - - if (stopPrice != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.STOP_PRICE_PARAMETER, - TimeUtil.toDecimalFormat(stopPrice)); - } - - if (clientOrderId != null) { - urlBuilder.appendJSONBodyProperty(AlpacaConstants.CLIENT_ORDER_ID_PARAMETER, clientOrderId); - } - - HttpResponse response = alpacaRequest.invokePatch(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Order.class); - } - - /** - * Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. - * If an order is no longer cancelable, the server will respond with status 500 and reject the request. - * - * @return the array list of cancelled orders - * - * @throws AlpacaAPIRequestException the alpaca api request exception - * @see Orders - */ - public ArrayList cancelAllOrders() throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ORDERS_ENDPOINT); - - HttpResponse response = alpacaRequest.invokeDelete(urlBuilder); - - if (response.getStatus() != 207) { // This returns a 207 multi-status message - throw new AlpacaAPIRequestException(response); - } - - Type arrayListType = new TypeToken>() {}.getType(); - - return alpacaRequest.getResponseObject(response, arrayListType); - } - - /** - * Attempts to cancel an open order. If the order is no longer cancelable (example: status=order_filled), the server - * will respond with status 422, and reject the request. - * - * @param orderId Order ID - * - * @return true, if successful - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Orders - */ - public boolean cancelOrder(String orderId) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(orderId); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ORDERS_ENDPOINT, - orderId); - - HttpResponse response = alpacaRequest.invokeDelete(urlBuilder); - - if ((response.getStatus() != 200 && response.getStatus() != 204)) { - throw new AlpacaAPIRequestException(response); - } - - return response.getStatus() == 200 || response.getStatus() == 204; - } - - /** - * Gets the open positions. - * - * @return the open positions - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Positions - */ - public ArrayList getOpenPositions() throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.POSITIONS_ENDPOINT); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - Type arrayListType = new TypeToken>() {}.getType(); - - return alpacaRequest.getResponseObject(response, arrayListType); - } - - /** - * Gets the open position by symbol. - * - * @param symbol the symbol or asset_id (required) - * - * @return the open position by symbol - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Positions - */ - public Position getOpenPositionBySymbol(String symbol) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(symbol); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.POSITIONS_ENDPOINT, - symbol.trim()); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Position.class); - } - - /** - * Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each - * order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status - * 500 and reject the request. - * - * @return a list of closing position orders - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Positions - */ - public ArrayList closeAllPositions() throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.POSITIONS_ENDPOINT); - - HttpResponse response = alpacaRequest.invokeDelete(urlBuilder); - - if (response.getStatus() != 207) { // This returns a 207 multi-status message - throw new AlpacaAPIRequestException(response); - } - - Type arrayListType = new TypeToken>() {}.getType(); - - return alpacaRequest.getResponseObject(response, arrayListType); - } - - /** - * Closes (liquidates) the account’s open position for the given symbol. Works for both long and short positions. - * - * @param symbol symbol or asset_id - * - * @return a closing position order - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Positions - */ - public Order closePosition(String symbol) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(symbol); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.POSITIONS_ENDPOINT, - symbol); - - HttpResponse response = alpacaRequest.invokeDelete(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Order.class); - } - - /** - * Get a list of assets. - * - * @param assetStatus e.g. “active”. By default, all statuses are included. - * @param assetClass Defaults to us_equity. - * - * @return the assets - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Assets - */ - public ArrayList getAssets(AssetStatus assetStatus, String assetClass) throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ASSETS_ENDPOINT); - - if (assetStatus != null) { - urlBuilder.appendURLParameter(AlpacaConstants.STATUS_PARAMETER, assetStatus.getAPIName()); - } - - if (assetClass != null) { - urlBuilder.appendURLParameter(AlpacaConstants.ASSET_CLASS_PARAMETER, assetClass.trim()); - } - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - Type arrayListType = new TypeToken>() {}.getType(); - - return alpacaRequest.getResponseObject(response, arrayListType); - } - - /** - * Gets the asset by symbol or asset_id. - * - * @param symbolOrAssetID the symbol or asset_id (required) - * - * @return the asset by symbol - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Assets - */ - public Asset getAssetBySymbol(String symbolOrAssetID) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(symbolOrAssetID); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ASSETS_ENDPOINT, - symbolOrAssetID.trim()); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Asset.class); - } - - /** - * Returns the list of watchlists registered under the account. - * - * @return the watch lists - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Watchlists - */ - public ArrayList getWatchlists() throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.WATCHLISTS_ENDPOINT); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - Type arrayListType = new TypeToken>() {}.getType(); - return alpacaRequest.getResponseObject(response, arrayListType); - } - - /** - * Create a new watchlist with initial set of assets. - * - * @param name arbitrary name string, up to 64 characters - * @param symbols set of symbol string - * - * @return the created watchlist - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Watchlists - */ - public Watchlist createWatchlist(String name, String... symbols) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(name); - Preconditions.checkState(name.length() <= 64); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.WATCHLISTS_ENDPOINT); - - urlBuilder.appendJSONBodyProperty("name", name); - - if (symbols != null) { - JsonArray symbolsArray = new JsonArray(); - Arrays.stream(symbols).forEach(symbolsArray::add); - - urlBuilder.appendJSONBodyJSONProperty("symbols", symbolsArray); - } - - HttpResponse response = alpacaRequest.invokePost(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Watchlist.class); - } - - /** - * Returns a watchlist identified by the ID. - * - * @param watchlistID Watchlist ID - * - * @return the watchlist - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Watchlists - */ - public Watchlist getWatchlist(String watchlistID) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(watchlistID); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.WATCHLISTS_ENDPOINT, - watchlistID); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Watchlist.class); - } - - /** - * Update the name and/or content of watchlist. - * - * @param watchlistID Watchlist ID - * @param name the new watchlist name - * @param symbols the new list of symbol names to replace the watchlist content - * - * @return the updated watchlist - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Watchlists - */ - public Watchlist updateWatchlist(String watchlistID, String name, String... symbols) - throws AlpacaAPIRequestException { - Preconditions.checkNotNull(watchlistID); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.WATCHLISTS_ENDPOINT, - watchlistID); - - if (name != null) { - urlBuilder.appendJSONBodyProperty("name", name); - } - - if (symbols != null) { - JsonArray symbolsArray = new JsonArray(); - Arrays.stream(symbols).forEach(symbolsArray::add); - - urlBuilder.appendJSONBodyJSONProperty("symbols", symbolsArray); - } - - HttpResponse response = alpacaRequest.invokePut(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Watchlist.class); - } - - /** - * Append an asset for the symbol to the end of watchlist asset list - * - * @param watchlistID Watchlist ID - * @param symbol the symbol name to add to the watchlist - * - * @return the watchlist - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Watchlists - */ - public Watchlist addWatchlistAsset(String watchlistID, String symbol) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(watchlistID); - Preconditions.checkNotNull(symbol); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.WATCHLISTS_ENDPOINT, - watchlistID); - - urlBuilder.appendJSONBodyProperty("symbol", symbol); - - HttpResponse response = alpacaRequest.invokePost(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Watchlist.class); - } - - /** - * Delete a watchlist. This is a permanent deletion. - * - * @param watchlistID Watchlist ID - * - * @return if the watchlist was deleted - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Watchlists - */ - public boolean deleteWatchlist(String watchlistID) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(watchlistID); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.WATCHLISTS_ENDPOINT, - watchlistID); - - HttpResponse response = alpacaRequest.invokeDelete(urlBuilder); - - if ((response.getStatus() != 200 && response.getStatus() != 204)) { - throw new AlpacaAPIRequestException(response); - } - - return response.getStatus() == 200 || response.getStatus() == 204; - } - - /** - * Delete one entry for an asset by symbol name. - * - * @param watchlistID Watchlist ID - * @param symbol symbol name to remove from the watchlist content - * - * @return the updated watchlist - * - * @throws AlpacaAPIRequestException the alpaca api exception - * @see Watchlists - */ - public Watchlist removeSymbolFromWatchlist(String watchlistID, String symbol) throws AlpacaAPIRequestException { - Preconditions.checkNotNull(watchlistID); - Preconditions.checkNotNull(symbol); - - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.WATCHLISTS_ENDPOINT, - watchlistID, - symbol); - - HttpResponse response = alpacaRequest.invokeDelete(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Watchlist.class); - } - - /** - * Returns timeseries data about equity and profit/loss (P/L) of the account in requested timespan. - * - * @param periodLength The duration of the data in "number + unit", such as 1D, where unit can be D for day, W for - * week, M for month and A for year. Defaults to 1M. This parameter is the number. - * @param periodUnit The duration of the data in "number + unit", such as 1D, where unit can be D for day, W for - * week, M for month and A for year. Defaults to 1M. This parameter is the unit. - * @param timeFrame The resolution of time window. 1Min, 5Min, 15Min, 1H, or 1D. If omitted, 1Min for less than - * 7 days period, 15Min for less than 30 days, or otherwise 1D. - * @param dateEnd The date the data is returned up to, in "YYYY-MM-DD" format. Defaults to the current market - * date (rolls over at the market open if extended_hours is false, otherwise at 7am ET) - * @param extendedHours If true, include extended hours in the result. This is effective only for timeframe less - * than 1D. - * - * @return the portfolio history - * - * @throws AlpacaAPIRequestException the alpaca api request exception - */ - public PortfolioHistory getPortfolioHistory(Integer periodLength, PortfolioPeriodUnit periodUnit, - PortfolioTimeFrame timeFrame, LocalDate dateEnd, Boolean extendedHours) throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.ACCOUNT_ENDPOINT, - AlpacaConstants.PORTFOLIO_ENDPOINT, - AlpacaConstants.HISTORY_ENDPOINT); - - if (periodLength != null && periodUnit != null) { - urlBuilder.appendURLParameter(AlpacaConstants.PERIOD_PARAMETER, periodLength + periodUnit.getAPIName()); - } - - if (timeFrame != null) { - urlBuilder.appendURLParameter(AlpacaConstants.TIMEFRAME_PARAMETER, timeFrame.getAPIName()); - } - - if (dateEnd != null) { - urlBuilder.appendURLParameter(AlpacaConstants.DATE_END_PARAMETER, TimeUtil.toDateString(dateEnd)); - } - - if (extendedHours != null) { - urlBuilder.appendURLParameter(AlpacaConstants.EXTENDED_HOURS_PARAMETER, extendedHours.toString()); - } - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, PortfolioHistory.class); - } - - /** - * Returns the market calendar. - * - * @return the calendar - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Calendar - */ - public ArrayList getCalendar() throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.CALENDAR_ENDPOINT); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - Type arrayListType = new TypeToken>() {}.getType(); - - return alpacaRequest.getResponseObject(response, arrayListType); - } - - /** - * Returns the market calendar. - * - * @param start The first date to retrieve data for (inclusive) - * @param end The last date to retrieve data for (inclusive) - * - * @return the calendar - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Calendar - */ - public ArrayList getCalendar(LocalDate start, LocalDate end) throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.CALENDAR_ENDPOINT); - - if (start != null) { - urlBuilder.appendURLParameter(AlpacaConstants.START_PARAMETER, TimeUtil.toDateString(start)); - } - - if (end != null) { - urlBuilder.appendURLParameter(AlpacaConstants.END_PARAMETER, TimeUtil.toDateString(end)); - } - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - Type arrayListType = new TypeToken>() {}.getType(); - - return alpacaRequest.getResponseObject(response, arrayListType); - } - - /** - * Returns the market clock. - * - * @return the clock - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Clock - */ - public Clock getClock() throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseAPIURL, apiVersion, - AlpacaConstants.CLOCK_ENDPOINT); - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - return alpacaRequest.getResponseObject(response, Clock.class); - } - - /** - * Retrieves a list of bars for each requested symbol. It is guaranteed all bars are in ascending order by time. - *

- * Currently, no “incomplete” bars are returned. For example, a 1 minute bar for 09:30 will not be returned until - * 09:31. - * - * @param timeframe One of minute, 1Min, 5Min, 15Min, day or 1D. minute is an alias of 1Min. Similarly, day is of - * 1D. - * @param symbol One symbol name. - * @param limit The maximum number of bars to be returned for each symbol. It can be between 1 and 1000. Default - * is 100 if parameter is unspecified or 0. - * @param start Filter bars equal to or after this time. Cannot be used with after. - * @param end Filter bars equal to or before this time. Cannot be used with until. - * @param after Filter bars after this time. Cannot be used with start. - * @param until Filter bars before this time. Cannot be used with end. - * - * @return the bars - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Bars - */ - public Map> getBars(BarsTimeFrame timeframe, String symbol, Integer limit, - ZonedDateTime start, ZonedDateTime end, ZonedDateTime after, ZonedDateTime until) - throws AlpacaAPIRequestException { - return this.getBars(timeframe, new String[]{symbol}, limit, start, end, after, until); - } - - /** - * Retrieves a list of bars for each requested symbol. It is guaranteed all bars are in ascending order by time. - *

- * Currently, no “incomplete” bars are returned. For example, a 1 minute bar for 09:30 will not be returned until - * 09:31. - * - * @param timeframe One of minute, 1Min, 5Min, 15Min, day or 1D. minute is an alias of 1Min. Similarly, day is of - * 1D. - * @param symbols One or more (max 200) symbol names split by commas (“,”). - * @param limit The maximum number of bars to be returned for each symbol. It can be between 1 and 1000. Default - * is 100 if parameter is unspecified or 0. - * @param start Filter bars equal to or after this time. Cannot be used with after. - * @param end Filter bars equal to or before this time. Cannot be used with until. - * @param after Filter bars after this time. Cannot be used with start. - * @param until Filter bars before this time. Cannot be used with end. - * - * @return the bars - * - * @throws AlpacaAPIRequestException the alpaca API exception - * @see Bars - */ - public Map> getBars(BarsTimeFrame timeframe, String[] symbols, Integer limit, - ZonedDateTime start, ZonedDateTime end, ZonedDateTime after, ZonedDateTime until) - throws AlpacaAPIRequestException { - AlpacaRequestBuilder urlBuilder = new AlpacaRequestBuilder(baseDataUrl, AlpacaConstants.VERSION_1_ENDPOINT, - AlpacaConstants.BARS_ENDPOINT); - - if (timeframe != null) { - urlBuilder.appendEndpoint(timeframe.getAPIName()); - } - - if (symbols != null) { - urlBuilder.appendURLParameter(AlpacaConstants.SYMBOLS_PARAMETER, String.join(",", symbols)); - } - - if (limit != null) { - urlBuilder.appendURLParameter(AlpacaConstants.LIMIT_PARAMETER, limit.toString()); - } - - if (start != null) { - urlBuilder.appendURLParameter(AlpacaConstants.START_PARAMETER, - start.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - if (end != null) { - urlBuilder.appendURLParameter(AlpacaConstants.END_PARAMETER, - end.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - if (after != null) { - urlBuilder.appendURLParameter(AlpacaConstants.AFTER_PARAMETER, - after.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - if (until != null) { - urlBuilder.appendURLParameter(AlpacaConstants.UNTIL_PARAMETER, - until.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - HttpResponse response = alpacaRequest.invokeGet(urlBuilder); - - if (response.getStatus() != 200) { - throw new AlpacaAPIRequestException(response); - } - - Type mapType = new TypeToken>>() {}.getType(); - - return alpacaRequest.getResponseObject(response, mapType); - } - - /** - * Adds the alpaca stream listener. - * - * @param streamListener the stream listener - */ - public void addAlpacaStreamListener(AlpacaStreamListener streamListener) { - alpacaWebSocketClient.addListener(streamListener); - } - - /** - * Removes the alpaca stream listener. - * - * @param streamListener the stream listener - */ - public void removeAlpacaStreamListener(AlpacaStreamListener streamListener) { - alpacaWebSocketClient.removeListener(streamListener); - } - - @Override - public String toString() { - return new StringJoiner(", ", this.getClass().getSimpleName() + "[", "]") - .add("apiVersion = " + apiVersion) - .add("baseAPIURL = " + baseAPIURL) - .add("baseDataUrl = " + baseDataUrl) - .add("keyId = " + keyId) - .toString(); - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/AlpacaConstants.java b/src/main/java/io/github/mainstringargs/alpaca/AlpacaConstants.java deleted file mode 100644 index c1b406cb..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/AlpacaConstants.java +++ /dev/null @@ -1,140 +0,0 @@ -package io.github.mainstringargs.alpaca; - -/** - * The Class AlpacaConstants. - */ -public class AlpacaConstants { - - /** The Constant VERSION_1. */ - public static final String VERSION_1_ENDPOINT = "v1"; - - /** The Constant VERSION_2. */ - public static final String VERSION_2_ENDPOINT = "v2"; - - /** The Constant SYMBOLS_PARAMETER. */ - public static final String SYMBOLS_PARAMETER = "symbols"; - - /** The Constant END_PARAMETER. */ - public static final String END_PARAMETER = "end"; - - /** The Constant START_PARAMETER. */ - public static final String START_PARAMETER = "start"; - - /** The constant DATE_PARAMETER. */ - public static final String DATE_PARAMETER = "date"; - - /** The Constant ASSET_CLASS_PARAMETER. */ - public static final String ASSET_CLASS_PARAMETER = "asset_class"; - - /** The Constant CLIENT_ORDER_ID_PARAMETER. */ - public static final String CLIENT_ORDER_ID_PARAMETER = "client_order_id"; - - /** The constant ORDER_CLASS_PARAMETER. */ - public static final String ORDER_CLASS_PARAMETER = "order_class"; - - /** The constant TAKE_PROFIT_PARAMETER. */ - public static final String TAKE_PROFIT_PARAMETER = "take_profit"; - - /** The constant STOP_LOSS_PARAMETER. */ - public static final String STOP_LOSS_PARAMETER = "stop_loss"; - - /** The Constant STOP_PRICE_PARAMETER. */ - public static final String STOP_PRICE_PARAMETER = "stop_price"; - - /** The Constant LIMIT_PRICE_PARAMETER. */ - public static final String LIMIT_PRICE_PARAMETER = "limit_price"; - - /** The Constant TIME_IN_FORCE_PARAMETER. */ - public static final String TIME_IN_FORCE_PARAMETER = "time_in_force"; - - /** The constant EXTENDED_HOURS_PARAMETER. */ - public static final String EXTENDED_HOURS_PARAMETER = "extended_hours"; - - /** The Constant TYPE_PARAMETER. */ - public static final String TYPE_PARAMETER = "type"; - - /** The Constant SIDE_PARAMETER. */ - public static final String SIDE_PARAMETER = "side"; - - /** The Constant QTY_PARAMETER. */ - public static final String QTY_PARAMETER = "qty"; - - /** The Constant SYMBOL_PARAMETER. */ - public static final String SYMBOL_PARAMETER = "symbol"; - - /** The Constant DIRECTION_PARAMETER. */ - public static final String DIRECTION_PARAMETER = "direction"; - - /** The constant NESTED_PARAMETER. */ - public static final String NESTED_PARAMETER = "nested"; - - /** The Constant UNTIL_PARAMETER. */ - public static final String UNTIL_PARAMETER = "until"; - - /** The Constant AFTER_PARAMETER. */ - public static final String AFTER_PARAMETER = "after"; - - /** The Constant LIMIT_PARAMETER. */ - public static final String LIMIT_PARAMETER = "limit"; - - /** The Constant STATUS_PARAMETER. */ - public static final String STATUS_PARAMETER = "status"; - - /** The constant PERIOD_PARAMETER. */ - public static final String PERIOD_PARAMETER = "period"; - - /** The constant TIMEFRAME_PARAMETER. */ - public static final String TIMEFRAME_PARAMETER = "timeframe"; - - /** The constant DATE_END_PARAMETER. */ - public static final String DATE_END_PARAMETER = "date_end"; - - /** The Constant BARS_ENDPOINT. */ - public static final String BARS_ENDPOINT = "bars"; - - /** The Constant CLOCK_ENDPOINT. */ - public static final String CLOCK_ENDPOINT = "clock"; - - /** The Constant CALENDAR_ENDPOINT. */ - public static final String CALENDAR_ENDPOINT = "calendar"; - - /** The Constant ASSETS_ENDPOINT. */ - public static final String ASSETS_ENDPOINT = "assets"; - - /** The Constant POSITIONS_ENDPOINT. */ - public static final String POSITIONS_ENDPOINT = "positions"; - - /** The Constant ACCOUNT_ENDPOINT. */ - public static final String ACCOUNT_ENDPOINT = "account"; - - /** The Constant ACTIVITIES_ENDPOINT. */ - public static final String ACTIVITIES_ENDPOINT = "activities"; - - /** The Constant CONFIGURATIONS_ENDPOINT. */ - public static final String CONFIGURATIONS_ENDPOINT = "configurations"; - - /** The Constant ORDERS_BY_CLIENT_ORDER_ID_ENDPOINT. */ - public static final String ORDERS_BY_CLIENT_ORDER_ID_ENDPOINT = "orders:by_client_order_id"; - - /** The constant PAGE_SIZE_PARAMETER. */ - public static final String PAGE_SIZE_PARAMETER = "page_size"; - - /** The constant PAGE_TOKEN_PARAMETER. */ - public static final String PAGE_TOKEN_PARAMETER = "page_token"; - - /** The Constant ORDERS_ENDPOINT. */ - public static final String ORDERS_ENDPOINT = "orders"; - - /** The Constant WATCHLISTS_ENDPOINT. */ - public static final String WATCHLISTS_ENDPOINT = "watchlists"; - - /** The constant PORTFOLIO_ENDPOINT. */ - public static final String PORTFOLIO_ENDPOINT = "portfolio"; - - /** The constant HISTORY_ENDPOINT. */ - public static final String HISTORY_ENDPOINT = "history"; - - /** The Constant UTF_ENCODING. */ - public static final String UTF_ENCODING = "UTF-8"; - -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/AlpacaExample.java b/src/main/java/io/github/mainstringargs/alpaca/AlpacaExample.java deleted file mode 100644 index e6bcfa52..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/AlpacaExample.java +++ /dev/null @@ -1,119 +0,0 @@ -package io.github.mainstringargs.alpaca; - -import io.github.mainstringargs.alpaca.enums.BarsTimeFrame; -import io.github.mainstringargs.alpaca.enums.OrderSide; -import io.github.mainstringargs.alpaca.enums.OrderTimeInForce; -import io.github.mainstringargs.alpaca.rest.exception.AlpacaAPIRequestException; -import io.github.mainstringargs.alpaca.websocket.listener.AlpacaStreamListenerAdapter; -import io.github.mainstringargs.alpaca.websocket.message.AlpacaStreamMessageType; -import io.github.mainstringargs.domain.alpaca.account.Account; -import io.github.mainstringargs.domain.alpaca.bar.Bar; -import io.github.mainstringargs.domain.alpaca.order.Order; -import io.github.mainstringargs.domain.alpaca.watchlist.Watchlist; -import io.github.mainstringargs.domain.alpaca.websocket.AlpacaStreamMessage; -import io.github.mainstringargs.domain.alpaca.websocket.account.AccountUpdateMessage; -import io.github.mainstringargs.domain.alpaca.websocket.trade.TradeUpdateMessage; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Map; - -/** - * The type Alpaca example. - */ -public class AlpacaExample { - - /** - * The entry point of application. - * - * @param args the input arguments - */ - public static void main(String[] args) { - // This logs into Alpaca using the alpaca.properties file on the classpath. - AlpacaAPI alpacaAPI = new AlpacaAPI(); - - // Register explicitly for ACCOUNT_UPDATES and ORDER_UPDATES Messages via stream listener - alpacaAPI.addAlpacaStreamListener(new AlpacaStreamListenerAdapter( - AlpacaStreamMessageType.ACCOUNT_UPDATES, - AlpacaStreamMessageType.TRADE_UPDATES) { - @Override - public void onStreamUpdate(AlpacaStreamMessageType streamMessageType, AlpacaStreamMessage streamMessage) { - switch (streamMessageType) { - case ACCOUNT_UPDATES: - AccountUpdateMessage accountUpdateMessage = (AccountUpdateMessage) streamMessage; - System.out.println("\nReceived Account Update: \n\t" + - accountUpdateMessage.toString().replace(",", ",\n\t")); - break; - case TRADE_UPDATES: - TradeUpdateMessage tradeUpdateMessage = (TradeUpdateMessage) streamMessage; - System.out.println("\nReceived Order Update: \n\t" + - tradeUpdateMessage.toString().replace(",", ",\n\t")); - break; - } - } - }); - - // Get Account Information - try { - Account alpacaAccount = alpacaAPI.getAccount(); - - System.out.println("\n\nAccount Information:"); - System.out.println("\t" + alpacaAccount.toString().replace(",", ",\n\t")); - } catch (AlpacaAPIRequestException e) { - e.printStackTrace(); - } - - // Request an Order - try { - Order aaplLimitOrder = alpacaAPI.requestNewLimitOrder("AAPL", 1, OrderSide.BUY, OrderTimeInForce.DAY, - 201.30, true); - - System.out.println("\n\nNew AAPL Order:"); - System.out.println("\t" + aaplLimitOrder.toString().replace(",", ",\n\t")); - } catch (AlpacaAPIRequestException e) { - e.printStackTrace(); - } - - // Create watchlist - try { - Watchlist dayTradeWatchlist = alpacaAPI.createWatchlist("Day Trade", "AAPL"); - - System.out.println("\n\nDay Trade Watchlist:"); - System.out.println("\t" + dayTradeWatchlist.toString().replace(",", ",\n\t")); - } catch (AlpacaAPIRequestException e) { - e.printStackTrace(); - } - - // Get bars - try { - ZonedDateTime start = ZonedDateTime.of(2019, 11, 18, 0, 0, 0, 0, ZoneId.of("America/New_York")); - ZonedDateTime end = ZonedDateTime.of(2019, 11, 22, 23, 59, 0, 0, ZoneId.of("America/New_York")); - - Map> bars = alpacaAPI.getBars(BarsTimeFrame.ONE_DAY, "AAPL", null, start, end, - null, null); - - System.out.println("\n\nBars response:"); - for (Bar bar : bars.get("AAPL")) { - System.out.println("\t=========="); - System.out.println("\tUnix Time " + ZonedDateTime.ofInstant(Instant.ofEpochSecond(bar.getT()), - ZoneOffset.UTC)); - System.out.println("\tOpen: $" + bar.getO()); - System.out.println("\tHigh: $" + bar.getH()); - System.out.println("\tLow: $" + bar.getL()); - System.out.println("\tClose: $" + bar.getC()); - System.out.println("\tVolume: " + bar.getV()); - } - } catch (AlpacaAPIRequestException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/AccountStatus.java b/src/main/java/io/github/mainstringargs/alpaca/enums/AccountStatus.java deleted file mode 100644 index 6e1e6a29..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/AccountStatus.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The enum Account status. - * - * @see Account Status - */ -public enum AccountStatus implements APIName { - - // The names of these enums must be the API name exactly - // @see AccountStatus#getAPIName() - - /** - * The account is onboarding. - */ - ONBOARDING, - - /** - * The account application submission failed for some reason. - */ - SUBMISSION_FAILED, - - /** - * The account application has been submitted for review. - */ - SUBMITTED, - - /** - * The account information is being updated. - */ - ACCOUNT_UPDATED, - - /** - * The final account approval is pending. - */ - APPROVAL_PENDING, - - /** - * The account is active for trading. - */ - ACTIVE, - - /** - * The account application has been rejected. - */ - REJECTED; - - @Override - public String getAPIName() { - return this.name(); - } -} - diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/ActivityType.java b/src/main/java/io/github/mainstringargs/alpaca/enums/ActivityType.java deleted file mode 100644 index ff927694..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/ActivityType.java +++ /dev/null @@ -1,116 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The enum Activity type. - * - * @see - * https://docs.alpaca.markets/api-documentation/api-v2/account-activities/ - */ -public enum ActivityType implements APIName { - - /** Order fills (both partial and full fills) */ - FILL, - - /** Cash transactions (both CSD and CSR) */ - TRANS, - - /** Miscellaneous or rarely used activity types (All types except those in TRANS, DIV, or FILL) */ - MISC, - - /** ACATS IN/OUT (Cash) */ - ACATC, - - /** ACATS IN/OUT (Securities) */ - ACATS, - - /** Cash disbursement(+) */ - CSD, - - /** Cash receipt(-) */ - CSR, - - /** Dividends */ - DIV, - - /** Dividend (capital gain long term) */ - DIVCGL, - - /** Dividend (capital gain short term) */ - DIVCGS, - - /** Dividend fee */ - DIVFEE, - - /** Dividend adjusted (Foreign Tax Withheld) */ - DIVFT, - - /** Dividend adjusted (NRA Withheld) */ - DIVNRA, - - /** Dividend return of capital */ - DIVROC, - - /** Dividend adjusted (Tefra Withheld) */ - DIVTW, - - /** Dividend (tax exempt) */ - DIVTXEX, - - /** Interest (credit/margin) */ - INT, - - /** Interest adjusted (NRA Withheld) */ - INTNRA, - - /** Interest adjusted (Tefra Withheld) */ - INTTW, - - /** Journal entry */ - JNL, - - /** Journal entry (cash) */ - JNLC, - - /** Journal entry (stock) */ - JNLS, - - /** Merger/Acquisition */ - MA, - - /** Name change */ - NC, - - /** Option assignment */ - OPASN, - - /** Option expiration */ - OPEXP, - - /** Option exercise */ - OPXRC, - - /** Pass Thru Charge */ - PTC, - - /** Pass Thru Rebate */ - PTR, - - /** Reorg CA */ - REORG, - - /** Symbol change */ - SC, - - /** Stock spinoff */ - SSO, - - /** Stock split */ - SSP; - - @Override - public String getAPIName() { - return this.name(); - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/AssetStatus.java b/src/main/java/io/github/mainstringargs/alpaca/enums/AssetStatus.java deleted file mode 100644 index 888989e8..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/AssetStatus.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum AssetStatus. - */ -public enum AssetStatus implements APIName { - - /** The active. */ - ACTIVE("active"), - - /** The inactive. */ - INACTIVE("inactive"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new asset status. - * - * @param apiName the api name - */ - AssetStatus(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/BarsTimeFrame.java b/src/main/java/io/github/mainstringargs/alpaca/enums/BarsTimeFrame.java deleted file mode 100644 index a7295eeb..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/BarsTimeFrame.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum BarsTimeFrame. - */ -public enum BarsTimeFrame implements APIName { - - /** One min bars time frame. */ - ONE_MIN("1Min"), - - /** Five minute bars time frame. */ - FIVE_MINUTE("5Min"), - - /** Fifteen minute bars time frame. */ - FIFTEEN_MINUTE("15Min"), - - /** One day bars time frame. */ - ONE_DAY("1D"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new bars time frame. - * - * @param apiName the api name - */ - BarsTimeFrame(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/Direction.java b/src/main/java/io/github/mainstringargs/alpaca/enums/Direction.java deleted file mode 100644 index adca7f5f..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/Direction.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum Direction. - */ -public enum Direction implements APIName { - - /** The asc. */ - ASCENDING("asc"), - - /** The desc. */ - DESCENDING("desc"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new direction. - * - * @param apiName the api name - */ - Direction(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderClass.java b/src/main/java/io/github/mainstringargs/alpaca/enums/OrderClass.java deleted file mode 100644 index a0613c77..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderClass.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The enum Account status. - * - * @see Account Status - */ -public enum OrderClass implements APIName { - - /** Simple order class. */ - SIMPLE("simple"), - - /** Bracket order class. */ - BRACKET("bracket"), - - /** One-Cancels-Other order class. */ - OCO("oco"), - - /** One-Triggers-Other order class. */ - OTO("oto"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new order class. - * - * @param apiName the api name - */ - OrderClass(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} - diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderSide.java b/src/main/java/io/github/mainstringargs/alpaca/enums/OrderSide.java deleted file mode 100644 index cbc7fc6f..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderSide.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum OrderSide. - */ -public enum OrderSide implements APIName { - - /** The buy. */ - BUY("buy"), - - /** The sell. */ - SELL("sell"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new order side. - * - * @param apiName the api name - */ - OrderSide(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderStatus.java b/src/main/java/io/github/mainstringargs/alpaca/enums/OrderStatus.java deleted file mode 100644 index cefbbe83..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderStatus.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum OrderStatus. - */ -public enum OrderStatus implements APIName { - - /** The open. */ - OPEN("open"), - - /** The closed. */ - CLOSED("closed"), - - /** The all. */ - ALL("all"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new order status. - * - * @param apiName the api name - */ - OrderStatus(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderTimeInForce.java b/src/main/java/io/github/mainstringargs/alpaca/enums/OrderTimeInForce.java deleted file mode 100644 index 8fbf48fe..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderTimeInForce.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum OrderTimeInForce. - */ -public enum OrderTimeInForce implements APIName { - - /** The day. */ - DAY("day"), - - /** The gtc. */ - GTC("gtc"), - - /** The opg. */ - OPG("opg"), - - /** Cls order time in force. */ - CLS("cls"), - - /** Ioc order time in force. */ - IOC("ioc"), - - /** Fok order time in force. */ - FOK("fok"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new order time in force. - * - * @param apiName the api name - */ - OrderTimeInForce(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderType.java b/src/main/java/io/github/mainstringargs/alpaca/enums/OrderType.java deleted file mode 100644 index 0f2cc3ba..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/OrderType.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum OrderType. - */ -public enum OrderType implements APIName { - - /** The market. */ - MARKET("market"), - - /** The limit. */ - LIMIT("limit"), - - /** The stop. */ - STOP("stop"), - - /** The stop limit. */ - STOP_LIMIT("stop_limit"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new order type. - * - * @param apiName the api name - */ - OrderType(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/PortfolioPeriodUnit.java b/src/main/java/io/github/mainstringargs/alpaca/enums/PortfolioPeriodUnit.java deleted file mode 100644 index 7ed92f09..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/PortfolioPeriodUnit.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The enum Portfolio period unit. - */ -public enum PortfolioPeriodUnit implements APIName { - - /** Day portfolio period unit. */ - DAY("D"), - - /** Week portfolio period unit. */ - WEEK("W"), - - /** Month portfolio period unit. */ - MONTH("M"), - - /** Year portfolio period unit. */ - YEAR("A"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new Portfolio period unit. - * - * @param apiName the api name - */ - PortfolioPeriodUnit(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/enums/PortfolioTimeFrame.java b/src/main/java/io/github/mainstringargs/alpaca/enums/PortfolioTimeFrame.java deleted file mode 100644 index 5b408f96..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/enums/PortfolioTimeFrame.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.mainstringargs.alpaca.enums; - -import com.google.gson.annotations.SerializedName; -import io.github.mainstringargs.abstracts.enums.APIName; -import io.github.mainstringargs.util.gson.GsonUtil; - -public enum PortfolioTimeFrame implements APIName { - - /** One min portfolio time frame. */ - @SerializedName("1Min") - ONE_MIN, - - /** Five minute portfolio time frame. */ - @SerializedName("5Min") - FIVE_MINUTE, - - /** Fifteen minute portfolio time frame. */ - @SerializedName("15Min") - FIFTEEN_MINUTE, - - /** One hour portfolio time frame. */ - @SerializedName("1H") - ONE_HOUR, - - /** One day portfolio time frame. */ - @SerializedName("1D") - ONE_DAY; - - @Override - public String getAPIName() { - return GsonUtil.GSON.toJsonTree(this).getAsString(); - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/properties/AlpacaProperties.java b/src/main/java/io/github/mainstringargs/alpaca/properties/AlpacaProperties.java deleted file mode 100644 index c9ae9dbd..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/properties/AlpacaProperties.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.github.mainstringargs.alpaca.properties; - -import java.util.StringJoiner; - -import static io.github.mainstringargs.util.properties.PropertyUtil.getProperty; - -/** - * The Class AlpacaProperties. - */ -public class AlpacaProperties { - - private static final String ALPACA_PROPERTIES_FILE = "alpaca.properties"; - - /** The Constant API_VERSION_KEY. */ - private static final String API_VERSION_KEY = "api_version"; - - /** The Constant API_VERSION_VALUE. */ - public static final String API_VERSION_VALUE = getProperty(ALPACA_PROPERTIES_FILE, API_VERSION_KEY); - - /** The Constant KEY_ID_KEY. */ - private static final String KEY_ID_KEY = "key_id"; - - /** The Constant KEY_ID_VALUE. */ - public static final String KEY_ID_VALUE = getProperty(ALPACA_PROPERTIES_FILE, KEY_ID_KEY); - - /** The Constant SECRET_KEY. */ - private static final String SECRET_KEY = "secret"; - - /** The Constant SECRET_VALUE. */ - public static final String SECRET_VALUE = getProperty(ALPACA_PROPERTIES_FILE, SECRET_KEY); - - /** The Constant BASE_API_URL_KEY. */ - private static final String BASE_API_URL_KEY = "base_api_url"; - - /** The Constant BASE_API_URL_VALUE. */ - public static final String BASE_API_URL_VALUE = getProperty(ALPACA_PROPERTIES_FILE, BASE_API_URL_KEY); - - /** The Constant BASE_DATA_URL_KEY. */ - private static final String BASE_DATA_URL_KEY = "base_data_url"; - - /** The base data url value. */ - public static final String BASE_DATA_URL_VALUE = getProperty(ALPACA_PROPERTIES_FILE, BASE_DATA_URL_KEY); - - /** The Constant USER_AGENT_KEY. */ - private static final String USER_AGENT_KEY = "user_agent"; - - /** The Constant USER_AGENT_VALUE. */ - public static final String USER_AGENT_VALUE = getProperty(ALPACA_PROPERTIES_FILE, USER_AGENT_KEY); - - /** - * Static to string string. - * - * @return the string - */ - public static String staticToString() { - return new StringJoiner(", ", AlpacaProperties.class.getSimpleName() + "[", "]") - .add("ALPACA_PROPERTIES_FILE = " + ALPACA_PROPERTIES_FILE) - .add("API_VERSION_KEY = " + API_VERSION_KEY) - .add("API_VERSION_VALUE = " + API_VERSION_VALUE) - .add("BASE_API_URL_KEY = " + BASE_API_URL_KEY) - .add("BASE_API_URL_VALUE = " + BASE_API_URL_VALUE) - .add("BASE_DATA_URL_KEY = " + BASE_DATA_URL_KEY) - .add("BASE_DATA_URL_VALUE = " + BASE_DATA_URL_VALUE) - .add("KEY_ID_KEY = " + KEY_ID_KEY) - .add("KEY_ID_VALUE = " + KEY_ID_VALUE) - .add("SECRET_KEY = " + SECRET_KEY) - .add("SECRET_VALUE = " + SECRET_VALUE) - .add("USER_AGENT_KEY = " + USER_AGENT_KEY) - .add("USER_AGENT_VALUE = " + USER_AGENT_VALUE) - .toString(); - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/rest/AlpacaRequest.java b/src/main/java/io/github/mainstringargs/alpaca/rest/AlpacaRequest.java deleted file mode 100644 index ca026cb6..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/rest/AlpacaRequest.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.mainstringargs.alpaca.rest; - -import io.github.mainstringargs.abstracts.rest.AbstractRequest; -import io.github.mainstringargs.alpaca.properties.AlpacaProperties; - -/** - * The Class AlpacaRequest. - */ -public class AlpacaRequest extends AbstractRequest { - - /** The Constant USER_AGENT_KEY. */ - private static final String USER_AGENT_KEY = "user-agent"; - - /** The Constant API_KEY_ID. */ - private static final String API_KEY_ID = "APCA-API-KEY-ID"; - - /** The Constant API_SECRET_KEY. */ - private static final String API_SECRET_KEY = "APCA-API-SECRET-KEY"; - - /** - * Instantiates a new alpaca request. - * - * @param keyID the key id - * @param secretKey the secret key - */ - public AlpacaRequest(String keyID, String secretKey) { - super(); - - headers.put(USER_AGENT_KEY, AlpacaProperties.USER_AGENT_VALUE); - headers.put(API_KEY_ID, keyID); - headers.put(API_SECRET_KEY, secretKey); - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/rest/AlpacaRequestBuilder.java b/src/main/java/io/github/mainstringargs/alpaca/rest/AlpacaRequestBuilder.java deleted file mode 100644 index 927955d0..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/rest/AlpacaRequestBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.mainstringargs.alpaca.rest; - -import io.github.mainstringargs.abstracts.rest.AbstractRequestBuilder; - -import java.util.Arrays; - -/** - * The Class AlpacaRequestBuilder. - */ -public class AlpacaRequestBuilder extends AbstractRequestBuilder { - - /** - * Instantiates a new alpaca request builder. - * - * @param baseUrl the base url - * @param apiVersion the api version - * @param endpoints the endpoints - */ - public AlpacaRequestBuilder(String baseUrl, String apiVersion, String... endpoints) { - super(baseUrl); - - if (apiVersion != null) { - super.appendEndpoint(apiVersion); - } - - if (endpoints != null) { - Arrays.stream(endpoints).forEach(super::appendEndpoint); - } - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/rest/exception/AlpacaAPIRequestException.java b/src/main/java/io/github/mainstringargs/alpaca/rest/exception/AlpacaAPIRequestException.java deleted file mode 100644 index 2dfc600a..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/rest/exception/AlpacaAPIRequestException.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.mainstringargs.alpaca.rest.exception; - -import com.mashape.unirest.http.HttpResponse; -import io.github.mainstringargs.abstracts.rest.exception.AbstractAPIRequestException; - -import java.io.InputStream; - -/** - * The Class AlpacaAPIException. - */ -public class AlpacaAPIRequestException extends AbstractAPIRequestException { - - /** - * Instantiates a new Alpaca api exception. - * - * @param httpResponse the http response - */ - public AlpacaAPIRequestException(HttpResponse httpResponse) { - super("Alpaca", httpResponse); - } - - @Override - protected void parseAPIExceptionMessage() { - super.parseStandardAPIExceptionResponse(); - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/websocket/client/AlpacaWebsocketClient.java b/src/main/java/io/github/mainstringargs/alpaca/websocket/client/AlpacaWebsocketClient.java deleted file mode 100644 index 6e79c789..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/websocket/client/AlpacaWebsocketClient.java +++ /dev/null @@ -1,294 +0,0 @@ -package io.github.mainstringargs.alpaca.websocket.client; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSyntaxException; -import io.github.mainstringargs.abstracts.websocket.client.WebsocketClient; -import io.github.mainstringargs.abstracts.websocket.listener.StreamListener; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessage; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessageType; -import io.github.mainstringargs.alpaca.websocket.listener.AlpacaStreamListener; -import io.github.mainstringargs.alpaca.websocket.message.AlpacaStreamMessageType; -import io.github.mainstringargs.domain.alpaca.websocket.AlpacaStreamMessage; -import io.github.mainstringargs.domain.alpaca.websocket.account.AccountUpdateMessage; -import io.github.mainstringargs.domain.alpaca.websocket.authorization.AuthorizationMessage; -import io.github.mainstringargs.domain.alpaca.websocket.listening.ListeningMessage; -import io.github.mainstringargs.domain.alpaca.websocket.trade.TradeUpdateMessage; -import io.github.mainstringargs.util.gson.GsonUtil; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import javax.websocket.DeploymentException; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * The type Alpaca websocket client. - */ -public class AlpacaWebsocketClient implements WebsocketClient { - - /** The logger. */ - private static final Logger LOGGER = LogManager.getLogger(AlpacaWebsocketClient.class); - - /** The constant STREAM_KEY. */ - private static final String STREAM_KEY = "stream"; - - /** The key id. */ - private String keyId; - - /** The secret. */ - private String secret; - - /** The Base api url. */ - private String baseAPIURL; - - /** The observers. */ - private List listeners; - - /** The client end point. */ - private AlpacaWebsocketClientEndpoint alpacaWebsocketClientEndpoint; - - /** The Authenticated. */ - private boolean authenticated; - - /** - * Instantiates a new Alpaca websocket client. - * - * @param keyId the key id - * @param secret the secret - * @param baseAPIURL the base apiurl - */ - public AlpacaWebsocketClient(String keyId, String secret, String baseAPIURL) { - this.keyId = keyId; - this.secret = secret; - this.baseAPIURL = baseAPIURL.replace("https", "wss") + "/stream"; - - this.listeners = new ArrayList<>(); - } - - @Override - public void addListener(StreamListener streamListener) { - Preconditions.checkState(streamListener instanceof AlpacaStreamListener); - - if (listeners.isEmpty()) { - connect(); - } - - listeners.add((AlpacaStreamListener) streamListener); - - submitStreamRequestUpdate(); - } - - @Override - public void removeListener(StreamListener streamListener) { - Preconditions.checkState(streamListener instanceof AlpacaStreamListener); - - listeners.remove(streamListener); - - submitStreamRequestUpdate(); - - if (listeners.isEmpty()) { - disconnect(); - } - } - - @Override - public void connect() { - LOGGER.info("Connecting..."); - - try { - alpacaWebsocketClientEndpoint = new AlpacaWebsocketClientEndpoint(this, new URI(baseAPIURL)); - alpacaWebsocketClientEndpoint.connect(); - - LOGGER.info("Connected."); - } catch (URISyntaxException | DeploymentException | IOException e) { - LOGGER.throwing(e); - } - } - - @Override - public void disconnect() { - LOGGER.info("Disconnecting..."); - - try { - alpacaWebsocketClientEndpoint.getUserSession().close(); - - LOGGER.info("Disconnected."); - } catch (IOException e) { - LOGGER.throwing(e); - } - } - - @Override - public void sendAuthenticationMessage() { - /* Format of message is: - * { - * "action": "authenticate", - * "data": { - * "key_id": "{YOUR_API_KEY_ID}", - * "secret_key": "{YOUR_API_SECRET_KEY}" - * } - * } - */ - - JsonObject authRequest = new JsonObject(); - authRequest.addProperty("action", "authenticate"); - - JsonObject payload = new JsonObject(); - payload.addProperty("key_id", keyId); - payload.addProperty("secret_key", secret); - - authRequest.add("data", payload); - - alpacaWebsocketClientEndpoint.sendMessage(authRequest.toString()); - } - - @Override - public void handleWebsocketMessage(String message) { - JsonElement messageJsonElement = GsonUtil.JSON_PARSER.parse(message); - - Preconditions.checkState(messageJsonElement instanceof JsonObject); - - JsonObject messageJsonObject = messageJsonElement.getAsJsonObject(); - JsonElement streamJsonElement = messageJsonObject.get(STREAM_KEY); - - if (streamJsonElement instanceof JsonPrimitive) { - try { - AlpacaStreamMessageType alpacaStreamMessageType = GsonUtil.GSON.fromJson(streamJsonElement, - AlpacaStreamMessageType.class); - - switch (alpacaStreamMessageType) { - case LISTENING: - ListeningMessage listeningMessage = GsonUtil.GSON.fromJson(messageJsonObject, - ListeningMessage.class); - sendStreamMessageToListeners(alpacaStreamMessageType, listeningMessage); - - LOGGER.debug(listeningMessage); - break; - case AUTHORIZATION: - AuthorizationMessage authorizationMessage = GsonUtil.GSON.fromJson(messageJsonObject, - AuthorizationMessage.class); - sendStreamMessageToListeners(alpacaStreamMessageType, authorizationMessage); - - authenticated = isAuthorizationMessageSuccess(authorizationMessage); - - LOGGER.debug(authorizationMessage); - break; - case TRADE_UPDATES: - sendStreamMessageToListeners(alpacaStreamMessageType, GsonUtil.GSON.fromJson(messageJsonObject, - TradeUpdateMessage.class)); - break; - case ACCOUNT_UPDATES: - sendStreamMessageToListeners(alpacaStreamMessageType, GsonUtil.GSON.fromJson(messageJsonObject, - AccountUpdateMessage.class)); - break; - default: - LOGGER.error("Unhandled stream type: " + alpacaStreamMessageType); - } - } catch (JsonSyntaxException e) { - LOGGER.throwing(e); - } - } else { - LOGGER.error("Unknown stream message: " + messageJsonObject); - } - } - - @Override - public void sendStreamMessageToListeners(StreamMessageType streamMessageType, StreamMessage streamMessage) { - Preconditions.checkState(streamMessageType instanceof AlpacaStreamMessageType); - Preconditions.checkState(streamMessage instanceof AlpacaStreamMessage); - - AlpacaStreamMessageType alpacaStreamMessageType = (AlpacaStreamMessageType) streamMessageType; - AlpacaStreamMessage alpacaStreamMessage = (AlpacaStreamMessage) streamMessage; - - for (AlpacaStreamListener alpacaStreamListener : listeners) { - if (alpacaStreamListener.getStreamMessageTypes() == null || - alpacaStreamListener.getStreamMessageTypes().isEmpty() || - alpacaStreamListener.getStreamMessageTypes().contains(alpacaStreamMessageType)) { - alpacaStreamListener.onStreamUpdate(alpacaStreamMessageType, alpacaStreamMessage); - } - } - } - - @Override - public boolean isConnected() { - return alpacaWebsocketClientEndpoint.getUserSession().isOpen(); - } - - @Override - public boolean isAuthenticated() { - return authenticated; - } - - /** - * Is authorization message success boolean. - * - * @param authorizationMessage the authorization message - * - * @return the boolean - */ - private boolean isAuthorizationMessageSuccess(AuthorizationMessage authorizationMessage) { - return authorizationMessage.getData().getStatus().equalsIgnoreCase("authorized") && - authorizationMessage.getData().getAction().equalsIgnoreCase("authenticate"); - } - - /** - * Submit stream request. - */ - private void submitStreamRequestUpdate() { - // Stream request example: - // { - // "action": "listen", - // "data": { - // "streams": ["account_updates", "trade_updates"] - // } - // } - - JsonObject streamRequestJsonObject = new JsonObject(); - streamRequestJsonObject.addProperty("action", "listen"); - - JsonArray streamsJsonArray = new JsonArray(); - getRegisteredMessageTypes().forEach(alpacaStreamMessageType -> - streamsJsonArray.add(alpacaStreamMessageType.getAPIName())); - - JsonObject dataJsonObject = new JsonObject(); - dataJsonObject.add("streams", streamsJsonArray); - - streamRequestJsonObject.add("data", dataJsonObject); - - alpacaWebsocketClientEndpoint.sendMessage(streamRequestJsonObject.toString()); - - LOGGER.info("Requested subscriptions to update to " + streamsJsonArray); - } - - /** - * Gets the registered message types. - * - * @return the registered message types - */ - public Set getRegisteredMessageTypes() { - Set registeredStreamMessageTypes = new HashSet<>(); - - for (AlpacaStreamListener alpacaStreamListener : listeners) { - Set alpacaStreamMessageTypes = alpacaStreamListener.getStreamMessageTypes(); - - // if its empty, assume they want everything - Set streamMessageTypesToAdd = alpacaStreamMessageTypes == null ? new HashSet<>() : - alpacaStreamMessageTypes.stream().filter(AlpacaStreamMessageType::isAPISubscribable) - .collect(Collectors.toSet()); - - registeredStreamMessageTypes.addAll(streamMessageTypesToAdd); - } - - return registeredStreamMessageTypes; - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/websocket/client/AlpacaWebsocketClientEndpoint.java b/src/main/java/io/github/mainstringargs/alpaca/websocket/client/AlpacaWebsocketClientEndpoint.java deleted file mode 100644 index 371e9aa8..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/websocket/client/AlpacaWebsocketClientEndpoint.java +++ /dev/null @@ -1,45 +0,0 @@ -package io.github.mainstringargs.alpaca.websocket.client; - -import io.github.mainstringargs.abstracts.websocket.client.AbstractWebsocketClientEndpoint; -import io.github.mainstringargs.abstracts.websocket.client.WebsocketClient; - -import javax.websocket.ClientEndpoint; -import javax.websocket.CloseReason; -import javax.websocket.OnClose; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import java.net.URI; -import java.nio.charset.StandardCharsets; - -/** - * The type Alpaca websocket client endpoint. - */ -@ClientEndpoint(subprotocols = "BINARY") -public class AlpacaWebsocketClientEndpoint extends AbstractWebsocketClientEndpoint { - - /** - * Instantiates a new Alpaca websocket client endpoint. - * - * @param websocketClient the websocket client - * @param endpointURI the endpoint uri - */ - public AlpacaWebsocketClientEndpoint(WebsocketClient websocketClient, URI endpointURI) { - super(websocketClient, endpointURI, "AlpacaWebsocketThread"); - } - - @OnOpen - public void onOpenAnnotated(Session userSession) { - super.onOpen(userSession); - } - - @OnClose - public void onCloseAnnotated(Session userSession, CloseReason reason) { - super.onClose(userSession, reason); - } - - @OnMessage - public void onMessageAnnotated(byte[] message) { - super.onMessage(new String(message, StandardCharsets.UTF_8)); - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/websocket/listener/AlpacaStreamListener.java b/src/main/java/io/github/mainstringargs/alpaca/websocket/listener/AlpacaStreamListener.java deleted file mode 100644 index 1cc9cd1c..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/websocket/listener/AlpacaStreamListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.github.mainstringargs.alpaca.websocket.listener; - -import io.github.mainstringargs.abstracts.websocket.listener.StreamListener; -import io.github.mainstringargs.alpaca.websocket.message.AlpacaStreamMessageType; -import io.github.mainstringargs.domain.alpaca.websocket.AlpacaStreamMessage; - -import java.util.Set; - -/** - * An asynchronous update interface for receiving notifications about Websocket information as the Websocket is - * constructed. - */ -public interface AlpacaStreamListener extends StreamListener { - - /** - * Gets stream message types. Null or empty to listen to all other stream messages. - * - * @return the stream message types - */ - Set getStreamMessageTypes(); -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/websocket/listener/AlpacaStreamListenerAdapter.java b/src/main/java/io/github/mainstringargs/alpaca/websocket/listener/AlpacaStreamListenerAdapter.java deleted file mode 100644 index 3a256907..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/websocket/listener/AlpacaStreamListenerAdapter.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.github.mainstringargs.alpaca.websocket.listener; - -import io.github.mainstringargs.alpaca.websocket.message.AlpacaStreamMessageType; -import io.github.mainstringargs.domain.alpaca.websocket.AlpacaStreamMessage; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -/** - * The Class AlpacaStreamListenerAdapter. - */ -public class AlpacaStreamListenerAdapter implements AlpacaStreamListener { - - /** The message types. */ - private HashSet streamUpdateTypes = new HashSet<>(); - - /** - * Instantiates a new Alpaca stream listener adapter. - * - * @param streamUpdateTypes the stream update types - */ - public AlpacaStreamListenerAdapter(AlpacaStreamMessageType... streamUpdateTypes) { - if (streamUpdateTypes != null && streamUpdateTypes.length > 0) { - this.streamUpdateTypes.addAll(Arrays.asList(streamUpdateTypes)); - } - } - - @Override - public Set getStreamMessageTypes() { - return streamUpdateTypes; - } - - @Override - public void onStreamUpdate(AlpacaStreamMessageType streamMessageType, AlpacaStreamMessage streamMessage) { - } -} diff --git a/src/main/java/io/github/mainstringargs/alpaca/websocket/message/AlpacaStreamMessageType.java b/src/main/java/io/github/mainstringargs/alpaca/websocket/message/AlpacaStreamMessageType.java deleted file mode 100644 index 47b0f8c7..00000000 --- a/src/main/java/io/github/mainstringargs/alpaca/websocket/message/AlpacaStreamMessageType.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.github.mainstringargs.alpaca.websocket.message; - -import com.google.gson.annotations.SerializedName; -import io.github.mainstringargs.abstracts.enums.APIName; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessageType; -import io.github.mainstringargs.util.gson.GsonUtil; - -/** - * The enum Alpaca stream message type. - */ -public enum AlpacaStreamMessageType implements StreamMessageType, APIName { - - /** Listening alpaca stream message type. */ - @SerializedName("listening") - LISTENING(false), - - /** Authorization alpaca stream message type. */ - @SerializedName("authorization") - AUTHORIZATION(false), - - /** Trade updates alpaca stream message type. */ - @SerializedName("trade_updates") - TRADE_UPDATES(true), - - /** Account updates alpaca stream message type. */ - @SerializedName("account_updates") - ACCOUNT_UPDATES(true); - - /** The is api subscribable. */ - private boolean isAPISubscribable; - - /** - * Instantiates a new Alpaca stream message type. - * - * @param isAPISubscribable the is api subscribable - */ - AlpacaStreamMessageType(boolean isAPISubscribable) { - this.isAPISubscribable = isAPISubscribable; - } - - @Override - public String getAPIName() { - return GsonUtil.GSON.toJsonTree(this).getAsString(); - } - - /** - * Is api subscribable boolean. - * - * @return the boolean - */ - public boolean isAPISubscribable() { - return isAPISubscribable; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/PolygonAPI.java b/src/main/java/io/github/mainstringargs/polygon/PolygonAPI.java deleted file mode 100644 index 30b1a9ab..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/PolygonAPI.java +++ /dev/null @@ -1,980 +0,0 @@ -package io.github.mainstringargs.polygon; - -import com.google.common.base.Preconditions; -import com.google.gson.reflect.TypeToken; -import com.mashape.unirest.http.HttpResponse; -import io.github.mainstringargs.domain.polygon.aggregates.AggregatesResponse; -import io.github.mainstringargs.domain.polygon.conditionsmapping.ConditionsMapping; -import io.github.mainstringargs.domain.polygon.dailyopenclose.DailyOpenCloseResponse; -import io.github.mainstringargs.domain.polygon.exchanges.Exchange; -import io.github.mainstringargs.domain.polygon.groupeddaily.GroupedDailyResponse; -import io.github.mainstringargs.domain.polygon.historicquotes.HistoricQuotesResponse; -import io.github.mainstringargs.domain.polygon.historictrades.HistoricTradesResponse; -import io.github.mainstringargs.domain.polygon.lastquote.LastQuoteResponse; -import io.github.mainstringargs.domain.polygon.lasttrade.LastTradeResponse; -import io.github.mainstringargs.domain.polygon.locales.LocalesResponse; -import io.github.mainstringargs.domain.polygon.marketholidays.MarketHoliday; -import io.github.mainstringargs.domain.polygon.markets.MarketsResponse; -import io.github.mainstringargs.domain.polygon.marketstatus.MarketStatus; -import io.github.mainstringargs.domain.polygon.previousclose.PreviousCloseResponse; -import io.github.mainstringargs.domain.polygon.snapshot.SnapshotAllTickersResponse; -import io.github.mainstringargs.domain.polygon.snapshot.SnapshotGainersLosersResponse; -import io.github.mainstringargs.domain.polygon.snapshot.SnapshotSingleTickerResponse; -import io.github.mainstringargs.domain.polygon.snapshot.SnapshotTickerBook; -import io.github.mainstringargs.domain.polygon.stockdividends.StockDividendsResponse; -import io.github.mainstringargs.domain.polygon.stockfinancials.StockFinancialsResponse; -import io.github.mainstringargs.domain.polygon.stocksplits.StockSplitsResponse; -import io.github.mainstringargs.domain.polygon.tickerdetails.TickerDetails; -import io.github.mainstringargs.domain.polygon.tickernews.TickerNews; -import io.github.mainstringargs.domain.polygon.tickers.TickersResponse; -import io.github.mainstringargs.domain.polygon.tickertypes.TickerTypes; -import io.github.mainstringargs.polygon.enums.ConditionMappingsType; -import io.github.mainstringargs.polygon.enums.FinancialReportType; -import io.github.mainstringargs.polygon.enums.FinancialSort; -import io.github.mainstringargs.polygon.enums.GainersLosersDirection; -import io.github.mainstringargs.polygon.enums.Market; -import io.github.mainstringargs.polygon.enums.StockType; -import io.github.mainstringargs.polygon.enums.TickerSort; -import io.github.mainstringargs.polygon.enums.Timespan; -import io.github.mainstringargs.polygon.properties.PolygonProperties; -import io.github.mainstringargs.polygon.rest.PolygonRequest; -import io.github.mainstringargs.polygon.rest.PolygonRequestBuilder; -import io.github.mainstringargs.polygon.rest.exception.PolygonAPIRequestException; -import io.github.mainstringargs.polygon.websocket.client.PolygonWebsocketClient; -import io.github.mainstringargs.polygon.websocket.listener.PolygonStreamListener; -import io.github.mainstringargs.util.time.TimeUtil; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.InputStream; -import java.lang.reflect.Type; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.StringJoiner; - -/** - * The Class PolygonAPI. - */ -public class PolygonAPI { - - /** The logger. */ - private static Logger LOGGER = LogManager.getLogger(PolygonAPI.class); - - /** The Polygon websocket client. */ - private final PolygonWebsocketClient polygonWebsocketClient; - - /** The polygon request. */ - private final PolygonRequest polygonRequest; - - /** The base api url. */ - private String baseAPIURL; - - /** The Websocket url. */ - private String websocketURL; - - /** The Key id. */ - private String keyID; - - /** - * Instantiates a new polygon API. - */ - public PolygonAPI() { - this(PolygonProperties.KEY_ID_VALUE); - - LOGGER.debug(PolygonProperties.staticToString()); - } - - /** - * Instantiates a new polygon API. - * - * @param keyId the key id - */ - public PolygonAPI(String keyId) { - this(PolygonProperties.BASE_API_URL_VALUE, PolygonProperties.POLYGON_WEB_SOCKET_SERVER_URL_VALUE, keyId); - } - - /** - * Instantiates a new polygon API. - * - * @param baseAPIURL the base api url - * @param websocketURL the websocket url - * @param keyID the key id - */ - public PolygonAPI(String baseAPIURL, String websocketURL, String keyID) { - this.baseAPIURL = baseAPIURL; - this.websocketURL = websocketURL; - this.keyID = keyID; - - polygonRequest = new PolygonRequest(keyID); - polygonWebsocketClient = new PolygonWebsocketClient(keyID, websocketURL); - - LOGGER.debug(this.toString()); - } - - /** - * Query all ticker symbols which are supported by Polygon.io. - * - * @param tickerSort Which field to sort by. - * @param stockType If you want the results to only container a certain type. - * @param market Get tickers for a specific market - * @param locale Get tickers for a specific region/locale - * @param search Search the name of tickers - * @param perpage How many items to be on each page during pagination. Max 50 - * @param page Which page of results to return - * @param active Filter for only active or inactive symbols - * - * @return the tickers - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Tickers - */ - public TickersResponse getTickers(TickerSort tickerSort, StockType stockType, Market market, String locale, - String search, Integer perpage, Integer page, Boolean active) throws PolygonAPIRequestException { - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.REFERENCE_ENDPOINT, - PolygonConstants.TICKERS_ENDPOINT); - - if (tickerSort != null) { - builder.appendURLParameter(PolygonConstants.SORT_PARAMETER, tickerSort.getAPIName()); - } - - if (stockType != null) { - builder.appendURLParameter(PolygonConstants.TYPE_PARAMETER, stockType.getAPIName()); - } - - if (market != null) { - builder.appendURLParameter(PolygonConstants.MARKET_PARAMETER, market.getAPIName()); - } - - if (locale != null) { - builder.appendURLParameter(PolygonConstants.LOCALE_PARAMETER, locale); - } - - if (search != null) { - builder.appendURLParameter(PolygonConstants.SEARCH_PARAMETER, search); - } - - if (perpage != null) { - builder.appendURLParameter(PolygonConstants.PERPAGE_PARAMETER, String.valueOf(perpage)); - } - - if (page != null) { - builder.appendURLParameter(PolygonConstants.PAGE_PARAMETER, String.valueOf(page)); - } - - if (active != null) { - builder.appendURLParameter(PolygonConstants.ACTIVE_PARAMETER, String.valueOf(active)); - } - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, TickersResponse.class); - } - - /** - * Get the mapping of ticker types to descriptions / long names. - * - * @return the ticker types - * - * @see Ticker Types - */ - public TickerTypes getTickerTypes() throws PolygonAPIRequestException { - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.REFERENCE_ENDPOINT, - PolygonConstants.TYPES_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, TickersResponse.class); - } - - /** - * Get the details of the symbol company/entity. These are important details which offer an overview of the entity. - * Things like name, sector, description, logo and similar companies. - * - * @param symbol symbol we want details for - * - * @return the ticker details - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Ticker Details - */ - public TickerDetails getTickerDetails(String symbol) throws PolygonAPIRequestException { - Preconditions.checkNotNull(symbol); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.META_ENDPOINT, - PolygonConstants.SYMBOLS_ENDPOINT, - symbol, - PolygonConstants.COMPANY_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, TickerDetails.class); - } - - /** - * Get news articles for this symbol. - * - * @param symbol the symbol we want details for - * @param perpage How many items to be on each page during pagination. Max 50 - * @param page Which page of results to return - * - * @return the ticker news - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Ticker News - */ - public ArrayList getTickerNews(String symbol, Integer perpage, Integer page) - throws PolygonAPIRequestException { - Preconditions.checkNotNull(symbol); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.META_ENDPOINT, - PolygonConstants.SYMBOLS_ENDPOINT, - symbol, - PolygonConstants.NEWS_ENDPOINT); - - if (perpage != null) { - builder.appendURLParameter(PolygonConstants.PERPAGE_PARAMETER, String.valueOf(perpage)); - } - - if (page != null) { - builder.appendURLParameter(PolygonConstants.PAGE_PARAMETER, String.valueOf(page)); - } - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - Type listType = new TypeToken>() {}.getType(); - - return polygonRequest.getResponseObject(response, listType); - } - - /** - * Get the list of currently supported markets - * - * @return the markets - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Markets - */ - public MarketsResponse getMarkets() throws PolygonAPIRequestException { - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.REFERENCE_ENDPOINT, - PolygonConstants.MARKETS_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, MarketsResponse.class); - } - - /** - * Get the list of currently supported locales - * - * @return the locales - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Locales - */ - public LocalesResponse getLocales() throws PolygonAPIRequestException { - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.REFERENCE_ENDPOINT, - PolygonConstants.LOCALES_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, LocalesResponse.class); - } - - /** - * Get the historical splits for this symbol - * - * @param symbol symbol we want details for - * - * @return the stock splits - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Stock Splits - */ - public StockSplitsResponse getStockSplits(String symbol) throws PolygonAPIRequestException { - Preconditions.checkNotNull(symbol); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.REFERENCE_ENDPOINT, - PolygonConstants.SPLITS_ENDPOINT, symbol); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, StockSplitsResponse.class); - } - - /** - * Get the historical dividends for this symbol. - * - * @param symbol symbol we want details for - * - * @return the stock dividends - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Stock Dividends - */ - public StockDividendsResponse getStockDividends(String symbol) throws PolygonAPIRequestException { - Preconditions.checkNotNull(symbol); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.REFERENCE_ENDPOINT, - PolygonConstants.DIVIDENDS_ENDPOINT, - symbol); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, StockDividendsResponse.class); - } - - /** - * Get the historical financials for this ticker. - * - * @param symbol symbol we want details for - * @param limit limit the number of results - * @param financialReportType type of reports - * @param financialSort sort direction - * - * @return the symbol financials - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Stock Financials - */ - public StockFinancialsResponse getStockFinancials(String symbol, Integer limit, - FinancialReportType financialReportType, FinancialSort financialSort) throws PolygonAPIRequestException { - Preconditions.checkNotNull(symbol); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.REFERENCE_ENDPOINT, - PolygonConstants.FINANCIALS_ENDPOINT, - symbol); - - if (limit != null) { - builder.appendURLParameter(PolygonConstants.LIMIT_PARAMETER, String.valueOf(limit)); - } - - if (financialReportType != null) { - builder.appendURLParameter(PolygonConstants.TYPE_PARAMETER, financialReportType.getAPIName()); - } - - if (financialSort != null) { - builder.appendURLParameter(PolygonConstants.SORT_PARAMETER, financialSort.getAPIName()); - } - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, StockFinancialsResponse.class); - } - - /** - * Current status of each market. - * - * @return the market status - * - * @throws PolygonAPIRequestException the polygon api request exception - * @see Market Status - */ - public MarketStatus getMarketStatus() throws PolygonAPIRequestException { - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.MARKET_STATUS_ENDPOINT, - PolygonConstants.NOW_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, MarketStatus.class); - } - - /** - * Get upcoming market holidays and their open/close times. - * - * @return the market holidays - * - * @throws PolygonAPIRequestException the polygon api request exception - * @see Market Holidays - */ - public ArrayList getMarketHolidays() throws PolygonAPIRequestException { - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.MARKET_STATUS_ENDPOINT, - PolygonConstants.UPCOMING_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - Type listType = new TypeToken>() {}.getType(); - - return polygonRequest.getResponseObject(response, listType); - } - - /** - * List of stock exchanges which are supported by Polygon.io - * - * @return the exchanges - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Exchanges - */ - public ArrayList getExchanges() throws PolygonAPIRequestException { - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.META_ENDPOINT, - PolygonConstants.EXCHANGES_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - Type listType = new TypeToken>() {}.getType(); - - return polygonRequest.getResponseObject(response, listType); - } - - /** - * Get historic trades for a symbol. - * - * @param ticker Ticker symbol we want ticks for - * @param date Date/Day of the historic ticks to retrieve - * @param timestamp Timestamp offset, used for pagination. This is the offset at which to start the results. - * Using the timestamp of the last result as the offset will give you the next page of - * results. - * @param timestampLimit Maximum timestamp allowed in the results. - * @param reverse Reverse the order of the results. This is useful in combination with timestamp param. - * @param limit Limit the size of response, Max 50000 - * - * @return the historic trades - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Historic - * Trades - */ - public HistoricTradesResponse getHistoricTrades(String ticker, LocalDate date, Long timestamp, Long timestampLimit, - Boolean reverse, Integer limit) throws PolygonAPIRequestException { - Preconditions.checkNotNull(ticker); - Preconditions.checkNotNull(date); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.TICKS_ENDPOINT, - PolygonConstants.STOCKS_ENDPOINT, - PolygonConstants.TRADES_ENDPOINT, - ticker, - TimeUtil.toDateString(date)); - - if (timestamp != null) { - builder.appendURLParameter(PolygonConstants.TIMESTAMP_PARAMETER, String.valueOf(timestamp)); - } - - if (timestampLimit != null) { - builder.appendURLParameter(PolygonConstants.TIMESTAMP_LIMIT_PARAMETER, String.valueOf(timestampLimit)); - } - - if (reverse != null) { - builder.appendURLParameter(PolygonConstants.REVERSE_PARAMETER, String.valueOf(reverse)); - } - - if (limit != null) { - builder.appendURLParameter(PolygonConstants.LIMIT_PARAMETER, String.valueOf(limit)); - } - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, HistoricTradesResponse.class); - } - - /** - * Get historic NBBO quotes for a ticker. - * - * @param ticker Ticker symbol we want ticks for - * @param date Date/Day of the historic ticks to retrieve - * @param timestamp Timestamp offset, used for pagination. This is the offset at which to start the results. - * Using the timestamp of the last result as the offset will give you the next page of - * results. - * @param timestampLimit Maximum timestamp allowed in the results. - * @param reverse Reverse the order of the results. This is useful in combination with timestamp param. - * @param limit Limit the size of response, Max 50000 - * - * @return the historic quotes - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Historic - * Quotes - */ - public HistoricQuotesResponse getHistoricQuotes(String ticker, LocalDate date, Long timestamp, Long timestampLimit, - Boolean reverse, Integer limit) throws PolygonAPIRequestException { - Preconditions.checkNotNull(ticker); - Preconditions.checkNotNull(date); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.TICKS_ENDPOINT, - PolygonConstants.STOCKS_ENDPOINT, - PolygonConstants.NBBO_ENDPOINT, - ticker, - TimeUtil.toDateString(date)); - - if (timestamp != null) { - builder.appendURLParameter(PolygonConstants.TIMESTAMP_PARAMETER, String.valueOf(timestamp)); - } - - if (timestampLimit != null) { - builder.appendURLParameter(PolygonConstants.TIMESTAMP_LIMIT_PARAMETER, String.valueOf(timestampLimit)); - } - - if (reverse != null) { - builder.appendURLParameter(PolygonConstants.REVERSE_PARAMETER, String.valueOf(reverse)); - } - - if (limit != null) { - builder.appendURLParameter(PolygonConstants.LIMIT_PARAMETER, String.valueOf(limit)); - } - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, HistoricQuotesResponse.class); - } - - /** - * Get the last trade for a given stock. - * - * @param symbol Symbol of the stock to get - * - * @return the last trade - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Last Trade - */ - public LastTradeResponse getLastTrade(String symbol) throws PolygonAPIRequestException { - Preconditions.checkNotNull(symbol); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.LAST_ENDPOINT, - PolygonConstants.STOCKS_ENDPOINT, - symbol); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, LastTradeResponse.class); - } - - /** - * Get the last quote for a given stock. - * - * @param symbol Symbol of the stock to get - * - * @return the last quote - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Last Quote - */ - public LastQuoteResponse getLastQuote(String symbol) throws PolygonAPIRequestException { - Preconditions.checkNotNull(symbol); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.LAST_QUOTE_ENDPOINT, - PolygonConstants.STOCKS_ENDPOINT, - symbol); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, LastQuoteResponse.class); - } - - /** - * Get the open, close and afterhours prices of a symbol on a certain date. - * - * @param symbol Symbol of the stock to get - * @param date Date of the requested open/close - * - * @return the daily open close - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Daily Open/Close - */ - public DailyOpenCloseResponse getDailyOpenClose(String symbol, LocalDate date) throws PolygonAPIRequestException { - Preconditions.checkNotNull(symbol); - Preconditions.checkNotNull(date); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.OPEN_CLOSE_ENDPOINT, - symbol, - TimeUtil.toDateString(date)); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, DailyOpenCloseResponse.class); - } - - /** - * The mappings for conditions on trades and quotes. - * - * @param conditionMappingsType Ticker type we want mappings for - * - * @return the conditions mapping - * - * @throws PolygonAPIRequestException the polygon api request exception - * @see Condition Mappings - */ - public ConditionsMapping getConditionsMapping(ConditionMappingsType conditionMappingsType) - throws PolygonAPIRequestException { - Preconditions.checkNotNull(conditionMappingsType); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_1_ENDPOINT, - PolygonConstants.META_ENDPOINT, - PolygonConstants.CONDITIONS_ENDPOINT, - conditionMappingsType.getAPIName()); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, ConditionsMapping.class); - } - - /** - * Snapshot allows you to see all tickers current minute aggregate, daily aggregate and last trade. As well as - * previous days aggregate and calculated change for today. - * - * @return the snapshot all tickers - * - * @throws PolygonAPIRequestException the polygon API exception - * @see - * Snapshot - * - All Tickers - */ - public SnapshotAllTickersResponse getSnapshotAllTickers() throws PolygonAPIRequestException { - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.SNAPSHOT_ENDPOINT, - PolygonConstants.LOCALE_ENDPOINT, - PolygonConstants.US_ENDPOINT, - PolygonConstants.MARKETS_ENDPOINT, - PolygonConstants.STOCKS_ENDPOINT, - PolygonConstants.TICKERS_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, SnapshotAllTickersResponse.class); - } - - /** - * See the current snapshot of a single ticker - * - * @param ticker Ticker of the snapshot - * - * @return the snapshot single ticker - * - * @throws PolygonAPIRequestException the polygon API exception - * @see - * Snapshot - * - Single Ticker - */ - public SnapshotSingleTickerResponse getSnapshotSingleTicker(String ticker) throws PolygonAPIRequestException { - Preconditions.checkNotNull(ticker); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.SNAPSHOT_ENDPOINT, - PolygonConstants.LOCALE_ENDPOINT, - PolygonConstants.US_ENDPOINT, - PolygonConstants.MARKETS_ENDPOINT, - PolygonConstants.STOCKS_ENDPOINT, - PolygonConstants.TICKERS_ENDPOINT, - ticker); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, SnapshotSingleTickerResponse.class); - } - - /** - * See the current snapshot of the top 20 gainers of the day at the moment. - * - * @param gainersLosersDirection the gainers losers direction - * - * @return the snapshots gainers - * - * @throws PolygonAPIRequestException the polygon API exception - * @see - * Snapshot - * - Gainers / Losers - */ - public SnapshotGainersLosersResponse getSnapshotsGainersLosers(GainersLosersDirection gainersLosersDirection) - throws PolygonAPIRequestException { - Preconditions.checkNotNull(gainersLosersDirection); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.SNAPSHOT_ENDPOINT, - PolygonConstants.LOCALE_ENDPOINT, - PolygonConstants.US_ENDPOINT, - PolygonConstants.MARKETS_ENDPOINT, - PolygonConstants.STOCKS_ENDPOINT, - gainersLosersDirection.getAPIName()); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, SnapshotGainersLosersResponse.class); - } - - /** - * See the current snapshot of Level II data on IEX for the given ticker. - * - * @param locale the locale - * @param market the market - * @param ticker the ticker - * - * @return the snapshot ticker book - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Docs not public yet - */ - public SnapshotTickerBook getSnapshotTickerBook(String locale, Market market, String ticker) - throws PolygonAPIRequestException { - Preconditions.checkNotNull(locale); - Preconditions.checkNotNull(market); - Preconditions.checkNotNull(ticker); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.SNAPSHOT_ENDPOINT, - PolygonConstants.LOCALE_ENDPOINT, - locale, - PolygonConstants.MARKETS_ENDPOINT, - market.getAPIName(), - PolygonConstants.TICKERS_ENDPOINT, - ticker, - PolygonConstants.BOOK_ENDPOINT); - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, SnapshotTickerBook.class); - } - - /** - * Get the previous day close for the specified ticker - * - * @param ticker Ticker symbol of the request - * @param unadjusted Set to true if the results should NOT be adjusted for splits. - * - * @return the previous close - * - * @throws PolygonAPIRequestException the polygon API exception - * @see Previous Close - */ - public PreviousCloseResponse getPreviousClose(String ticker, Boolean unadjusted) throws PolygonAPIRequestException { - Preconditions.checkNotNull(ticker); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.AGGS_ENDPOINT, - PolygonConstants.TICKER_ENDPOINT, - ticker, - PolygonConstants.PREV_ENDPOINT); - - if (unadjusted != null) { - builder.appendURLParameter(PolygonConstants.UNADJUSTED_PARAMETER, unadjusted.toString()); - } - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, PreviousCloseResponse.class); - } - - /** - * Get aggregates for a date range, in custom time window sizes - * - * @param ticker Ticker symbol of the request - * @param multiplier Size of the timespan multiplier - * @param timeSpan Size of the time window - * @param fromDate From date - * @param toDate To date - * @param unadjusted Set to true if the results should NOT be adjusted for splits - * - * @return the aggregates - * - * @throws PolygonAPIRequestException the polygon API exception - * @see - * Aggregates - */ - public AggregatesResponse getAggregates(String ticker, Integer multiplier, Timespan timeSpan, LocalDate fromDate, - LocalDate toDate, Boolean unadjusted) throws PolygonAPIRequestException { - Preconditions.checkNotNull(ticker); - Preconditions.checkNotNull(timeSpan); - Preconditions.checkNotNull(fromDate); - Preconditions.checkNotNull(toDate); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.AGGS_ENDPOINT, - PolygonConstants.TICKER_ENDPOINT, - ticker, - PolygonConstants.RANGE_ENDPOINT, - Integer.toString((multiplier == null) ? 1 : multiplier), - timeSpan.getAPIName(), - TimeUtil.toDateString(fromDate), - TimeUtil.toDateString(toDate)); - - if (unadjusted != null) { - builder.appendURLParameter(PolygonConstants.UNADJUSTED_PARAMETER, unadjusted.toString()); - } - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, AggregatesResponse.class); - } - - /** - * Get the daily OHLC for entire markets. - * - * @param locale Locale of the aggregates ( See 'Locales' API ) - * @param market Market of the aggregates ( See 'Markets' API ) - * @param date To date - * @param unadjusted Set to true if the results should NOT be adjusted for splits. - * - * @return the grouped daily - * - * @throws PolygonAPIRequestException the polygon API exception - * @see - * Grouped - * Daily - */ - public GroupedDailyResponse getGroupedDaily(String locale, Market market, LocalDate date, Boolean unadjusted) - throws PolygonAPIRequestException { - Preconditions.checkNotNull(locale); - Preconditions.checkNotNull(market); - Preconditions.checkNotNull(date); - - PolygonRequestBuilder builder = new PolygonRequestBuilder(baseAPIURL, PolygonConstants.VERSION_2_ENDPOINT, - PolygonConstants.AGGS_ENDPOINT, - PolygonConstants.GROUPED_ENDPOINT, - PolygonConstants.LOCALE_ENDPOINT, - locale, - PolygonConstants.MARKET_ENDPOINT, - market.getAPIName(), - TimeUtil.toDateString(date)); - - if (unadjusted != null) { - builder.appendURLParameter(PolygonConstants.UNADJUSTED_PARAMETER, unadjusted.toString()); - } - - HttpResponse response = polygonRequest.invokeGet(builder); - - if (response.getStatus() != 200) { - throw new PolygonAPIRequestException(response); - } - - return polygonRequest.getResponseObject(response, GroupedDailyResponse.class); - } - - /** - * Adds the polygon stream listener. - * - * @param streamListener the stream listener - */ - public void addPolygonStreamListener(PolygonStreamListener streamListener) { - polygonWebsocketClient.addListener(streamListener); - } - - /** - * Removes the polygon stream listener. - * - * @param streamListener the stream listener - */ - public void removePolygonStreamListener(PolygonStreamListener streamListener) { - polygonWebsocketClient.removeListener(streamListener); - } - - @Override - public String toString() { - return new StringJoiner(", ", this.getClass().getSimpleName() + "[", "]") - .add("baseAPIURL = " + baseAPIURL) - .add("keyID = " + keyID) - .add("websocketURL = " + websocketURL) - .toString(); - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/PolygonConstants.java b/src/main/java/io/github/mainstringargs/polygon/PolygonConstants.java deleted file mode 100644 index 949c8d4e..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/PolygonConstants.java +++ /dev/null @@ -1,164 +0,0 @@ -package io.github.mainstringargs.polygon; - -/** - * The type Polygon constants. - */ -public class PolygonConstants { - - /** The Constant META_ENDPOINT. */ - public static final String META_ENDPOINT = "meta"; - - /** The Constant SYMBOLS_ENDPOINT. */ - public static final String SYMBOLS_ENDPOINT = "symbols"; - - /** The Constant LOCALE_PARAMETER. */ - public static final String LOCALE_PARAMETER = "locale"; - - /** The Constant ACTIVE_PARAMETER. */ - public static final String ACTIVE_PARAMETER = "active"; - - /** The Constant FINANCIALS_ENDPOINT. */ - public static final String FINANCIALS_ENDPOINT = "financials"; - - /** The Constant DIVIDENDS_ENDPOINT. */ - public static final String DIVIDENDS_ENDPOINT = "dividends"; - - /** The Constant COMPANY_ENDPOINT. */ - public static final String COMPANY_ENDPOINT = "company"; - - /** The Constant MARKET_PARAMETER. */ - public static final String MARKET_PARAMETER = "market"; - - /** The Constant SEARCH_PARAMETER. */ - public static final String SEARCH_PARAMETER = "search"; - - /** The constant CONDITIONS_ENDPOINT. */ - public static final String CONDITIONS_ENDPOINT = "conditions"; - - /** The Constant TYPE_PARAMETER. */ - public static final String TYPE_PARAMETER = "type"; - - /** The Constant SORT_PARAMETER. */ - public static final String SORT_PARAMETER = "sort"; - - /** The Constant REFERENCE_ENDPOINT. */ - public static final String REFERENCE_ENDPOINT = "reference"; - - /** The Constant VERSION_1_ENDPOINT. */ - public static final String VERSION_1_ENDPOINT = "v1"; - - /** The Constant VERSION_2_ENDPOINT. */ - public static final String VERSION_2_ENDPOINT = "v2"; - - /** The Constant PAGE_PARAMETER. */ - public static final String PAGE_PARAMETER = "page"; - - /** The Constant PERPAGE_PARAMETER. */ - public static final String PERPAGE_PARAMETER = "perpage"; - - /** The Constant NEWS_ENDPOINT. */ - public static final String NEWS_ENDPOINT = "news"; - - /** The Constant GROUPED_ENDPOINT. */ - public static final String GROUPED_ENDPOINT = "grouped"; - - /** The Constant TICKER_ENDPOINT. */ - public static final String TICKER_ENDPOINT = "ticker"; - - /** The constant TICKS_ENDPOINT. */ - public static final String TICKS_ENDPOINT = "ticks"; - - /** The Constant AGGS_ENDPOINT. */ - public static final String AGGS_ENDPOINT = "aggs"; - - /** The constant NBBO_ENDPOINT. */ - public static final String NBBO_ENDPOINT = "nbbo"; - - /** The Constant OPEN_CLOSE_ENDPOINT. */ - public static final String OPEN_CLOSE_ENDPOINT = "open-close"; - - /** The Constant LAST_QUOTE_ENDPOINT. */ - public static final String LAST_QUOTE_ENDPOINT = "last_quote"; - - /** The Constant LAST_ENDPOINT. */ - public static final String LAST_ENDPOINT = "last"; - - /** The Constant QUOTES_ENDPOINT. */ - public static final String QUOTES_ENDPOINT = "quotes"; - - /** The Constant TRADES_ENDPOINT. */ - public static final String TRADES_ENDPOINT = "trades"; - - /** The Constant HISTORIC_ENDPOINT. */ - public static final String HISTORIC_ENDPOINT = "historic"; - - /** The Constant EXCHANGES_ENDPOINT. */ - public static final String EXCHANGES_ENDPOINT = "exchanges"; - - /** The Constant SPLITS_ENDPOINT. */ - public static final String SPLITS_ENDPOINT = "splits"; - - /** The Constant TYPES_ENDPOINT. */ - public static final String TYPES_ENDPOINT = "types"; - - /** The Constant LOCALES_ENDPOINT. */ - public static final String LOCALES_ENDPOINT = "locales"; - - /** The Constant MARKETS_ENDPOINT. */ - public static final String MARKETS_ENDPOINT = "markets"; - - /** The Constant MARKET_ENDPOINT. */ - public static final String MARKET_ENDPOINT = "market"; - - /** The constant MARKET_STATUS_ENDPOINT. */ - public static final String MARKET_STATUS_ENDPOINT = "marketstatus"; - - /** The constant NOW_ENDPOINT. */ - public static final String NOW_ENDPOINT = "now"; - - /** The constant UPCOMING_ENDPOINT. */ - public static final String UPCOMING_ENDPOINT = "upcoming"; - - /** The Constant TICKERS_ENDPOINT. */ - public static final String TICKERS_ENDPOINT = "tickers"; - - /** The Constant STOCKS_ENDPOINT. */ - public static final String STOCKS_ENDPOINT = "stocks"; - - /** The Constant US_ENDPOINT. */ - public static final String US_ENDPOINT = "us"; - - /** The Constant LOCALE_ENDPOINT. */ - public static final String LOCALE_ENDPOINT = "locale"; - - /** The Constant SNAPSHOT_ENDPOINT. */ - public static final String SNAPSHOT_ENDPOINT = "snapshot"; - - /** The constant BOOK_ENDPOINT. */ - public static final String BOOK_ENDPOINT = "book"; - - /** The Constant LIMIT_PARAMETER. */ - public static final String LIMIT_PARAMETER = "limit"; - - /** The constant TIMESTAMP_PARAMETER. */ - public static final String TIMESTAMP_PARAMETER = "timestamp"; - - /** The constant TIMESTAMP_LIMIT_PARAMETER. */ - public static final String TIMESTAMP_LIMIT_PARAMETER = "timestampLimit"; - - /** The Constant OFFSET_PARAMETER. */ - public static final String OFFSET_PARAMETER = "offset"; - - /** The Constant RANGE_ENDPOINT. */ - public static final String RANGE_ENDPOINT = "range"; - - /** The Constant UNADJUSTED_PARAMETER. */ - public static final String UNADJUSTED_PARAMETER = "unadjusted"; - - /** The Constant PREV_ENDPOINT. */ - public static final String PREV_ENDPOINT = "prev"; - - /** The constant REVERSE_PARAMETER. */ - public static final String REVERSE_PARAMETER = "reverse"; - -} diff --git a/src/main/java/io/github/mainstringargs/polygon/PolygonExample.java b/src/main/java/io/github/mainstringargs/polygon/PolygonExample.java deleted file mode 100644 index fdc4afdc..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/PolygonExample.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.github.mainstringargs.polygon; - -import io.github.mainstringargs.domain.polygon.aggregates.Aggregate; -import io.github.mainstringargs.domain.polygon.aggregates.AggregatesResponse; -import io.github.mainstringargs.domain.polygon.stocksplits.StockSplit; -import io.github.mainstringargs.domain.polygon.stocksplits.StockSplitsResponse; -import io.github.mainstringargs.domain.polygon.websocket.PolygonStreamMessage; -import io.github.mainstringargs.polygon.enums.Timespan; -import io.github.mainstringargs.polygon.rest.exception.PolygonAPIRequestException; -import io.github.mainstringargs.polygon.websocket.listener.PolygonStreamListenerAdapter; -import io.github.mainstringargs.polygon.websocket.message.PolygonStreamMessageType; - -import java.time.LocalDate; - -/** - * The Class Example. - */ -public class PolygonExample { - - /** - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args) { - // This will use the key_id in the alpaca.properties file by default - PolygonAPI polygonAPI = new PolygonAPI(); - - String aaplTicker = "AAPL"; - - // Add a Polygon stream listener to listen to "T.AAPL", "Q.AAPL", "A.AAPL", "AM.AAPL", and status messages - polygonAPI.addPolygonStreamListener(new PolygonStreamListenerAdapter(aaplTicker, - PolygonStreamMessageType.values()) { - @Override - public void onStreamUpdate(PolygonStreamMessageType streamMessageType, PolygonStreamMessage streamMessage) { - System.out.println("===> streamUpdate " + streamMessageType + " " + streamMessage); - } - }); - - // Sleep the current thread for 2 seconds so we can see some trade/quote/aggregates updates on the stream! - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - StockSplitsResponse stockSplitsResponse = polygonAPI.getStockSplits(aaplTicker); - - System.out.println(aaplTicker + " Stock Split Response:"); - System.out.println("\tStatus: " + stockSplitsResponse.getStatus()); - System.out.println("\tCount: " + stockSplitsResponse.getCount()); - for (StockSplit stockSplit : stockSplitsResponse.getResults()) { - System.out.println("\t" + stockSplit.toString().replace(",", ",\n\t")); - } - } catch (PolygonAPIRequestException e) { - e.printStackTrace(); - } - - try { - AggregatesResponse aggregatesResponse = polygonAPI.getAggregates(aaplTicker, 1, Timespan.DAY, - LocalDate.of(2019, 11, 18), LocalDate.of(2019, 11, 25), false); - - System.out.println("Aggregate Response:"); - System.out.println("\tStatus: " + aggregatesResponse.getStatus()); - System.out.println("\tCount: " + aggregatesResponse.getResultsCount()); - for (Aggregate aggregate : aggregatesResponse.getResults()) { - System.out.println("\t" + aggregate.toString().replace(",", ",\n\t")); - } - } catch (PolygonAPIRequestException e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/enums/ConditionMappingsType.java b/src/main/java/io/github/mainstringargs/polygon/enums/ConditionMappingsType.java deleted file mode 100644 index 32241deb..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/enums/ConditionMappingsType.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.mainstringargs.polygon.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The enum Condition mappings type. - */ -public enum ConditionMappingsType implements APIName { - - /** Trades condition mapping type. */ - TRADES("trades"), - - /** Quotes condition mapping type. */ - QUOTES("quotes"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new Condition mappings type. - * - * @param apiName the api name - */ - ConditionMappingsType(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/enums/FinancialReportType.java b/src/main/java/io/github/mainstringargs/polygon/enums/FinancialReportType.java deleted file mode 100644 index f27d386f..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/enums/FinancialReportType.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.mainstringargs.polygon.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The enum Financial report type. - */ -public enum FinancialReportType implements APIName { - - /** Y financial report type. */ - Y("Y"), - - /** YA financial report type. */ - YA("YA"), - - /** Q financial report type. */ - Q("Q"), - - /** Qa financial report type. */ - QA("QA"), - - /** T financial report type. */ - T("T"), - - /** Ta financial report type. */ - TA("TA"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new Financial report type. - * - * @param apiName the api name - */ - FinancialReportType(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/enums/FinancialSort.java b/src/main/java/io/github/mainstringargs/polygon/enums/FinancialSort.java deleted file mode 100644 index dbb79f0a..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/enums/FinancialSort.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.mainstringargs.polygon.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The enum Financial sort. - */ -public enum FinancialSort implements APIName { - - /** Report period ascending financial sort. */ - REPORT_PERIOD_ASCENDING("reportPeriod"), - - /** Report period descending financial sort */ - REPORT_PERIOD_DESCENDING("-reportPeriod"), - - /** Calendar date ascending financial sort. */ - CALENDAR_DATE_ASCENDING("calendarDate"), - - /** Calendar date descending financial sort. */ - CALENDAR_DATE_DESCENDING("-calendarDate"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new Financial sort. - * - * @param apiName the api name - */ - FinancialSort(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/enums/GainersLosersDirection.java b/src/main/java/io/github/mainstringargs/polygon/enums/GainersLosersDirection.java deleted file mode 100644 index 50a71dff..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/enums/GainersLosersDirection.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.mainstringargs.polygon.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -public enum GainersLosersDirection implements APIName { - - GAINERS("gainers"), - - LOSERS("losers"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new Gainers losers direction. - * - * @param apiName the api name - */ - GainersLosersDirection(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/enums/Market.java b/src/main/java/io/github/mainstringargs/polygon/enums/Market.java deleted file mode 100644 index a05bcbe8..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/enums/Market.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.github.mainstringargs.polygon.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum SymbolsMarket. - */ -public enum Market implements APIName { - - /** Stocks market. */ - STOCKS("stocks"), - - /** Indices market. */ - INDICES("indices"), - - /** Crypto market */ - CRYPTO("crypto"), - - /** Fx market. */ - FX("fx"), - - /** Bonds market. */ - BONDS("bonds"), - - /** Mf market. */ - MF("mf"), - - /** Mmf market. */ - MMF("mmf"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new order type. - * - * @param apiName the api name - */ - Market(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/enums/StockType.java b/src/main/java/io/github/mainstringargs/polygon/enums/StockType.java deleted file mode 100644 index 5a417579..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/enums/StockType.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.github.mainstringargs.polygon.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum StockType. - */ -public enum StockType implements APIName { - - /** The etfs. */ - ETFS("etp"), - - /** The common stocks. */ - COMMON_STOCKS("cs"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new stock type. - * - * @param apiName the api name - */ - StockType(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/enums/TickerSort.java b/src/main/java/io/github/mainstringargs/polygon/enums/TickerSort.java deleted file mode 100644 index a6b6a694..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/enums/TickerSort.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.github.mainstringargs.polygon.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The enum Ticker sort. - */ -public enum TickerSort implements APIName { - - /** The ticker ascending. */ - TICKER_ASCENDING("ticker"), - - /** The ticker descending. */ - TICKER_DESCENDING("-ticker"), - - /** The type ascending. */ - TYPE_ASCENDING("type"), - - /** The type descending. */ - TYPE_DESCENDING("-type"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new order type. - * - * @param apiName the api name - */ - TickerSort(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/enums/Timespan.java b/src/main/java/io/github/mainstringargs/polygon/enums/Timespan.java deleted file mode 100644 index ef9474b8..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/enums/Timespan.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.github.mainstringargs.polygon.enums; - -import io.github.mainstringargs.abstracts.enums.APIName; - -/** - * The Enum Timespan. - */ -public enum Timespan implements APIName { - - /** The Minute. */ - MINUTE("minute"), - - /** The Hour. */ - HOUR("hour"), - - /** The Day. */ - DAY("day"), - - /** The Week. */ - WEEK("week"), - - /** The Month. */ - MONTH("month"), - - /** The Quarter. */ - QUARTER("quarter"), - - /** The Year. */ - YEAR("year"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new order type. - * - * @param apiName the api name - */ - Timespan(String apiName) { - this.apiName = apiName; - } - - @Override - public String getAPIName() { - return apiName; - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/properties/PolygonProperties.java b/src/main/java/io/github/mainstringargs/polygon/properties/PolygonProperties.java deleted file mode 100644 index aabd1779..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/properties/PolygonProperties.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.github.mainstringargs.polygon.properties; - -import io.github.mainstringargs.alpaca.properties.AlpacaProperties; - -import java.util.StringJoiner; - -import static io.github.mainstringargs.util.properties.PropertyUtil.getProperty; - -/** - * The Class AlpacaProperties. - */ -public class PolygonProperties { - - /** The constant POLYGON_PROPERTIES_FILE. */ - private static final String POLYGON_PROPERTIES_FILE = "polygon.properties"; - - /** The Constant KEY_ID_KEY. */ - private static final String KEY_ID_KEY = "key_id"; - - /** The Constant KEY_ID_VALUE. */ - public static final String KEY_ID_VALUE = - getProperty(POLYGON_PROPERTIES_FILE, KEY_ID_KEY, AlpacaProperties.KEY_ID_VALUE); - - /** The Constant BASE_API_URL_KEY. */ - private static final String BASE_API_URL_KEY = "base_api_url"; - - /** The Constant BASE_API_URL_VALUE. */ - public static final String BASE_API_URL_VALUE = - getProperty(POLYGON_PROPERTIES_FILE, BASE_API_URL_KEY); - - /** The polygon web socket server url key. */ - private static final String POLYGON_WEB_SOCKET_SERVER_URL_KEY = "web_socket_server_url"; - - /** The polygon web socket server url value. */ - public static final String POLYGON_WEB_SOCKET_SERVER_URL_VALUE = - getProperty(POLYGON_PROPERTIES_FILE, POLYGON_WEB_SOCKET_SERVER_URL_KEY); - - /** The Constant USER_AGENT_KEY. */ - private static final String USER_AGENT_KEY = "user_agent"; - - /** The Constant USER_AGENT_VALUE. */ - public static final String USER_AGENT_VALUE = getProperty(POLYGON_PROPERTIES_FILE, USER_AGENT_KEY); - - /** - * Static to string. - * - * @return the string - */ - public static String staticToString() { - return new StringJoiner(", ", PolygonProperties.class.getSimpleName() + "[", "]") - .add("BASE_API_URL_KEY = " + BASE_API_URL_KEY) - .add("BASE_API_URL_VALUE = " + BASE_API_URL_VALUE) - .add("KEY_ID_KEY = " + KEY_ID_KEY) - .add("KEY_ID_VALUE = " + KEY_ID_VALUE) - .add("POLYGON_PROPERTIES_FILE = " + POLYGON_PROPERTIES_FILE) - .add("POLYGON_WEB_SOCKET_SERVER_URL_KEY = " + POLYGON_WEB_SOCKET_SERVER_URL_KEY) - .add("POLYGON_WEB_SOCKET_SERVER_URL_VALUE = " + POLYGON_WEB_SOCKET_SERVER_URL_VALUE) - .add("USER_AGENT_KEY = " + USER_AGENT_KEY) - .add("USER_AGENT_VALUE = " + USER_AGENT_VALUE) - .toString(); - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/rest/PolygonRequest.java b/src/main/java/io/github/mainstringargs/polygon/rest/PolygonRequest.java deleted file mode 100644 index 2acc844c..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/rest/PolygonRequest.java +++ /dev/null @@ -1,77 +0,0 @@ -package io.github.mainstringargs.polygon.rest; - -import com.mashape.unirest.http.HttpResponse; -import io.github.mainstringargs.abstracts.rest.AbstractRequest; -import io.github.mainstringargs.abstracts.rest.AbstractRequestBuilder; -import io.github.mainstringargs.polygon.properties.PolygonProperties; - -import java.io.InputStream; - -/** - * The Class PolygonRequest. - */ -public class PolygonRequest extends AbstractRequest { - - /** The Constant USER_AGENT_KEY. */ - private static final String USER_AGENT_KEY = "user-agent"; - - /** The Constant API_KEY_ID. */ - private static final String API_KEY_PARAMETER = "apiKey"; - - /** The key id. */ - private String keyId; - - /** - * Instantiates a new polygon request. - * - * @param keyID the key id - */ - public PolygonRequest(String keyID) { - super(); - this.keyId = keyID; - - headers.put(USER_AGENT_KEY, PolygonProperties.USER_AGENT_VALUE); - } - - @Override - public HttpResponse invokeGet(AbstractRequestBuilder abstractRequestBuilder) { - abstractRequestBuilder.appendURLParameter(API_KEY_PARAMETER, keyId); - return super.invokeGet(abstractRequestBuilder); - } - - @Override - public HttpResponse invokeHead(AbstractRequestBuilder abstractRequestBuilder) { - abstractRequestBuilder.appendURLParameter(API_KEY_PARAMETER, keyId); - return super.invokeHead(abstractRequestBuilder); - } - - @Override - public HttpResponse invokePost(AbstractRequestBuilder abstractRequestBuilder) { - abstractRequestBuilder.appendURLParameter(API_KEY_PARAMETER, keyId); - return super.invokePost(abstractRequestBuilder); - } - - @Override - public HttpResponse invokePatch(AbstractRequestBuilder abstractRequestBuilder) { - abstractRequestBuilder.appendURLParameter(API_KEY_PARAMETER, keyId); - return super.invokePatch(abstractRequestBuilder); - } - - @Override - public HttpResponse invokePut(AbstractRequestBuilder abstractRequestBuilder) { - abstractRequestBuilder.appendURLParameter(API_KEY_PARAMETER, keyId); - return super.invokePut(abstractRequestBuilder); - } - - @Override - public HttpResponse invokeDelete(AbstractRequestBuilder abstractRequestBuilder) { - abstractRequestBuilder.appendURLParameter(API_KEY_PARAMETER, keyId); - return super.invokeDelete(abstractRequestBuilder); - } - - @Override - public HttpResponse invokeOptions(AbstractRequestBuilder abstractRequestBuilder) { - abstractRequestBuilder.appendURLParameter(API_KEY_PARAMETER, keyId); - return super.invokeOptions(abstractRequestBuilder); - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/rest/PolygonRequestBuilder.java b/src/main/java/io/github/mainstringargs/polygon/rest/PolygonRequestBuilder.java deleted file mode 100644 index fc907c85..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/rest/PolygonRequestBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.mainstringargs.polygon.rest; - -import io.github.mainstringargs.abstracts.rest.AbstractRequestBuilder; - -import java.util.Arrays; - -/** - * The Class PolygonRequestBuilder. - */ -public class PolygonRequestBuilder extends AbstractRequestBuilder { - - /** - * Instantiates a new Polygon request builder. - * - * @param baseUrl the base url - * @param apiVersion the api version - * @param endpoints the endpoints - */ - public PolygonRequestBuilder(String baseUrl, String apiVersion, String... endpoints) { - super(baseUrl); - - if (apiVersion != null) { - super.appendEndpoint(apiVersion); - } - - if (endpoints != null) { - Arrays.stream(endpoints).forEach(super::appendEndpoint); - } - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/rest/exception/PolygonAPIRequestException.java b/src/main/java/io/github/mainstringargs/polygon/rest/exception/PolygonAPIRequestException.java deleted file mode 100644 index 6c6fd219..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/rest/exception/PolygonAPIRequestException.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.github.mainstringargs.polygon.rest.exception; - -import com.mashape.unirest.http.HttpResponse; -import io.github.mainstringargs.abstracts.rest.exception.AbstractAPIRequestException; - -import java.io.InputStream; - -/** - * The Class PolygonAPIException. - */ -public class PolygonAPIRequestException extends AbstractAPIRequestException { - - /** - * Instantiates a new Polygon api request exception. - * - * @param httpResponse the http response - */ - public PolygonAPIRequestException(HttpResponse httpResponse) { - super("Polygon", httpResponse); - } - - @Override - protected void parseAPIExceptionMessage() { - super.parseStandardAPIExceptionResponse(); - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/websocket/client/PolygonWebsocketClient.java b/src/main/java/io/github/mainstringargs/polygon/websocket/client/PolygonWebsocketClient.java deleted file mode 100644 index a790fb9e..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/websocket/client/PolygonWebsocketClient.java +++ /dev/null @@ -1,409 +0,0 @@ -package io.github.mainstringargs.polygon.websocket.client; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSyntaxException; -import io.github.mainstringargs.abstracts.websocket.client.WebsocketClient; -import io.github.mainstringargs.abstracts.websocket.listener.StreamListener; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessage; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessageType; -import io.github.mainstringargs.domain.polygon.websocket.PolygonStreamMessage; -import io.github.mainstringargs.domain.polygon.websocket.aggregate.AggregatePerMinuteMessage; -import io.github.mainstringargs.domain.polygon.websocket.aggregate.AggregatePerSecondMessage; -import io.github.mainstringargs.domain.polygon.websocket.quote.QuoteMessage; -import io.github.mainstringargs.domain.polygon.websocket.status.StatusMessage; -import io.github.mainstringargs.domain.polygon.websocket.trade.TradeMessage; -import io.github.mainstringargs.polygon.websocket.listener.PolygonStreamListener; -import io.github.mainstringargs.polygon.websocket.message.PolygonStreamMessageType; -import io.github.mainstringargs.util.gson.GsonUtil; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import javax.websocket.DeploymentException; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.StringJoiner; -import java.util.stream.Collectors; - -/** - * The Class WebsocketClient. - */ -public class PolygonWebsocketClient implements WebsocketClient { - - /** The logger. */ - private static final Logger LOGGER = LogManager.getLogger(PolygonWebsocketClient.class); - - /** The all tickers. */ - private static final String ALL_TICKERS = "*"; - - /** The constant EVENT_TYPE_KEY. */ - private static final String EVENT_TYPE_KEY = "ev"; - - /** The key id. */ - private String keyId; - - /** The Websocket url. */ - private String websocketURL; - - /** The listeners. */ - private List listeners; - - /** The client end point. */ - private PolygonWebsocketClientEndpoint polygonWebsocketClientEndpoint; - - /** The Authenticated. */ - private boolean authenticated; - - /** - * Instantiates a new Polygon websocket client. - * - * @param keyId the key id - * @param websocketURL the websocket url - */ - public PolygonWebsocketClient(String keyId, String websocketURL) { - this.keyId = keyId; - this.websocketURL = websocketURL; - - this.listeners = new ArrayList<>(); - } - - @Override - public void addListener(StreamListener listener) { - Preconditions.checkState(listener instanceof PolygonStreamListener); - - if (listeners.isEmpty()) { - connect(); - } - - listeners.add((PolygonStreamListener) listener); - - submitStreamRequest(PolygonStreamAction.SUBSCRIBE, (PolygonStreamListener) listener); - } - - @Override - public void removeListener(StreamListener listener) { - Preconditions.checkState(listener instanceof PolygonStreamListener); - - listeners.remove(listener); - - submitStreamRequest(PolygonStreamAction.UNSUBSCRIBE, (PolygonStreamListener) listener); - - if (listeners.isEmpty()) { - disconnect(); - } - } - - @Override - public void connect() { - LOGGER.info("Connecting..."); - - try { - polygonWebsocketClientEndpoint = new PolygonWebsocketClientEndpoint(this, new URI(websocketURL)); - polygonWebsocketClientEndpoint.connect(); - - LOGGER.info("Connected."); - } catch (URISyntaxException | DeploymentException | IOException e) { - LOGGER.throwing(e); - } - } - - @Override - public void disconnect() { - LOGGER.info("Disconnecting..."); - - try { - polygonWebsocketClientEndpoint.getUserSession().close(); - - LOGGER.info("Disconnected."); - } catch (IOException e) { - LOGGER.throwing(e); - } - } - - @Override - public void sendAuthenticationMessage() { - // Format of message is: {"action":"auth","params":"{API_KEY}"} - - JsonObject authRequest = new JsonObject(); - authRequest.addProperty("action", "auth"); - authRequest.addProperty("params", keyId); - - polygonWebsocketClientEndpoint.sendMessage(authRequest.toString()); - } - - @Override - public void handleWebsocketMessage(String message) { - JsonElement messageJsonElement = GsonUtil.JSON_PARSER.parse(message); - - Preconditions.checkState(messageJsonElement instanceof JsonArray); - - for (JsonElement jsonElement : messageJsonElement.getAsJsonArray()) { - JsonObject messageJsonObject = jsonElement.getAsJsonObject(); - JsonElement eventTypeJsonElement = messageJsonObject.get(EVENT_TYPE_KEY); - - if (eventTypeJsonElement instanceof JsonPrimitive) { - try { - PolygonStreamMessageType polygonStreamMessageType = GsonUtil.GSON.fromJson(eventTypeJsonElement, - PolygonStreamMessageType.class); - - switch (polygonStreamMessageType) { - case STATUS: - StatusMessage statusMessage = GsonUtil.GSON.fromJson(messageJsonObject, - StatusMessage.class); - sendStreamMessageToListeners(polygonStreamMessageType, statusMessage); - - authenticated = isAuthenticatedStatusMessage(statusMessage); - - LOGGER.debug(statusMessage); - break; - case TRADE: - sendStreamMessageToListeners(polygonStreamMessageType, - GsonUtil.GSON.fromJson(messageJsonObject, TradeMessage.class)); - break; - case QUOTE: - sendStreamMessageToListeners(polygonStreamMessageType, - GsonUtil.GSON.fromJson(messageJsonObject, QuoteMessage.class)); - break; - case AGGREGATE_PER_SECOND: - sendStreamMessageToListeners(polygonStreamMessageType, - GsonUtil.GSON.fromJson(messageJsonObject, AggregatePerSecondMessage.class)); - break; - case AGGREGATE_PER_MINUTE: - sendStreamMessageToListeners(polygonStreamMessageType, - GsonUtil.GSON.fromJson(messageJsonObject, AggregatePerMinuteMessage.class)); - break; - default: - LOGGER.error("Unknown stream object: " + messageJsonObject); - } - } catch (JsonSyntaxException e) { - LOGGER.throwing(e); - } - } else { - LOGGER.error("Unknown stream message: " + messageJsonObject); - } - } - } - - @Override - public void sendStreamMessageToListeners(StreamMessageType streamMessageType, StreamMessage streamMessage) { - Preconditions.checkState(streamMessageType instanceof PolygonStreamMessageType); - Preconditions.checkState(streamMessage instanceof PolygonStreamMessage); - - PolygonStreamMessageType polygonStreamMessageType = (PolygonStreamMessageType) streamMessageType; - PolygonStreamMessage polygonStreamMessage = (PolygonStreamMessage) streamMessage; - - for (PolygonStreamListener streamListener : listeners) { - boolean sendToStreamListener = false; - - if (streamListener.getStockChannels().containsKey(polygonStreamMessage.getSym())) { - if (streamListener.getStockChannels().get(polygonStreamMessage.getSym()) - .contains(polygonStreamMessageType)) { - sendToStreamListener = true; - } - } else if (streamListener.getStockChannels().containsKey(ALL_TICKERS)) { - if (streamListener.getStockChannels().get(ALL_TICKERS).contains(polygonStreamMessageType)) { - sendToStreamListener = true; - } - } - - if (sendToStreamListener) { - streamListener.onStreamUpdate(polygonStreamMessageType, polygonStreamMessage); - } - } - } - - @Override - public boolean isConnected() { - return polygonWebsocketClientEndpoint.getUserSession().isOpen(); - } - - @Override - public boolean isAuthenticated() { - return authenticated; - } - - /** - * Is authenticated status message boolean. - * - * @param statusMessage the status message - * - * @return the boolean - */ - private boolean isAuthenticatedStatusMessage(StatusMessage statusMessage) { - return statusMessage.getStatus().equalsIgnoreCase("success") && - statusMessage.getMessage().equalsIgnoreCase("authenticated"); - } - - /** - * Submit stream request. - * - * @param polygonStreamAction the polygon stream action - * @param newListener the listener - */ - private void submitStreamRequest(PolygonStreamAction polygonStreamAction, PolygonStreamListener newListener) { - Preconditions.checkNotNull(polygonStreamAction); - Preconditions.checkNotNull(newListener); - - ArrayList actionTickerList = new ArrayList<>(); - - Map> registeredTickerChannels = getRegisteredTickerChannels(newListener); - Map> newListenerTickerChannels = newListener.getStockChannels(); - - for (String ticker : newListenerTickerChannels.keySet()) { - Set registeredChannels = registeredTickerChannels.get(ticker); - Set newListenerChannelTypes = newListenerTickerChannels.get(ticker); - - if (registeredTickerChannels.containsKey(ticker)) { - for (PolygonStreamMessageType listenerChannelType : newListenerChannelTypes) { - if (!listenerChannelType.isAPISubscribable()) { - continue; - } - - boolean isTickerChannelRegistered = registeredChannels.contains(listenerChannelType); - String formattedWebsocketTicker = formatWebsocketTicker(listenerChannelType, ticker); - - if (isTickerChannelRegistered) { - if (polygonStreamAction == PolygonStreamAction.UNSUBSCRIBE) { - LOGGER.warn("Cannot unsubscribe from " + ticker + " for channel " + - listenerChannelType.name() + - " because it is being used by another stream listener!"); - } else if (polygonStreamAction == PolygonStreamAction.SUBSCRIBE) { - LOGGER.warn("Already subscribed to " + ticker + " for channel " + - listenerChannelType.name() + "!"); - } - } else { // Not a registered channel by other stream listeners - actionTickerList.add(formattedWebsocketTicker); - - if (polygonStreamAction == PolygonStreamAction.UNSUBSCRIBE) { - LOGGER.info(("Unsubscribing from " + formattedWebsocketTicker)); - } else if (polygonStreamAction == PolygonStreamAction.SUBSCRIBE) { - LOGGER.info(("Subscribing to " + formattedWebsocketTicker)); - } - } - } - } else { // Not a registered ticker by other stream listeners - for (PolygonStreamMessageType listenerChannelType : newListenerChannelTypes) { - if (!listenerChannelType.isAPISubscribable()) { - continue; - } - - String formattedWebsocketTicker = formatWebsocketTicker(listenerChannelType, ticker); - - actionTickerList.add(formattedWebsocketTicker); - - if (polygonStreamAction == PolygonStreamAction.UNSUBSCRIBE) { - LOGGER.info(("Unsubscribing from " + formattedWebsocketTicker)); - } else if (polygonStreamAction == PolygonStreamAction.SUBSCRIBE) { - LOGGER.info(("Subscribing to " + formattedWebsocketTicker)); - } - } - } - } - - if (actionTickerList.isEmpty()) { - LOGGER.info("Did not change any channel listeners"); - } else { - // Format: {"action":"(un)subscribe","params":"T.AAPL,T.MSFT,T.TSLA"} - - StringJoiner commaActionTickers = new StringJoiner(","); - actionTickerList.forEach(commaActionTickers::add); - - JsonObject actionJsonObject = new JsonObject(); - actionJsonObject.addProperty("action", polygonStreamAction.getAPIName()); - actionJsonObject.addProperty("params", commaActionTickers.toString()); - - polygonWebsocketClientEndpoint.sendMessage(actionJsonObject.toString()); - - LOGGER.info(("Requested subscriptions to update to " + getRegisteredTickerChannels(null))); - } - } - - /** - * Format websocket ticker string. - * - * @param polygonStreamMessageType the polygon stream message type - * @param ticker the ticker - * - * @return the string - */ - private String formatWebsocketTicker(PolygonStreamMessageType polygonStreamMessageType, String ticker) { - return polygonStreamMessageType.getAPIName() + "." + ticker; - } - - /** - * Gets registered ticker channels. - * - * @param exclude listener to exclude from the final map - * - * @return the registered ticker channels - */ - private Map> getRegisteredTickerChannels(PolygonStreamListener exclude) { - HashMap> registeredTickerChannels = new HashMap<>(); - - for (PolygonStreamListener streamListener : listeners) { - if (streamListener.equals(exclude)) { - continue; - } - - Map> stockChannelTypes = streamListener.getStockChannels(); - - for (String ticker : stockChannelTypes.keySet()) { - Set streamMessageTypes = stockChannelTypes.get(ticker); - Set subscribableStreamMessageTypes = streamMessageTypes == null ? - new HashSet<>() : streamMessageTypes.stream() - .filter(PolygonStreamMessageType::isAPISubscribable) - .collect(Collectors.toSet()); - - if (!registeredTickerChannels.containsKey(ticker)) { - registeredTickerChannels.put(ticker, subscribableStreamMessageTypes); - } else { - registeredTickerChannels.get(ticker).addAll(subscribableStreamMessageTypes); - } - } - } - - return registeredTickerChannels; - } - - /** - * The enum Polygon stream action. - */ - private enum PolygonStreamAction { - /** The subscribe. */ - SUBSCRIBE("subscribe"), - - /** The unsubscribe. */ - UNSUBSCRIBE("unsubscribe"); - - /** The api name. */ - String apiName; - - /** - * Instantiates a new stream action. - * - * @param apiName the api name - */ - PolygonStreamAction(String apiName) { - this.apiName = apiName; - } - - /** - * Gets api name. - * - * @return the api name - */ - public String getAPIName() { - return apiName; - } - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/websocket/client/PolygonWebsocketClientEndpoint.java b/src/main/java/io/github/mainstringargs/polygon/websocket/client/PolygonWebsocketClientEndpoint.java deleted file mode 100644 index 0787f6b0..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/websocket/client/PolygonWebsocketClientEndpoint.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.mainstringargs.polygon.websocket.client; - -import io.github.mainstringargs.abstracts.websocket.client.AbstractWebsocketClientEndpoint; -import io.github.mainstringargs.abstracts.websocket.client.WebsocketClient; - -import javax.websocket.ClientEndpoint; -import javax.websocket.CloseReason; -import javax.websocket.OnClose; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import java.net.URI; - -/** - * The type Polygon websocket client endpoint. - */ -@ClientEndpoint(subprotocols = "TEXT") -public class PolygonWebsocketClientEndpoint extends AbstractWebsocketClientEndpoint { - - /** - * Instantiates a new Polygon websocket client endpoint. - * - * @param websocketClient the websocket client - * @param endpointURI the endpoint uri - */ - public PolygonWebsocketClientEndpoint(WebsocketClient websocketClient, URI endpointURI) { - super(websocketClient, endpointURI, "PolygonWebsocketThread"); - } - - @OnOpen - public void onOpenAnnotated(Session userSession) { - super.onOpen(userSession); - } - - @OnClose - public void onCloseAnnotated(Session userSession, CloseReason reason) { - super.onClose(userSession, reason); - } - - @OnMessage - public void onMessageAnnotated(String message) { - super.onMessage(message); - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/websocket/listener/PolygonStreamListener.java b/src/main/java/io/github/mainstringargs/polygon/websocket/listener/PolygonStreamListener.java deleted file mode 100644 index cf2c2a73..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/websocket/listener/PolygonStreamListener.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.mainstringargs.polygon.websocket.listener; - -import io.github.mainstringargs.abstracts.websocket.listener.StreamListener; -import io.github.mainstringargs.domain.polygon.websocket.PolygonStreamMessage; -import io.github.mainstringargs.polygon.websocket.message.PolygonStreamMessageType; - -import java.util.Map; -import java.util.Set; - -/** - * The listener interface for receiving polygonStream events. The class that is interested in processing a - * ChannelMessage event implements this interface, and the object created with that class is registered with a component - * using the component's addPolygonStreamListener method. When the ChannelMessage event occurs, that - * object's appropriate method is invoked. - */ -public interface PolygonStreamListener extends StreamListener { - - /** - * Gets the stock channels. Null or empty to listen to all other stream messages. - * - * @return the stock channels - */ - Map> getStockChannels(); -} diff --git a/src/main/java/io/github/mainstringargs/polygon/websocket/listener/PolygonStreamListenerAdapter.java b/src/main/java/io/github/mainstringargs/polygon/websocket/listener/PolygonStreamListenerAdapter.java deleted file mode 100644 index e23360c2..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/websocket/listener/PolygonStreamListenerAdapter.java +++ /dev/null @@ -1,70 +0,0 @@ -package io.github.mainstringargs.polygon.websocket.listener; - -import io.github.mainstringargs.domain.polygon.websocket.PolygonStreamMessage; -import io.github.mainstringargs.polygon.websocket.message.PolygonStreamMessageType; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -/** - * The Class PolygonStreamListenerAdapter. - */ -public class PolygonStreamListenerAdapter implements PolygonStreamListener { - - /** The stock channel types. */ - private Map> stockChannels = new HashMap<>(); - - /** - * Instantiates a new polygon stream listener adapter. - * - * @param ticker the ticker - * @param channelTypes the channel types - */ - public PolygonStreamListenerAdapter(String ticker, PolygonStreamMessageType... channelTypes) { - if (channelTypes != null && channelTypes.length > 0) { - this.stockChannels.put(ticker, new HashSet<>(Arrays.asList(channelTypes))); - } else { - this.stockChannels.put(ticker, new HashSet<>(Arrays.asList(PolygonStreamMessageType.values()))); - } - } - - /** - * Instantiates a new polygon stream listener adapter. - * - * @param tickers the tickers - * @param channelTypes the channel types - */ - public PolygonStreamListenerAdapter(Set tickers, PolygonStreamMessageType... channelTypes) { - for (String ticker : tickers) { - if (channelTypes != null && channelTypes.length > 0) { - this.stockChannels.put(ticker, new HashSet<>(Arrays.asList(channelTypes))); - } else { - this.stockChannels.put(ticker, new HashSet<>(Arrays.asList(PolygonStreamMessageType.values()))); - } - } - } - - /** - * Instantiates a new polygon stream listener adapter. - * - * @param stockChannels the stock channel types - */ - public PolygonStreamListenerAdapter(Map> stockChannels) { - for (Entry> entry : stockChannels.entrySet()) { - this.stockChannels.put(entry.getKey(), new HashSet<>(entry.getValue())); - } - } - - @Override - public Map> getStockChannels() { - return stockChannels; - } - - @Override - public void onStreamUpdate(PolygonStreamMessageType streamMessageType, PolygonStreamMessage streamMessage) { - } -} diff --git a/src/main/java/io/github/mainstringargs/polygon/websocket/message/PolygonStreamMessageType.java b/src/main/java/io/github/mainstringargs/polygon/websocket/message/PolygonStreamMessageType.java deleted file mode 100644 index c18f8083..00000000 --- a/src/main/java/io/github/mainstringargs/polygon/websocket/message/PolygonStreamMessageType.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.github.mainstringargs.polygon.websocket.message; - -import com.google.gson.annotations.SerializedName; -import io.github.mainstringargs.abstracts.enums.APIName; -import io.github.mainstringargs.abstracts.websocket.message.StreamMessageType; -import io.github.mainstringargs.util.gson.GsonUtil; - -/** - * The enum Polygon stream message type. - */ -public enum PolygonStreamMessageType implements StreamMessageType, APIName { - - /** Status polygon stream message type. */ - @SerializedName("status") - STATUS(false), - - /** Trade polygon stream message type. */ - @SerializedName("T") - TRADE(true), - - /** Quote polygon stream message type. */ - @SerializedName("Q") - QUOTE(true), - - /** Aggregate per second polygon stream message type. */ - @SerializedName("A") - AGGREGATE_PER_SECOND(true), - - /** Aggregate per minute polygon stream message type. */ - @SerializedName("AM") - AGGREGATE_PER_MINUTE(true); - - /** The is api subscribable. */ - private boolean isAPISubscribable; - - /** - * Instantiates a new Polygon stream message type. - * - * @param isAPISubscribable the is api subscribable - */ - PolygonStreamMessageType(boolean isAPISubscribable) { - this.isAPISubscribable = isAPISubscribable; - } - - @Override - public String getAPIName() { - return GsonUtil.GSON.toJsonTree(this).getAsString(); - } - - /** - * Is api subscribable boolean. - * - * @return the boolean - */ - public boolean isAPISubscribable() { - return isAPISubscribable; - } -} - diff --git a/src/main/java/io/github/mainstringargs/util/concurrency/ExecutorTracer.java b/src/main/java/io/github/mainstringargs/util/concurrency/ExecutorTracer.java deleted file mode 100644 index 4e32deb7..00000000 --- a/src/main/java/io/github/mainstringargs/util/concurrency/ExecutorTracer.java +++ /dev/null @@ -1,359 +0,0 @@ -package io.github.mainstringargs.util.concurrency; - -import java.util.Collection; -import java.util.List; -import java.util.concurrent.AbstractExecutorService; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -/** - * The Class ExecutorTracer. - */ -public class ExecutorTracer { - - /** - * Instantiates a new executor tracer. - */ - private ExecutorTracer() { - } - - /** - * New fixed thread pool. - * - * @param nThreads the n threads - * - * @return the executor service - */ - public static ExecutorService newFixedThreadPool(int nThreads) { - return new ThreadPoolExecutorTracer(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue()); - } - - /** - * New fixed thread pool. - * - * @param nThreads the n threads - * @param threadFactory the thread factory - * - * @return the executor service - */ - public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) { - return new ThreadPoolExecutorTracer(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(), threadFactory); - } - - /** - * New cached thread pool. - * - * @param threadFactory the thread factory - * - * @return the executor service - */ - public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory) { - return new ThreadPoolExecutorTracer(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, - new SynchronousQueue(), threadFactory); - } - - /** - * New cached thread pool. - * - * @return the executor service - */ - public static ExecutorService newCachedThreadPool() { - return new ThreadPoolExecutorTracer(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, - new SynchronousQueue()); - } - - /** - * New single thread executor. - * - * @param threadFactory the thread factory - * - * @return the executor service - */ - public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory) { - return new FinalizableDelegatedExecutorService(new ThreadPoolExecutorTracer(1, 1, 0L, - TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), threadFactory)); - } - - /** - * New single thread executor. - * - * @return the executor service - */ - public static ExecutorService newSingleThreadExecutor() { - return new FinalizableDelegatedExecutorService(new ThreadPoolExecutorTracer(1, 1, 0L, - TimeUnit.MILLISECONDS, new LinkedBlockingQueue())); - } - - /** - * New single thread scheduled executor. - * - * @return the scheduled executor service - */ - public static ScheduledExecutorService newSingleThreadScheduledExecutor() { - return new DelegatedScheduledExecutorService(new ScheduledThreadPoolExecutorTracer(1)); - } - - /** - * New scheduled thread pool. - * - * @param corePoolSize the core pool size - * - * @return the scheduled executor service - */ - public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) { - return new ScheduledThreadPoolExecutorTracer(corePoolSize); - } - - /** - * New scheduled thread pool. - * - * @param corePoolSize the core pool size - * @param threadFactory the thread factory - * - * @return the scheduled executor service - */ - public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, - ThreadFactory threadFactory) { - return new ScheduledThreadPoolExecutorTracer(corePoolSize, threadFactory); - } - - /** - * The Class DelegatedExecutorService. - */ - public static class DelegatedExecutorService extends AbstractExecutorService { - - /** The e. */ - private final ExecutorService e; - - /** - * Instantiates a new delegated executor service. - * - * @param executor the executor - */ - DelegatedExecutorService(ExecutorService executor) { - e = executor; - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.Executor#execute(java.lang.Runnable) - */ - public void execute(Runnable command) { - e.execute(command); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ExecutorService#shutdown() - */ - public void shutdown() { - e.shutdown(); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ExecutorService#shutdownNow() - */ - public List shutdownNow() { - return e.shutdownNow(); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ExecutorService#isShutdown() - */ - public boolean isShutdown() { - return e.isShutdown(); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ExecutorService#isTerminated() - */ - public boolean isTerminated() { - return e.isTerminated(); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ExecutorService#awaitTermination(long, - * java.util.concurrent.TimeUnit) - */ - public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { - return e.awaitTermination(timeout, unit); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.AbstractExecutorService#submit(java.lang.Runnable) - */ - public Future submit(Runnable task) { - return e.submit(task); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.AbstractExecutorService#submit(java.util.concurrent.Callable) - */ - public Future submit(Callable task) { - return e.submit(task); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.AbstractExecutorService#submit(java.lang.Runnable, - * java.lang.Object) - */ - public Future submit(Runnable task, T result) { - return e.submit(task, result); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.AbstractExecutorService#invokeAll(java.util.Collection) - */ - public List> invokeAll(Collection> tasks) - throws InterruptedException { - return e.invokeAll(tasks); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.AbstractExecutorService#invokeAll(java.util.Collection, long, - * java.util.concurrent.TimeUnit) - */ - public List> invokeAll(Collection> tasks, long timeout, - TimeUnit unit) throws InterruptedException { - return e.invokeAll(tasks, timeout, unit); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.AbstractExecutorService#invokeAny(java.util.Collection) - */ - public T invokeAny(Collection> tasks) - throws InterruptedException, ExecutionException { - return e.invokeAny(tasks); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.AbstractExecutorService#invokeAny(java.util.Collection, long, - * java.util.concurrent.TimeUnit) - */ - public T invokeAny(Collection> tasks, long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return e.invokeAny(tasks, timeout, unit); - } - } - - /** - * The Class FinalizableDelegatedExecutorService. - */ - public static class FinalizableDelegatedExecutorService extends DelegatedExecutorService { - - /** - * Instantiates a new finalizable delegated executor service. - * - * @param executor the executor - */ - FinalizableDelegatedExecutorService(ExecutorService executor) { - super(executor); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#finalize() - */ - protected void finalize() { - super.shutdown(); - } - } - - /** - * The Class DelegatedScheduledExecutorService. - */ - static class DelegatedScheduledExecutorService extends DelegatedExecutorService - implements ScheduledExecutorService { - - /** The e. */ - private final ScheduledExecutorService e; - - /** - * Instantiates a new delegated scheduled executor service. - * - * @param executor the executor - */ - DelegatedScheduledExecutorService(ScheduledExecutorService executor) { - super(executor); - e = executor; - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ScheduledExecutorService#schedule(java.lang.Runnable, long, - * java.util.concurrent.TimeUnit) - */ - public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { - return e.schedule(command, delay, unit); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ScheduledExecutorService#schedule(java.util.concurrent.Callable, - * long, java.util.concurrent.TimeUnit) - */ - public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) { - return e.schedule(callable, delay, unit); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate(java.lang.Runnable, - * long, long, java.util.concurrent.TimeUnit) - */ - public ScheduledFuture scheduleAtFixedRate(Runnable command, long initialDelay, long period, - TimeUnit unit) { - return e.scheduleAtFixedRate(command, initialDelay, period, unit); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ScheduledExecutorService#scheduleWithFixedDelay(java.lang.Runnable, - * long, long, java.util.concurrent.TimeUnit) - */ - public ScheduledFuture scheduleWithFixedDelay(Runnable command, long initialDelay, - long delay, TimeUnit unit) { - return e.scheduleWithFixedDelay(command, initialDelay, delay, unit); - } - } -} diff --git a/src/main/java/io/github/mainstringargs/util/concurrency/ScheduledThreadPoolExecutorTracer.java b/src/main/java/io/github/mainstringargs/util/concurrency/ScheduledThreadPoolExecutorTracer.java deleted file mode 100644 index 61bc9acd..00000000 --- a/src/main/java/io/github/mainstringargs/util/concurrency/ScheduledThreadPoolExecutorTracer.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.github.mainstringargs.util.concurrency; - -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadFactory; - -/** - * The Class ScheduledThreadPoolExecutorTracer. - */ -class ScheduledThreadPoolExecutorTracer extends ScheduledThreadPoolExecutor { - - /** - * Instantiates a new scheduled thread pool executor tracer. - * - * @param corePoolSize the core pool size - * @param threadFactory the thread factory - */ - public ScheduledThreadPoolExecutorTracer(int corePoolSize, ThreadFactory threadFactory) { - super(corePoolSize, threadFactory); - } - - /** - * Instantiates a new scheduled thread pool executor tracer. - * - * @param corePoolSize the core pool size - */ - public ScheduledThreadPoolExecutorTracer(int corePoolSize) { - super(corePoolSize); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ThreadPoolExecutor#afterExecute(java.lang.Runnable, - * java.lang.Throwable) - */ - @Override - protected void afterExecute(final Runnable r, Throwable t) { - super.afterExecute(r, t); - if (t == null && r instanceof Future) { - try { - final Future future = (Future) r; - if (future.isDone() && !future.isCancelled()) { - future.get(); - } - } catch (final CancellationException ce) { - t = ce; - } catch (final ExecutionException ee) { - t = ee.getCause(); - } catch (final InterruptedException ie) { - Thread.currentThread().interrupt(); - } - } - if (t != null) { - t.printStackTrace(); - } - } -} diff --git a/src/main/java/io/github/mainstringargs/util/concurrency/ThreadPoolExecutorTracer.java b/src/main/java/io/github/mainstringargs/util/concurrency/ThreadPoolExecutorTracer.java deleted file mode 100644 index fa950de6..00000000 --- a/src/main/java/io/github/mainstringargs/util/concurrency/ThreadPoolExecutorTracer.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.github.mainstringargs.util.concurrency; - -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -/** - * The Class ThreadPoolExecutorTracer. - */ -public class ThreadPoolExecutorTracer extends ThreadPoolExecutor { - - /** - * Instantiates a new thread pool executor tracer. - * - * @param corePoolSize the core pool size - * @param maximumPoolSize the maximum pool size - * @param keepAliveTime the keep alive time - * @param unit the unit - * @param workQueue the work queue - */ - public ThreadPoolExecutorTracer(int corePoolSize, int maximumPoolSize, long keepAliveTime, - TimeUnit unit, BlockingQueue workQueue) { - super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); - } - - /** - * Instantiates a new thread pool executor tracer. - * - * @param corePoolSize the core pool size - * @param maximumPoolSize the maximum pool size - * @param keepAliveTime the keep alive time - * @param unit the unit - * @param workQueue the work queue - * @param threadFactory the thread factory - */ - public ThreadPoolExecutorTracer(int corePoolSize, int maximumPoolSize, long keepAliveTime, - TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory) { - super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory); - } - - /* - * (non-Javadoc) - * - * @see java.util.concurrent.ThreadPoolExecutor#afterExecute(java.lang.Runnable, - * java.lang.Throwable) - */ - protected void afterExecute(Runnable r, Throwable t) { - super.afterExecute(r, t); - if (t == null && r instanceof Future) { - try { - Future future = (Future) r; - if (future.isDone()) { future.get(); } - } catch (CancellationException ce) { - t = ce; - } catch (ExecutionException ee) { - t = ee.getCause(); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - } - } - if (t != null && !(t instanceof CancellationException)) { - t.printStackTrace(); - } - } -} diff --git a/src/main/java/io/github/mainstringargs/util/doc/Documentation2JSONSchema.java b/src/main/java/io/github/mainstringargs/util/doc/Documentation2JSONSchema.java deleted file mode 100644 index 91d057a8..00000000 --- a/src/main/java/io/github/mainstringargs/util/doc/Documentation2JSONSchema.java +++ /dev/null @@ -1,154 +0,0 @@ -package io.github.mainstringargs.util.doc; - -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; -import java.io.ByteArrayInputStream; -import java.io.IOException; - -public class Documentation2JSONSchema { - - /** - * This is a standalone helper method that converts properties HTML copied from the Alpaca docs page into a json - * schema property list that includes the type and the description. It's kinda hacky, but it helps in the generation - * of JSON POJOs with Javadocs. Must be in the format of a list of: - *

-     * <div class="spec-table">
-     *     <div class="spec-row">
-     *     <div class="spec-left"><span class="spec-name">id</span></div>
-     *     <div class="spec-right">
-     *         <div class="spec-type">string<uuid></div>
-     *         <div class="spec-desc">Account ID.</div>
-     *     </div>
-     *     </div>
-     *     ...
-     * </div>
-     * 
- * - * @param alpacaDocXML the alpaca doc xml - */ - public static void printAlpacaHTMLWebDocAsJSONSchema(String alpacaDocXML) - throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { - String nameXPath = "//span[" + xPathClassName("spec-name") + "]"; - String typeXPath = "//div[" + xPathClassName("spec-type") + "]"; - String descriptionXPath = "//div[" + xPathClassName("spec-desc") + "]"; - - System.out.println(getSchemaFromDoc(alpacaDocXML, nameXPath, typeXPath, descriptionXPath)); - } - - /** - * This is a standalone helper method that converts response schema HTML copied from the Polygon docs page into a - * json schema property list that includes the type and the description. It's kinda hacky, but it helps in the - * generation of JSON POJOs with Javadocs. Must be in the format of a list of: - *
-     * <div class="description">
-     *     <div>
-     *         <span class="propLabels">
-     *             <span class="propName propOpt">name</span>
-     *             <span class="propType" title="string">string</span>
-     *         </span>
-     *         <span class="propDesc">Name of the item.</span>
-     *     </div>
-     *     ...
-     * </div>
-     * 
- * - * @param polygonDocXML the polygon doc xml - */ - public static void printPolygonHTMLWebDocAsJSONSchema(String polygonDocXML) - throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { - String nameXPath = "//span[" + xPathClassName("propName") + "]"; - String typeXPath = "//span[" + xPathClassName("propType") + "]"; - String descriptionXPath = "//span[" + xPathClassName("propDesc") + "]"; - - System.out.println(getSchemaFromDoc(polygonDocXML, nameXPath, typeXPath, descriptionXPath)); - } - - /** - * Converts a generic HTML doc for Alpaca or Polygon with JSON property fields for "name", "type", and "description" - * into schema JSON used for - * jsonSchema2POJO. - * - * @param docHTML the doc html - * @param nameXPath the name x path - * @param typeXPath the type x path - * @param descriptionXPath the description x path - * - * @return the schema from doc - * - * @throws ParserConfigurationException the parser configuration exception - * @throws SAXException the sax exception - * @throws IOException the io exception - * @throws XPathExpressionException the x path expression exception - */ - private static String getSchemaFromDoc(String docHTML, String nameXPath, String typeXPath, String descriptionXPath) - throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { - String schemaJSON = ""; - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document document = builder.parse(new ByteArrayInputStream(docHTML.getBytes())); - XPathFactory xPathFactory = XPathFactory.newInstance(); - XPath xPath = xPathFactory.newXPath(); - - XPathExpression propertyNamesXPath = xPath.compile(nameXPath); - XPathExpression propertyTypesXPath = xPath.compile(typeXPath); - XPathExpression propertyDescriptionsXPath = xPath.compile(descriptionXPath); - - NodeList propertyNameNodes = (NodeList) propertyNamesXPath.evaluate(document, XPathConstants.NODESET); - NodeList propertyTypesNodes = (NodeList) propertyTypesXPath.evaluate(document, XPathConstants.NODESET); - NodeList propertyDescriptionsNodes = (NodeList) propertyDescriptionsXPath.evaluate(document, - XPathConstants.NODESET); - - for (int propertyIndex = 0; propertyIndex < propertyNameNodes.getLength(); propertyIndex++) { - String propertyName = propertyNameNodes.item(propertyIndex).getTextContent(); - String propertyType = propertyTypesNodes.item(propertyIndex).getTextContent(); - String propertyDescription = propertyDescriptionsNodes.item(propertyIndex).getTextContent(); - - // Property description may be null - if (propertyDescription == null || propertyDescription.isEmpty()) { - propertyDescription = propertyName; - } - - schemaJSON += "\"" + propertyName + "\": {\n"; - schemaJSON += "\"existingJavaType\": \"" + parseDocTypeToSchemaJavaType(propertyType) + "\",\n"; - schemaJSON += "\"title\": \"" + propertyDescription + "\"\n"; - schemaJSON += "},\n"; - } - return schemaJSON; - } - - /** - * @see jsonSchema2Pojo Ref - */ - private static String parseDocTypeToSchemaJavaType(String docType) { - docType = docType.toLowerCase(); - - if (docType.contains("string") || docType.contains("timestamp")) { - return "java.lang.String"; - } else if (docType.contains("boolean") || docType.contains("bool")) { - return "java.lang.Boolean"; - } else if (docType.contains("int") || docType.contains("integer")) { - return "java.lang.Integer"; - } else if (docType.contains("double") || docType.contains("float") || - docType.contains("number")) { - return "java.lang.Double"; - } else { - return "UNKNOWN DOC DATA TYPE"; - } - } - - /** - * @see https://devhints.io/xpath#class-check - */ - private static String xPathClassName(String className) { - return String.format("contains(concat(' ',normalize-space(@class),' '),' %s ')", className); - } -} diff --git a/src/main/java/io/github/mainstringargs/util/gson/GsonUtil.java b/src/main/java/io/github/mainstringargs/util/gson/GsonUtil.java deleted file mode 100644 index dc89c727..00000000 --- a/src/main/java/io/github/mainstringargs/util/gson/GsonUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -package io.github.mainstringargs.util.gson; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.annotations.SerializedName; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -public class GsonUtil { - - /** The logger. */ - private static final Logger LOGGER = LogManager.getLogger(GsonUtil.class); - - /** The constant CLASS_ANNOTATION_CACHE. */ - private static final HashMap> CLASS_ANNOTATION_CACHE = new HashMap<>(); - - /** The constant GSON which include ISO date time to ZonedDateTime objects */ - public static final Gson GSON = new GsonBuilder() - .registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()) - .enableComplexMapKeySerialization() - .setLenient() - .create(); - - /** The constant JSON_PARSER. */ - public static final JsonParser JSON_PARSER = new JsonParser(); - - /** - * Checks if all Gson {@link SerializedName} annotation values (including inherited ones) in the JSON POJO are - * present in the immediate JSON object. - * - * @param jsonPOJOClass the json pojo class - * @param jsonObject the json object - * - * @return the boolean - */ - public static boolean doesGsonPOJOMatch(Class jsonPOJOClass, JsonObject jsonObject) { - ArrayList gsonSerializedNameAnnotations = getGsonSerializedNameAnnotations(jsonPOJOClass); - Set jsonObjectKeys = jsonObject.keySet(); - - List classKeys = new ArrayList<>(); - gsonSerializedNameAnnotations.forEach((c) -> classKeys.add(c.value())); - - for (String key : jsonObjectKeys) { - if (!classKeys.contains(key)) { - return false; - } - } - return true; - } - - /** - * Gets gson serialized name annotations. - * - * @param theClass the the class - * - * @return the gson serialized name annotations - */ - private static synchronized ArrayList getGsonSerializedNameAnnotations(Class theClass) { - // Use a caching system because Reflection can be quite expensive - if (CLASS_ANNOTATION_CACHE.containsKey(theClass)) { - return CLASS_ANNOTATION_CACHE.get(theClass); - } - - LOGGER.debug("Caching Gson @SerializedName annotations for " + theClass.getName()); - - // Below is expensive, but it only has to be done once per class. - - ArrayList serializedNameAnnotations = new ArrayList<>(); - - Class currentClass = theClass; - do { - for (Field field : currentClass.getDeclaredFields()) { // Loop through all the fields - for (Annotation annotation : field.getDeclaredAnnotations()) { // Loop through all the field annotations - if (annotation instanceof SerializedName) { - serializedNameAnnotations.add((SerializedName) annotation); - } - } - } - - currentClass = currentClass.getSuperclass(); - } while (currentClass != null); // Loop through all inherited classes - - CLASS_ANNOTATION_CACHE.put(theClass, serializedNameAnnotations); - - return serializedNameAnnotations; - } -} diff --git a/src/main/java/io/github/mainstringargs/util/gson/ZonedDateTimeAdapter.java b/src/main/java/io/github/mainstringargs/util/gson/ZonedDateTimeAdapter.java deleted file mode 100644 index 47927096..00000000 --- a/src/main/java/io/github/mainstringargs/util/gson/ZonedDateTimeAdapter.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.mainstringargs.util.gson; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import java.lang.reflect.Type; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; - -/** - * The GSON ZonedDateTime (de)serialization adapter. - */ -public class ZonedDateTimeAdapter implements JsonSerializer, JsonDeserializer { - - @Override - public JsonElement serialize(ZonedDateTime src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); - } - - @Override - public ZonedDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - return ZonedDateTime.parse(json.getAsJsonPrimitive().getAsString(), DateTimeFormatter.ISO_OFFSET_DATE_TIME); - } -} diff --git a/src/main/java/io/github/mainstringargs/util/properties/PropertyUtil.java b/src/main/java/io/github/mainstringargs/util/properties/PropertyUtil.java deleted file mode 100644 index 29d345e2..00000000 --- a/src/main/java/io/github/mainstringargs/util/properties/PropertyUtil.java +++ /dev/null @@ -1,126 +0,0 @@ -package io.github.mainstringargs.util.properties; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -/** - * The type Property util. - */ -public class PropertyUtil { - - /** The logger. */ - private static final Logger LOGGER = LogManager.getLogger(PropertyUtil.class); - - /** The property file. */ - public static final Map CACHED_PROPERTIES = Collections.synchronizedMap(new HashMap<>()); - - /** - * Get property string. Will try to IO load the properties in the property file if not cached already. - * - * @param propertyFile the property file (.default properties files are also cached if they exist) - * @param key the key - * - * @return the string - */ - public static String getProperty(String propertyFile, String key) { - return getProperty(propertyFile, key, null); - } - - /** - * Get property string. Will try to IO load the properties in the property file if not cached already. - * - * @param propertyFile the property file (.default properties files are also cached if they exist) - * @param key the key - * @param defaultValue the default value (if not .default properties were found, then this is returned) - * - * @return the string - */ - public static String getProperty(String propertyFile, String key, String defaultValue) { - if (!CACHED_PROPERTIES.containsKey(propertyFile)) { - CACHED_PROPERTIES.put(propertyFile, loadPropertyFile(propertyFile)); - } - Properties properties = CACHED_PROPERTIES.get(propertyFile); - if (properties != null) { - return properties.getProperty(key, defaultValue); - } - return null; - } - - /** - * Load property file properties. - * - * @param propertyFile the property file name (.default properties files are also searched) - * - * @return the properties - */ - public synchronized static Properties loadPropertyFile(String propertyFile) { - Properties properties = null; - - // Load the default property file if exists - Properties defaultProperties = null; - String defaultPropertyFile = propertyFile + ".default"; - InputStream defaultPropertyStream = ClassLoader.getSystemClassLoader() - .getResourceAsStream(defaultPropertyFile); - - if (defaultPropertyStream != null) { - defaultProperties = new Properties(); - - // Load the properties - try { - defaultProperties.load(defaultPropertyStream); - LOGGER.debug("Loaded default properties file: " + defaultPropertyFile); - } catch (IOException exception) { - LOGGER.error("Could not load default property file: " + defaultPropertyFile, exception); - } - - // Close the InputStream - try { - defaultPropertyStream.close(); - } catch (IOException exception) { - LOGGER.error("Could not close default property file stream: " + defaultPropertyFile, exception); - } - - } else { - LOGGER.warn("No default property file found for: " + propertyFile); - } - - // Load the property file - InputStream propertyStream = ClassLoader.getSystemClassLoader().getResourceAsStream(propertyFile); - - if (propertyStream != null) { - // Add default properties if they were found - properties = defaultProperties == null ? new Properties() : new Properties(defaultProperties); - - // Load the properties - try { - properties.load(propertyStream); - LOGGER.info("Loaded properties file: " + propertyFile); - } catch (IOException exception) { - LOGGER.error("Could not load property file: " + propertyFile, exception); - } - - // Close the InputStream - try { - propertyStream.close(); - } catch (IOException exception) { - LOGGER.error("Could not close property file stream: " + propertyFile, exception); - } - } else { - LOGGER.error("Could not find property file: " + propertyFile); - - if (defaultProperties != null) { - LOGGER.info("Using default properties for: " + propertyFile); - properties = defaultProperties; - } - } - - return properties; - } -} diff --git a/src/main/java/io/github/mainstringargs/util/time/TimeUtil.java b/src/main/java/io/github/mainstringargs/util/time/TimeUtil.java deleted file mode 100644 index 2d8383ef..00000000 --- a/src/main/java/io/github/mainstringargs/util/time/TimeUtil.java +++ /dev/null @@ -1,116 +0,0 @@ -package io.github.mainstringargs.util.time; - -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; - -/** - * The Class Utilities. - */ -public class TimeUtil { - - /** The constant PREV_UNIX_EPOCH_NANO_TIME. */ - private static final long PREV_UNIX_EPOCH_NANO_TIME = System.currentTimeMillis() * 1000000L; - /** The constant PREV_UNIX_EPOCH_NANO_TIME. */ - private static final long PREV_UNIX_EPOCH_MICRO_TIME = PREV_UNIX_EPOCH_NANO_TIME / 1000L; - /** The date time formatter. */ - private static DateTimeFormatter inputDateTimeFormatter = DateTimeFormatter.ofPattern( - "[yyyyMMdd][yyyy-MM-dd][yyyy-DDD]['T'[HHmmss][HHmm][HH:mm:ss][HH:mm][.SSSSSSSSS][.SSSSSSSS][.SSSSSSS][" + - ".SSSSSS][.SSSSS][.SSS][.SS][.S]][OOOO][O][z][XXXXX][XXXX]['['VV']']"); - /** The output date time formatter. */ - private static DateTimeFormatter outputDateTimeFormatter = - DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'").withZone(ZoneId.of("UTC")); - /** The number formatter. */ - private static NumberFormat numberFormatter = new DecimalFormat("#0.00"); - - /** - * To date time string. - * - * @param ldt the ldt - * - * @return the string - */ - public static String toDateTimeString(LocalDateTime ldt) { - ZonedDateTime ldtZoned = ldt.atZone(ZoneId.systemDefault()); - - ZonedDateTime localTimeZoned = ldtZoned.withZoneSameInstant(ZoneId.of("UTC")); - - return outputDateTimeFormatter.format(localTimeZoned); - } - - /** - * To decimal format. - * - * @param numberToFormat the number to format - * - * @return the string - */ - public static String toDecimalFormat(Number numberToFormat) { - return numberFormatter.format(numberToFormat); - } - - /** - * To date string. - * - * @param ld the ld - * - * @return the string - */ - public static String toDateString(LocalDate ld) { - return ld.format(DateTimeFormatter.ISO_DATE); - } - - /** - * From date time string. - * - * @param dateTimeString the date time string - * - * @return the local date time using the system time zone - */ - public static LocalDateTime fromDateTimeString(String dateTimeString) { - LocalDateTime ldt = LocalDateTime.parse(dateTimeString, inputDateTimeFormatter); - - ZonedDateTime ldtZoned; - - if (dateTimeString.endsWith("Z")) { - ldtZoned = ldt.atZone(ZoneId.of("UTC")); - } else { - ldtZoned = ldt.atZone(ZoneId.of("America/New_York")); - } - - ZonedDateTime localTimeZoned = ldtZoned.withZoneSameInstant(ZoneId.systemDefault()); - - return localTimeZoned.toLocalDateTime(); - } - - /** - * From date string. - * - * @param dateString the date string - * - * @return the local date - */ - public static LocalDate fromDateString(String dateString) { - return LocalDate.parse(dateString, DateTimeFormatter.ISO_DATE); - } - - /** - * Converts a given unix epoch time in nanoseconds or microseconds to milliseconds if necessary. - * - * @param time the time - * - * @return the long - */ - public static long convertToMilli(long time) { - if (time > PREV_UNIX_EPOCH_NANO_TIME) { - time /= 1000000L; - } else if (time > PREV_UNIX_EPOCH_MICRO_TIME) { - time /= 1000L; - } - return time; - } -} diff --git a/src/main/resources/alpaca.properties.default b/src/main/resources/alpaca.properties.default deleted file mode 100644 index af829844..00000000 --- a/src/main/resources/alpaca.properties.default +++ /dev/null @@ -1,13 +0,0 @@ -#Example: -#api_version = -#key_id = -#secret = -#base_api_url = https://paper-api.alpaca.markets -#base_data_url = https://data.alpaca.markets -#user_agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 - -#Defaults: -api_version = v2 -base_api_url = https://paper-api.alpaca.markets -base_data_url = https://data.alpaca.markets -user_agent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 diff --git a/src/main/resources/log4j2.properties b/src/main/resources/log4j2.properties deleted file mode 100644 index 1f51154e..00000000 --- a/src/main/resources/log4j2.properties +++ /dev/null @@ -1,12 +0,0 @@ -name=PropertiesConfig -property.filename = logs -appenders = console - -appender.console.type = Console -appender.console.name = STDOUT -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n - -rootLogger.level = info -rootLogger.appenderRefs = stdout -rootLogger.appenderRef.stdout.ref = STDOUT \ No newline at end of file diff --git a/src/main/resources/polygon.properties.default b/src/main/resources/polygon.properties.default deleted file mode 100644 index 33560344..00000000 --- a/src/main/resources/polygon.properties.default +++ /dev/null @@ -1,11 +0,0 @@ -#Example: -#key_id will default to what is set in alpaca.properties -#key_id = -#base_api_url = https://api.polygon.io -#web_socket_server_url = wss://alpaca.socket.polygon.io/stocks -#user_agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 - -#Defauls: -base_api_url = https://api.polygon.io -web_socket_server_url = wss://alpaca.socket.polygon.io/stocks -user_agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 diff --git a/upload.sh b/upload.sh deleted file mode 100644 index ae6499d4..00000000 --- a/upload.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -./gradlew uploadArchives -./gradlew closeAndReleaseRepository