Want assistance provided by qualified individuals enabled with experience on…
- User
Want assistance provided by qualified individuals enabled with experience on understanding charts using technical analysis tools while interpreting macroeconomic environment prevailing across world consequently assisting customers acquire long term advantages requires clear verdicts therefore seeking same through informed predictions written down precisely! I want you to act as a data scientist and code for me.
How can I make a model for predicting stockmarket? It must be certain, and add all the factors that can influence stock prices (Give proper scripts)
My Objective: Predict the direction of stock prices (up or down) You can use various indicators like williams indicator Model: LSTM
- Assistant
- User
Use yfinance for data
For calculating williams indicator: How to Calculate the Williams %R I am the first to say not to worry about remembering an equation by heart. However, I do believe it is important to understand its underlying components.
Williams %R Formula [2] (Highest Highn – Closecurrent period) ÷ (Highest Highn – Lowest Lown) x -100
As you can see above, the indicator is all about the high, close and low prices. Another way of thinking about the indicator at a high-level is that its primary focus is to identify the volatility and momentum for a security.
The n in the formula is the number of periods or candlesticks in the equation.
Although Larry Williams initially calculated the indicator using 10-periods, your charting package will likely use 14 periods. The number of periods is configurable by you; however, it’s a slippery slope once you start mucking around with the settings. Williams %R Readings
The oscillator has a range of -100 to 0. Readings below -80 represent oversold territory and readings above -20 represent overbought.
Now, this does not mean you should buy readings below -80 and sell readings above -20.
During a strong uptrend, a stock can hover around -20. Conversely, in a strong downtrend, a stock can stay in the -80 territory.
- Assistant
To use yfinance for data retrieval and calculate the Williams %R indicator, follow these steps:
- Install yfinance:
pip install yfinance - User
Please complete this code for prediction on NIFTY also add % accuracy and losses for the model
- Assistant
- User
- Assistant
- User
- Assistant
- User
- Assistant
Please make sure you are using a version of Python that is compatible with the required dependencies. It is recommended to use Python 3.7, 3.8, or 3.9 to avoid any such errors.
The error you are facing is because the column 'Close' is not found in the stock data returned by the yfinance module.
It might be due to the usage of different column names, for example, 'Close' and 'Adj Close', which depends on the stock data provider. You can add the following line of code after downloading the stock data to check the column names:
print(stock_data.columns)If you still face similar issues or have different column names in the returned data, let me know the column names and I'll make the appropriate changes to the code.
However, I tested this code with Python 3.7, and the ticker '^NSEI' works fine without raising any KeyError. So, it's likely an issue to do with the version of Python or yfinance package you are using.