From 23eb86015fa4cf03901fd9fdb11b491afeb9f80c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:20:51 +0530 Subject: [PATCH 1/2] v2.04 - Moved to TA-Lib-Precompiled (0.4.25), Progressbar for GUI 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 --- .github/workflows/workflow-build-matrix.yml | 129 ++++++++++---------- .github/workflows/workflow-test.yml | 17 +-- Dockerfile | 15 +-- README.md | 9 +- requirements.txt | 3 +- src/classes/Changelog.py | 12 +- src/release.md | 10 +- src/screenipy.py | 4 +- src/streamlit_app.py | 58 +++++++-- 9 files changed, 149 insertions(+), 108 deletions(-) diff --git a/.github/workflows/workflow-build-matrix.yml b/.github/workflows/workflow-build-matrix.yml index 091be3f7..a08493b9 100644 --- a/.github/workflows/workflow-build-matrix.yml +++ b/.github/workflows/workflow-build-matrix.yml @@ -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 diff --git a/.github/workflows/workflow-test.yml b/.github/workflows/workflow-test.yml index 90792575..10952d98 100644 --- a/.github/workflows/workflow-test.yml +++ b/.github/workflows/workflow-test.yml @@ -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 @@ -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 diff --git a/Dockerfile b/Dockerfile index 30cc5a75..c2ba423d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" diff --git a/README.md b/README.md index ccce323f..e1cace3d 100644 --- a/README.md +++ b/README.md @@ -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) | |

Scan QR Code to join [Official Telegram Group](https://t.me/+0Tzy08mR0do0MzNl) for Additional Discussions

| -| **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 | @@ -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. diff --git a/requirements.txt b/requirements.txt index b8521039..3e5d5c6b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/src/classes/Changelog.py b/src/classes/Changelog.py index e7f9ee0e..91144fc0 100644 --- a/src/classes/Changelog.py +++ b/src/classes/Changelog.py @@ -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] @@ -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 diff --git a/src/release.md b/src/release.md index 8300651c..fa81ffec 100644 --- a/src/release.md +++ b/src/release.md @@ -8,9 +8,10 @@ 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 @@ -18,7 +19,8 @@ Celebrating more than 7K+ Downloads - Thank You for your support :tada: [![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)** | diff --git a/src/screenipy.py b/src/screenipy.py index c15d105f..d1cf2c31 100644 --- a/src/screenipy.py +++ b/src/screenipy.py @@ -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: @@ -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() diff --git a/src/streamlit_app.py b/src/streamlit_app.py index c311b571..22cfaa7f 100644 --- a/src/streamlit_app.py +++ b/src/streamlit_app.py @@ -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="📈") @@ -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 = [] @@ -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(""" + + """, 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(): From 46b05c21e7bc2a34510c1436e18955f19ad60b68 Mon Sep 17 00:00:00 2001 From: pranjal-joshi Date: Fri, 6 Oct 2023 16:24:08 +0530 Subject: [PATCH 2/2] 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 --- .github/workflows/workflow-build-matrix.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow-build-matrix.yml b/.github/workflows/workflow-build-matrix.yml index a08493b9..4eb289f3 100644 --- a/.github/workflows/workflow-build-matrix.yml +++ b/.github/workflows/workflow-build-matrix.yml @@ -14,10 +14,10 @@ on: jobs: # Job for builing packages - Build-Executables-(Disabled onwards v2.03): + Build-Executables: name: Build Packages runs-on: ubuntu-latest - #needs: Create-Release + needs: Docker-Build # runs-on: ${{ matrix.os }} # strategy: # matrix: