@@ -408,67 +408,10 @@ def setOrders(self, orders):
408
408
# A python expert could do waaaaay better optimized on this function
409
409
# But anyway... it works...
410
410
#########
411
- def displayPnL (self , trades , df , wallet ):
412
-
413
- pnl_data = {}
414
-
415
- '''
416
- pnl_data['time'] = []
417
- #pnl_data['pnlcomm'] = []
418
- # temporary
419
- tradesDatetimeIndex = []
420
- tradesPnl = []
421
-
422
- # Prepare data before plotting Pnl
423
- for key, values in trades:
424
-
425
- row = 0
426
- for trade in values[0]:
427
-
428
- if not trade.isopen:
429
-
430
- tradesDatetimeIndex.append( bt.num2date(trade.dtclose) )
431
- #tradesDatetimeIndex.append( pd.to_datetime(trade.dtclose) )
432
- tradesPnl.append(trade.pnlcomm)
433
-
434
- row += 1
435
-
436
- # Re-index :
437
- # Trades are only few times on all the datetime index
438
- current_pnl = 0
439
- for i,timeIndex in enumerate(df.index):
440
-
441
- # Convert Timestamp to datetime
442
- timeIndex_datetime = pd.to_datetime(timeIndex)
443
-
444
- # is the current datetime in the trade closed times ?
445
- # if so : register a
446
- if timeIndex_datetime in tradesDatetimeIndex:
447
- pnl_index = tradesDatetimeIndex.index(timeIndex_datetime)
448
- current_pnl = tradesPnl[pnl_index]
449
-
450
- #pnl_data['cash'].append(broker.value.array[i])
451
- pnl_data['time'].append(timeIndex)
452
-
453
- pass
454
-
455
- '''
456
-
457
- #pnl_data['cash'] = broker.value.array.tolist()
458
- pnl_data ['value' ] = wallet .value_list
459
- pnl_data ['equity' ] = wallet .equity_list
460
- pnl_data ['cash' ] = wallet .cash_list
461
- pnl_data ['time' ] = df .index
462
-
463
- # Data prepared
464
- #pnl_data['broker'] = broker.plotlines._getvalues()
465
- #taille_cash = len(pnl_data['cash'])
466
- #taille_time = len(pnl_data['time'])
467
-
468
- pnl_df = pd .DataFrame (pnl_data )
411
+ def displayPnL (self , pnl_dataframe ):
469
412
470
413
# draw charts
471
- self .fpltWindow .drawPnL (pnl_df )
414
+ self .fpltWindow .drawPnL (pnl_dataframe )
472
415
pass
473
416
474
417
#########
0 commit comments