mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-09-20 01:21:11 +00:00
chore: Don't override builtins
This commit is contained in:
parent
8296e7010c
commit
deeabbca12
|
@ -2065,7 +2065,7 @@ class Exchange:
|
|||
def get_fee(
|
||||
self,
|
||||
symbol: str,
|
||||
type: str = "",
|
||||
order_type: str = "",
|
||||
side: str = "",
|
||||
amount: float = 1,
|
||||
price: float = 1,
|
||||
|
@ -2074,13 +2074,13 @@ class Exchange:
|
|||
"""
|
||||
Retrieve fee from exchange
|
||||
:param symbol: Pair
|
||||
:param type: Type of order (market, limit, ...)
|
||||
:param order_type: Type of order (market, limit, ...)
|
||||
:param side: Side of order (buy, sell)
|
||||
:param amount: Amount of order
|
||||
:param price: Price of order
|
||||
:param taker_or_maker: 'maker' or 'taker' (ignored if "type" is provided)
|
||||
"""
|
||||
if type and type == "market":
|
||||
if order_type and order_type == "market":
|
||||
taker_or_maker = "taker"
|
||||
try:
|
||||
if self._config["dry_run"] and self._config.get("fee", None) is not None:
|
||||
|
@ -2091,7 +2091,7 @@ class Exchange:
|
|||
|
||||
return self._api.calculate_fee(
|
||||
symbol=symbol,
|
||||
type=type,
|
||||
type=order_type,
|
||||
side=side,
|
||||
amount=amount,
|
||||
price=price,
|
||||
|
|
|
@ -45,10 +45,10 @@ class TensorBoardCallback(BaseTensorBoardCallback):
|
|||
return False
|
||||
|
||||
evals = ["validation", "train"]
|
||||
for metric, eval in zip(evals_log.items(), evals):
|
||||
for metric, eval_ in zip(evals_log.items(), evals):
|
||||
for metric_name, log in metric[1].items():
|
||||
score = log[-1][0] if isinstance(log[-1], tuple) else log[-1]
|
||||
self.writer.add_scalar(f"{eval}-{metric_name}", score, epoch)
|
||||
self.writer.add_scalar(f"{eval_}-{metric_name}", score, epoch)
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
@ -465,25 +465,25 @@ class Backtesting:
|
|||
return data
|
||||
|
||||
def _get_close_rate(
|
||||
self, row: Tuple, trade: LocalTrade, exit: ExitCheckTuple, trade_dur: int
|
||||
self, row: Tuple, trade: LocalTrade, exit_: ExitCheckTuple, trade_dur: int
|
||||
) -> float:
|
||||
"""
|
||||
Get close rate for backtesting result
|
||||
"""
|
||||
# Special handling if high or low hit STOP_LOSS or ROI
|
||||
if exit.exit_type in (
|
||||
if exit_.exit_type in (
|
||||
ExitType.STOP_LOSS,
|
||||
ExitType.TRAILING_STOP_LOSS,
|
||||
ExitType.LIQUIDATION,
|
||||
):
|
||||
return self._get_close_rate_for_stoploss(row, trade, exit, trade_dur)
|
||||
elif exit.exit_type == (ExitType.ROI):
|
||||
return self._get_close_rate_for_roi(row, trade, exit, trade_dur)
|
||||
return self._get_close_rate_for_stoploss(row, trade, exit_, trade_dur)
|
||||
elif exit_.exit_type == (ExitType.ROI):
|
||||
return self._get_close_rate_for_roi(row, trade, exit_, trade_dur)
|
||||
else:
|
||||
return row[OPEN_IDX]
|
||||
|
||||
def _get_close_rate_for_stoploss(
|
||||
self, row: Tuple, trade: LocalTrade, exit: ExitCheckTuple, trade_dur: int
|
||||
self, row: Tuple, trade: LocalTrade, exit_: ExitCheckTuple, trade_dur: int
|
||||
) -> float:
|
||||
# our stoploss was already lower than candle high,
|
||||
# possibly due to a cancelled trade exit.
|
||||
|
@ -491,7 +491,7 @@ class Backtesting:
|
|||
is_short = trade.is_short or False
|
||||
leverage = trade.leverage or 1.0
|
||||
side_1 = -1 if is_short else 1
|
||||
if exit.exit_type == ExitType.LIQUIDATION and trade.liquidation_price:
|
||||
if exit_.exit_type == ExitType.LIQUIDATION and trade.liquidation_price:
|
||||
stoploss_value = trade.liquidation_price
|
||||
else:
|
||||
stoploss_value = trade.stop_loss
|
||||
|
@ -506,7 +506,7 @@ class Backtesting:
|
|||
# Special case: trailing triggers within same candle as trade opened. Assume most
|
||||
# pessimistic price movement, which is moving just enough to arm stoploss and
|
||||
# immediately going down to stop price.
|
||||
if exit.exit_type == ExitType.TRAILING_STOP_LOSS and trade_dur == 0:
|
||||
if exit_.exit_type == ExitType.TRAILING_STOP_LOSS and trade_dur == 0:
|
||||
if (
|
||||
not self.strategy.use_custom_stoploss
|
||||
and self.strategy.trailing_stop
|
||||
|
@ -537,7 +537,7 @@ class Backtesting:
|
|||
return stoploss_value
|
||||
|
||||
def _get_close_rate_for_roi(
|
||||
self, row: Tuple, trade: LocalTrade, exit: ExitCheckTuple, trade_dur: int
|
||||
self, row: Tuple, trade: LocalTrade, exit_: ExitCheckTuple, trade_dur: int
|
||||
) -> float:
|
||||
is_short = trade.is_short or False
|
||||
leverage = trade.leverage or 1.0
|
||||
|
|
|
@ -32,12 +32,12 @@ def get_request_or_thread_id() -> Optional[str]:
|
|||
"""
|
||||
Helper method to get either async context (for fastapi requests), or thread id
|
||||
"""
|
||||
id = _request_id_ctx_var.get()
|
||||
if id is None:
|
||||
request_id = _request_id_ctx_var.get()
|
||||
if request_id is None:
|
||||
# when not in request context - use thread id
|
||||
id = str(threading.current_thread().ident)
|
||||
request_id = str(threading.current_thread().ident)
|
||||
|
||||
return id
|
||||
return request_id
|
||||
|
||||
|
||||
_SQL_DOCS_URL = "http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls"
|
||||
|
|
|
@ -2012,7 +2012,7 @@ class Trade(ModelBase, LocalTrade):
|
|||
).all()
|
||||
|
||||
resp: List[Dict] = []
|
||||
for id, enter_tag, exit_reason, profit, profit_abs, count in mix_tag_perf:
|
||||
for _, enter_tag, exit_reason, profit, profit_abs, count in mix_tag_perf:
|
||||
enter_tag = enter_tag if enter_tag is not None else "Other"
|
||||
exit_reason = exit_reason if exit_reason is not None else "Other"
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ class IResolver:
|
|||
|
||||
# Add extra directory to the top of the search paths
|
||||
if extra_dirs:
|
||||
for dir in extra_dirs:
|
||||
abs_paths.insert(0, Path(dir).resolve())
|
||||
for directory in extra_dirs:
|
||||
abs_paths.insert(0, Path(directory).resolve())
|
||||
|
||||
if cls.extra_path and (extra := config.get(cls.extra_path)):
|
||||
abs_paths.insert(0, Path(extra).resolve())
|
||||
|
|
|
@ -311,9 +311,9 @@ def warn_deprecated_setting(strategy: IStrategy, old: str, new: str, error=False
|
|||
setattr(strategy, new, getattr(strategy, f"{old}"))
|
||||
|
||||
|
||||
def check_override(object, parentclass, attribute):
|
||||
def check_override(obj, parentclass, attribute: str):
|
||||
"""
|
||||
Checks if a object overrides the parent class attribute.
|
||||
:returns: True if the object is overridden.
|
||||
"""
|
||||
return getattr(type(object), attribute) != getattr(parentclass, attribute)
|
||||
return getattr(type(obj), attribute) != getattr(parentclass, attribute)
|
||||
|
|
Loading…
Reference in New Issue
Block a user