Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Get the maximum value of PNL

Hi !
I search since 3 days to get the maximum pnl.
I tried :

pnl = np.arange(context.portfolio.pnl)  
context.max_pnl = np.nanmax(pnl)

that seems to me the best way, but :

ValueError: zero-size array to reduction operation fmax which has no identity

Some-one help ?

May be a tip to call the record(pnl = pnl) ?

2 responses

Just big thanks !

the code adapted :

def initialize(context):

   context.max_pnl = 0  
   for i in range(1, 12):  
          schedule_function(max_pnl, date_rules.every_day(), time_rules.market_open(hours=i))

......

def max_pnl(context, data):

if context.portfolio.pnl > context.max_pnl:  
    context.max_pnl = context.portfolio.pnl  
    record(max_pnl = context.max_pnl)