<commit_before>"""
Spyder Editor
"""
import numpy as np
from pandas_datareader import data
import pandas as pd
import time as t
start = t.time()
ticker = '^GSPC'
s = data.DataReader(ticker, 'yahoo', start='01/01/2016', end='01/01/2050') 
#start = t.time() #for timing purposes un-comment this line and lines 56-57
window = 10 #minimum window is 10 days
s['NDayHigh'] = s['Adj Close'].rolling(center=False, window=window).max()
s['NDayHigh'] = s['NDayHigh'].fillna(0)
s['NDayHigh'][:window-1]  = s.loc[:,'NDayHigh'][window]
s['NDayLow'] = s['Adj Close'].rolling(center=False, window=window).min()
s['NDayLow'] = s['NDayLow'].fillna(0)
s['NDayLow'][:window-1]  = s.loc[:,'NDayLow'][window]
s.loc[:,'Ranger'] = range(len(s))
k = pd.DataFrame()
derp = list(s['Adj Close'])
kk = pd.Series(derp,index = range(len(s)))
k['Adj Close'] = kk
listo = []
x = []
for i in s['NDayHigh']:
    x.append(i)
for xx in x:
    xxx = min(k['Adj Close'][k['Adj Close'] == xx].index)
    listo.append(xxx)
listo1 = []
y = []
for ii in s['NDayLow']:
    y.append(ii)
for yy in y:
    yyy = min(k['Adj Close'][k['Adj Close'] == yy].index)
    listo1.append(yyy)
HighIndex = pd.Series(listo,index=s.index)
LowIndex = pd.Series(listo1,index=s.index)
HighDF = pd.DataFrame(HighIndex,columns = ['HighDF'])
LowDF = pd.DataFrame(LowIndex,columns = ['LowDF'])
s = pd.concat([s, HighDF, LowDF], axis = 1)
s['DaysPastHigh'] = s['Ranger'] - s['HighDF']
s['DaysPastLow'] = s['Ranger'] - s['LowDF']
s['AroonUp'] = ((window - s['DaysPastHigh']) / window) * 100
s['AroonDown'] = ((window - s['DaysPastLow']) / window) * 100
s = s[window:]
for q in s['AroonUp']:
    if q < 0:
        print('There is an error, please proceed with caution')
        print('The window size with trouble is ', window)
for qq in s['AroonDown']:
    if qq < 0:
        print('There is an error, please proceed with caution')
        print('The window size with trouble is ', window)
#end = t.time()
#print(end-start)
s[['AroonUp', 'AroonDown']].plot(grid=True, figsize=(8,3))<commit_msg>Update Aroon.py<commit_after>"""
Spyder Editor
"""
from pandas_datareader import data
import pandas as pd
import time as t
start = t.time()
ticker = '^GSPC'
s = data.DataReader(ticker, 'yahoo', start='01/01/2016', end='01/01/2050') 
#start = t.time() #for timing purposes un-comment this line and lines 56-57
window = 25 #minimum practical window days is probably 5
s['NDayHigh'] = s['Adj Close'].rolling(center=False, window=window).max()
s.loc[:,'NDayHigh'] = s['NDayHigh'].fillna(0)
s.loc[:,'NDayHigh'][:window-1]  = s.loc[:,'NDayHigh'][window]
s['NDayLow'] = s['Adj Close'].rolling(center=False, window=window).min()
s.loc[:,'NDayLow'] = s['NDayLow'].fillna(0)
s.loc[:,'NDayLow'][:window-1] = s.loc[:,'NDayLow'][window]
s.loc[:,'Ranger'] = range(len(s))
k = pd.DataFrame()
derp = list(s['Adj Close'])
kk = pd.Series(derp,index = range(len(s)))
k['Adj Close'] = kk
listo = []
x = []
s = s[window:]
for i in s['NDayHigh']:
    x.append(i)
for xx in x:
    xxx = min(k['Adj Close'][k['Adj Close'] == xx].index)
    listo.append(xxx)
listo1 = []
y = []
for ii in s['NDayLow']:
    y.append(ii)
for yy in y:
    yyy = min(k['Adj Close'][k['Adj Close'] == yy].index)
    listo1.append(yyy)
HighIndex = pd.Series(listo,index=s.index)
LowIndex = pd.Series(listo1,index=s.index)
HighDF = pd.DataFrame(HighIndex,columns = ['HighDF'])
LowDF = pd.DataFrame(LowIndex,columns = ['LowDF'])
s = pd.concat([s, HighDF, LowDF], axis = 1)
s.loc[:,'DaysPastHigh'] = s['Ranger'] - s['HighDF']
s['DaysPastLow'] = s['Ranger'] - s['LowDF']
s['AroonUp'] = ((window - s['DaysPastHigh']) / window) * 100
s['AroonDown'] = ((window - s['DaysPastLow']) / window) * 100
z = set(s['AroonUp'])
zz = set(s['AroonDown'])
z1 = sorted(z)
zz1 = sorted(zz)
z2 = [l for l in z1 if l >= 0]
zz2 = [ll for ll in zz1 if ll >= 0]
s.loc[:,'AroonUp'][s['AroonUp'] < 0] = z2[0]
s.loc[:,'AroonDown'][s['AroonDown'] < 0] = zz2[0]
s['Divergence'] = s['AroonUp'] - s['AroonDown']
#end = t.time()
#print(end-start)
s[['AroonUp', 'AroonDown']].plot(grid=True, figsize=(8,3))
{'fraction_non_alphanumeric': 0.2207952580884169, 'fraction_numerical': 0.023462583353914546, 'mean_word_length': 4.895196506550218, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4339791', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1649, 'n_words': 375}