Skip to content

Commit b85acea

Browse files
authored
Merge pull request #258 from zhourunlai/fix/portfolio_df_keyerror
fix: portfolio df keyerror when states is empty
2 parents 81976e2 + 6fd59d4 commit b85acea

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • frontend/pages/orchestration/portfolio

frontend/pages/orchestration/portfolio/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ def portfolio_state_to_df(portfolio_state):
2626
"value": info["value"],
2727
"available_units": info["available_units"],
2828
})
29+
if not data:
30+
return pd.DataFrame(columns=[
31+
"account", "exchange", "token", "price",
32+
"units", "value", "available_units"
33+
])
2934
return pd.DataFrame(data)
3035

3136

@@ -47,6 +52,11 @@ def portfolio_history_to_df(history):
4752
"value": info["value"],
4853
"available_units": info["available_units"],
4954
})
55+
if not data:
56+
return pd.DataFrame(columns=[
57+
"timestamp", "account", "exchange", "token",
58+
"price", "units", "value", "available_units"
59+
])
5060
return pd.DataFrame(data)
5161

5262

0 commit comments

Comments
 (0)