Go to file
2026-02-14 10:41:07 -06:00
agent Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
assets/icon Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
manesh_trader Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
ManeshTraderMac@82f326ea93 Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
scripts Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
tests Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
.gitignore Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:41:07 -06:00
AGENTS.md Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
app.py Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
backend_embedded_launcher.py Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
desktop_launcher.py Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
Makefile Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
ManeshTrader_Architecture.md Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
ONBOARDING.md Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
README.md Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
requirements.txt Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
Run ManeshTrader.command Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00
run.sh Signed-off-by: Matt Bruce <mbrucedogs@gmail.com> 2026-02-14 10:39:49 -06:00

Real Bars vs Fake Bars Trend Analyzer (Streamlit)

A Python web app that implements the Real Bars vs Fake Bars strategy:

  • Classifies each closed bar against the prior bar as real_bull, real_bear, or fake
  • Ignores fake bars for trend sequence logic
  • Starts/continues trend on 2+ same-direction real bars
  • Reverses trend only after 2 consecutive real bars of the opposite direction

Features

  • Symbol/timeframe/period inputs (Yahoo Finance via yfinance)
  • Optional wick filtering (use previous candle body range)
  • Optional volume filter (minimum Volume vs Volume-SMA)
  • Trend events table (starts and reversals)
  • Chart visualization (candles + real-bar markers + trend-colored volume)
  • Market session gap handling for stocks via Hide market-closed gaps (stocks):
    • 1d: removes weekend spacing
    • intraday: removes weekends and closed-hour overnight spans
  • Session alerts for newly detected trend events
  • Export classified data to CSV
  • Export chart to PDF (via Plotly + Kaleido)
  • Lightweight backtest snapshot (signal at trend changes, scored by next-bar direction)

Project Structure

  • app.py: Streamlit entrypoint and UI orchestration
  • manesh_trader/constants.py: intervals, periods, trend labels
  • manesh_trader/models.py: data models (TrendEvent)
  • manesh_trader/data.py: market data fetch and live-bar safeguard
  • manesh_trader/strategy.py: bar classification and trend detection logic
  • manesh_trader/analytics.py: backtest snapshot metrics
  • manesh_trader/charting.py: Plotly chart construction
  • manesh_trader/exporting.py: export DataFrame transformation
  • requirements.txt: dependencies

Onboarding

See ONBOARDING.md for a complete step-by-step tutorial.

Xcode macOS Shell

An Xcode-based desktop shell lives in ManeshTraderMac/.

It provides a native window that starts/stops an embedded local backend executable and renders the UI in WKWebView (no external browser). Backend source of truth stays at project root (app.py, manesh_trader/), and packaging compiles those files into ManeshTraderBackend inside the app bundle. See ManeshTraderMac/README.md for setup and run steps.

Setup

Easiest (one command)

./run.sh

macOS Double-Click Launcher

Double-click Run ManeshTrader.command in Finder.

If macOS blocks first launch, run once in Terminal:

xattr -d com.apple.quarantine "Run ManeshTrader.command"

macOS App Wrapper (.app)

Build a native .app launcher:

./scripts/create_mac_app.sh

This creates ManeshTrader.app in the project root. You can double-click it or move it to /Applications.

Build a distributable installer DMG:

./scripts/create_installer_dmg.sh

Output: ManeshTrader-YYYYMMDD-HHMMSS.dmg in project root.

Self-Contained macOS App (WKWebView + Embedded Backend)

Build an installable app where all backend logic ships inside ManeshTraderMac.app:

./scripts/build_selfcontained_mac_app.sh

This outputs dist-mac/<timestamp>/ManeshTraderMac.app.

Then package that app as DMG:

APP_BUNDLE_PATH="dist-mac/<timestamp>/ManeshTraderMac.app" ./scripts/create_installer_dmg.sh

Note: for easiest install on other Macs, use Apple code signing + notarization before sharing publicly.

Standalone Streamlit App (Alternative)

This older path builds a standalone Streamlit wrapper app:

./scripts/build_standalone_app.sh

Output: dist-standalone/<timestamp>/dist/ManeshTrader.app

Optional with Make

make run
make build-mac-selfcontained

Manual

  1. Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the app:
streamlit run app.py
  1. Open the local URL printed by Streamlit (usually http://localhost:8501).

Usage

  1. Set Symbol (examples: AAPL, MSFT, BTC-USD, ETH-USD).
  2. Choose Timeframe and Period.
  3. Optionally adjust filters:
    • Use previous body range (ignore wicks)
    • Enable volume filter
    • Hide market-closed gaps (stocks)
  4. Review:
    • Current trend status
    • Real/fake bar counts
    • Trend events and chart markers
  5. Export results from the Export section.

Strategy Logic Implemented

For closed bar i and previous closed bar i-1:

  • Real Bullish Bar: close[i] > high[i-1] (or previous body high if wick filter enabled)
  • Real Bearish Bar: close[i] < low[i-1] (or previous body low if wick filter enabled)
  • Fake Bar: otherwise (inclusive range)

Trend state machine:

  • Two consecutive real bullish bars => bullish trend active
  • Two consecutive real bearish bars => bearish trend active
  • Active trend persists until two consecutive real bars in opposite direction
  • Single opposite real bar is treated as noise/fluke and does not reverse trend

Notes

  • The app is analysis-only; no order execution.
  • Yahoo Finance interval availability depends on symbol and lookback window.
  • "Ignore potentially live last bar" is enabled by default to reduce incomplete-bar bias.
  • Gap-hiding behavior is currently optimized for regular U.S. stock sessions; exchange holidays/half-days may still show occasional spacing.

Troubleshooting

  • If data fetch fails, verify symbol spelling and use a compatible interval/period combination.
  • If PDF export is unavailable, ensure kaleido is installed in the same environment.