Skip to content

Commit f1de75d

Browse files
Minor fix for new holdings mapping (#549)
1 parent ba8da2f commit f1de75d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lean/components/util/live_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ def get_last_portfolio_cash_holdings(api_client: APIClient, brokerage_instance:
104104
last_cash[key] = InsensitiveCaseDict(value)
105105
if "holdings" in last_portfolio:
106106
for key, value in last_portfolio["holdings"].items():
107-
last_holdings[key] = InsensitiveCaseDict(value)
108-
last_holdings[key]["symbol"] = InsensitiveCaseDict(last_holdings[key]["symbol"])
107+
new_dic = InsensitiveCaseDict(value)
108+
new_dic["averagePrice"] = new_dic.get("averagePrice", new_dic.get("a", 0))
109+
new_dic["quantity"] = new_dic.get("quantity", new_dic.get("q", 0))
110+
new_dic["symbol"] = InsensitiveCaseDict(
111+
new_dic.get("symbol", { "ID": key, "Value": key.split(' ')[0]}))
112+
last_holdings[key] = new_dic
109113
else:
110114
last_cash = None
111115
last_holdings = None

0 commit comments

Comments
 (0)