robinhood-to-csv icon indicating copy to clipboard operation
robinhood-to-csv copied to clipboard

in generated csv file, the field name mismatch with value

Open Momingjian opened this issue 4 years ago • 2 comments

The field name mismatch with its value. For example in my generated file:

executed_notional | execution_state | extended_hours | fees {u'currency_id': u'1072fc76-1862-41ab-82c2-485837590762' | u'amount': u'903.80' | u'currency_code': u'USD'} | completed

Momingjian avatar Mar 07 '20 07:03 Momingjian

When the file is read as comma delimited, commas within the executed_notional limit buy/sell field (which is a dictionary) cause that column to be read as three separate columns and this spills over to execution_state and extended_hours. The same is true for the total_notional column.

For a very quick fix, I've added the following snippet at line 74 of csv_export.py:

    if order['executed_notional'] is not None:
        order['executed_notional'] = order['executed_notional']['currency_id']+' | '+order['executed_notional']['amount']+' | '+order['executed_notional']['currency_code']
    if order['total_notional'] is not None:
        order['total_notional'] = order['total_notional']['currency_id']+' | '+order['total_notional']['amount']+' | '+order['total_notional']['currency_code']

jlothringer avatar Mar 22 '20 15:03 jlothringer

When the file is read as comma delimited, commas within the executed_notional limit buy/sell field (which is a dictionary) cause that column to be read as three separate columns and this spills over to execution_state and extended_hours. The same is true for the total_notional column.

For a very quick fix, I've added the following snippet at line 74 of csv_export.py:

    if order['executed_notional'] is not None:
        order['executed_notional'] = order['executed_notional']['currency_id']+' | '+order['executed_notional']['amount']+' | '+order['executed_notional']['currency_code']
    if order['total_notional'] is not None:
        order['total_notional'] = order['total_notional']['currency_id']+' | '+order['total_notional']['amount']+' | '+order['total_notional']['currency_code']

it seems last_trail_price may have the same issue.

        if order['executed_notional'] is not None:
            order['executed_notional'] = order['executed_notional']['currency_id']+' | '+order['executed_notional']['amount']+' | '+order['executed_notional']['currency_code']
        if order['total_notional'] is not None:
            order['total_notional'] = order['total_notional']['currency_id']+' | '+order['total_notional']['amount']+' | '+order['total_notional']['currency_code']
        if order['last_trail_price'] is not None:
            order['last_trail_price'] = order['last_trail_price']['currency_id']+' | '+order['last_trail_price']['amount']+' | '+order['last_trail_price']['currency_code']

DeqingSun avatar Dec 16 '20 02:12 DeqingSun