Giter VIP home page Giter VIP logo

stock_market_indicators's People

Contributors

voice32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stock_market_indicators's Issues

AttributeError: 'DataFrame' object has no attribute 'set_value'

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

/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?

NameError: name 'ema' is not defined

Dear all. When executing the function that calculates the MACD, it gives me the following error show on the titlle.

`import pandas as pd
import yfinance as yf

def macd(data, period_long=26, period_short=12, period_signal=9, column='Close'):
remove_cols = []
if not 'ema' + str(period_long) in data.columns:
data = ema(data, period_long)
remove_cols.append('ema' + str(period_long))

if not 'ema' + str(period_short) in data.columns:
    data = ema(data, period_short)
    remove_cols.append('ema' + str(period_short))

data['macd_val'] = data['ema' + str(period_short)] - data['ema' + str(period_long)]
data['macd_signal_line'] = data['macd_val'].ewm(ignore_na=False, min_periods=0, com=period_signal, adjust=True).mean()

data = data.drop(remove_cols, axis=1)
    
return data

data = yf.download('AAPL', start= '2016-1-4', end = '2021-12-30')

data = macd(data, period_long=26, period_short=12, period_signal=9, column='Close')
data

NameError Traceback (most recent call last)
/tmp/ipykernel_12947/116451859.py in
21 data = yf.download('AAPL', start= '2016-1-4', end = '2021-12-30')
22
---> 23 data = macd(data, period_long=26, period_short=12, period_signal=9, column='Close')
24 data

/tmp/ipykernel_12947/116451859.py in macd(data, period_long, period_short, period_signal, column)
5 remove_cols = []
6 if not 'ema' + str(period_long) in data.columns:
----> 7 data = ema(data, period_long)
8 remove_cols.append('ema' + str(period_long))
9

NameError: name 'ema' is not defined`

I don't understand this error. I will appreciate clarification

I don't understand this error.

chaikin_oscillator

  1. Money Flow Multiplier = [(Close - Low) - (High - Close)] /(High - Low)

  2. Money Flow Volume = Money Flow Multiplier x Volume for the Period

  3. ADL = Previous ADL + Current Period's Money Flow Volume

  4. Chaikin Oscillator = (3-day EMA of ADL) - (10-day EMA of ADL)


Функция не учитывает предыдущее значение ADL, а в целом спасибо!
ADL = Previous ADL + Current Period's Money Flow Volume

def chaikin_oscillator(data, periods_short=3, periods_long=10, high_col='',
low_col='', close_col='', vol_col=''):
ac = pd.Series([])
val_last = 0
for index, row in data.iterrows():
if row[high_col] != row[low_col]:
val = val_last + ((row[close_col] - row[low_col]) - (row[high_col] - row[close_col])) / (row[high_col] - row[low_col]) * row[vol_col]
else:
val = val_last
ac.set_value(index, val)
val_last = val
ema_long = ac.ewm(ignore_na=False, min_periods=0, com=periods_long, adjust=True).mean()
ema_short = ac.ewm(ignore_na=False, min_periods=0, com=periods_short, adjust=True).mean()
data['ch_osc'] = ema_short - ema_long

return data

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.