Command line app that fetches stock prices, compares them to defined references and triggers alert if necessary.
- Run this app e.g. once per day to fetch prices,
- it will create its own price database,
- that allows for comparing stock prices to past ones.
- For example: "If the price of stock A is less than 5% of its value of yesterday trigger an alarm"
- Alarms will be printed to stderr and also result in a non-zero return code.
- This way you could embed this app in some infrastructure that sends emails containing stderr on failed jobs.
Note:
- The app can scrape or parses prices from websites or APIs, via an extensible parser mechanism. You can add your own favorite website via a parser (see bellow).
- If want less output (only the alerts), just skip stdout by appending
> /dev/nullto your command.
Using the docker image is most convenient. It brings its own nodejs installation an does not need to be downloaded explicitly.
docker run -v $(pwd)/example:/workdir schnatterer/stock-alertYou can also run it with a local node js instance.
yarn install
cd example
node ../src/cli/main.jsAll configuration is done via config.json that is read from the working directory.
See example/config.json
The stock prices are read from and written to a prices.json in the working directory.
There is one exemplary parser implementation (including a test) but you can easily extend this for your favorit stock website:
- Just provide an
<name>parser.jsonin thesrc/parsersfolder that scrapes/parses the price of your stock from a URL. - In
config.json: set thesourceof a stock to<name>.
Example (let's set <name> to paul):
docker run -v $(pwd)/example:/workdir -v $(pwd)/src/parsers/paulParser.js:/app/src/parsers/paulParser.js schnatterer/stock-alertPRs for new parsers welcome.
- config contains readable name
- Alerts: Display readable name and stock url
- global alerts
- Parser: yahoo finance API
- gzipping prices for more efficient storage of huge numbers of prices