The requirements.txt file contains the necessary Python packages with the versions you need to run the script. Just run $pip install -r requirements.txt to first install everything necessary.
The code could be run in two modes: live data mode (LIVE = 1
), and pre-existing data mode (LIVE = 0
).
If you do not have any pre-existing stock data, do the following:
- Set
get_data = 1
and make sureLIVE = 0
- Change the 'GC=F' in the ticker variable for a ticker of your choice
- Set the start and end times during which the data is required. The data will be obtained from Yahoo finance and the default data interval is 1 day.
- Run the code.
In live data mode, the code uses Selenium to obtain the price data from the desired website(s) through xpath.
Running the code will save a csv file titled "xx.csv", where xx is the ticker, to the local folder your code is in.
The code will calculate a parameter called "threshold" and this parameter will lie in the range [-1, 1]. The threshold is calculated as an average of momentum deciding parameters obtained from 7 technical indicators. The 7 indicators are as follows:
- Moving Average (ma)
- Exponential Moving Average (ema)
- Moving Average Convergence Divergence (macd)
- Bollinger Bands (bb)
- Relative Strength Index (rsi)
- Commodity Channel Index (cci)
- Stochastic Oscillator (si)
The momentum deciding parameters obtained from these 7 indicators also lie in the range [-1, 1]. The momentum deciding parameters are estimated based on the difference between the current and average of previous prices parameter called "diff" and based on variables corresponding to each indicator.
The diff parameter is decided by comparing with a parameter called "min_per_change". min_per_change is the minimum percentage of change required between current price of the stock and the average of previous prices and is set by the user. min_per_change is positive if diff is positive and so on. Thus min_per_change acts as the sensitivity parameter. Fine tuning can be done by adjusting the weights and variables in each technical indicator.