mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-16 21:01:14 +00:00
exchange: fix import of clean_ohlcv_dataframe, raise exception when no trades received
This commit is contained in:
@@ -22,7 +22,7 @@ from pandas import DataFrame, concat
|
|||||||
from freqtrade.constants import (DEFAULT_TRADES_COLUMNS, DEFAULT_AMOUNT_RESERVE_PERCENT, NON_OPEN_EXCHANGE_STATES, BidAsk,
|
from freqtrade.constants import (DEFAULT_TRADES_COLUMNS, DEFAULT_AMOUNT_RESERVE_PERCENT, NON_OPEN_EXCHANGE_STATES, BidAsk,
|
||||||
BuySell, Config, EntryExit, ExchangeConfig,
|
BuySell, Config, EntryExit, ExchangeConfig,
|
||||||
ListPairsWithTimeframes, MakerTaker, OBLiteral, PairWithTimeframe)
|
ListPairsWithTimeframes, MakerTaker, OBLiteral, PairWithTimeframe)
|
||||||
from freqtrade.data.converter import clean_ohlcv_dataframe, ohlcv_to_dataframe, trades_dict_to_list, public_trades_to_dataframe
|
from freqtrade.data.converter import clean_duplicate_trades, clean_ohlcv_dataframe, ohlcv_to_dataframe, trades_dict_to_list, public_trades_to_dataframe
|
||||||
from freqtrade.data.converter.converter import _calculate_ohlcv_candle_start_and_end
|
from freqtrade.data.converter.converter import _calculate_ohlcv_candle_start_and_end
|
||||||
from freqtrade.enums import OPTIMIZE_MODES, CandleType, MarginMode, PriceType, TradingMode
|
from freqtrade.enums import OPTIMIZE_MODES, CandleType, MarginMode, PriceType, TradingMode
|
||||||
from freqtrade.exceptions import (DDosProtection, ExchangeError, InsufficientFundsError,
|
from freqtrade.exceptions import (DDosProtection, ExchangeError, InsufficientFundsError,
|
||||||
@@ -2361,6 +2361,7 @@ class Exchange:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Refreshing TRADES data for {pair} failed")
|
logger.error(f"Refreshing TRADES data for {pair} failed")
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
if new_ticks:
|
if new_ticks:
|
||||||
@@ -2374,6 +2375,9 @@ class Exchange:
|
|||||||
results_df[(pair, timeframe, candle_type)] = trades_df
|
results_df[(pair, timeframe, candle_type)] = trades_df
|
||||||
data_handler.trades_store(f"{pair}-cached", trades_df[DEFAULT_TRADES_COLUMNS])
|
data_handler.trades_store(f"{pair}-cached", trades_df[DEFAULT_TRADES_COLUMNS])
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise "no new ticks"
|
||||||
|
|
||||||
return results_df
|
return results_df
|
||||||
|
|
||||||
|
|
||||||
@@ -2573,7 +2577,8 @@ class Exchange:
|
|||||||
trades = await self._api_async.fetch_trades(pair, since=since, limit=candle_limit)
|
trades = await self._api_async.fetch_trades(pair, since=since, limit=candle_limit)
|
||||||
trades = self._trades_contracts_to_amount(trades)
|
trades = self._trades_contracts_to_amount(trades)
|
||||||
|
|
||||||
logger.debug( "Fetched trades for pair %s, datetime: %s (%d).", pair, trades[0]['datetime'], trades[0]['timestamp'] )
|
if trades:
|
||||||
|
logger.debug("Fetched trades for pair %s, datetime: %s (%d).", pair, trades[0]['datetime'], trades[0]['timestamp'] )
|
||||||
return trades_dict_to_list(trades)
|
return trades_dict_to_list(trades)
|
||||||
except ccxt.NotSupported as e:
|
except ccxt.NotSupported as e:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
@@ -2614,10 +2619,13 @@ class Exchange:
|
|||||||
# e.g. Binance returns the "last 1000" candles within a 1h time interval
|
# e.g. Binance returns the "last 1000" candles within a 1h time interval
|
||||||
# - so we will miss the first trades.
|
# - so we will miss the first trades.
|
||||||
trade = await self._async_fetch_trades(pair, since=since)
|
trade = await self._async_fetch_trades(pair, since=since)
|
||||||
|
if trade:
|
||||||
# DEFAULT_TRADES_COLUMNS: 0 -> timestamp
|
# DEFAULT_TRADES_COLUMNS: 0 -> timestamp
|
||||||
# DEFAULT_TRADES_COLUMNS: 1 -> id
|
# DEFAULT_TRADES_COLUMNS: 1 -> id
|
||||||
from_id = trade[-1][1]
|
from_id = trade[-1][1]
|
||||||
trades.extend(trade[:-1])
|
trades.extend(trade[:-1])
|
||||||
|
else:
|
||||||
|
return (pair, trades)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
t = await self._async_fetch_trades(pair,
|
t = await self._async_fetch_trades(pair,
|
||||||
|
|||||||
Reference in New Issue
Block a user