bugfix
This commit is contained in:
@ -5,12 +5,14 @@ from v2realbot.utils.utils import slice_dict_lists,zoneUTC,safe_get, AttributeDi
|
|||||||
#id = "b11c66d9-a9b6-475a-9ac1-28b11e1b4edf"
|
#id = "b11c66d9-a9b6-475a-9ac1-28b11e1b4edf"
|
||||||
#state = AttributeDict(vars={})
|
#state = AttributeDict(vars={})
|
||||||
from rich import print
|
from rich import print
|
||||||
|
from traceback import format_exc
|
||||||
|
|
||||||
def attach_previous_data(state):
|
def attach_previous_data(state):
|
||||||
"""""
|
"""""
|
||||||
Attaches data from previous runner of the same batch.
|
Attaches data from previous runner of the same batch.
|
||||||
"""""
|
"""""
|
||||||
print("ATTACHING PREVIOUS DATA")
|
print("ATTACHING PREVIOUS DATA")
|
||||||
|
try:
|
||||||
runner : Runner
|
runner : Runner
|
||||||
#get batch_id of current runer
|
#get batch_id of current runer
|
||||||
res, runner = cs.get_runner(state.runner_id)
|
res, runner = cs.get_runner(state.runner_id)
|
||||||
@ -57,6 +59,10 @@ def attach_previous_data(state):
|
|||||||
detail = RunArchiveDetail(**val)
|
detail = RunArchiveDetail(**val)
|
||||||
#print("toto jsme si dotahnuli", detail.bars)
|
#print("toto jsme si dotahnuli", detail.bars)
|
||||||
|
|
||||||
|
if len(detail.bars["time"]) == 0:
|
||||||
|
print(f"no bars for runner {last_runner}")
|
||||||
|
return None
|
||||||
|
|
||||||
# from stratvars directives
|
# from stratvars directives
|
||||||
attach_previous_bar_data = safe_get(state.vars, "attach_previous_bar_data", 50)
|
attach_previous_bar_data = safe_get(state.vars, "attach_previous_bar_data", 50)
|
||||||
attach_previous_tick_data = safe_get(state.vars, "attach_previous_tick_data", None)
|
attach_previous_tick_data = safe_get(state.vars, "attach_previous_tick_data", None)
|
||||||
@ -67,6 +73,7 @@ def attach_previous_data(state):
|
|||||||
#time -datetime utc, updated - timestamp float
|
#time -datetime utc, updated - timestamp float
|
||||||
bars = slice_dict_lists(d=detail.bars, last_item=attach_previous_bar_data, time_to_datetime=True)
|
bars = slice_dict_lists(d=detail.bars, last_item=attach_previous_bar_data, time_to_datetime=True)
|
||||||
|
|
||||||
|
cbar_ids = {}
|
||||||
#zarovname tick spolu s bar daty
|
#zarovname tick spolu s bar daty
|
||||||
if attach_previous_tick_data is None:
|
if attach_previous_tick_data is None:
|
||||||
oldest_timestamp = bars["updated"][0]
|
oldest_timestamp = bars["updated"][0]
|
||||||
@ -98,6 +105,8 @@ def attach_previous_data(state):
|
|||||||
# if hasattr(detail, "ext_data") and "dailyBars" in detail.ext_data:
|
# if hasattr(detail, "ext_data") and "dailyBars" in detail.ext_data:
|
||||||
# state.dailyBars = detail.ext_data["dailyBars"]
|
# state.dailyBars = detail.ext_data["dailyBars"]
|
||||||
return
|
return
|
||||||
|
except Exception as e:
|
||||||
|
print(str(e)+format_exc())
|
||||||
|
return None
|
||||||
# if __name__ == "__main__":
|
# if __name__ == "__main__":
|
||||||
# attach_previous_data(state)
|
# attach_previous_data(state)
|
||||||
Reference in New Issue
Block a user