Reduce arrow usage throughout code

This commit is contained in:
Matthias
2023-05-14 09:13:25 +02:00
parent 1d03e8bc5f
commit 2477ef57f9
2 changed files with 7 additions and 6 deletions
+3 -2
View File
@@ -3,6 +3,7 @@
import logging import logging
from collections import defaultdict from collections import defaultdict
from copy import deepcopy from copy import deepcopy
from datetime import datetime, timezone
from typing import Any, Dict, List, NamedTuple from typing import Any, Dict, List, NamedTuple
import arrow import arrow
@@ -97,7 +98,7 @@ class Edge:
heartbeat = self.edge_config.get('process_throttle_secs') heartbeat = self.edge_config.get('process_throttle_secs')
if (self._last_updated > 0) and ( if (self._last_updated > 0) and (
self._last_updated + heartbeat > arrow.utcnow().int_timestamp): self._last_updated + heartbeat > int(datetime.now(timezone.utc).timestamp())):
return False return False
data: Dict[str, Any] = {} data: Dict[str, Any] = {}
@@ -189,7 +190,7 @@ class Edge:
# Fill missing, calculable columns, profit, duration , abs etc. # Fill missing, calculable columns, profit, duration , abs etc.
trades_df = self._fill_calculable_fields(DataFrame(trades)) trades_df = self._fill_calculable_fields(DataFrame(trades))
self._cached_pairs = self._process_expectancy(trades_df) self._cached_pairs = self._process_expectancy(trades_df)
self._last_updated = arrow.utcnow().int_timestamp self._last_updated = int(datetime.now(timezone.utc).timestamp())
return True return True
+4 -4
View File
@@ -1,10 +1,9 @@
""" Binance exchange subclass """ """ Binance exchange subclass """
import logging import logging
from datetime import datetime from datetime import datetime, timezone
from pathlib import Path from pathlib import Path
from typing import Dict, List, Optional, Tuple from typing import Dict, List, Optional, Tuple
import arrow
import ccxt import ccxt
from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode
@@ -105,8 +104,9 @@ class Binance(Exchange):
if x and x[3] and x[3][0] and x[3][0][0] > since_ms: if x and x[3] and x[3][0] and x[3][0][0] > since_ms:
# Set starting date to first available candle. # Set starting date to first available candle.
since_ms = x[3][0][0] since_ms = x[3][0][0]
logger.info(f"Candle-data for {pair} available starting with " logger.info(
f"{arrow.get(since_ms // 1000).isoformat()}.") f"Candle-data for {pair} available starting with "
f"{datetime.fromtimestamp(since_ms // 1000, tz=timezone.utc).isoformat()}.")
return await super()._async_get_historic_ohlcv( return await super()._async_get_historic_ohlcv(
pair=pair, pair=pair,