- ☑ Create a rust library to compute rolling OHLC.
- ☑ Use created crate as a dependency to read JSON data and produce output in given format.
- ☑ Provide tests.
- ☑ Provide benchmarks.
The time taken for the functions to process each ticker was measured using the Struct std::time::Instant.
The following code describes the measurement parameters -
for ticker in data {
let now: Instant = Instant::now();
{
//ticker processing code here
}
let elapsed: std::time::Duration = now.elapsed();
let output: f32 = elapsed.as_nanos() as f32;
bencher.push(output);
mode.push(output as i32);
}
let mean = statistical::mean(&bencher);
let median = statistical::median(&bencher);
let mode = statistical::mode(&mode).unwrap();
let sd = statistical::standard_deviation(&bencher, Some(mean));
- The algorithm which has O(n) time complexity, completes processing a ticker with the following stats :
Due to O(n) time complexity, the time taken to processing goes on increasing linearly as the amount of tickers processed increases (around 476200 ns was the highest for this dataset).
- On the other hand the update algorithm that uses Deque(s), completes processing a ticker completes processing a ticker with the following stats :
I have provided two tests in the library that will take the "output files" as their input and compare it with the expected "correct" provided to us.
-
The first test compares the output provided 'ohlc-5m-a.txt', with the output produced by this code.
-
The second test compares an expected output where some tickers occur with a gap of more than 300_000 ms, and makes sure the open-high-low-close should change accordingly.
-
Both these tests pass successfully.