Overview
In general there are two types of data formats, the split and merged formats. For most applications, the merged format is preferred, however, data often comes in split format.
Split Format
In split format, the price for each asset on each period is recorded in a separate record. As an example, consider the following dataset.
The table written out as code would look like:
let prices = [
{date:'2000-01-01', close:100, id:'IBM'},
{date:'2000-01-02', close:101, id:'IBM'},
{date:'2000-01-03', close:100, id:'IBM'},
{date:'2000-01-01', close:145, id:'MSFT'},
{date:'2000-01-02', close:144, id:'MSFT'},
];
Merged Format
In the merged format, the price for each asset is included on the same record for each date.
let prices = [
{date:'2000-01-01', IBM:100, MSFT:145},
{date:'2000-01-02', IBM:101, MSFT:144},
];
Converting Between Formats
The following demonstrate how to convert between the two formats.