Check if the current buying price is greater than that of the previous transaction
while ( len ( transaction ) != 0 and prices [ buy ] < prices [ transaction [ len ( transaction ) - 1 ] [ 0 ] ] ) : NEW_LINE INDENT p = transaction [ len ( transaction ) - 1 ] NEW_LINE DEDENT