Skip to main content

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 yfinance data. ๐Ÿ“Š
  • 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 ๐Ÿš€

  1. 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 ๐Ÿ› ๏ธ).

  2. Install Dependencies: The package requires the following Python libraries:

    • yfinance>=0.2.44
    • pandas>=2.2.2
    • numpy>=1.26.4
    • matplotlib>=3.9.2
    • gspread>=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
    
  3. 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.json in your project directory.
    • Share your Google Sheet with the service accountโ€™s email (found in the JSON file) with edit access.
    • Update the spreadsheet_id in main_pipeline.py with 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, or nifty_500. ๐Ÿ“‹
  • Period/Interval: Change period (e.g., "1y", "max") and interval (e.g., "1d", "1h") for yfinance data. โณ
  • Output Format: Set output_format to "csv", "google_sheets", or "both". ๐Ÿ“„
  • Proximity Percentage: Adjust proximity_percentage (default 2.0) for the screener. ๐Ÿ“
  • Visualization: Set visualize=True for charts or False for faster execution. ๐Ÿ“‰
  • Clear Output: Set clear=True to 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) and analysis/smc_analysis_levels.csv (key levels). ๐Ÿ“„
    • Google Sheets: Saves to Summaries and Levels worksheets (if enabled). ๐Ÿ“‘
    • Visualization: Candlestick charts with SMC levels (if visualize=True). ๐Ÿ“‰
  • SMC Screener:
    • CSV: Saves to screener_results.csv with stocks near SMC levels. ๐Ÿ“„
    • Google Sheets: Saves to Screener_Results worksheet (if enabled). ๐Ÿ“‘
    • Console: Displays a table of stocks near key levels. ๐Ÿ–ฅ๏ธ

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_size or increase delay in main_pipeline.py. ๐Ÿ•’
  • Google Sheets Errors: Verify Credentials/credentials.json and share the Google Sheet with the service account. ๐Ÿ”‘
  • No Data: Check ticker validity (e.g., RELIANCE.NS). Use yf.Ticker("TICKER").info to verify. ๐Ÿ“Š
  • Visualization Issues: Ensure matplotlib is installed and visualize=True. ๐Ÿ“‰
  • Screener Empty: Run SMC Analysis first to generate smc_analysis_levels.csv and smc_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smc_screener-0.0.1.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smc_screener-0.0.1-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

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

Hashes for smc_screener-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b785329c013f4f2356d383b7762c5c34d49f6181c6792849b9c4af9477ce5b7b
MD5 57a10738708eb737f92ae1180641e301
BLAKE2b-256 b95fd0f0dce75247fe7d30de0d77e3fd8c1b9166d9372cfb4b427b1fc296a900

See more details on using hashes here.

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

Hashes for smc_screener-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f686bbd931e3f7ffcbb1d9cf12c6c24b2888553d5897b8e479e2ce42635ae2e
MD5 2fd5f39fcde4a214bf7722a80b2c16cc
BLAKE2b-256 af924659e6d4646144477ddda7e39e83f5a300e1607c7e7684b80180e57767a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page