mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Update exchange_ws get_ohlcv logic
This commit is contained in:
@@ -7,7 +7,6 @@ import asyncio
|
||||
import inspect
|
||||
import logging
|
||||
import signal
|
||||
import time
|
||||
from copy import deepcopy
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from math import floor, isnan
|
||||
@@ -2258,7 +2257,7 @@ class Exchange:
|
||||
# Usable result ...
|
||||
logger.info(f"reuse watch result for {pair}, {timeframe}, {x}")
|
||||
|
||||
return self._exchange_ws.get_ohlcv(pair, timeframe, candle_type)
|
||||
return self._exchange_ws.get_ohlcv(pair, timeframe, candle_type, candle_date)
|
||||
|
||||
# Check if 1 call can get us updated candles without hole in the data.
|
||||
if min_date < last_refresh:
|
||||
|
||||
@@ -101,18 +101,24 @@ class ExchangeWS():
|
||||
self,
|
||||
pair: str,
|
||||
timeframe: str,
|
||||
candle_type: CandleType
|
||||
candle_type: CandleType,
|
||||
candle_date: int,
|
||||
) -> OHLCVResponse:
|
||||
"""
|
||||
Returns cached klines from ccxt's "watch" cache.
|
||||
:param candle_date: timestamp of the end-time of the candle.
|
||||
"""
|
||||
candles = self.ccxt_object.ohlcvs.get(pair, {}).get(timeframe)
|
||||
refresh_time = int(self.klines_last_refresh[(pair, timeframe, candle_type)] * 1000)
|
||||
refresh_date = self.klines_last_refresh[(pair, timeframe, candle_type)]
|
||||
drop_hint = False
|
||||
if refresh_date > candle_date:
|
||||
# Refreshed after candle was complete.
|
||||
logger.info(f"{candles[-1][0] // 1000} >= {candle_date}")
|
||||
drop_hint = (candles[-1][0] // 1000) >= candle_date
|
||||
logger.info(
|
||||
f"watch result for {pair}, {timeframe} with length {len(candles)}, "
|
||||
f"{datetime.fromtimestamp(candles[-1][0] // 1000)}, "
|
||||
f"lref={datetime.fromtimestamp(self.klines_last_refresh[(pair, timeframe, candle_type)])}")
|
||||
# Fake 1 candle - which is then removed again
|
||||
# TODO: is this really a good idea??
|
||||
# candles.append([refresh_time, 0, 0, 1, 2, 0])
|
||||
return pair, timeframe, candle_type, candles
|
||||
f"lref={datetime.fromtimestamp(self.klines_last_refresh[(pair, timeframe, candle_type)])}"
|
||||
f"candle_date={datetime.fromtimestamp(candle_date)}, {drop_hint=}"
|
||||
)
|
||||
return pair, timeframe, candle_type, candles, drop_hint
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import asyncio
|
||||
import threading
|
||||
from time import sleep
|
||||
|
||||
Reference in New Issue
Block a user