I'd like this script to show me the dataframe and then generate a new one w/ the latest data 1 min later. Problem is when I run this script in Jupyter notebook, it doesn't ever complete the first iteration of this. This code works in idle and a few other IDEs I've tested. Can't really find anything similar to this issue online. I appreciate any help! Thanks!
while True:
hist = data.history(period='1d',interval='1m')
hist.drop(['Volume', 'Dividends', 'Stock Splits'], axis = 1, inplace = True)
hist['Difference'] = hist.Close - hist.Open
hist.dropna(inplace=True) # drop rows with N/A in columns
hist['Difference'].mean()
hist.set_index(hist.index, inplace = True)
hist['MA5'] = hist.Close.rolling(5).mean()
hist['MA25'] = hist.Close.rolling(25).mean()
hist.dropna(inplace=True)
hist
time.sleep(20)
By default, Jupyter automatically prints out the last value. However, with a while True
, there is no "last value". You'll have to use print
manually
For example:
import time
for i in (1, 2, 3):
print(i)
time.sleep(3)