Don't use arrow for everything
This commit is contained in:
@@ -3,9 +3,9 @@ Minimum age (days listed) pair list filter
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
from datetime import timedelta
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import arrow
|
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
|
|
||||||
from freqtrade.constants import Config, ListPairsWithTimeframes
|
from freqtrade.constants import Config, ListPairsWithTimeframes
|
||||||
@@ -13,7 +13,7 @@ from freqtrade.exceptions import OperationalException
|
|||||||
from freqtrade.exchange.types import Tickers
|
from freqtrade.exchange.types import Tickers
|
||||||
from freqtrade.misc import plural
|
from freqtrade.misc import plural
|
||||||
from freqtrade.plugins.pairlist.IPairList import IPairList
|
from freqtrade.plugins.pairlist.IPairList import IPairList
|
||||||
from freqtrade.util import PeriodicCache
|
from freqtrade.util import PeriodicCache, dt_floor_day, dt_now, dt_ts
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -84,10 +84,7 @@ class AgeFilter(IPairList):
|
|||||||
since_days = -(
|
since_days = -(
|
||||||
self._max_days_listed if self._max_days_listed else self._min_days_listed
|
self._max_days_listed if self._max_days_listed else self._min_days_listed
|
||||||
) - 1
|
) - 1
|
||||||
since_ms = int(arrow.utcnow()
|
since_ms = dt_ts(dt_floor_day(dt_now()) + timedelta(days=since_days))
|
||||||
.floor('day')
|
|
||||||
.shift(days=since_days)
|
|
||||||
.float_timestamp) * 1000
|
|
||||||
candles = self._exchange.refresh_latest_ohlcv(needed_pairs, since_ms=since_ms, cache=False)
|
candles = self._exchange.refresh_latest_ohlcv(needed_pairs, since_ms=since_ms, cache=False)
|
||||||
if self._enabled:
|
if self._enabled:
|
||||||
for p in deepcopy(pairlist):
|
for p in deepcopy(pairlist):
|
||||||
@@ -116,7 +113,7 @@ class AgeFilter(IPairList):
|
|||||||
):
|
):
|
||||||
# We have fetched at least the minimum required number of daily candles
|
# We have fetched at least the minimum required number of daily candles
|
||||||
# Add to cache, store the time we last checked this symbol
|
# Add to cache, store the time we last checked this symbol
|
||||||
self._symbolsChecked[pair] = arrow.utcnow().int_timestamp * 1000
|
self._symbolsChecked[pair] = dt_ts()
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
self.log_once((
|
self.log_once((
|
||||||
@@ -127,6 +124,6 @@ class AgeFilter(IPairList):
|
|||||||
" or more than "
|
" or more than "
|
||||||
f"{self._max_days_listed} {plural(self._max_days_listed, 'day')}"
|
f"{self._max_days_listed} {plural(self._max_days_listed, 'day')}"
|
||||||
) if self._max_days_listed else ''), logger.info)
|
) if self._max_days_listed else ''), logger.info)
|
||||||
self._symbolsCheckFailed[pair] = arrow.utcnow().int_timestamp * 1000
|
self._symbolsCheckFailed[pair] = dt_ts()
|
||||||
return False
|
return False
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ Volatility pairlist filter
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
from datetime import timedelta
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import arrow
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from cachetools import TTLCache
|
from cachetools import TTLCache
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
@@ -16,6 +16,7 @@ from freqtrade.exceptions import OperationalException
|
|||||||
from freqtrade.exchange.types import Tickers
|
from freqtrade.exchange.types import Tickers
|
||||||
from freqtrade.misc import plural
|
from freqtrade.misc import plural
|
||||||
from freqtrade.plugins.pairlist.IPairList import IPairList
|
from freqtrade.plugins.pairlist.IPairList import IPairList
|
||||||
|
from freqtrade.util import dt_floor_day, dt_now, dt_ts
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -73,10 +74,7 @@ class VolatilityFilter(IPairList):
|
|||||||
needed_pairs: ListPairsWithTimeframes = [
|
needed_pairs: ListPairsWithTimeframes = [
|
||||||
(p, '1d', self._def_candletype) for p in pairlist if p not in self._pair_cache]
|
(p, '1d', self._def_candletype) for p in pairlist if p not in self._pair_cache]
|
||||||
|
|
||||||
since_ms = (arrow.utcnow()
|
since_ms = dt_ts(dt_floor_day(dt_now()) - timedelta(days=self._days - 1))
|
||||||
.floor('day')
|
|
||||||
.shift(days=-self._days - 1)
|
|
||||||
.int_timestamp) * 1000
|
|
||||||
# Get all candles
|
# Get all candles
|
||||||
candles = {}
|
candles = {}
|
||||||
if needed_pairs:
|
if needed_pairs:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Volume PairList provider
|
|||||||
Provides dynamic pair list based on trade volumes
|
Provides dynamic pair list based on trade volumes
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import timedelta
|
||||||
from typing import Any, Dict, List, Literal
|
from typing import Any, Dict, List, Literal
|
||||||
|
|
||||||
from cachetools import TTLCache
|
from cachetools import TTLCache
|
||||||
@@ -15,6 +15,7 @@ from freqtrade.exchange import timeframe_to_minutes, timeframe_to_prev_date
|
|||||||
from freqtrade.exchange.types import Tickers
|
from freqtrade.exchange.types import Tickers
|
||||||
from freqtrade.misc import format_ms_time
|
from freqtrade.misc import format_ms_time
|
||||||
from freqtrade.plugins.pairlist.IPairList import IPairList
|
from freqtrade.plugins.pairlist.IPairList import IPairList
|
||||||
|
from freqtrade.util import dt_now
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -161,13 +162,13 @@ class VolumePairList(IPairList):
|
|||||||
# get lookback period in ms, for exchange ohlcv fetch
|
# get lookback period in ms, for exchange ohlcv fetch
|
||||||
since_ms = int(timeframe_to_prev_date(
|
since_ms = int(timeframe_to_prev_date(
|
||||||
self._lookback_timeframe,
|
self._lookback_timeframe,
|
||||||
datetime.now(timezone.utc) + timedelta(
|
dt_now() + timedelta(
|
||||||
minutes=-(self._lookback_period * self._tf_in_min) - self._tf_in_min)
|
minutes=-(self._lookback_period * self._tf_in_min) - self._tf_in_min)
|
||||||
).timestamp()) * 1000
|
).timestamp()) * 1000
|
||||||
|
|
||||||
to_ms = int(timeframe_to_prev_date(
|
to_ms = int(timeframe_to_prev_date(
|
||||||
self._lookback_timeframe,
|
self._lookback_timeframe,
|
||||||
datetime.now(timezone.utc) - timedelta(minutes=self._tf_in_min)
|
dt_now() - timedelta(minutes=self._tf_in_min)
|
||||||
).timestamp()) * 1000
|
).timestamp()) * 1000
|
||||||
|
|
||||||
# todo: utc date output for starting date
|
# todo: utc date output for starting date
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ Rate of change pairlist filter
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
from datetime import timedelta
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import arrow
|
|
||||||
from cachetools import TTLCache
|
from cachetools import TTLCache
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@ from freqtrade.exceptions import OperationalException
|
|||||||
from freqtrade.exchange.types import Tickers
|
from freqtrade.exchange.types import Tickers
|
||||||
from freqtrade.misc import plural
|
from freqtrade.misc import plural
|
||||||
from freqtrade.plugins.pairlist.IPairList import IPairList
|
from freqtrade.plugins.pairlist.IPairList import IPairList
|
||||||
|
from freqtrade.util import dt_floor_day, dt_now, dt_ts
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -71,10 +72,7 @@ class RangeStabilityFilter(IPairList):
|
|||||||
needed_pairs: ListPairsWithTimeframes = [
|
needed_pairs: ListPairsWithTimeframes = [
|
||||||
(p, '1d', self._def_candletype) for p in pairlist if p not in self._pair_cache]
|
(p, '1d', self._def_candletype) for p in pairlist if p not in self._pair_cache]
|
||||||
|
|
||||||
since_ms = (arrow.utcnow()
|
since_ms = dt_ts(dt_floor_day(dt_now()) - timedelta(days=self._days - 1))
|
||||||
.floor('day')
|
|
||||||
.shift(days=-self._days - 1)
|
|
||||||
.int_timestamp) * 1000
|
|
||||||
# Get all candles
|
# Get all candles
|
||||||
candles = {}
|
candles = {}
|
||||||
if needed_pairs:
|
if needed_pairs:
|
||||||
|
|||||||
Reference in New Issue
Block a user