def max_return(nbarprice, islong):
 high = (-1000000)
 low = 1000000
 maxdiffs = []
 if islong:
  for ith_price in nbarprice:
   if (ith_price > high):
    high = ith_price
    low = 1000000
   elif (ith_price < low):
    low = ith_price
    maxdiffs.append((high - low))
  return (max(maxdiffs) if maxdiffs else 0)
 else:
  for ith_price in nbarprice:
   if (ith_price < low):
    low = ith_price
    high = (-1000000)
   elif (ith_price > high):
    high = ith_price
    maxdiffs.append((high - low))
  return (max(maxdiffs) if maxdiffs else 0)

def max_return ( nbarprice , islong ) : high = ( - 1000000 ) low = 1000000 maxdiffs = [ ] if islong : for ith_price in nbarprice : if ( ith_price > high ) : high = ith_price low = 1000000 elif ( ith_price < low ) : low = ith_price maxdiffs . append ( ( high - low ) ) return ( max ( maxdiffs ) if maxdiffs else 0 ) else : for ith_price in nbarprice : if ( ith_price < low ) : low = ith_price high = ( - 1000000 ) elif ( ith_price > high ) : high = ith_price maxdiffs . append ( ( high - low ) ) return ( max ( maxdiffs ) if maxdiffs else 0 )
docstring for maxreturn .