Thanks for sharing this work. I try to understand it by running some sscripts. In the script for calculating the 'Accumulation Distribution', it returns the error that I mention in the title.
`import pandas as pd
import yfinance as yf
Accumulation Distribution
def acc_dist(data, trend_periods=21, open_col='Open', high_col='High', low_col='Low', close_col='Close', vol_col='Volume'):
for index, row in data.iterrows():
if row[high_col] != row[low_col]:
ac = ((row[close_col] - row[low_col]) - (row[high_col] - row[close_col])) / (row[high_col] - row[low_col]) * row[vol_col]
else:
ac = 0
data.set_value(index, 'acc_dist', ac)
data['acc_dist_ema' + str(trend_periods)] = data['acc_dist'].ewm(ignore_na=False, min_periods=0, com=trend_periods, adjust=True).mean()
return data
n = 14
data = df = yf.download('AAPL', start= start_day, end = end_day)
data = acc_dist(df_val, trend_periods=21, open_col='Open>', high_col='High', low_col='Low', close_col=nom_val, vol_col='Volume')
`
Me devuelve,
`[*100%***] 1 of 1 completed
AttributeError Traceback (most recent call last)
/tmp/ipykernel_2963/3008653052.py in
33
34 data = df = yf.download('AAPL', start= start_day, end = end_day)
---> 35 data = acc_dist(df_val, trend_periods=21, open_col='Open>', high_col='High', low_col='Low', close_col=nom_val, vol_col='Volume')
36
Thanks for sharing this work. I try to understand it by running some sscripts. In the script for calculating the 'Accumulation Distribution', it returns the error that I mention in the title.
`import pandas as pd import yfinance as yf
Accumulation Distribution
def acc_dist(data, trend_periods=21, open_col='Open', high_col='High', low_col='Low', close_col='Close', vol_col='Volume'): for index, row in data.iterrows(): if row[high_col] != row[low_col]: ac = ((row[close_col] - row[low_col]) - (row[high_col] - row[close_col])) / (row[high_col] - row[low_col]) * row[vol_col] else: ac = 0 data.set_value(index, 'acc_dist', ac) data['acc_dist_ema' + str(trend_periods)] = data['acc_dist'].ewm(ignore_na=False, min_periods=0, com=trend_periods, adjust=True).mean()
n = 14 data = df = yf.download('AAPL', start= start_day, end = end_day) data = acc_dist(df_val, trend_periods=21, open_col='Open>', high_col='High', low_col='Low', close_col=nom_val, vol_col='Volume')
` Me devuelve,
`[*100%***] 1 of 1 completed
AttributeError Traceback (most recent call last) /tmp/ipykernel_2963/3008653052.py in
33
34 data = df = yf.download('AAPL', start= start_day, end = end_day)
---> 35 data = acc_dist(df_val, trend_periods=21, open_col='Open>', high_col='High', low_col='Low', close_col=nom_val, vol_col='Volume')
36
/tmp/ipykernel_2963/3008653052.py in acc_dist(data, trend_periods, open_col, high_col, low_col, close_col, vol_col) 27 else: 28 ac = 0 ---> 29 data.set_value(index, 'acc_dist', ac) 30 data['acc_dist_ema' + str(trend_periods)] = data['acc_dist'].ewm(ignore_na=False, min_periods=0, com=trend_periods, adjust=True).mean() 31
~/anaconda3/envs/yfinance/lib/python3.9/site-packages/pandas/core/generic.py in getattr(self, name) 5485 ): 5486 return self[name] -> 5487 return object.getattribute(self, name) 5488 5489 def setattr(self, name: str, value) -> None:
AttributeError: 'DataFrame' object has no attribute 'set_value'`
What can be the cause?