Many apologies for the inane question, but I just can't seem to figure out why one section of my code won't display an output, and runs seemingly indefinitely. Hopefully it is immediately obvious to someone here, and then I can bang my head against my desk at how obvious it was.
Here is the snippet:
i = 0
j = 0
while i < len(data):
if data['Pos'][i] == 1:
while j < len(data[i+1:]):
if data[i+1:]['Close'][j] >= data['High'][i] or data[i+1:]['Close'][j] <= data['Low'][i]:
print('The position that was opened on date', data.index[i],'was closed on date', data[i+1:].index[j])
j += 1
i += 1
data
is a pandas DataFrame with datetime index, and columns Pos
, Close
, High
and Low
.
Aucun commentaire:
Enregistrer un commentaire