[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/improve pnl graph #22

Merged
merged 6 commits into from
May 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
(feat) fine tune graph
  • Loading branch information
cardosofede committed May 18, 2023
commit 61d49ab9780bfee4da83450e56b77690fb706c18
50 changes: 25 additions & 25 deletions utils/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas_ta as ta # noqa: F401
import streamlit as st

from utils.data_manipulation import StrategyData
from utils.data_manipulation import StrategyData, SingleMarketStrategyData
import plotly.graph_objs as go


Expand Down Expand Up @@ -176,40 +176,40 @@ def add_pnl(self, strategy_data: SingleMarketStrategyData, row=4):

self.base_figure.add_trace(
go.Scatter(
x=merged_df["timestamp"],
y=merged_df["net_pnl_continuos"].apply(lambda x: round(x, 3)),
name="Cumulative Net PnL",
mode="lines",
marker=dict(color="black", size=6),
line=dict(color="black", width=2),
text=merged_df["net_pnl_continuos"],
textposition="top center",
texttemplate="%{text:.3f}"
x=merged_df["datetime"],
y=merged_df["cum_fees_in_quote"].apply(lambda x: round(-x, 2)),
name="Cum Fees",
mode='lines',
line_color='teal',
fill="tozeroy", # Fill to the line below (trade pnl)
stackgroup='one'
),
row=row, col=1
)

self.base_figure.add_trace(
go.Scatter(
x=merged_df["timestamp"],
y=merged_df["cum_fees_in_quote"].apply(lambda x: round(x, 3)),
name="Cumulative Fees",
mode="lines",
fill="tozeroy", # Fill to the line below (trade pnl)
line=dict(color="yellow", width=2),
text=merged_df["cum_fees_in_quote"],
x=merged_df["datetime"],
y=merged_df["trade_pnl_continuos"].apply(lambda x: round(x, 2)),
name="Cum Trade PnL",
mode='lines',
line_color='pink',
fill="tonexty", # Fill to the line below (net pnl)
stackgroup='one'
),
row=row, col=1
)

self.base_figure.add_trace(
go.Scatter(
x=merged_df["timestamp"],
y=merged_df["trade_pnl_continuos"].apply(lambda x: round(x, 3)),
name="Cumulative Trade PnL",
mode="lines",
fill="tonexty", # Fill to the line below (net pnl)
line=dict(color="salmon", width=2),
text=merged_df["trade_pnl_continuos"],
x=merged_df["datetime"],
y=merged_df["net_pnl_continuos"].apply(lambda x: round(x, 2)),
name="Cum Net PnL",
mode="lines+markers+text",
marker=dict(color="black", size=6),
line=dict(color="black", width=2),
textposition="top center",
text=merged_df["net_pnl_continuos"],
texttemplate="%{text:.1f}"
),
row=row, col=1
)
Expand Down