ibflex icon indicating copy to clipboard operation
ibflex copied to clipboard

EquitySummaryByReportDateInBase has no attribute 'currency'

Open clifton opened this issue 1 year ago • 2 comments

Getting this error despite the currency attribute being present on every item.

<EquitySummaryByReportDateInBase accountId="..." currency="USD" ... />

trace:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:115, in parse_data_element(elem)
    [114](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:114) try:
--> [115](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:115)     attrs = dict(
    [116](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:116)         parse_element_attr(Class, k, v)
    [117](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:117)         for k, v in elem.attrib.items()
    [118](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:118)     )
    [119](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:119) except KeyError as exc:

File ~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:116, in <genexpr>(.0)
    [114](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:114) try:
    [115](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:115)     attrs = dict(
--> [116](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:116)         parse_element_attr(Class, k, v)
    [117](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:117)         for k, v in elem.attrib.items()
    [118](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:118)     )
    [119](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:119) except KeyError as exc:

File ~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:156, in parse_element_attr(Class, name, value)
    [151](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:151) #  FIXME
    [152](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:152) #  This "dot reference" gets hit a lot by parse_data_element(), and `Class`
    [153](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:153) #  is always the same in the list comprehension that calls this function.
    [154](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:154) #  Consider moving `Class.__annotations__` up out of the list comprehension
    [155](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:155) #  in parse_data_element(), instead accepting it as a function arg here.
--> [156](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:156) Type = Class.__annotations__[name]
...
    [123](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:123) #  FlexQueryResponse & FlexStatement are the only data elements
    [124](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:124) #  that contain other data elements.
    [125](https://file+.vscode-resource.vscode-cdn.net/Users/clifton/code/port/~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:125) contained_elements = {child.tag: parse_element(child) for child in elem}

FlexParserError: EquitySummaryByReportDateInBase has no attribute 'currency'

clifton avatar Aug 20 '24 18:08 clifton

If I have somehow given the impression that I am willing to act as tech support for low effort bug reports, allow me to take this opportunity to correct that.

On Tue, Aug 20, 2024 at 11:55 AM Clifton King @.***> wrote:

Getting this error despite the currency attribute being present on every item.

<EquitySummaryByReportDateInBase accountId="..." currency="USD" ... />

trace:


KeyError Traceback (most recent call last) File ~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:115, in parse_data_element(elem) 114 try: --> 115 attrs = dict( 116 parse_element_attr(Class, k, v) 117 for k, v in elem.attrib.items() 118 ) 119 except KeyError as exc:

File ~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:116, in (.0) 114 try: 115 attrs = dict( --> 116 parse_element_attr(Class, k, v) 117 for k, v in elem.attrib.items() 118 ) 119 except KeyError as exc:

File ~/code/port/.venv/lib/python3.11/site-packages/ibflex/parser.py:156, in parse_element_attr(Class, name, value) 151 # FIXME 152 # This "dot reference" gets hit a lot by parse_data_element(), and Class 153 # is always the same in the list comprehension that calls this function. 154 # Consider moving Class.__annotations__ up out of the list comprehension 155 # in parse_data_element(), instead accepting it as a function arg here. --> 156 Type = Class.annotations[name] ... 123 # FlexQueryResponse & FlexStatement are the only data elements 124 # that contain other data elements. 125 contained_elements = {child.tag: parse_element(child) for child in elem}

FlexParserError: EquitySummaryByReportDateInBase has no attribute 'currency'

— Reply to this email directly, view it on GitHub https://github.com/csingley/ibflex/issues/85, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBNFGRCUE6K6LK4NYKYH3ZSOGLFAVCNFSM6AAAAABM2QALIGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TMMZSGUZDGNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

csingley avatar Aug 21 '24 14:08 csingley

apologies. ill try stepping through a debugger and submit a PR when i have time

clifton avatar Aug 21 '24 15:08 clifton

@csingley here is the PR to fix the issue

N0-man avatar Nov 10 '24 23:11 N0-man