npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rsistocktrigger

v1.0.0

Published

Google Cloud Project Setup:

Downloads

5

Readme

RSIStockTrigger

This Node.js application is designed to monitor the Relative Strength Index (RSI) of stocks, alerting users via email when RSI values indicate significant trading opportunities. It automatically checks stocks listed in a tickers.txt file against RSI thresholds and sends notifications using Gmail with OAuth2 authentication.

Features

  • Automated RSI Monitoring: Automatically checks the RSI for stocks at scheduled intervals.
  • Email Alerts: Sends emails when RSI values are below 30 or above 70, which often indicate oversold and overbought conditions respectively.
  • Secure Email Transmission: Uses OAuth2 for secure email transmission through Gmail.

Prerequisites

Before running this application, you will need:

  • Node.js installed on your machine.
  • A Gmail account configured with OAuth2 credentials for sending emails.
  • An accessible HTTP endpoint for RSI calculation.

Installation

To get started with this application, follow these steps:

  1. Clone the repository:
    git clone https://github.com/rsabh/RSIStockTrigger.git
    cd RSIStockTrigger
    
  2. Install dependencies:
    npm install
      
  3. Set up environment variables: Create a .env file in the root directory with the following content:
     [email protected]
     CLIENT_ID=your-client-id
     CLIENT_SECRET=your-client-secret
     REFRESH_TOKEN=your-refresh-token
     [email protected]
    
  4. Prepare the ticker list: Populate the tickers.txt file with the stock symbols you wish to monitor, one per line.

Running the Application

  • Start the server:
    node app.js
  • The script will execute based on the cron schedule set to monitor the RSI values at the desired frequency.

Configuration

  • Modify the cron job setup in app.js to adjust the frequency of checks:

    cron.schedule('* * * * *', async () => {
    // This sets the job to run every minute. Adjust as necessary.
    });

Troubleshooting

  • Authorization Errors: Double-check your OAuth2 credentials if you encounter authorization errors. -Email Delivery Issues: Ensure that the Gmail API is enabled and the quota is not exceeded.

Configuring OAuth2 for Gmail API

Follow these steps to configure OAuth2 credentials to enable your application to send emails using the Gmail API.

Step 1: Google Cloud Console Setup

  1. Access the Google Cloud Console

  2. Create or Select a Project

    • Create a new project or select an existing project from the project dropdown in the header.
  3. Enable the Gmail API

    • Navigate to APIs & Services > Library.
    • Search for "Gmail API" and select it from the results.
    • Click Enable to activate the Gmail API for your project.

Step 2: Create OAuth2 Credentials

  1. Configure Consent Screen

    • Go to APIs & Services > Credentials.
    • Click on Configure Consent Screen and provide the necessary information.
    • Save the settings.
  2. Create Credentials

    • In the Credentials tab, click Create Credentials and select OAuth 2.0 Client IDs.
    • Fill out the form. For application type, choose Web application.
    • Add https://developers.google.com/oauthplayground as a redirect URI if you plan to use the OAuth 2.0 Playground to obtain the refresh token.

Step 3: Obtain Refresh Token Using OAuth 2.0 Playground

  1. Visit OAuth 2.0 Playground

  2. Configure the Playground

    • Click on the gear icon (Settings) and check Use your own OAuth credentials.
    • Enter your Client ID and Client Secret.
  3. Select & Authorize APIs

    • In the Step 1 section of the Playground, scroll or search for the Gmail API scopes you need, such as https://mail.google.com/.
    • Authorize the APIs by authenticating with your Google account and consenting to the access.
  4. Exchange Authorization Code for Tokens

    • In Step 2, click Exchange authorization code for tokens.
    • The refresh token and access token will be displayed. Copy the refresh token for use in your application.

Remember to secure your credentials and never commit them directly into your version control system.