When getting account info using get_account_info_v2, sometimes the returned stock info has no costDetail fields (for example, the stock NXU for some reason). This causes an error when trying to build the position object.
For example, this is the position data for NXU when printed:
{ "quantity": 1, "quantityBeforeSplit": 1, "marginRequirement": 0, "percentageOfAccount": 0.63, "symbolDetail": { "symbol": "NXU", "cusip": "62956D204", "description": "NXU INC CLASS A", "quoteSymbol": "NXU", "defaultSymbol": "NXU", "schwabSecurityId": 95217935, "underlyingSchwabSecurityId": 0, "isLink": True, "isMarginable": True, "securityGroupCode": "COMNEQTY", "ruleSetSuffix": 0, "accountingRuleCode": 1, "positionType": 0, "securityType": 1, "symbolForDetailedQuotes": "NXU", }, "priceDetail": { "price": 2.66, "priceChange": 0, "priceChangePercent": 0, "priceDate": "12/28/2023", "isPriceRealTime": True, "marketValue": 2.66, "dayChange": 0, "dayChangePercent": 0, }, "reinvestDetail": {}, "marginDetail": { "pegAmount": 0, "nakedQuantity": 0, "nakedRequirementAmount": 0, "spreadQuantity": 0, "spreadRequirementAmount": 0, "strangleQuantity": 0, "strangleRequirementAmount": 0, "coverQuantity": 0, }, }
Which causes the below error:
This isn't happening with every stock, but if an account holds the problematic stock then it crashes
When getting account info using
get_account_info_v2
, sometimes the returned stock info has nocostDetail
fields (for example, the stock NXU for some reason). This causes an error when trying to build the position object.For example, this is the
position
data for NXU when printed:{ "quantity": 1, "quantityBeforeSplit": 1, "marginRequirement": 0, "percentageOfAccount": 0.63, "symbolDetail": { "symbol": "NXU", "cusip": "62956D204", "description": "NXU INC CLASS A", "quoteSymbol": "NXU", "defaultSymbol": "NXU", "schwabSecurityId": 95217935, "underlyingSchwabSecurityId": 0, "isLink": True, "isMarginable": True, "securityGroupCode": "COMNEQTY", "ruleSetSuffix": 0, "accountingRuleCode": 1, "positionType": 0, "securityType": 1, "symbolForDetailedQuotes": "NXU", }, "priceDetail": { "price": 2.66, "priceChange": 0, "priceChangePercent": 0, "priceDate": "12/28/2023", "isPriceRealTime": True, "marketValue": 2.66, "dayChange": 0, "dayChangePercent": 0, }, "reinvestDetail": {}, "marginDetail": { "pegAmount": 0, "nakedQuantity": 0, "nakedRequirementAmount": 0, "spreadQuantity": 0, "spreadRequirementAmount": 0, "strangleQuantity": 0, "strangleRequirementAmount": 0, "coverQuantity": 0, }, }
Which causes the below error:
This isn't happening with every stock, but if an account holds the problematic stock then it crashes