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

View File

@ -3,6 +3,7 @@
import logging
from collections import defaultdict
from copy import deepcopy
from datetime import datetime, timezone
from typing import Any, Dict, List, NamedTuple
import arrow
@ -97,7 +98,7 @@ class Edge:
heartbeat = self.edge_config.get('process_throttle_secs')
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
data: Dict[str, Any] = {}
@ -189,7 +190,7 @@ class Edge:
# Fill missing, calculable columns, profit, duration , abs etc.
trades_df = self._fill_calculable_fields(DataFrame(trades))
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

View File

@ -1,10 +1,9 @@
""" Binance exchange subclass """
import logging
from datetime import datetime
from datetime import datetime, timezone
from pathlib import Path
from typing import Dict, List, Optional, Tuple
import arrow
import ccxt
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:
# Set starting date to first available candle.
since_ms = x[3][0][0]
logger.info(f"Candle-data for {pair} available starting with "
f"{arrow.get(since_ms // 1000).isoformat()}.")
logger.info(
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(
pair=pair,