Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Broker API - documents API returning document types not supported by the enum #233

Closed
1 task done
whitej125 opened this issue Jan 13, 2023 · 2 comments
Closed
1 task done

Comments

@whitej125
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In the Broker API sandbox I am making an API call to the Trade Documents API using the get_trade_documents_for_account method in the SDK.

I am requesting all document types (account statements, tax, and trade confs) so I do this by leaving the optional TradeDocumentType parameter as None. According to the API documentation this parameter is also optional.

However, the API is returning documents that are not supported by the TradeDocumentType enumeration. Specifically... in addition to trade_confirmation type documents I am also receiving trade_confirmation_json type documents. Because this document type is unknown enumeration to the SDK it crashes (pydantic error) when trying to parse the result.

Snippet of the crash:

__root__ -> 7 -> type
  value is not a valid enumeration member; permitted: 'account_statement', 'trade_confirmation', 'tax_statement', 'tax_1099_b_details', 'tax_1099_b_form', 'tax_1099_div_details', 'tax_1099_div_form', 'tax_1099_int_details', 'tax_1099_int_form', 'tax_w8' (type=type_error.enum; enum_values=[<TradeDocumentType.ACCOUNT_STATEMENT: 'account_statement'>, <TradeDocumentType.TRADE_CONFIRMATION: 'trade_confirmation'>, <TradeDocumentType.TAX_STATEMENT: 'tax_statement'>, <TradeDocumentType.TAX_1099_B_DETAILS: 'tax_1099_b_details'>, <TradeDocumentType.TAX_1099_B_FORM: 'tax_1099_b_form'>, <TradeDocumentType.TAX_1099_DIV_DETAILS: 'tax_1099_div_details'>, <TradeDocumentType.TAX_1099_DIV_FORM: 'tax_1099_div_form'>, <TradeDocumentType.TAX_1099_INT_DETAILS: 'tax_1099_int_details'>, <TradeDocumentType.TAX_1099_INT_FORM: 'tax_1099_int_form'>, <TradeDocumentType.TAX_W8: 'tax_w8'>])

Snippet of the response:

[..., {
    'id': '<redacted>',
    'name': '',
    'type': 'trade_confirmation',
    'sub_type': '',
    'date': '2023-01-10'
}, {
    'id': '<redacted>',
    'name': '',
    'type': 'trade_confirmation_json',
    'sub_type': '',
    'date': '2022-12-12'
}, ...]

Expected Behavior

When I make a request of all document types from the API... the SDK should be able to parse the results.

Either:
a) there is an error in the API and it should not be generating responses with type = trade_confirmation_json
b) the SDK (and API documentation) need to add support for this new document type (add to TradeDocumentType enum)

SDK Version I encountered this issue in

alpaca-py version: 0.6.1

Steps To Reproduce

client = BrokerClient(...)

doc_filter = GetTradeDocumentsRequest(start=<date>, end=<date>). # leave the "type" filter empty
client.get_trade_documents_for_account(account_id=<id>, document_filter=doc_filter)

# crash will happen if there are `trade_confirmation_json` documents in the account for that time range


### Filled out the Steps to Reproduce section?

- [X] I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

### Anything else?

_No response_
@Viicos
Copy link

Viicos commented Jan 19, 2023

This seems to be missing on the Alpaca docs as well. I've raised an issue: alpacahq/alpaca-docs#44. Once we get the confirmation this is indeed missing, this could get fixed on this repo as well

@haxdds
Copy link
Contributor

haxdds commented Jan 23, 2023

Closed by #237

@haxdds haxdds closed this as completed Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants