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

indicator-value-area-yesterday

v0.0.116

Published

get yesterday's VAH/VAL/VPOC tacked onto today's candles

Downloads

11

Readme

indicator-value-area-yesterday

Get the value area low/high/VPOC for a set of OHLCV candles.

Given a set of candles with iso-string date fields, get yesterday's VAH/VAL/VPOC tacked onto today's candles.

Experimental, use at your own risk.

Installation

npm i indicator-value-area-yesterday

Usage

var candles = require('candles-sample-aapl').loadMinutes(true).slice(-1000);
//in this example we use 1-min candles [{date, open, high, low, close, bid, ask, volume}, ...]
//where "date" is an iso string date [important to determine which candles where "yesterday"!]

var vah = require('indicator-value-area-yesterday');

var valueAreaPercentile = 0.7; //percent of volume to capture in value area. default 0.7
var nBarsVolumeProfile = 20; //number of bars to put in volume profile while calculating VA. default 20.
var doCache = false; //default false. if true, cache the value area calculations, per-day

//this function will add the fields estDate, prevDate, vahYest, valYest, highYest, lowYest to each candle
var alteredCandles = vah.addYesterdayValueArea(candles, valueAreaPercentile, nBarsVolumeProfile, doCache /* , doCalcFirstHourCandle=false */);

//doCalcFirstHourCandle = true to calculate "80%" rule metric [see below]

//more functions:

//generic value area function for any set of candles
//vah.getValueArea(candles, percentile = 0.7, numBarsVolumeProfile = 20) => { valueAreaHigh, valueAreaLow, candlesHigh, candlesLow, vpocPrice }

//create volume profile...
//vah.createVolumeProfile(candles, numBars = 20) => [{volume,priceRange: [priceLow, priceHigh]}]

//vah.clearCache() //clears the cache
//vah.getEstDate(isoString) //convert iso string to EST date M/D/YYYY

//example of bad data:
// console.log(alteredCandles.slice(0,10));

// [
//   {
//     date: '2022-11-18T18:34:09.263Z',
//     open: 151.0699,
//     high: 151.0699,
//     low: 151.0699,
//     close: 151.0699,
//     bid: 151.06,
//     ask: 151.07,
//     volume: 73457,
//     estDate: '11/18/2022',
//     prevDate: null,
//     vahYest: NaN, //notice that candles that dont have a "prevDate" before them, get NaNs and Infinities
//     valYest: NaN,
//     highYest: -Infinity,
//     lowYest: Infinity,
//     vpocPrice: NaN
//   },

//see also extra data about demarks indicators, supports, pivots [see test-graph.js]
// var pivot = candle.pivotData.basic.pivot;
// var r1 = candle.pivotData.basic.resistance1;
// var s1 = candle.pivotData.basic.support1;
// var r2 = candle.pivotData.basic.resistance2;
// var s2 = candle.pivotData.basic.support2;
//
//DeMark's projections: 
// var demarkHigh = candle.pivotData.deMarks.today.high;
// var demarkLow = candle.pivotData.deMarks.today.low;

//example of good data:
// console.log(alteredCandles.slice(390));

//with 1 more day of data [390 candles], we can calculate the indicator properly...

// [
//   {
//     date: '2022-11-21T18:34:38.429Z',
//     open: 148.5899,
//     high: 148.5899,
//     low: 148.5899,
//     close: 148.5899,
//     bid: 148.57,
//     ask: 148.58,
//     volume: 52336,
//     estDate: '11/21/2022',
//     prevDate: '11/18/2022',
//     vahYest: 151.4652,
//     valYest: 150.81,
//     highYest: 151.85,
//     lowYest: 141.58875
//     //if doCalcFirstHourCandle = true... 
//     //eightyPercentRuleUp: openedUnderValueAreaLowToday && gotIntoValueAreaWithin1Hour
//     //eightyPercentRuleDown: openedOverValueAreaHighToday && gotIntoValueAreaWithin1Hour
//   }, ...]

Chart with VAH/VAL/VPOC as blue/red/black lines on top of some AAPL 15-min candles. Notice the discontinuities at the daily boundaries.

graph

stonks