Skip to content

Commit

Permalink
v2.04 - Moved to TA-Lib-Precompiled (0.4.25), Progressbar for GUI
Browse files Browse the repository at this point in the history
v2.04 - Moved to TA-Lib-Precompiled (0.4.25), Progressbar for GUI
- TA-Lib-Precompiled added instead of building from source for faster docker builds
- TA-Lib-Precompiled(v0.4.25) now replaces TA-Lib installation using source for test and build workflows, test workflow moved to ubuntu runner
- test runner downgraded to ubuntu-20.04
- OTA checking cached for every 1h to eliminate Github API quota
- progressbar added to GUI, counter shared from env vars
- progressbar errors handled
- matrix build disabled and moved to ubuntu-latest

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: pranjal-joshi <joshi.pranjal5@gmail.com>
  • Loading branch information
github-actions[bot] and pranjal-joshi authored Oct 6, 2023
1 parent 2c2f250 commit 23eb860
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 108 deletions.
129 changes: 65 additions & 64 deletions .github/workflows/workflow-build-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,72 +14,73 @@ on:
jobs:

# Job for builing packages
Build-Executables:
name: Build Packages (Disabled onwards v2.03)
Build-Executables-(Disabled onwards v2.03):
name: Build Packages
runs-on: ubuntu-latest
#needs: Create-Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
TARGET: Windows
CMD_BUILD: |
pyinstaller --onefile --icon=src\icon.ico src\screenipy.py --hidden-import cmath --hidden-import talib.stream --hidden-import numpy --hidden-import pandas --hidden-import alive-progress --hidden-import alive_progress --hidden-import chromadb
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
cd ..
cd ..
python -m pip install --upgrade pip
pip install -r requirements.txt
TEST_BUILD: |
./dist/screenipy.exe --testbuild
exit $?
OUT_PATH: .\dist\screenipy.exe
FILE_NAME: screenipy.exe
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# include:
# - os: windows-latest
# TARGET: Windows
# CMD_BUILD: |
# pyinstaller --onefile --icon=src\icon.ico src\screenipy.py --hidden-import cmath --hidden-import talib.stream --hidden-import numpy --hidden-import pandas --hidden-import alive-progress --hidden-import alive_progress --hidden-import chromadb
# 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
# cd ..
# cd ..
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# TEST_BUILD: |
# ./dist/screenipy.exe --testbuild
# exit $?
# OUT_PATH: .\dist\screenipy.exe
# FILE_NAME: screenipy.exe

- os: ubuntu-20.04
TARGET: Linux
CMD_BUILD: |
pyinstaller --onefile --icon=src/icon.ico src/screenipy.py --hidden-import cmath --hidden-import talib.stream --hidden-import numpy --hidden-import pandas --hidden-import alive-progress --hidden-import alive_progress --hidden-import chromadb
mv /home/runner/work/Screeni-py/Screeni-py/dist/screenipy /home/runner/work/Screeni-py/Screeni-py/dist/screenipy.bin
chmod +x /home/runner/work/Screeni-py/Screeni-py/dist/screenipy.bin
DEP_BUILD: |
cd .github/dependencies/
pwd
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install
cd /home/runner/work/Screeni-py/Screeni-py/
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ta-lib==0.4.24
TEST_BUILD: |
/home/runner/work/Screeni-py/Screeni-py/dist/screenipy.bin --testbuild
exit $?
OUT_PATH: /home/runner/work/Screeni-py/Screeni-py/dist/screenipy.bin
FILE_NAME: screenipy.bin

