{
{
"symbol": "MSFT",
"close": [0, 1, 2, 3, 4, 5],
"open": [0, 1, 2, 3, 4, 5],
"high": [0, 1, 2, 3, 4, 5],
"low": [0, 1, 2, 3, 4, 5],
"volume": [0, 1, 2, 3, 4, 5],
"dates": ["2022-01-01", "2022-01-02", "2022-01-03", "2022-01-04", "2022-01-05", "2022-01-06"],
"date_to_index": {
"2022-01-01": 0,
"2022-01-02": 1,
"2022-01-03": 2,
"2022-01-04": 3,
"2022-01-05": 4,
"2022-01-06": 5
}
}
when I need the data of MicroSoft from 2022-01-03 to 2022-01-05, I will get the start and end indices from date_to_index and then retrieve the slice from index 2 to index 4 of the data arrays I want.
2
Answers
You can certainly store data this way, but
Overall, I’d explore alternate strategies.
I would store them like this
That way you can set an index for symbol and date so that its easier to perform find and aggregate queries