(feat) add visualizations for backtesting

This commit is contained in:
cardosofede
2024-05-16 18:21:37 -04:00
parent 810642df37
commit 4ba64bfbd4
4 changed files with 83 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import plotly.graph_objects as go
import numpy as np
import pandas as pd
def get_pnl_trace(executors):
pnl = [e.net_pnl_quote for e in executors]
cum_pnl = np.cumsum(pnl)
return go.Scatter(
x=pd.to_datetime([e.close_timestamp for e in executors], unit="ms"),
y=cum_pnl,
mode='lines',
line=dict(color='blue', width=2, dash="dash"),
name='Cumulative PNL'
)