Prepare protections for backtesting

This commit is contained in:
Matthias
2020-11-16 20:09:34 +01:00
parent 3426e99b8b
commit 98c88fa58e
6 changed files with 84 additions and 34 deletions

View File

@@ -3,7 +3,7 @@ Protection manager class
"""
import logging
from datetime import datetime, timezone
from typing import Dict, List
from typing import Dict, List, Optional
from freqtrade.persistence import PairLocks
from freqtrade.plugins.protections import IProtection
@@ -43,8 +43,9 @@ class ProtectionManager():
"""
return [{p.name: p.short_desc()} for p in self._protection_handlers]
def global_stop(self) -> bool:
now = datetime.now(timezone.utc)
def global_stop(self, now: Optional[datetime] = None) -> bool:
if not now:
now = datetime.now(timezone.utc)
result = False
for protection_handler in self._protection_handlers:
if protection_handler.has_global_stop:
@@ -57,8 +58,9 @@ class ProtectionManager():
result = True
return result
def stop_per_pair(self, pair) -> bool:
now = datetime.now(timezone.utc)
def stop_per_pair(self, pair, now: Optional[datetime] = None) -> bool:
if not now:
now = datetime.now(timezone.utc)
result = False
for protection_handler in self._protection_handlers:
if protection_handler.has_local_stop: