@@ -271,15 +271,6 @@ def snapshot(
271
271
],
272
272
)
273
273
274
- # fig = make_subplots(
275
- # rows=3, cols=1,
276
- # shared_xaxes=True,
277
- # vertical_spacing=0.03,
278
- # specs=[[{"type": "table"}],
279
- # [{"type": "scatter"}],
280
- # [{"type": "scatter"}]]
281
- # )
282
-
283
274
# display the NAV
284
275
fig .add_trace (
285
276
go .Scatter (x = self .nav .index , y = self .nav , name = label_strategy ), row = 2 , col = 1
@@ -363,14 +354,10 @@ def snapshot(
363
354
364
355
table .loc [label_strategy , "start" ] = self .nav .index [0 ].strftime ("%Y-%m-%d" )
365
356
table .loc [label_strategy , "end" ] = self .nav .index [- 1 ].strftime ("%Y-%m-%d" )
366
- # table["start"][label_benchmark] = benchmark.index[0].strftime("%Y-%m-%d")
367
- # table["end"][label_benchmark] = benchmark.index[-1].strftime("%Y-%m-%d")
368
357
table .loc [label_strategy , "# assets" ] = len (self .assets )
369
- # table['# assets'][label_benchmark] =
370
- table .loc [label_strategy , "Sharpe ratio" ] = sharpe (
371
- self .nav .pct_change ().dropna ()
372
- )
373
- # table["Sharpe ratio"][label_benchmark] = sharpe(benchmark.pct_change().dropna())
358
+
359
+ s = sharpe (self .nav .pct_change ().dropna ())
360
+ table .loc [label_strategy , "Sharpe ratio" ] = f"{ s :.2f} "
374
361
375
362
if benchmark is not None :
376
363
table_bench = pd .DataFrame (
@@ -384,9 +371,9 @@ def snapshot(
384
371
"%Y-%m-%d"
385
372
)
386
373
table_bench .loc [label_benchmark , "# assets" ] = ""
387
- table_bench .loc [label_benchmark , "Sharpe ratio" ] = sharpe (
388
- benchmark . pct_change (). dropna ()
389
- )
374
+ table_bench .loc [
375
+ label_benchmark , "Sharpe ratio"
376
+ ] = f" { sharpe ( benchmark . pct_change (). dropna ()):.2f } "
390
377
391
378
table = pd .concat ([table , table_bench ], axis = 0 )
392
379
0 commit comments