A Python package for Smart Money Concepts (SMC) analysis and stock screening
Project description
SMC Screener ๐
A Python package for Smart Money Concepts (SMC) analysis and stock screening, designed to identify key market levels such as swing highs/lows, order blocks, fair value gaps (FVGs), and premium/discount zones.
Features โจ
- SMC Analysis: Identifies swing highs/lows, order blocks, FVGs, and market structure breaks using
yfinancedata. ๐ - Stock Screener: Screens stocks near key SMC levels based on a proximity percentage. ๐
- Visualization: Generates candlestick charts with SMC levels using
matplotlib. ๐ - Output Options: Saves results to CSV files and/or Google Sheets. ๐๐
- Interactive CLI: Choose tasks (analysis, screener, or both) and stock lists (e.g., Nifty 50, F&O). ๐ฅ๏ธ
Installation ๐
-
Install via pip:
pip install smc-screener
Note: The package is not yet on PyPI. To install locally, use the wheel file (see Development Setup ๐ ๏ธ).
-
Install Dependencies: The package requires the following Python libraries:
yfinance>=0.2.44pandas>=2.2.2numpy>=1.26.4matplotlib>=3.9.2gspread>=6.1.2(optional, for Google Sheets)oauth2client>=4.1.3(optional, for Google Sheets)tqdm>=4.66.5
Install them manually if needed:
pip install yfinance pandas numpy matplotlib gspread oauth2client tqdm
-
Google Sheets Setup (optional, for
output_format="google_sheets"or"both") ๐:- Create a Google Cloud project and enable the Google Sheets API and Google Drive API. ๐ง
- Create a service account and download the JSON credentials file. ๐
- Save the JSON file as
Credentials/credentials.jsonin your project directory. - Share your Google Sheet with the service accountโs email (found in the JSON file) with edit access.
- Update the
spreadsheet_idinmain_pipeline.pywith your Google Sheet ID (from the URL:https://docs.google.com/spreadsheets/d/<SPREADSHEET_ID>/edit).
Usage ๐ ๏ธ
Command-Line Interface
Run the package directly from the command line:
smc-trading
This launches an interactive CLI where you can:
- Select a task: SMC Analysis, SMC Screener, or both. ๐
- Choose a stock list: Nifty Top 10, Nifty 50, F&O, or Nifty 500. ๐
Example interaction:
Select the task to run:
1. SMC Analysis
2. SMC Screener
3. Both (Analysis + Screener)
Enter your choice (1, 2, or 3): 3
Select the stock list to process:
1. Nifty Top 10
2. Nifty 50
3. F&O
4. Nifty 500
Enter your choice (1, 2, 3, or 4): 1
Selected stock list: Nifty Top 10 (10 stocks)
Step 1: Running SMC Analysis... ๐
Step 2: Running SMC Screener... ๐
Task 'both' completed for Nifty Top 10! ๐
Programmatic Usage
Run the pipeline programmatically:
from smc_trading import main_pipeline
import asyncio
asyncio.run(main_pipeline.run_full_pipeline())
Customizing Parameters
Edit main_pipeline.py to customize:
- Stock Lists: Modify
nifty_top_10,nifty_50,fn_o_stocks, ornifty_500. ๐ - Period/Interval: Change
period(e.g.,"1y","max") andinterval(e.g.,"1d","1h") foryfinancedata. โณ - Output Format: Set
output_formatto"csv","google_sheets", or"both". ๐ - Proximity Percentage: Adjust
proximity_percentage(default2.0) for the screener. ๐ - Visualization: Set
visualize=Truefor charts orFalsefor faster execution. ๐ - Clear Output: Set
clear=Trueto overwrite existing CSV files or Google Sheets. ๐๏ธ
Example:
await main_pipeline.main_analysis(
stock_codes=["RELIANCE.NS"],
spreadsheet_id="your_spreadsheet_id",
period="6mo",
interval="1h",
visualize=True,
output_format="both"
)
main_pipeline.main_screener(
proximity_percentage=1.5,
output_csv="screener_results.csv",
spreadsheet_id="your_spreadsheet_id",
output_format="both"
)
Output ๐
- SMC Analysis:
- CSV: Saves to
analysis/smc_analysis_summaries.csv(summary data) andanalysis/smc_analysis_levels.csv(key levels). ๐ - Google Sheets: Saves to
SummariesandLevelsworksheets (if enabled). ๐ - Visualization: Candlestick charts with SMC levels (if
visualize=True). ๐
- CSV: Saves to
- SMC Screener:
- CSV: Saves to
screener_results.csvwith stocks near SMC levels. ๐ - Google Sheets: Saves to
Screener_Resultsworksheet (if enabled). ๐ - Console: Displays a table of stocks near key levels. ๐ฅ๏ธ
- CSV: Saves to
Project Structure ๐ ๏ธ
smc_trading/
โโโ smc_trading/
โ โโโ __init__.py
โ โโโ smc_analysis.py
โ โโโ smc_screener.py
โ โโโ main_pipeline.py
โโโ Credentials/
โ โโโ credentials.json
โโโ pyproject.toml
โโโ README.md
โโโ LICENSE
โโโ requirements.txt
yfinance Period & Interval Reference ๐
- Period:
"1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max" - Interval:
"1m","2m","5m","15m","30m","60m","90m","1h","1d","5d","1wk","1mo","3mo" - Restrictions:
"1m"interval: Only last 7 days max.- Intraday intervals (
"1m","1h", etc.):period โค 60d. - Daily/weekly/monthly: Longer periods allowed.
Troubleshooting ๐
- yfinance Rate Limits: Reduce
batch_sizeor increasedelayinmain_pipeline.py. ๐ - Google Sheets Errors: Verify
Credentials/credentials.jsonand share the Google Sheet with the service account. ๐ - No Data: Check ticker validity (e.g.,
RELIANCE.NS). Useyf.Ticker("TICKER").infoto verify. ๐ - Visualization Issues: Ensure
matplotlibis installed andvisualize=True. ๐ - Screener Empty: Run SMC Analysis first to generate
smc_analysis_levels.csvandsmc_analysis_summaries.csv. ๐
License ๐
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing ๐ค
Contributions are welcome! Please submit a pull request or open an issue on the repository.
Happy trading! ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smc_screener-0.0.1.tar.gz.
File metadata
- Download URL: smc_screener-0.0.1.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b785329c013f4f2356d383b7762c5c34d49f6181c6792849b9c4af9477ce5b7b
|
|
| MD5 |
57a10738708eb737f92ae1180641e301
|
|
| BLAKE2b-256 |
b95fd0f0dce75247fe7d30de0d77e3fd8c1b9166d9372cfb4b427b1fc296a900
|
File details
Details for the file smc_screener-0.0.1-py3-none-any.whl.
File metadata
- Download URL: smc_screener-0.0.1-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f686bbd931e3f7ffcbb1d9cf12c6c24b2888553d5897b8e479e2ce42635ae2e
|
|
| MD5 |
2fd5f39fcde4a214bf7722a80b2c16cc
|
|
| BLAKE2b-256 |
af924659e6d4646144477ddda7e39e83f5a300e1607c7e7684b80180e57767a8
|