Replay data from static tables
This guide will show you how to replay historical data as if it was live data in Deephaven.
Deephaven excels at handling live data. Integrating historical data into real-time analysis is common in a multitude of fields including machine learning, validation, modeling, simulation, and forecasting.
For learning, testing, and other purposes, it can be useful to replay pre-recorded data as if it were live.
In this guide, we will take historical data and play it back as real-time data based on timestamps in a table. This example could be easily extended towards a variety of real-world applications.
Get a historical data table
To replay historical data, we need a table with timestamps in DateTime format. Let's grab one from Deephaven's examples repository. We'll use data from a 100 km bike ride in a file called metriccentury.csv.
Replay the data
The data is in memory. We can replay it with the following steps:
- Import
TableReplayer. - Set a start and end time for data replay.
- These times correspond to those in the table itself.
- Create the replayer using the start and end time.
- Call
add_tableto prepare the replayed table.- This takes two inputs: the table and the
DateTimecolumn name.
- This takes two inputs: the table and the
- Call
startto start replaying data.
Replay a table with no date-time column
Some historical data tables don't have a date-time column.
In such a case, a date-time column can be added.
Then, the data can be replayed just as before.
Replay multiple tables
Real-time applications in Deephaven commonly involve more than a single ticking table. These tables tick simultaneously. A table replayer can be used to replay multiple tables at the same time, provided that the timestamps overlap.
The following code creates two tables with timestamps that overlap.
To replay multiple tables with the same replayer, simply call add_table twice before start.