
Update August, 2, 2025
Last Friday was a downer. But Tapir has these tickers doing well: AZO, URI, MSFT
Update ticker list which can be used with the Tapir program: stocks_etf_tickers.txt
________________
Update July 27, 2025
Tapir’s recommendations: SPY, IVV, PH, VOO, GS
Matlab code package: tapir_alpha_7_27_2025.zip
_______________
Update July 20, 2025
My software is recommending these three ETF funds: VGT, VPU, VUG.
VOO & QQQ also rank high.
The code makes buy, hold, sell recommendations which are suitable for once-per-day trade orders.
Here is the Matlab code package. tapir_alpha_7_20_2025.zip
I have included a sample tickers.txt file but limited to ETFs.
The tapir_alpha.m code is free, but requires:
Alpha Advantage API Key to access stock prices and technical metrics at $49.99 per month.
If you don’t want to pay for the API Key, then just check back with this page for trade recommendations, which I will post periodically.
My email is: tom@irvinemail.org
___________________
Well I needed a name for this project. So I whimsically chose tapir. These herbivore mammals are known for their distinctive short, prehensile snouts and are closely related to horses and rhinoceroses. Tapirs inhabit jungle and forest regions of South and Central America and Southeast Asia.
I have been working to parlay my signal processing skills to stock investing in tandem with ChatGPT AI. My goals are a balance of dividends and growth somewhere moderately above the S&P 500. My tools are a family of technical and fundamental indicators with Monte Carlo with risk-adjusted scoring based on simulations, mean values, standard deviations and a k factor.
This risk-adjusted Monte Carlo approach is commonly used in portfolio theory, decision analysis, and robust scoring systems under uncertainty.
I am nearly ready to offer my Matlab program tapir_alpha.m to the public, free-of-charge. Hey, if this software is a fraction as good as I claim, then I don’t need your money.
I just need to do some more tweaks and forward testing on the code. I have already successfully completed back testing using historical data.
I also have some strong convictions about the democratization of knowledge. Knowledge is power, and it should be distributed in a widespread manner to benefit all mankind.
I am mindful that many fine people are losing their government or commercial employment positions due to the current layoff frenzy. So I want to offer a method for people to supplement their incomes. But don’t quit your day job to become a fulltime trader.
___________________________
Notes and disclaimers:
- I am not a licensed financial professional of any sort.
- This is not a method for intraday trading or “get rich quick.”
- It is intended for maybe once-a-day trade.
- No guarantees.
- A “black swan” event such as a natural disaster, terrorist attack or war outbreak may occur on any given day, thus disrupting the financial markets.
- Some stocks have still not fully recovered from the COVID pandemic.
- Do not put all of your eggs in one basket.
- Consult with a licensed financial advisor regarding your own circumstances.
Three third-party software products are recommended or required to run the tapir_alpha code. I do not get any kickback payments from these sources.
- ChatGPT Plus Subscription at $21.80 per month. You might get by the free version, but I am well beyond that.
- Matlab. But ChatGPT can convert tapir_alpha.m into Python. You may have to do some debugging for compatibility.
- Alpha Advantage API Key to access stock prices and technical metrics. $49.99 per month.
You will also need an online brokerage account. Pick your own.
___________________________
Here are the comments from the main function.
% tapir_alpha.m ver 1.0 by Tom Irvine email: tom@irvinemail.org
%
% This script evaluates a list of stock tickers using a fuzzy logic-based scoring
% system that integrates multiple technical and fundamental indicators.
%
% The model computes a composite score for each stock based.
% That score is then used to assign a trading action: BUY, HOLD, or SELL. Trade size is
% scaled proportionally to the deviation of the score from the neutral threshold.
%
% === Indicators Used ===
%
% 1. RSI (Relative Strength Index) – Measures recent price momentum and identifies
% overbought or oversold conditions (typically scaled 0–100).
%
% 2. SMA20 (Simple Moving Average, 20-day) – Captures short-term price trends.
%
% 3. SMA50 – Medium-term trend indicator, helps confirm upward or downward bias.
%
% 4. SMA200 – Long-term support/resistance indicator, often used to identify trend regimes.
%
% 5. EMA12 (Exponential Moving Average, 12-day) – Reacts more quickly than SMAs to recent prices.
%
% 6. EMA26 – Used in conjunction with EMA12 to compute MACD; slower-moving trend indicator.
%
% 7. Momentum – Calculates the difference between current and past price to estimate velocity of price movement.
%
% 8. Dividend Yield – Measures cash return relative to stock price; a proxy for income-oriented valuation.
%
% 9. Fibonacci Proximity – Quantifies how close the current price is to a key Fibonacci retracement level
% (e.g., 61.8%, 38.2%) derived from longer-term moving averages or trend swings.
%
% 10. PE Ratio – Price-to-Earnings ratio; a valuation indicator showing how expensive a stock is relative to its earnings.
%
% 11. Bollinger Band Width – Indicates current price volatility; calculated as the width between upper and lower Bollinger Bands.
%
% === Additional Supporting Indicators ===
%
% – MACD Line & Signal Line – Extracted from EMA12/EMA26; gauges momentum shifts and crossovers.
% – OBV (On-Balance Volume) – Tracks cumulative buying/selling pressure based on volume.
% – RS (Relative Strength vs SPY) – Compares stock performance to the S&P 500 to filter laggards/outperformers.
%
% ======================================================================
%
% User Input Requirements
% ======================================================================
%
% The following two files must be present in the same directory as this script:
%
% 1. apiKey.txt
% – Contains your Alpha Vantage API key.
% – Format: A single line with only the API key string.
% – Example:
% Insert your own key here
%
% 2. tickers.txt
% – Contains a list of stock ticker symbols to analyze.
% – Format: One ticker symbol per line (no commas or brackets).
% – Example:
% AAPL
% MSFT
% NVDA
% F
% IBM
%
% Ensure that both files are saved in plain text format and are accessible
% from the directory where this script is run.
% ======================================================================
%
% === Output ===
%
% The computed results are presented in a sorted table by score (descending), showing
% key metrics and action decisions. Final output is also saved as an Excel spreadsheet
% with a timestamped filename for review or archival.
___________________________
Here are the comments from the helper function.
%————————————————————————–
% Function: compute_fuzzy_score
%
% Purpose:
% Computes a fuzzy score for a stock using 11 technical and fundamental
% indicators combined through a Monte Carlo simulation of weighted sums.
% Bonus rules are then applied to reward strong momentum, valuation, yield,
% and technical confluence.
%
% Monte Carlo Logic Summary:
% – Step 1: Compute a feature vector of normalized indicator scores
% (RSI, EMA, PE, Momentum, Dividend Yield, etc.).
% – Step 2: Generate ‘numSamples’ random weight vectors, each normalized
% to prevent overweighting any single indicator.
% – Step 3: For each weight vector, compute the weighted sum with the
% score vector → one possible scenario.
% – Step 4: Collect all Monte Carlo score outcomes, then compute:
% • meanScore = expected strength across random weights
% • stdScore = variability (uncertainty) in the score
% – Step 5: Final fuzzy score is:
% score = 50 + meanScore – k * stdScore
% (this penalizes stocks with inconsistent signal behavior)
%
% Bonus Adjustments (applied after Monte Carlo score):
% – Momentum Bonus: If RSI > 55 and Momentum > 0, +2 pts
% – Relative Strength Bonus: If RS > 1.05 (vs SPY), +1.5 pts
% – Indicator Confluence: If ≥ 3 bullish signals (RSI, MACD, EMA, Momentum), +2 pts
% – Dividend + RS: If DividendYield > 1% and RS > 1.05, bonus ∝ log(rs)
% – Dividend + EMA: If DividendYield > 1% and EMA12 > EMA26, bonus ∝ EMA spread
% – Moving Average Bonus: If price is above SMA20, SMA50, SMA200, up to +1.5 pts
% – Low Volatility Breakout: If Bollinger width < 0.05 and EMA bullish, +1.5 pts % – Positive PE & Uptrend: If PE > 0 and SMA20 > SMA50 > SMA200, +2 pts
%
% Inputs:
% rsi, sma20, sma50, sma200, ema12, ema26, momentum,
% dividendYield, fiboProximity, pe, bollingerWidth,
% lastPrice, macdLine, signalLine, obv, rs
%
% Output:
% score – a scalar fuzzy score representing technical/fundamental strength
%
%————————————————————————–
___________________________
My tickers.txt file has over 800 stocks and rising to scour for the best values. I can share it, but you can easily make your own with the help of ChatGPT.
Today’s run shows that the best stock/ETF for under $1000 is VGT.
There is some correlation between stock price and technical strength.
The best stock under $200 and $100 are JNJ and BK, respectively.
You are welcome to copy and paste the above comments into ChatGPT and create your own Matlab or Python version. But ChatGPT is imperfect. So be prepared for some late night debugging.
More later…
Thank you,
Tom Irvine
Hi Tom,
I’ve been working on recreating the Python program to closely match the MATLAB code, and I have a few questions:
Thanks,
I do not have a set schedule for running the tapir program. I may run it after market hours to set up trades for the next morning. I might also run it once or twice per day. I use it as a guideline to buy, hold and sell. But I also look at charts to make final decisions. I do not work with candlesticks, but I should probably do so. My Alpha Advantage api key has a 15 minute delay. So I am not trying to do near real-time intraday trades. I am continuing to tweak the code. I will post an update on the main post later this evening.