Skip to content

Commit

Permalink
(feat) add trades table in panel metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasgaudino committed Sep 20, 2023
1 parent 1a12e72 commit 5bb3ad6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pages/strategy_performance/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ def candles_graph(candles: pd.DataFrame, strat_data, show_volume=False, extra_ro
st.plotly_chart(intraday_performance(page_data_filtered.trade_fill), use_container_width=True)
st.plotly_chart(returns_histogram(page_data_filtered.trade_fill), use_container_width=True)
with table_tab:
st.dataframe(page_data_filtered.trade_fill[["timestamp", "realized_pnl"]].dropna(subset="realized_pnl"),
st.dataframe(page_data_filtered.trade_fill[["timestamp", "gross_pnl", "trade_fee", "realized_pnl"]].dropna(subset="realized_pnl"),
use_container_width=True,
hide_index=True,
height=candles_chart.layout.height - 180)
height=(min(len(page_data_filtered.trade_fill) * 39, candles_chart.layout.height - 180)))
else:
st.plotly_chart(candles_graph(candles_df, page_data_filtered), use_container_width=True)
else:
Expand Down
2 changes: 2 additions & 0 deletions utils/database_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def get_trade_fills(self, config_file_path=None, start_date=None, end_date=None)
trade_fills["realized_trade_pnl"] = trade_fills["unrealized_trade_pnl"] + trade_fills["inventory_cost"]
trade_fills["net_realized_pnl"] = trade_fills["realized_trade_pnl"] - trade_fills["cum_fees_in_quote"]
trade_fills["realized_pnl"] = trade_fills["net_realized_pnl"].diff()
trade_fills["gross_pnl"] = trade_fills["realized_trade_pnl"].diff()
trade_fills["trade_fee"] = trade_fills["cum_fees_in_quote"].diff()
trade_fills["timestamp"] = pd.to_datetime(trade_fills["timestamp"], unit="ms")
trade_fills["market"] = trade_fills["market"].apply(lambda x: x.lower().replace("_papertrade", ""))
trade_fills["quote_volume"] = trade_fills["price"] * trade_fills["amount"]
Expand Down

0 comments on commit 5bb3ad6

Please sign in to comment.