I am using the package from here. What I am trying to do is to calculate the Stochastic value for each ticker. I have the following code:
import lxml
from urllib.request import urlopen
from bs4 import BeautifulSoup
import pandas as pd
from pandas import datetime
from pandas import DataFrame as df
# import matplotlib
from pandas_datareader import data as web
import matplotlib.pyplot as plt
import datetime
import numpy as np
import ta
html = urlopen('https://en.wikipedia.org/wiki/NIFTY_50')
soup = BeautifulSoup(html,'lxml')
niftylist_raw = soup.find('table', {'class': 'wikitable sortable'})
nifty_symbol =[]
for row in niftylist_raw.findAll('tr')[1:]:
nifty_symbols = row.findAll('td')[1].text
nifty_symbol.append(nifty_symbols)
tickerss = nifty_symbol
df = web.DataReader(tickerss, 'yahoo')
stoch1 = ta.momentum.StochasticOscillator(high= df['High'], low = df['Low'], close = df['Close'], n=14, fillna=False)
The above code works, however when I try:
stoch1.stoch()
It produces the following error:
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
What can I do to fix this error?