Skip to content

simy46/CANSLIM_SERVER

Repository files navigation

CANSLIM_SERVER

© @simy46, 2024

Project Description

CANSLIM_SERVER is the backend server for the CANSLIM Calculator application, designed to implement the investment principles from "How to Make Money in Stocks Getting Started: A Guide to Putting CAN SLIM Concepts into Action" by Matthew Galgani. The server handles requests from the front-end, fetches data from external APIs, processes it, and sends back the necessary information to evaluate the investment potential of stocks based on the CAN SLIM criteria.

Project Links

Project Structure

This server is developed using Express.js on Node.js and handles the backend operations of the CANSLIM Calculator.

Criteria Calculated

The CANSLIM Calculator evaluates stocks based on the following criteria, each derived from the CAN SLIM methodology:

  • Composite Rating: An overall rating combining several fundamental and technical factors, targeting a score of 95 or higher.
  • EPS Rating: Earnings Per Share rating of 80 or higher.
  • EPS Growth: Growth in EPS of 25% or higher in recent quarters.
  • Accelerating Earnings Growth: Evidence of accelerating earnings growth.
  • Average Annual EPS Growth: An average annual EPS growth of 25% or more over the last 3 years.
  • Sales Growth: Sales growth of 20%-25% or higher in the most recent quarter.
  • Return on Equity (ROE): ROE of 17% or higher.
  • SMR Rating: Sales + Margins + Return on Equity rating of A or B.
  • Increase in Funds Ownership: Increase in the number of institutional funds owning the stock.
  • Accumulation/Distribution Rating: Rating of A, B, or C, indicating the buying and selling activity of institutional investors.
  • Relative Strength Rating: Measures a stock's price performance relative to all other stocks, targeting a high rating.
  • Current Share Price: Share price above $15.
  • Average Daily Volume: Average daily trading volume of 400,000 shares or more.
  • Breaking Out of Sound Base: Stock breaking out of a sound base or an alternative buy point.
  • Volume Above Average on Breakout: Volume at least 40% to 50% above average on breakout.
  • Relative Strength Line in New High Ground: Indicates if the relative strength line is in new high ground.
  • Within Buy Point: Stock price within 5% of the ideal buy point.

Usage Guidelines

This server is intended for personal and educational use only. Commercial use of this code is not permitted. While I welcome comments and suggestions for improvement, I ask that you do not copy or redistribute the code or the core ideas without my consent.

Installation

To install and run the server locally, follow these steps:

  1. Clone the repository:
   git clone https://github.com/simy46/CANSLIM_SERVER.git
   cd CANSLIM_SERVER
  1. Install the dependencies:
    npm install
  1. Start the server:
   npm start

For development purposes, you can use the following command to start the server with nodemon:

   npm run dev

Server Error Alerts (Telegram)

All server-side HTTP errors and runtime exceptions are sent through one centralized function:

  • notifyServerError(...) in services/errorAlert.js

This is wired in:

  • Route-level catches/validation errors (server.js)
  • Global Express error middleware (middlewares/errorHandler.js)
  • Process-level events (uncaughtException, unhandledRejection) in index.js

Error alerts are always enabled and use:

  • TELEGRAM_BOT_TOKEN
  • TELEGRAM_CHAT_ID

SEO Automation Jobs

This project includes two lightweight SEO monitoring jobs designed for Heroku Scheduler (not always-on workers).

  • npm run seo:daily: health checks for core pages, robots.txt, and sitemap.xml
  • npm run seo:weekly: daily checks + weekly Search Console insights (when configured)
  • npm run seo:dry-run: local test mode (prints report and skips Telegram send)

What is checked

  • Check-path URLs status, response time, and content-type sanity
  • llms.txt reachability + minimum content length sanity
  • robots.txt Sitemap directive
  • sitemap.xml XML validity, URL count, and required URL coverage (indexable pages only)
  • Weekly mode: GSC 7-day vs previous 7-day query/page insights (optional)
  • Weekly mode: GA4 7-day vs previous 7-day traffic/performance signals (optional)

Environment variables

Copy .env.example and set at least:

  • TELEGRAM_BOT_TOKEN
  • TELEGRAM_CHAT_ID

All non-secret defaults are centralized in:

  • consts/seo.js

Only add overrides in .env when you intentionally want non-default behavior.

Optional GSC variables:

  • GSC_PROPERTY
  • GOOGLE_CLIENT_EMAIL
  • GOOGLE_PRIVATE_KEY

If GSC variables are missing, weekly job still runs and reports GSC not configured.

Optional GA4 variable:

  • GA4_PROPERTY_ID (uses GOOGLE_CLIENT_EMAIL + GOOGLE_PRIVATE_KEY already configured above)

If GA4 variables are missing, weekly job still runs and reports GA4 not configured.

Optional reliability variables:

  • SEO_FAIL_ON_TELEGRAM_ERROR=true to fail the job if Telegram send fails
  • SEO_HTTP_TIMEOUT_MS, SEO_ALERT_RESPONSE_MS to tune checks
  • SEO_LOW_CTR_THRESHOLD, SEO_MIN_IMPRESSIONS_FOR_OPPORTUNITY, SEO_MAX_ACTION_ITEMS for weekly insights

Local commands

npm run seo:dry-run
npm run seo:daily
npm run seo:weekly
npm test

Heroku Scheduler setup

In Heroku dashboard:

  1. Install Heroku Scheduler add-on.
  2. Add config vars from .env.example.
  3. Create scheduler jobs:
npm run seo:daily
npm run seo:weekly

Suggested cadence:

  • seo:daily: every day
  • seo:weekly: once per week

Telegram message example (sanitized)

SEO WEEKLY REPORT
Environment: production
Run ID: 6b6f2c52-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Overall: WARN
Site: https://www.canslimcalculator.com

Daily checks:
- Paths: pass 6, warn 1, fail 0
- Avg response: 412ms
- llms.txt: PASS (482 chars)
- robots.txt: PASS
- sitemap.xml: PASS (38 URLs)

Weekly insights:
- GA4: configured (2026-02-28 to 2026-03-06)

Basic traffic stats:
- Sessions: 842 (+9.10% vs prev 7d)
- Total users: 601 (+6.22%)
- New users: 280 (+4.48%)
- Page views: 1922 (+11.00%)
- Conversions: 14 (+7.69%)
- Engagement rate: 57.10% (+1.90 pts)
- Avg session duration: 73.40s (+3.20s)

Strong signals:
- Organic search sessions: 476 (+12.80%), share 56.53%
- Top country: 🇺🇸 United States (390 sessions, 282 users, 58.1% eng.)
- Top countries this week:
  - 🇺🇸 United States: 390 sessions, 58.1% eng.
  - 🇨🇦 Canada: 210 sessions, 54.3% eng.

- GSC: configured (2026-02-28 to 2026-03-06)
- Top gaining queries: 5
- Top losing queries: 3
- Low CTR opportunities: 4

Next actions:
- Rewrite title/meta for query \"canslim calculator\" (impressions 1432, CTR 0.9%).
- Improve response time on /market-news.

API Endpoints

The server provides several endpoints to interact with the front-end application. These include fetching stock data, processing CANSLIM criteria, and more. Detailed documentation of the endpoints will be provided in future updates.

Contributions

Feedback and suggestions are highly encouraged! Please feel free to open issues or pull requests on the project's GitHub repository.

Disclaimer

This project is a personal academic exercise and is not affiliated with any company or professional entity, including Yahoo Finance or Matthew Galgani. The results provided by the algorithm should be viewed as educational insights rather than professional investment advice. Always perform your own due diligence before making any investment decisions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors