#NEWLINE# def moving_average_convergence( x , nslow = 26 , nfast = 12 , nsign = 9 , simple = False ) : #NEWLINE# #INDENT# "\n    compute the MACD (Moving Average Convergence/Divergence) using a fast and\n    slow exponential moving avg'\n    " #NEWLINE# macd_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# macd_dict [ 'fast' ] = moving_average ( x , nfast , type = 'exponential' ) #NEWLINE# macd_dict [ 'slow' ] = moving_average ( x , nslow , type = 'exponential' ) #NEWLINE# macd_dict [ 'macd' ] = map ( ( lambda f , s : round ( ( f - s ) , 5 ) ) , macd_dict [ 'fast' ] , macd_dict [ 'slow' ] ) #NEWLINE# macd_dict [ 'sign' ] = moving_average ( macd_dict [ 'macd' ] , simple ) #NEWLINE# if ( not simple ) : #NEWLINE# #INDENT# return macd_dict #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return macd_dict [ 'macd' ]