dimanche 16 octobre 2016

Best Way to Use Back-to-Back if Statements That Rely on the Same Variable

I am working on a script that streams real time data and appends it to numpy arrays. If the array is a certain length, I will use it as a trigger to perform another action. However I noticed sometimes they cancel one and other. To give an example:

if len(closeBidArray) > 20:
    execution_logic()   

if len(closeBidArray) > 1:  
    # spreadsheet_append 
    data = "%s" % (closeBidArray[-1])
    ayTools.spreadsheet_append(fileName, data)  

closeBidArray = np.append(closeBidArray, bidPrice)

Given the example above, so long as closeBidArray is less than 20 it does not trigger the execution logic, but does do spreadsheet_append and appends to the numpy array (as seen in the last line above). However, if the length of closeBidArray is greater than 20, that when it refuses to perform spreadsheet_append nor will it append to numpy array, despite the fact that both of those tasks are set to take place after. Any ideas on where I am going astray? Thanks

Aucun commentaire:

Enregistrer un commentaire