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:
![Screenshot 2023-12-28 at 6 48 21 PM](https://private-user-images.githubusercontent.com/47427072/293294017-a8892c1b-1886-4288-9ae0-4b65b0d3b1f4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE3MTE4NzEsIm5iZiI6MTcyMTcxMTU3MSwicGF0aCI6Ii80NzQyNzA3Mi8yOTMyOTQwMTctYTg4OTJjMWItMTg4Ni00Mjg4LTlhZTAtNGI2NWIwZDNiMWY0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIzVDA1MTI1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU1ZDU4MjUwMDY4M2M4Y2ViZWZhZWRhY2VmYTMyMTRhYWMxN2NhMzc5YmZhMTIwMWRiMWQyYjFjZGEyNWFkZTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.U7nPnB70L4GSRApC_dZQaCQcrgKVNlVCNYdMazFKVMc)
This isn't happening with every stock, but if an account holds the problematic stock then it crashes