Skip to content

Commit

Permalink
Merging for v1.11 - Reversal Signals and Performance Improvements
Browse files Browse the repository at this point in the history
[Screenipy Test] New Features Added - Test Passed
  • Loading branch information
pranjal-joshi authored May 8, 2021
2 parents d648fe0 + d55cc0b commit 3490077
Show file tree
Hide file tree
Showing 15 changed files with 329 additions and 123 deletions.
51 changes: 0 additions & 51 deletions .github/workflows/workflow-build-macos.yml

This file was deleted.

14 changes: 13 additions & 1 deletion .github/workflows/workflow-build-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Created : 30/04/2021
# Description : Workflow for building screenipy on pushing a tag

name: Screenipy Build & Release
name: Screenipy Build - New Release

on:
push:
Expand All @@ -27,6 +27,7 @@ jobs:
pyinstaller --onefile --icon=src\icon.ico src\screenipy.py --hidden-import cmath --hidden-import talib.stream
DEP_BUILD: |
python -m pip install --upgrade pip
echo Installing TA-lib...
cd .github/dependencies/
echo %cd%
pip install TA_Lib-0.4.19-cp39-cp39-win_amd64.whl
Expand Down Expand Up @@ -82,6 +83,17 @@ jobs:
with:
python-version: 3.9.4

- name: Load Cache for Linux Dependencies
uses: actions/cache@v2
if: startsWith(runner.os, 'Linux')
with:
path: |
/usr/include/ta-lib
/usr/bin/ta-lib-config
key: ${{ runner.os }}-talib
restore-keys: |
${{ runner.os }}-talib
- name: Install dependencies for ${{ matrix.TARGET }}
run: ${{ matrix.DEP_BUILD }}

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/workflow-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,27 @@ jobs:
with:
python-version: 3.9.4

- name: Restore Dependencies from Cache
uses: actions/cache@v2
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies for TA-Lib
run: |
python -m pip install --upgrade pip
cd .github/dependencies/
echo %cd%
pip install TA_Lib-0.4.19-cp39-cp39-win_amd64.whl
# - name: Install Numpy-MKL for Windows
# run: |
# echo Downloading Numpy-MKL (212MB), Please wait!
# powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('https://download.lfd.uci.edu/pythonlibs/w4tscw6k/numpy-1.20.2+mkl-cp39-cp39-win_amd64.whl','numpy-1.20.2+mkl-cp39-cp39-win_amd64.whl')
# pip install numpy-1.20.2+mkl-cp39-cp39-win_amd64.whl

- name: Install dependencies using pip
run: |
python -m pip install --upgrade pip
Expand Down
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue with owner or other contributers.

## Install Project Dependencies

