Fork me on GitHub

xts endpoints in Javascript

Description
I couldn't easily find a pre-built method with javascript to do something like endpoints from the xts package in R. I am sure it exists, but I made this crude getEndPeriod function and thought I would apply here with S&P 500 data from the Federal Reserve Bank of St. Louis (FRED). Finding endpoints is important in finance to handle things like rebalancing.
Try One of These Examples

The formatting function supplied to getEndPeriod is flexible so it can use d3.js, moment.js, or any custom function that allows comparison to find breaks.

Result