prvni draft LSTM

This commit is contained in:
David Brazda
2023-09-26 15:52:33 +02:00
parent b2365cc318
commit 940348412f
11 changed files with 827 additions and 15 deletions

View File

@ -27,8 +27,39 @@ from collections import deque
import numpy as np
def slice_dict_lists(d, last_item, to_tmstp = False):
"""Slices every list in the dictionary to the last last_item items.
Args:
d: A dictionary.
last_item: The number of items to keep at the end of each list.
to_tmstp: For "time" elements change it to timestamp from datetime if required.
Returns:
A new dictionary with the sliced lists.
"""
sliced_d = {}
for key in d.keys():
if key == "time" and to_tmstp:
sliced_d[key] = [datetime.timestamp(t) for t in d[key][-last_item:]]
else:
sliced_d[key] = d[key][-last_item:]
return sliced_d
# keys_set = set(keys)
# sliced_d = {}
# for key, value in d.items():
# if key in keys_set and isinstance(value, list):
# if key == "time" and to_tmstp:
# sliced_d[key] = [datetime.timestamp(t) for t in value[-last_item:]]
# else:
# sliced_d[key] = value[-last_item:]
# return sliced_d
#WIP
def create_new_bars(bars, new_resolution):
"""Creates new bars dictionary in the new resolution.
"""WIP - Creates new bars dictionary in the new resolution.
Args:
bars: A dictionary representing ohlcv bars.