* This project uses [**TA-Lib**](https://github.com/mrjbq7/ta-lib). Please visit the hyperlink for the official guide of installation.

## Create Dependency Requirements

1. Install [**pip-chill**](https://pypi.org/project/pip-chill/) by running `pip install pip-chill` which is a developer friendly version of classic `pip freeze`.
2. Update the `requirements.txt` file by running `pip-chill --all --no-version -v > requirements.txt`.
3. Ensure to **uncomment** all the dependency modules from the `requirements.txt`

## Pull Request Process

1. Ensure that dependecy list have been generated in the `requirements.txt` using above section.
2. If you are contributing new feature or a bug-fix, Always create a Pull Request to `new-features` branch as it have workflows to test the source before merging with the `main`.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Screeni-py
![GitHub release (latest by date)](https://img.shields.io/github/v/release/pranjal-joshi/Screeni-py) ![GitHub all releases](https://img.shields.io/github/downloads/pranjal-joshi/Screeni-py/total?color=Green&label=Downloads) ![GitHub](https://img.shields.io/github/license/pranjal-joshi/Screeni-py)

[![Screenipy Test - New Features](https://github.com/pranjal-joshi/Screeni-py/actions/workflows/workflow-test.yml/badge.svg?branch=new-features)](https://github.com/pranjal-joshi/Screeni-py/actions/workflows/workflow-test.yml) [![Screenipy Build & Release](https://github.com/pranjal-joshi/Screeni-py/actions/workflows/workflow-build-matrix.yml/badge.svg)](https://github.com/pranjal-joshi/Screeni-py/actions/workflows/workflow-build-matrix.yml) ![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/pranjal-joshi/Screeni-py)
[![Screenipy Test - New Features](https://github.com/pranjal-joshi/Screeni-py/actions/workflows/workflow-test.yml/badge.svg?branch=new-features)](https://github.com/pranjal-joshi/Screeni-py/actions/workflows/workflow-test.yml) [![Screenipy Build - New Release](https://github.com/pranjal-joshi/Screeni-py/actions/workflows/workflow-build-matrix.yml/badge.svg)](https://github.com/pranjal-joshi/Screeni-py/actions/workflows/workflow-build-matrix.yml) ![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/pranjal-joshi/Screeni-py)


## [Quick Download](https://github.com/pranjal-joshi/Screeni-py/releases/latest)
Expand Down Expand Up @@ -46,12 +46,11 @@ onlystagetwostocks = y
```
Try to tweak this parameters as per your trading styles. For example, If you're comfortable with weekly charts, make `duration=5d` and so on.

## Contributing:
* Please feel free to Suggest improvements bugs by creating an issue.
* Please follow the [Guidelines for Contributing](https://github.com/pranjal-joshi/Screeni-py/blob/new-features/CONTRIBUTING.md) while making a Pull Request.

## Disclaimer:
* DO NOT use the result provided by the software 'solely' to make your trading decisions.
* Always backtest and analyze the stocks manually before you trade.
* The Author and the software will not be held liable for your losses.

## Contribution:
Please feel free to Suggest improvements and post known bugs in issue.

PRs will be welcome if you are contributing with the source code.
38 changes: 26 additions & 12 deletions src/classes/CandlePatterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
from classes.ColorText import colorText

class CandlePatterns:

reversalPatternsBullish = ['Morning Star', 'Morning Doji Star', '3 Inside Up', 'Hammer', '3 White Soldiers', 'Bullish Engulfing', 'Dragonfly Doji']
reversalPatternsBearish = ['Evening Star', 'Evening Doji Star', '3 Inside Down', 'Inverted Hammer', 'Hanging Man', '3 Black Crows', 'Bearish Engulfing', 'Shooting Star', 'Gravestone Doji']

def __init__(self):
pass

Expand Down Expand Up @@ -68,6 +72,16 @@ def findPattern(self, data, dict, saveDict):
saveDict['Pattern'] = '3 Black Crows'
return True

check = talib.CDL3INSIDE(data['Open'], data['High'], data['Low'], data['Close'])
if(check.tail(1).item() != 0):
if(check.tail(1).item() > 0):
dict['Pattern'] = colorText.BOLD + colorText.GREEN + '3 Outside Up' + colorText.END
saveDict['Pattern'] = '3 Inside Up'
else:
dict['Pattern'] = colorText.BOLD + colorText.FAIL + '3 Outside Down' + colorText.END
saveDict['Pattern'] = '3 Inside Down'
return True

check = talib.CDL3OUTSIDE(data['Open'], data['High'], data['Low'], data['Close'])
if(check.tail(1).item() != 0):
if(check.tail(1).item() > 0):
Expand All @@ -84,16 +98,6 @@ def findPattern(self, data, dict, saveDict):
saveDict['Pattern'] = '3 White Soldiers'
return True

check = talib.CDLENGULFING(data['Open'], data['High'], data['Low'], data['Close'])
if(check.tail(1).item() != 0):
if(check.tail(1).item() > 0):
dict['Pattern'] = colorText.BOLD + colorText.GREEN + 'Bullish Engulfing' + colorText.END
saveDict['Pattern'] = 'Bullish Engulfing'
else:
dict['Pattern'] = colorText.BOLD + colorText.FAIL + 'Bearish Engulfing' + colorText.END
saveDict['Pattern'] = 'Bearish Engulfing'
return True

check = talib.CDLHARAMI(data['Open'], data['High'], data['Low'], data['Close'])
if(check.tail(1).item() != 0):
if(check.tail(1).item() > 0):
Expand Down Expand Up @@ -126,8 +130,8 @@ def findPattern(self, data, dict, saveDict):

check = talib.CDLHANGINGMAN(data['Open'], data['High'], data['Low'], data['Close'])
if(check.tail(1).item() != 0):
dict['Pattern'] = colorText.BOLD + colorText.FAIL + 'Inverted Hammer' + colorText.END
saveDict['Pattern'] = 'Inverted Hammer'
dict['Pattern'] = colorText.BOLD + colorText.FAIL + 'Hanging Man' + colorText.END
saveDict['Pattern'] = 'Hanging Man'
return True

check = talib.CDLHAMMER(data['Open'], data['High'], data['Low'], data['Close'])
Expand Down Expand Up @@ -166,6 +170,16 @@ def findPattern(self, data, dict, saveDict):
saveDict['Pattern'] = 'Doji'
return True

check = talib.CDLENGULFING(data['Open'], data['High'], data['Low'], data['Close'])
if(check.tail(1).item() != 0):
if(check.tail(1).item() > 0):
dict['Pattern'] = colorText.BOLD + colorText.GREEN + 'Bullish Engulfing' + colorText.END
saveDict['Pattern'] = 'Bullish Engulfing'
else:
dict['Pattern'] = colorText.BOLD + colorText.FAIL + 'Bearish Engulfing' + colorText.END
saveDict['Pattern'] = 'Bearish Engulfing'
return True

dict['Pattern'] = ''
saveDict['Pattern'] = ''
return False
8 changes: 7 additions & 1 deletion src/classes/Changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from classes.ColorText import colorText

VERSION = "1.10"
VERSION = "1.11"

changelog = colorText.BOLD + '[ChangeLog]\n' + colorText.END + colorText.BLUE + '''
[1.00 - Beta]
Expand Down Expand Up @@ -61,5 +61,11 @@
[1.10]
1. Trend detection for the timeframe of analysis added.
[1.11]
1. Option-6 -> Screen for stocks showing Reversal Signal added
2. Stage-2 Screening logic improved for identifying best stocks only.
3. Trend detection has been improved.
4. Bugs and Runtime warnings fixed.
--- END ---
''' + colorText.END
31 changes: 21 additions & 10 deletions src/classes/Fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
import classes.ConfigManager as ConfigManager
from nsetools import Nse
from classes.ColorText import colorText
from classes.SuppressOutput import SuppressOutput

listStockCodes = []
screenCounter = 1
nse = Nse()

# Exception class if yfinance stock delisted
class StockDataEmptyException(Exception):
pass

# This Class Handles Fetching of Stock Data over the internet
class tools:

Expand All @@ -38,32 +43,38 @@ def fetchStockCodes(executeOption):
print(colorText.GREEN + ("=> Done! Fetched %d stock codes." % len(listStockCodes)) + colorText.END)
if ConfigManager.shuffleEnabled:
random.shuffle(listStockCodes)
print(colorText.WARN + "[+] Stock shuffling is active." + colorText.END)
print(colorText.BLUE + "[+] Stock shuffling is active." + colorText.END)
else:
print(colorText.FAIL + "[+] Stock shuffling is inactive." + colorText.END)
if ConfigManager.stageTwo:
print(colorText.BLUE + "[+] Screening only for the stocks in Stage-2! Edit User Config to change this." + colorText.END)
else:
print(colorText.WARN + "[+] Stock shuffling is inactive." + colorText.END)
print(colorText.FAIL + "[+] Screening only for the stocks in all Stages! Edit User Config to change this." + colorText.END)

else:
input(colorText.FAIL + "=> Error getting stock codes from NSE! Press any key to exit!" + colorText.END)
sys.exit("Exiting script..")

# Fetch stock price data from Yahoo finance
def fetchStockData(stockCode, period, duration, proxyServer, screenResults):
global screenCounter
data = yf.download(
tickers = stockCode+".NS",
period = period,
duration = duration,
proxy = proxyServer,
progress=False
)
with SuppressOutput(suppress_stdout = True, suppress_stderr = True):
data = yf.download(
tickers = stockCode+".NS",
period = period,
duration = duration,
proxy = proxyServer,
progress=False
)
sys.stdout.write("\r\033[K")
try:
print(colorText.BOLD + colorText.GREEN + ("[%d%%] Screened %d, Found %d. Fetching data & Analyzing %s..." % (int(screenCounter/len(listStockCodes)*100), screenCounter, len(screenResults), stockCode)) + colorText.END, end='')
except ZeroDivisionError:
pass
if len(data) == 0:
print(colorText.BOLD + colorText.FAIL + "=> Failed to fetch!" + colorText.END, end='\r', flush=True)
raise StockDataEmptyException
return None
print(colorText.BOLD + colorText.GREEN + "=> Done!" + colorText.END, end='\r', flush=True)
screenCounter += 1
return data

2 changes: 1 addition & 1 deletion src/classes/OtaUpdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def updateForLinux(url):
echo "[+] Screenipy Software Updater!"
echo "[+] Downloading Software Update..."
echo "[+] This may take some time as per your Internet Speed, Please Wait..."
echo "[+] Newly downloaded file saved in $(pwd)"
wget -q """ + url + """ -O screenipy.bin
echo "[+] Newly downloaded file saved in $(pwd)"
echo "[+] Update Completed! Run 'screenipy.bin' again as usual to continue.."
rm updater.sh
"""
Expand Down
Loading

0 comments on commit 3490077

Please sign in to comment.