- os: macos-latest
TARGET: MacOS
CMD_BUILD: |
pyinstaller --onefile --windowed --icon=src/icon.ico src/screenipy.py --hidden-import cmath --hidden-import talib.stream --hidden-import numpy --hidden-import pandas --hidden-import alive-progress --hidden-import alive_progress --hidden-import chromadb
mv /Users/runner/work/Screeni-py/Screeni-py/dist/screenipy /Users/runner/work/Screeni-py/Screeni-py/dist/screenipy.run
DEP_BUILD: |
brew install ta-lib
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ta-lib==0.4.24
TEST_BUILD: |
/Users/runner/work/Screeni-py/Screeni-py/dist/screenipy.run --testbuild
exit $?
OUT_PATH: /Users/runner/work/Screeni-py/Screeni-py/dist/screenipy.run
FILE_NAME: screenipy.run
# - os: ubuntu-20.04
# TARGET: Linux
# CMD_BUILD: |
# pyinstaller --onefile --icon=src/icon.ico src/screenipy.py --hidden-import cmath --hidden-import talib.stream --hidden-import numpy --hidden-import pandas --hidden-import alive-progress --hidden-import alive_progress --hidden-import chromadb
# mv /home/runner/work/Screeni-py/Screeni-py/dist/screenipy /home/runner/work/Screeni-py/Screeni-py/dist/screenipy.bin
# chmod +x /home/runner/work/Screeni-py/Screeni-py/dist/screenipy.bin
# DEP_BUILD: |
# cd .github/dependencies/
# pwd
# tar -xzf ta-lib-0.4.0-src.tar.gz
# cd ta-lib/
# ./configure --prefix=/usr
# make
# sudo make install
# cd /home/runner/work/Screeni-py/Screeni-py/
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# pip install ta-lib==0.4.24
# TEST_BUILD: |
# /home/runner/work/Screeni-py/Screeni-py/dist/screenipy.bin --testbuild
# exit $?
# OUT_PATH: /home/runner/work/Screeni-py/Screeni-py/dist/screenipy.bin
# FILE_NAME: screenipy.bin

# - os: macos-latest
# TARGET: MacOS
# CMD_BUILD: |
# pyinstaller --onefile --windowed --icon=src/icon.ico src/screenipy.py --hidden-import cmath --hidden-import talib.stream --hidden-import numpy --hidden-import pandas --hidden-import alive-progress --hidden-import alive_progress --hidden-import chromadb
# mv /Users/runner/work/Screeni-py/Screeni-py/dist/screenipy /Users/runner/work/Screeni-py/Screeni-py/dist/screenipy.run
# DEP_BUILD: |
# brew install ta-lib
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# pip install ta-lib==0.4.24
# TEST_BUILD: |
# /Users/runner/work/Screeni-py/Screeni-py/dist/screenipy.run --testbuild
# exit $?
# OUT_PATH: /Users/runner/work/Screeni-py/Screeni-py/dist/screenipy.run
# FILE_NAME: screenipy.run

steps:
- uses: actions/checkout@v4
Expand Down
17 changes: 1 addition & 16 deletions .github/workflows/workflow-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# Test the source-code
Test-Source:

runs-on: windows-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4
Expand All @@ -35,25 +35,10 @@ jobs:
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
pip install flake8 pytest pytest-mock
pip install numpy==1.21.0
pip install ta-lib
pip install -r requirements.txt
- name: Lint with flake8
Expand Down
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ WORKDIR /opt/program

RUN chmod +x *

WORKDIR /opt/program/.github/dependencies/
RUN tar -xzf ta-lib-0.4.0-src.tar.gz
# Removed build ta-lib from source as we're using [pip3 install TA-Lib-Precompiled] for faster docker build

WORKDIR /opt/program/.github/dependencies/ta-lib/
RUN ./configure --prefix=/usr --build=$(uname -m)-unknown-linux-gnu
RUN make
RUN make install
# WORKDIR /opt/program/.github/dependencies/
# RUN tar -xzf ta-lib-0.4.0-src.tar.gz

# WORKDIR /opt/program/.github/dependencies/ta-lib/
# RUN ./configure --prefix=/usr --build=$(uname -m)-unknown-linux-gnu
# RUN make
# RUN make install

WORKDIR /opt/program/
RUN python3 -m pip install --upgrade pip
# RUN pip3 install ta-lib==0.4.24

