mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Remove formatting changes
This commit is contained in:
@@ -9,8 +9,7 @@ import numpy as np
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from pandas import DataFrame, to_datetime
|
from pandas import DataFrame, to_datetime
|
||||||
|
|
||||||
from freqtrade.constants import (DEFAULT_DATAFRAME_COLUMNS, DEFAULT_ORDERFLOW_COLUMNS,
|
from freqtrade.constants import DEFAULT_DATAFRAME_COLUMNS, DEFAULT_ORDERFLOW_COLUMNS, Config
|
||||||
Config)
|
|
||||||
from freqtrade.enums import CandleType, TradingMode
|
from freqtrade.enums import CandleType, TradingMode
|
||||||
from freqtrade.exchange.exchange_utils import timeframe_to_resample_freq
|
from freqtrade.exchange.exchange_utils import timeframe_to_resample_freq
|
||||||
|
|
||||||
@@ -31,8 +30,7 @@ def ohlcv_to_dataframe(ohlcv: list, timeframe: str, pair: str, *,
|
|||||||
:param drop_incomplete: Drop the last candle of the dataframe, assuming it's incomplete
|
:param drop_incomplete: Drop the last candle of the dataframe, assuming it's incomplete
|
||||||
:return: DataFrame
|
:return: DataFrame
|
||||||
"""
|
"""
|
||||||
logger.debug(
|
logger.debug(f"Converting candle (OHLCV) data to dataframe for pair {pair}.")
|
||||||
f"Converting candle (OHLCV) data to dataframe for pair {pair}.")
|
|
||||||
cols = DEFAULT_DATAFRAME_COLUMNS
|
cols = DEFAULT_DATAFRAME_COLUMNS
|
||||||
df = DataFrame(ohlcv, columns=cols)
|
df = DataFrame(ohlcv, columns=cols)
|
||||||
|
|
||||||
@@ -375,8 +373,7 @@ def ohlcv_fill_up_missing_data(dataframe: DataFrame, timeframe: str, pair: str)
|
|||||||
df.reset_index(inplace=True)
|
df.reset_index(inplace=True)
|
||||||
len_before = len(dataframe)
|
len_before = len(dataframe)
|
||||||
len_after = len(df)
|
len_after = len(df)
|
||||||
pct_missing = (len_after - len_before) / \
|
pct_missing = (len_after - len_before) / len_before if len_before > 0 else 0
|
||||||
len_before if len_before > 0 else 0
|
|
||||||
if len_before != len_after:
|
if len_before != len_after:
|
||||||
message = (f"Missing data fillup for {pair}, {timeframe}: "
|
message = (f"Missing data fillup for {pair}, {timeframe}: "
|
||||||
f"before: {len_before} - after: {len_after} - {pct_missing:.2%}")
|
f"before: {len_before} - after: {len_after} - {pct_missing:.2%}")
|
||||||
@@ -421,8 +418,7 @@ def trim_dataframes(preprocessed: Dict[str, DataFrame], timerange,
|
|||||||
processed: Dict[str, DataFrame] = {}
|
processed: Dict[str, DataFrame] = {}
|
||||||
|
|
||||||
for pair, df in preprocessed.items():
|
for pair, df in preprocessed.items():
|
||||||
trimed_df = trim_dataframe(
|
trimed_df = trim_dataframe(df, timerange, startup_candles=startup_candles)
|
||||||
df, timerange, startup_candles=startup_candles)
|
|
||||||
if not trimed_df.empty:
|
if not trimed_df.empty:
|
||||||
processed[pair] = trimed_df
|
processed[pair] = trimed_df
|
||||||
else:
|
else:
|
||||||
@@ -478,18 +474,15 @@ def convert_ohlcv_format(
|
|||||||
candle_types = [CandleType.from_string(ct) for ct in config.get('candle_types', [
|
candle_types = [CandleType.from_string(ct) for ct in config.get('candle_types', [
|
||||||
c.value for c in CandleType])]
|
c.value for c in CandleType])]
|
||||||
logger.info(candle_types)
|
logger.info(candle_types)
|
||||||
paircombs = src.ohlcv_get_available_data(
|
paircombs = src.ohlcv_get_available_data(config['datadir'], TradingMode.SPOT)
|
||||||
config['datadir'], TradingMode.SPOT)
|
paircombs.extend(src.ohlcv_get_available_data(config['datadir'], TradingMode.FUTURES))
|
||||||
paircombs.extend(src.ohlcv_get_available_data(
|
|
||||||
config['datadir'], TradingMode.FUTURES))
|
|
||||||
|
|
||||||
if 'pairs' in config:
|
if 'pairs' in config:
|
||||||
# Filter pairs
|
# Filter pairs
|
||||||
paircombs = [comb for comb in paircombs if comb[0] in config['pairs']]
|
paircombs = [comb for comb in paircombs if comb[0] in config['pairs']]
|
||||||
|
|
||||||
if 'timeframes' in config:
|
if 'timeframes' in config:
|
||||||
paircombs = [comb for comb in paircombs if comb[1]
|
paircombs = [comb for comb in paircombs if comb[1] in config['timeframes']]
|
||||||
in config['timeframes']]
|
|
||||||
paircombs = [comb for comb in paircombs if comb[2] in candle_types]
|
paircombs = [comb for comb in paircombs if comb[2] in candle_types]
|
||||||
|
|
||||||
paircombs = sorted(paircombs, key=lambda x: (x[0], x[1], x[2].value))
|
paircombs = sorted(paircombs, key=lambda x: (x[0], x[1], x[2].value))
|
||||||
@@ -506,8 +499,7 @@ def convert_ohlcv_format(
|
|||||||
drop_incomplete=False,
|
drop_incomplete=False,
|
||||||
startup_candles=0,
|
startup_candles=0,
|
||||||
candle_type=candle_type)
|
candle_type=candle_type)
|
||||||
logger.info(
|
logger.info(f"Converting {len(data)} {timeframe} {candle_type} candles for {pair}")
|
||||||
f"Converting {len(data)} {timeframe} {candle_type} candles for {pair}")
|
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
trg.ohlcv_store(
|
trg.ohlcv_store(
|
||||||
pair=pair,
|
pair=pair,
|
||||||
@@ -517,8 +509,7 @@ def convert_ohlcv_format(
|
|||||||
)
|
)
|
||||||
if erase and convert_from != convert_to:
|
if erase and convert_from != convert_to:
|
||||||
logger.info(f"Deleting source data for {pair} / {timeframe}")
|
logger.info(f"Deleting source data for {pair} / {timeframe}")
|
||||||
src.ohlcv_purge(pair=pair, timeframe=timeframe,
|
src.ohlcv_purge(pair=pair, timeframe=timeframe, candle_type=candle_type)
|
||||||
candle_type=candle_type)
|
|
||||||
|
|
||||||
|
|
||||||
def reduce_dataframe_footprint(df: DataFrame) -> DataFrame:
|
def reduce_dataframe_footprint(df: DataFrame) -> DataFrame:
|
||||||
|
|||||||
Reference in New Issue
Block a user