mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-26 22:31:32 +00:00
feat: use get_dry_run_wallet helper
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Any
|
||||
from freqtrade import constants
|
||||
from freqtrade.enums import RunMode
|
||||
from freqtrade.exceptions import ConfigurationError, OperationalException
|
||||
from freqtrade.util import get_dry_run_wallet
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -26,7 +27,7 @@ def setup_optimize_configuration(args: dict[str, Any], method: RunMode) -> dict[
|
||||
RunMode.HYPEROPT: "hyperoptimization",
|
||||
}
|
||||
if method in no_unlimited_runmodes.keys():
|
||||
wallet_size = config["dry_run_wallet"] * config["tradable_balance_ratio"]
|
||||
wallet_size = get_dry_run_wallet(config) * config["tradable_balance_ratio"]
|
||||
# tradable_balance_ratio
|
||||
if (
|
||||
config["stake_amount"] != constants.UNLIMITED_STAKE_AMOUNT
|
||||
|
||||
@@ -10,7 +10,7 @@ from freqtrade.constants import Config
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.optimize.analysis.lookahead import LookaheadAnalysis
|
||||
from freqtrade.resolvers import StrategyResolver
|
||||
from freqtrade.util import print_rich_table
|
||||
from freqtrade.util import get_dry_run_wallet, print_rich_table
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -163,7 +163,7 @@ class LookaheadAnalysisSubFunctions:
|
||||
config["max_open_trades"] = len(config["pairs"])
|
||||
|
||||
min_dry_run_wallet = 1000000000
|
||||
if config["dry_run_wallet"] < min_dry_run_wallet:
|
||||
if get_dry_run_wallet(config) < min_dry_run_wallet:
|
||||
logger.info(
|
||||
"Dry run wallet was not set to 1 billion, pushing it up there "
|
||||
"just to avoid false positives"
|
||||
|
||||
@@ -12,6 +12,7 @@ from pandas import DataFrame
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.data.metrics import calculate_calmar
|
||||
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||
from freqtrade.util import get_dry_run_wallet
|
||||
|
||||
|
||||
class CalmarHyperOptLoss(IHyperOptLoss):
|
||||
@@ -36,7 +37,7 @@ class CalmarHyperOptLoss(IHyperOptLoss):
|
||||
|
||||
Uses Calmar Ratio calculation.
|
||||
"""
|
||||
starting_balance = config["dry_run_wallet"]
|
||||
starting_balance = get_dry_run_wallet(config)
|
||||
calmar_ratio = calculate_calmar(results, min_date, max_date, starting_balance)
|
||||
# print(expected_returns_mean, max_drawdown, calmar_ratio)
|
||||
return -calmar_ratio
|
||||
|
||||
@@ -10,6 +10,7 @@ from pandas import DataFrame
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.data.metrics import calculate_underwater
|
||||
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||
from freqtrade.util import get_dry_run_wallet
|
||||
|
||||
|
||||
class MaxDrawDownRelativeHyperOptLoss(IHyperOptLoss):
|
||||
@@ -31,7 +32,7 @@ class MaxDrawDownRelativeHyperOptLoss(IHyperOptLoss):
|
||||
total_profit = results["profit_abs"].sum()
|
||||
try:
|
||||
drawdown_df = calculate_underwater(
|
||||
results, value_col="profit_abs", starting_balance=config["dry_run_wallet"]
|
||||
results, value_col="profit_abs", starting_balance=get_dry_run_wallet(config)
|
||||
)
|
||||
max_drawdown = abs(min(drawdown_df["drawdown"]))
|
||||
relative_drawdown = max(drawdown_df["drawdown_relative"])
|
||||
|
||||
@@ -36,6 +36,7 @@ from pandas import DataFrame
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.data.metrics import calculate_expectancy, calculate_max_drawdown
|
||||
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||
from freqtrade.util import get_dry_run_wallet
|
||||
|
||||
|
||||
# smaller numbers penalize drawdowns more severely
|
||||
@@ -83,7 +84,7 @@ class MultiMetricHyperOptLoss(IHyperOptLoss):
|
||||
# Calculate drawdown
|
||||
try:
|
||||
drawdown = calculate_max_drawdown(
|
||||
results, starting_balance=config["dry_run_wallet"], value_col="profit_abs"
|
||||
results, starting_balance=get_dry_run_wallet(config), value_col="profit_abs"
|
||||
)
|
||||
relative_account_drawdown = drawdown.relative_account_drawdown
|
||||
except ValueError:
|
||||
|
||||
@@ -13,6 +13,7 @@ from pandas import DataFrame
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.data.metrics import calculate_max_drawdown
|
||||
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||
from freqtrade.util import get_dry_run_wallet
|
||||
|
||||
|
||||
# smaller numbers penalize drawdowns more severely
|
||||
@@ -26,7 +27,7 @@ class ProfitDrawDownHyperOptLoss(IHyperOptLoss):
|
||||
|
||||
try:
|
||||
drawdown = calculate_max_drawdown(
|
||||
results, starting_balance=config["dry_run_wallet"], value_col="profit_abs"
|
||||
results, starting_balance=get_dry_run_wallet(config), value_col="profit_abs"
|
||||
)
|
||||
relative_account_drawdown = drawdown.relative_account_drawdown
|
||||
except ValueError:
|
||||
|
||||
@@ -12,6 +12,7 @@ from pandas import DataFrame
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.data.metrics import calculate_sharpe
|
||||
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||
from freqtrade.util.dry_run_wallet import get_dry_run_wallet
|
||||
|
||||
|
||||
class SharpeHyperOptLoss(IHyperOptLoss):
|
||||
@@ -36,7 +37,7 @@ class SharpeHyperOptLoss(IHyperOptLoss):
|
||||
|
||||
Uses Sharpe Ratio calculation.
|
||||
"""
|
||||
starting_balance = config["dry_run_wallet"]
|
||||
starting_balance = get_dry_run_wallet(config)
|
||||
sharp_ratio = calculate_sharpe(results, min_date, max_date, starting_balance)
|
||||
# print(expected_returns_mean, up_stdev, sharp_ratio)
|
||||
return -sharp_ratio
|
||||
|
||||
@@ -12,6 +12,7 @@ from pandas import DataFrame
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.data.metrics import calculate_sortino
|
||||
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||
from freqtrade.util import get_dry_run_wallet
|
||||
|
||||
|
||||
class SortinoHyperOptLoss(IHyperOptLoss):
|
||||
@@ -36,7 +37,7 @@ class SortinoHyperOptLoss(IHyperOptLoss):
|
||||
|
||||
Uses Sortino Ratio calculation.
|
||||
"""
|
||||
starting_balance = config["dry_run_wallet"]
|
||||
starting_balance = get_dry_run_wallet(config)
|
||||
sortino_ratio = calculate_sortino(results, min_date, max_date, starting_balance)
|
||||
# print(expected_returns_mean, down_stdev, sortino_ratio)
|
||||
return -sortino_ratio
|
||||
|
||||
@@ -18,7 +18,7 @@ from freqtrade.data.metrics import (
|
||||
calculate_sortino,
|
||||
)
|
||||
from freqtrade.ft_types import BacktestResultType
|
||||
from freqtrade.util import decimals_per_coin, fmt_coin
|
||||
from freqtrade.util import decimals_per_coin, fmt_coin, get_dry_run_wallet
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -373,7 +373,7 @@ def generate_strategy_stats(
|
||||
return {}
|
||||
config = content["config"]
|
||||
max_open_trades = min(config["max_open_trades"], len(pairlist))
|
||||
start_balance = config["dry_run_wallet"]
|
||||
start_balance = get_dry_run_wallet(config)
|
||||
stake_currency = config["stake_currency"]
|
||||
|
||||
pair_results = generate_pair_metrics(
|
||||
|
||||
@@ -28,6 +28,7 @@ from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist
|
||||
from freqtrade.resolvers import ExchangeResolver, StrategyResolver
|
||||
from freqtrade.strategy import IStrategy
|
||||
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
|
||||
from freqtrade.util import get_dry_run_wallet
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -706,7 +707,7 @@ def plot_profit(config: Config) -> None:
|
||||
trades,
|
||||
config["timeframe"],
|
||||
config.get("stake_currency", ""),
|
||||
config.get("available_capital", config["dry_run_wallet"]),
|
||||
config.get("available_capital", get_dry_run_wallet(config)),
|
||||
)
|
||||
store_plot_file(
|
||||
fig,
|
||||
|
||||
Reference in New Issue
Block a user