dvmlls / bdscale

Remove Weekends and Holidays From ggplot2 Axes
9 stars 0 forks source link

Removing non-trading minutes in a trading day? #6

Open mingzhou opened 9 years ago

mingzhou commented 9 years ago

Hi, if I want to plot financial data in minute-scale, can I remove non-trading minutes to get a continuous axis scale? Thank you!

dvmlls commented 9 years ago

Hey!

Currently bdscale only does a business date scale...hence the name. You're asking for a business time scale, which is the same concept but with a couple additional restrictions.

So the short answer is no, it can't.

In order to get it to work though, you'd just need to implement two functions:

  1. transform: given an actual time t in some time format like POSIXct, return an integer or double bt representing how long t occurred after some point in time epoch on your business-time scale
  2. inverse: given a bt, how do I get a t

For transform you'd need to know:

That would make it work. To make it pretty, you'd also need to implement a function that determines where to put the grid lines.