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

hst-parser

v0.2.2

Published

Parser for the MetaTrader History (.hst) File Format

Downloads

4

Readme

HST File Parser

Summary

Parser for the MetaTrader History (.hst) File Format in Node.js

Table of Contents

Installation

npm install hst-parser --save
# or
yarn add hst-parser
# or
bower install hst-parser --save

Usage

const HSTParser = require('hst-parser');

const tradeHistory = new HSTParser('./data/USDGBP.hst'); // your .hst file

Variables

the HSTParser class exposes some variables for you to use

console.log(tradeHistory.version); // file version from headers
// example output: 400

console.log(tradeHistory.symbol); // the symbol / ticker / currency pair from the file
// example output: "USDGBP"

console.log(tradeHistory.period); // the interval (in minutes) of the data
// example output: 1

console.log(tradeHistory.start); // the JS Date of the first candle
// example output: Tue Nov 05 1985 00:52:00 GMT+0000 (GMT)

console.log(tradeHistory.candleNumber); // the number of the last read candle
// example output: 12345

console.log(tradeHistory.endOfFile); // true or false, has the parser hit the end of the file?
// example output: false

Candle

Candles are a section of data at any given interval.

Example:

{ 
  "close": 90.26,
  "high": 90.27,
  "low": 90.25,
  "open": 90.27,
  "realVolume": 0,
  "spread": 0,
  "timestamp": "2010-01-26T00:00:00.000Z",
  "volume": 9 
}

isValidFormat()

Checks if file can be parsed by HSTParser. (currently supports versions 400 and 401 of .hst files)

if(tradeHistory.isValidFormat()) {
  // do stuff
} else {
  // error?
}

getCandleNumber(candleNumber)

Returns candle data at specified position

console.log(tradeHistory.getCandleNumber(200));
// output: {Candle}

getCandleNumberAsync(candleNumber)

Returns promise that resolves to candle data at specified position

tradeHistory.getCandleNumber(200).then(candle => {
  console.log(candle);
}).catch(err => {
  console.log(err);
})
// output: {Candle}

getNextCandle()

Returns next set of candle data

console.log(tradeHistory.getNextCandle());
// output: {Candle}

getNextCandleAsync()

Returns promise that resolves to next set of candle data

tradeHistory.getNextCandleAsync().then(candle => {
  console.log(candle);
}).catch(err => {
  console.log(err);
})
// output: {Candle}

getPrevCandle()

Returns previous set of candle data

console.log(tradeHistory.getPrevCandle());
// output: {Candle}

getPrevCandleAsync()

Returns promise that resolves to previous set of candle data

tradeHistory.getPrevCandleAsync().then(candle => {
  console.log(candle);
}).catch(err => {
  console.log(err);
})
// output: {Candle}

getCandleAt(date, ...[startDate, i])

Returns set of candle data at specified date and time

const myBirthday = new Date(1996, 0, 26);
console.log(tradeHistory.getCandleAt(myBirthday));
// output: {Candle}

getCandleAtAsync(date)

Returns promise that resolves to set of candle data at specified date and time

const myBirthday = new Date(1996, 0, 26);
tradeHistory.getCandleAt(myBirthday).then(candle => {
  console.log(candle);
}).catch(err => {
  console.log(err);
})
// output: {Candle}

Author

Kyron Taylor (gitbugr)

Thank You

Simon Gniadkowski: HTS File Specification

Licence

MIT