mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-06 14:20:24 +00:00
Ruff --fix
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"""
|
||||
Functions to convert data from one format to another
|
||||
"""
|
||||
import itertools
|
||||
import logging
|
||||
import time
|
||||
from typing import Dict
|
||||
@@ -125,7 +124,7 @@ def populate_dataframe_with_trades(config: Config, dataframe: DataFrame, trades:
|
||||
pd.Timedelta(minutes=timeframe_minutes)
|
||||
# skip if there are no trades at next candle because that this candle isn't finished yet
|
||||
# if not np.any((candle_next == df.candle_start)):
|
||||
if not candle_next in trades_grouped_by_candle_start.groups:
|
||||
if candle_next not in trades_grouped_by_candle_start.groups:
|
||||
logger.warning(
|
||||
f"candle at {candle_start} with {len(trades_grouped_df)} trades might be unfinished, because no finished trades at {candle_next}")
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from pandas import DataFrame, Timedelta, Timestamp, to_timedelta
|
||||
|
||||
from freqtrade.configuration import TimeRange
|
||||
from freqtrade.constants import (FULL_DATAFRAME_THRESHOLD, Config, ListPairsWithTimeframes,
|
||||
ListTicksWithTimeframes, PairWithTimeframe)
|
||||
PairWithTimeframe)
|
||||
from freqtrade.data.converter import public_trades_to_dataframe
|
||||
from freqtrade.data.history import load_pair_history
|
||||
from freqtrade.data.history.idatahandler import get_datahandler
|
||||
|
||||
@@ -447,7 +447,7 @@ class Exchange:
|
||||
def trades(self, pair_interval: PairWithTimeframe, copy: bool = True) -> DataFrame:
|
||||
if pair_interval in self._trades:
|
||||
if copy:
|
||||
return self._trades[pair_interval].copy()
|
||||
return self._trades[pair_interval].copy()
|
||||
else:
|
||||
return self._trades[pair_interval]
|
||||
else:
|
||||
@@ -2310,7 +2310,7 @@ class Exchange:
|
||||
|
||||
def refresh_latest_trades(self,
|
||||
pair_list: ListPairsWithTimeframes,
|
||||
data_handler: Callable, # using IDataHandler ends with circular import,
|
||||
data_handler: Callable, # using IDataHandler ends with circular import,
|
||||
*,
|
||||
cache: bool = True,
|
||||
) -> Dict[PairWithTimeframe, DataFrame]:
|
||||
@@ -2342,13 +2342,13 @@ class Exchange:
|
||||
# fetch trades since latest _trades and
|
||||
# store together with existing trades
|
||||
try:
|
||||
until = None
|
||||
until = None
|
||||
from_id = None
|
||||
if is_in_cache:
|
||||
from_id = self._trades[(pair, timeframe, candle_type)].iloc[-1]['id']
|
||||
until = dt_ts() # now
|
||||
|
||||
else:
|
||||
else:
|
||||
until = int(timeframe_to_prev_date(timeframe).timestamp()) * 1000
|
||||
all_stored_ticks_df = data_handler.trades_load(f"{pair}-cached")
|
||||
|
||||
@@ -2358,7 +2358,7 @@ class Exchange:
|
||||
# only use cached if it's closer than first_candle_ms
|
||||
since_ms = last_cached_ms if last_cached_ms > first_candle_ms else first_candle_ms
|
||||
# doesn't go far enough
|
||||
else:
|
||||
else:
|
||||
all_stored_ticks_df = DataFrame(columns=DEFAULT_TRADES_COLUMNS + ['date'])
|
||||
|
||||
# from_id overrules with exchange set to id paginate
|
||||
@@ -2406,7 +2406,7 @@ class Exchange:
|
||||
# Timeframe in seconds
|
||||
df = self.klines((pair, timeframe, candle_type), True)
|
||||
_calculate_ohlcv_candle_start_and_end(df, timeframe)
|
||||
interval_in_sec = timeframe_to_seconds(timeframe)
|
||||
timeframe_to_seconds(timeframe)
|
||||
# plr = self._trades_last_refresh_time.get((pair, timeframe, candle_type), 0) + interval_in_sec
|
||||
plr = round(df.iloc[-1]["candle_end"].timestamp())
|
||||
now = int(timeframe_to_prev_date(timeframe).timestamp())
|
||||
@@ -2498,7 +2498,7 @@ class Exchange:
|
||||
pair, candle_type, timeframe, since_ms
|
||||
)
|
||||
params = deepcopy(self._ft_has.get('trades_params', {}))
|
||||
candle_limit = self.trades_candle_limit(
|
||||
candle_limit = self.trades_candle_limit(
|
||||
timeframe, candle_type=candle_type, since_ms=since_ms)
|
||||
|
||||
if candle_type and candle_type != CandleType.SPOT:
|
||||
@@ -2777,7 +2777,7 @@ class Exchange:
|
||||
pass
|
||||
return self.loop.run_until_complete(task)
|
||||
|
||||
def _download_trades_history(self,
|
||||
def _download_trades_history(self,
|
||||
pair: str,
|
||||
*,
|
||||
new_pairs_days: int = 30,
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
import arrow
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import pytest
|
||||
from pandas import DataFrame
|
||||
|
||||
from freqtrade.configuration import Configuration
|
||||
from freqtrade.constants import DEFAULT_ORDERFLOW_COLUMNS
|
||||
from freqtrade.data.converter import populate_dataframe_with_trades, public_trades_to_dataframe
|
||||
from freqtrade.data.converter.converter import trades_to_volumeprofile_with_total_delta_bid_ask
|
||||
from freqtrade.enums import CandleType, MarginMode, TradingMode
|
||||
from freqtrade.exchange.exchange import timeframe_to_minutes
|
||||
|
||||
|
||||
BIN_SIZE_SCALE = 0.5
|
||||
|
||||
Reference in New Issue
Block a user