Skip to content

Abhi-d-gr8/SMAPredictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mean Reversion Prediction System

Important function defination:

  1. def get_mean_reversion_signals(symbol, index="NS", lookback_days=60, investment_amount=100000):
FUNCTION get_mean_reversion_signals(symbol, index, lookback_days, investment_amount):
    TRY:
        // --- Setup ---
        GET the official ticker using get_ticker_symbol().
        GET the currency symbol using get_currency_symbol().
        CALCULATE total days of data needed (lookback_days + a buffer).
        CONVERT total days to a Yahoo Finance range string (e.g., "6mo").
        
        // --- Data Fetching & Prep ---
        FETCH historical data using get_yahoo_finance_history().
        IF no data is returned, DISPLAY error and RETURN None.
        TRIM the data to the exact lookback_days.
        
        // --- Calculations ---
        DETERMINE dynamic short and long SMA periods based on lookback_days.
        GET current price and historical prices.
        CALCULATE Short SMA, Long SMA, and Standard Deviation.
        CALCULATE Bollinger Bands (SMA +/- 2 * Standard Deviation).
        CALCULATE Z-Score ((Price - Long SMA) / Standard Deviation).
        CALCULATE recent volatility.
        DETERMINE a dynamic Z-Score threshold.
        CALCULATE VWAP (Volume Weighted Average Price).
        
        // --- Signal Generation ---
        DETERMINE action ('BUY', 'SELL', 'HOLD') based on the Z-Score vs. threshold.
        CALCULATE expected reversion price (the Long SMA).
        CALCULATE potential return percentage.
        CALCULATE stop-loss and take-profit price levels.
        
        // --- Final Output ---
        GATHER all results into a dictionary.
        RETURN the result dictionary.
        
    CATCH any exception:
        DISPLAY error message.
        RETURN None.
END FUNCTION
  1. def get_stock_recommendations(search_term, market_index):
FUNCTION get_stock_recommendations(search_term, market_index):
    IF search_term is empty, RETURN an empty list.
    
    // Attempt 1: Live API search
    CALL get_yahoo_finance_suggestions() with the search_term.
    
    // Attempt 2: Fallback to local data
    IF the live search returned no suggestions:
        DEFINE a local database of common stocks for all markets.
        SELECT the stock list for the given market_index.
        FILTER the local list for symbols or names containing the search_term.
        SORT the filtered list to prioritize better matches.
        
    RETURN the top 5 suggestions found.
END FUNCTION

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages