The user wish to do technical analysis on a series of price bar built from plain old arrays. The timestamps are irrelevant to the user, but still the data is expected to be easily aligned with the input arrays.
Proposed solution in C#:
| double[] open = {1.1, 2.1, 3.1, 4.0, 5.0, 6.0}; double[] high = {1.3, 2.3, 3.3, 4.3, 5.3, 6.3}; double[] low = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}; double[] close = {1.2, 2.2, 3.2, 4.2, 5.2, 6.2}; int[] volume = {100, 200, 300, 400, 500, 600}; // With no timestamp specified, the time series will // default the first element to "1970-01-01 00:00:00" // (Unix Epoch). The next element is for the next day. Timeseries ts1 = new Timeseries(); ts1.SetVar( "Open", open ); ts1.SetVar( "High", high ); ts1.SetVar( "Low", low ); ts1.SetVar( "Close", close ); ts1.SetVar( "Volume", volume ); // User can perform technical analysis as usual. // Here, doing a simple moving average of the typical price. ts1["Sma"] = ts1.TypPrice().Sma(3); // User can still get a timestamp. The user // can calculate the difference in seconds since // the Unix epoch and find that way find the offset of // the output relative to the original plain old arrays. for( int i=0; i < ts1.Length; i++ ) { Console.WriteLine( "{0} {1} {2}\n", ts1.Timestamps[i], ts1["Sma"][i] ); } |
WARNING: Work in progress.