mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Fix default argument handling for timeframe_to_nextdate
This commit is contained in:
parent
23a70932d2
commit
ca739f71fb
|
@ -801,7 +801,7 @@ def timeframe_to_prev_date(timeframe: str, date: datetime = None) -> datetime:
|
|||
:returns: date of previous candle (with utc timezone)
|
||||
"""
|
||||
if not date:
|
||||
date = datetime.utcnow()
|
||||
date = datetime.now(timezone.utc)
|
||||
timeframe_secs = timeframe_to_seconds(timeframe)
|
||||
# Get offset based on timerame_secs
|
||||
offset = date.timestamp() % timeframe_secs
|
||||
|
|
|
@ -1588,6 +1588,9 @@ def test_timeframe_to_prev_date():
|
|||
for interval, result in tf_list:
|
||||
assert timeframe_to_prev_date(interval, date) == result
|
||||
|
||||
date = datetime.now(tz=timezone.utc)
|
||||
assert timeframe_to_prev_date("5m", date) < date
|
||||
|
||||
|
||||
def test_timeframe_to_next_date():
|
||||
# 2019-08-12 13:22:08
|
||||
|
@ -1609,3 +1612,6 @@ def test_timeframe_to_next_date():
|
|||
|
||||
for interval, result in tf_list:
|
||||
assert timeframe_to_next_date(interval, date) == result
|
||||
|
||||
date = datetime.now(tz=timezone.utc)
|
||||
assert timeframe_to_next_date("5m", date) > date
|
||||
|
|
Loading…
Reference in New Issue
Block a user