mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
refactor format_ms_time to misc.py
This commit is contained in:
parent
016232a8e9
commit
f51ef1a791
|
@ -72,3 +72,11 @@ def file_dump_json(filename, data) -> None:
|
|||
"""
|
||||
with open(filename, 'w') as fp:
|
||||
json.dump(data, fp, default=str)
|
||||
|
||||
|
||||
def format_ms_time(date: str) -> str:
|
||||
"""
|
||||
convert MS date to readable format.
|
||||
: epoch-string in ms
|
||||
"""
|
||||
return datetime.fromtimestamp(date/1000.0).strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
|
|
@ -4,7 +4,6 @@ import gzip
|
|||
import json
|
||||
import os
|
||||
from typing import Optional, List, Dict, Tuple
|
||||
from datetime import datetime
|
||||
|
||||
from freqtrade import misc
|
||||
from freqtrade.exchange import get_ticker_history
|
||||
|
@ -136,8 +135,8 @@ def download_backtesting_testdata(datadir: str, pair: str, interval: int = 5) ->
|
|||
if os.path.isfile(filename):
|
||||
with open(filename, "rt") as file:
|
||||
data = json.load(file)
|
||||
logger.debug("Current Start: %s", format_ms_time(data[1][0]))
|
||||
logger.debug("Current End: %s", format_ms_time(data[-1:][0][0]))
|
||||
logger.debug("Current Start: %s", misc.format_ms_time(data[1][0]))
|
||||
logger.debug("Current End: %s", misc.format_ms_time(data[-1:][0][0]))
|
||||
else:
|
||||
data = []
|
||||
logger.debug("Current Start: None")
|
||||
|
@ -147,14 +146,10 @@ def download_backtesting_testdata(datadir: str, pair: str, interval: int = 5) ->
|
|||
for row in new_data:
|
||||
if row not in data:
|
||||
data.append(row)
|
||||
logger.debug("New Start: %s", format_ms_time(data[0][0]))
|
||||
logger.debug("New End: %s", format_ms_time(data[-1:][0][0]))
|
||||
logger.debug("New Start: %s", misc.format_ms_time(data[0][0]))
|
||||
logger.debug("New End: %s", misc.format_ms_time(data[-1:][0][0]))
|
||||
data = sorted(data, key=lambda data: data[0])
|
||||
|
||||
misc.file_dump_json(filename, data)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def format_ms_time(date: str) -> str:
|
||||
return datetime.fromtimestamp(date/1000.0).strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
|
Loading…
Reference in New Issue
Block a user