RUN pip3 install -r "requirements.txt"

Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
| ![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white) ![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black) ![Mac OS](https://img.shields.io/badge/mac%20os-D3D3D3?style=for-the-badge&logo=apple&logoColor=000000) ![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge&logo=docker&logoColor=white) |
| <img width="240" src="https://user-images.githubusercontent.com/6128978/217814499-7934edf6-fcc3-46d7-887e-7757c94e1632.png"><h2>Scan QR Code to join [Official Telegram Group](https://t.me/+0Tzy08mR0do0MzNl) for Additional Discussions</h2> |

| **Download** | **Use** | **Discussion** | **Bugs/Issues** | **Documentation** |
| **YouTube** | **Use** | **Discussion** | **Bugs/Issues** | **Documentation** |
| :---: | :---: | :---: | :---: | :---: |
| [![cloud-computing (1)](https://user-images.githubusercontent.com/6128978/149935359-ca0a7155-d1e3-4e47-98e8-67f879e707e7.png)](https://github.com/pranjal-joshi/Screeni-py/releases/latest) | [![docker](https://github.com/pranjal-joshi/Screeni-py/assets/6128978/f44054b8-9fcb-465c-a38b-63f6ecc4a0c9)](https://hub.docker.com/r/joshipranjal/screeni-py/tags) | [![meeting](https://user-images.githubusercontent.com/6128978/149935812-31266023-cc5b-4c98-a416-1d4cf8800c0c.png)](https://github.com/pranjal-joshi/Screeni-py/discussions) | [![warning](https://user-images.githubusercontent.com/6128978/149936142-04d7cf1c-5bc5-45c1-a8e4-015454a2de48.png)](https://github.com/pranjal-joshi/Screeni-py/issues?q=is%3Aissue) | [![help](https://user-images.githubusercontent.com/6128978/149937331-5ee5c00a-748d-4fbf-a9f9-e2273480d8a2.png)](https://github.com/pranjal-joshi/Screeni-py/blob/main/README.md#what-is-screeni-py) |
| Download the Latest Version (DEPRECATED) | Get started quickly using Docker | Join/Read the Community Discussion | Raise an Issue about a Problem | Get Help about Usage |
| [![youtube](https://github.com/pranjal-joshi/Screeni-py/assets/6128978/9673bbcf-4798-48f4-918d-692b90e28d37)](https://www.youtube.com/playlist?list=PLsGnKKT_974J3UVS8M6bxqePfWLeuMsBi) | [![docker](https://github.com/pranjal-joshi/Screeni-py/assets/6128978/f44054b8-9fcb-465c-a38b-63f6ecc4a0c9)](https://hub.docker.com/r/joshipranjal/screeni-py/tags) | [![meeting](https://user-images.githubusercontent.com/6128978/149935812-31266023-cc5b-4c98-a416-1d4cf8800c0c.png)](https://github.com/pranjal-joshi/Screeni-py/discussions) | [![warning](https://user-images.githubusercontent.com/6128978/149936142-04d7cf1c-5bc5-45c1-a8e4-015454a2de48.png)](https://github.com/pranjal-joshi/Screeni-py/issues?q=is%3Aissue) | [![help](https://user-images.githubusercontent.com/6128978/149937331-5ee5c00a-748d-4fbf-a9f9-e2273480d8a2.png)](https://github.com/pranjal-joshi/Screeni-py/blob/main/README.md#what-is-screeni-py) |
| Watch our [YouTube](https://www.youtube.com/playlist?list=PLsGnKKT_974J3UVS8M6bxqePfWLeuMsBi) playlist | Get started quickly using Docker | Join/Read the Community Discussion | Raise an Issue about a Problem | Get Help about Usage |

<!-- ## [**Click to Download the Latest Version**](https://github.com/pranjal-joshi/Screeni-py/releases/latest) -->

Expand All @@ -23,6 +23,9 @@
Screenipy is totally customizable and it can screen stocks with the settings that you have provided.

## How to use? (New Version - GUI Based)

[![Screeni-py - Configuration and Usage | Screenipy - Python NSE Stock Screener](https://markdown-videos-api.jorgenkh.no/url?url=https%3A%2F%2Fyoutu.be%2FJCn6z1A7INI)](https://youtu.be/JCn6z1A7INI)

* Install Docker Desktop and pull the `latest` docker image from the [release](https://github.com/pranjal-joshi/Screeni-py/releases/latest) page.
* Checkout this [YouTube Video](https://youtu.be/2HMN0ac4H20) for detailed installation guide.

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ pytest-mock
pytoml
retrying
scipy==1.11.2
ta-lib
# ta-lib
TA-Lib-Precompiled
tabulate
yfinance==0.1.87
alive-progress==1.6.2
Expand Down
12 changes: 10 additions & 2 deletions 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 = "2.03"
VERSION = "2.04"

changelog = colorText.BOLD + '[ChangeLog]\n' + colorText.END + colorText.BLUE + '''
[1.00 - Beta]
Expand Down Expand Up @@ -218,6 +218,14 @@
[2.03]
1. AI based Nifty-50 Gap up/down prediction added to GUI
2. Cosmetic updates and minor bug-fixes.
2. Cosmetic updates and minor bug-fixes
3. Search Similar Stock Added
4. Executables Deprecated now onwards
[2.04]
1. OTA update fixed - caching added in GUI
2. Moved to TA-Lib-Precompiled (0.4.25)
3. Progressbar added for screening to GUI
4. Documentation updated
''' + colorText.END
10 changes: 6 additions & 4 deletions src/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ Celebrating more than 7K+ Downloads - Thank You for your support :tada:
⚠️ **Executable files (.exe, .bin and .run) are now DEPRECATED! Please Switch to Docker**

1. **Search Similar Stocks** Added using Vector Similarity search - Try `Search Similar Stocks`.
2. New Index - **F&O Stocks Only** Added for F&O traders with modified screening criterias.
3. **Artificial Intelligence v2 for Nifty 50 Prediction** - Predict Next day Gap-up/down - Try `Select Index for Screening > N`
4. New Screener **Buy at Trendline** added for Swing/Mid/Long term traders - Try `Option > 7 > 5`.
2. Progressbar added for Screener in GUI mode!
3. New Index - **F&O Stocks Only** Added for F&O traders with modified screening criterias.
4. **Artificial Intelligence v2 for Nifty 50 Prediction** - Predict Next day Gap-up/down - Try `Select Index for Screening > N`
5. New Screener **Buy at Trendline** added for Swing/Mid/Long term traders - Try `Option > 7 > 5`.
6. Alternate Data Source for faster After-Market Analysis - OTA Optimizations and Cosmetic Updates for Docker/GUI!

## Installation Guide

[![Screeni-py - Detailed Installation Guide](https://markdown-videos-api.jorgenkh.no/url?url=https%3A%2F%2Fyoutu.be%2F2HMN0ac4H20)](https://youtu.be/2HMN0ac4H20)

## Downloads
### Deprycated - Use Docker Method mentioned in next section
### Deprecated - Use Docker Method mentioned in next section

| Operating System | Executable File |
| :-: | --- |
| ![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white) | **[screenipy.exe](https://github.com/pranjal-joshi/Screeni-py/releases/download/2.02/screenipy.exe)** |
Expand Down
4 changes: 3 additions & 1 deletion src/screenipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ def main(testing=False, testBuild=False, downloadOnly=False, execute_inputs:list
for _ in range(multiprocessing.cpu_count()):
tasks_queue.put(None)
try:
numStocks = len(listStockCodes)
numStocks, totalStocks = len(listStockCodes), len(listStockCodes)
os.environ['SCREENIPY_TOTAL_STOCKS'] = str(totalStocks)
print(colorText.END+colorText.BOLD)
bar, spinner = Utility.tools.getProgressbarStyle()
with alive_bar(numStocks, bar=bar, spinner=spinner) as progressbar:
Expand All @@ -419,6 +420,7 @@ def main(testing=False, testBuild=False, downloadOnly=False, execute_inputs:list
saveResults = saveResults.append(
result[1], ignore_index=True)
numStocks -= 1
os.environ['SCREENIPY_SCREEN_COUNTER'] = str(int((totalStocks-numStocks)/totalStocks*100))
progressbar.text(colorText.BOLD + colorText.GREEN +
f'Found {screenResultsCounter.value} Stocks' + colorText.END)
progressbar()
Expand Down
58 changes: 48 additions & 10 deletions src/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import urllib
from time import sleep
from pathlib import Path
from threading import Thread
from time import sleep
import classes.ConfigManager as ConfigManager

st.set_page_config(layout="wide", page_title="Screeni-py", page_icon="📈")
Expand All @@ -25,7 +27,14 @@
except KeyError:
proxyServer = ""

isDevVersion, guiUpdateMessage = OTAUpdater.checkForUpdate(proxyServer, VERSION)
isDevVersion, guiUpdateMessage = None, None

@st.cache_data(ttl='1h', show_spinner=False)
def check_updates():
isDevVersion, guiUpdateMessage = OTAUpdater.checkForUpdate(proxyServer, VERSION)
return isDevVersion, guiUpdateMessage

isDevVersion, guiUpdateMessage = check_updates()

execute_inputs = []

Expand Down Expand Up @@ -64,15 +73,44 @@ def on_start_button_click():
global execute_inputs
if isDevVersion != None:
st.info(f'Received inputs (Debug only): {execute_inputs}')
with st.spinner('Screening stocks for you...'):
try:
screenipy_main(execute_inputs=execute_inputs)
except StopIteration:
pass
except requests.exceptions.RequestException as e:
st.error('Failed to reach Screeni-py server!', icon='🫤')
st.info('This issue is related with your Internet Service Provider (ISP) - Many **Jio** users faced this issue as the screeni-py data cache server appeared to be not reachable for them!\n\nPlease go through this thread carefully to resolve this error: https://github.com/pranjal-joshi/Screeni-py/issues/164', icon='ℹ️')
st.exception(e)

def dummy_call():
try:
screenipy_main(execute_inputs=execute_inputs)
except StopIteration:
pass
except requests.exceptions.RequestException:
os.environ['SCREENIPY_REQ_ERROR'] = "TRUE"

t = Thread(target=dummy_call)
t.start()

st.markdown("""
<style>
.stProgress p {
font-size: 17px;
}
</style>
""", unsafe_allow_html=True)

progress_text = "🚀 Preparing Screener, Please Wait! "
progress_bar = st.progress(0, text=progress_text)

os.environ['SCREENIPY_SCREEN_COUNTER'] = '0'
while int(os.environ.get('SCREENIPY_SCREEN_COUNTER')) < 100:
sleep(0.05)
cnt = int(os.environ.get('SCREENIPY_SCREEN_COUNTER'))
if cnt > 0:
progress_text = "🔍 Screening stocks for you... "
progress_bar.progress(cnt, text=progress_text + f"**:red[{cnt}%]** Done")
if os.environ.get('SCREENIPY_REQ_ERROR') and "TRUE" in os.environ.get('SCREENIPY_REQ_ERROR'):
st.error('Failed to reach Screeni-py server!', icon='🫤')
st.info('This issue is related with your Internet Service Provider (ISP) - Many **Jio** users faced this issue as the screeni-py data cache server appeared to be not reachable for them!\n\nTry with another ISP/Network or go through this thread carefully to resolve this error: https://github.com/pranjal-joshi/Screeni-py/issues/164', icon='ℹ️')
del os.environ['SCREENIPY_REQ_ERROR']
break

t.join()
progress_bar.empty()

def nifty_predict(col):
with col.container():
Expand Down

0 comments on commit 23eb860

Please sign in to comment.