|
13 | 13 | import numpy as np |
14 | 14 | import pandas as pd |
15 | 15 |
|
16 | | -from freqtrade.constants import LAST_BT_RESULT_FN, IntOrInf |
| 16 | +from freqtrade.constants import LAST_BT_RESULT_FN |
17 | 17 | from freqtrade.exceptions import ConfigurationError, OperationalException |
18 | 18 | from freqtrade.ft_types import BacktestHistoryEntryType, BacktestResultType |
19 | 19 | from freqtrade.misc import file_dump_json, json_load |
@@ -491,57 +491,6 @@ def load_exit_signal_candles(backtest_dir: Path) -> dict[str, dict[str, pd.DataF |
491 | 491 | return load_backtest_analysis_data(backtest_dir, "exited") |
492 | 492 |
|
493 | 493 |
|
494 | | -def analyze_trade_parallelism(trades: pd.DataFrame, timeframe: str) -> pd.DataFrame: |
495 | | - """ |
496 | | - Find overlapping trades by expanding each trade once per period it was open |
497 | | - and then counting overlaps. |
498 | | - :param trades: Trades Dataframe - can be loaded from backtest, or created |
499 | | - via trade_list_to_dataframe |
500 | | - :param timeframe: Timeframe used for backtest |
501 | | - :return: dataframe with open-counts per time-period in timeframe |
502 | | - """ |
503 | | - from freqtrade.exchange import timeframe_to_resample_freq |
504 | | - |
505 | | - timeframe_freq = timeframe_to_resample_freq(timeframe) |
506 | | - dates = [ |
507 | | - pd.Series( |
508 | | - pd.date_range( |
509 | | - row[1]["open_date"], |
510 | | - row[1]["close_date"], |
511 | | - freq=timeframe_freq, |
512 | | - # Exclude right boundary - the date is the candle open date. |
513 | | - inclusive="left", |
514 | | - ) |
515 | | - ) |
516 | | - for row in trades[["open_date", "close_date"]].iterrows() |
517 | | - ] |
518 | | - deltas = [len(x) for x in dates] |
519 | | - dates = pd.Series(pd.concat(dates).values, name="date") |
520 | | - df2 = pd.DataFrame(np.repeat(trades.values, deltas, axis=0), columns=trades.columns) |
521 | | - |
522 | | - df2 = pd.concat([dates, df2], axis=1) |
523 | | - df2 = df2.set_index("date") |
524 | | - df_final = df2.resample(timeframe_freq)[["pair"]].count() |
525 | | - df_final = df_final.rename({"pair": "open_trades"}, axis=1) |
526 | | - return df_final |
527 | | - |
528 | | - |
529 | | -def evaluate_result_multi( |
530 | | - trades: pd.DataFrame, timeframe: str, max_open_trades: IntOrInf |
531 | | -) -> pd.DataFrame: |
532 | | - """ |
533 | | - Find overlapping trades by expanding each trade once per period it was open |
534 | | - and then counting overlaps |
535 | | - :param trades: Trades Dataframe - can be loaded from backtest, or created |
536 | | - via trade_list_to_dataframe |
537 | | - :param timeframe: Frequency used for the backtest |
538 | | - :param max_open_trades: parameter max_open_trades used during backtest run |
539 | | - :return: dataframe with open-counts per time-period in freq |
540 | | - """ |
541 | | - df_final = analyze_trade_parallelism(trades, timeframe) |
542 | | - return df_final[df_final["open_trades"] > max_open_trades] |
543 | | - |
544 | | - |
545 | 494 | def trade_list_to_dataframe(trades: list[Trade] | list[LocalTrade]) -> pd.DataFrame: |
546 | 495 | """ |
547 | 496 | Convert list of Trade objects to pandas Dataframe |
|
0 commit comments