From d3f3c49b13a45bbccc9daded6af96b63570b6328 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 26 Dec 2021 15:29:10 +0100 Subject: [PATCH] Fix minor "gotchas" --- docs/strategy-advanced.md | 6 +++--- freqtrade/freqtradebot.py | 6 ++++-- tests/test_freqtradebot.py | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/strategy-advanced.md b/docs/strategy-advanced.md index 165faa299..a2d8d1b06 100644 --- a/docs/strategy-advanced.md +++ b/docs/strategy-advanced.md @@ -238,7 +238,7 @@ For performance reasons, it's disabled by default and freqtrade will show a warn The strategy is expected to return a stake_amount if and when an additional buy order should be made (position is increased). If there is not enough funds in the wallet then nothing will happen. Additional orders also mean additional fees and those orders don't count towards `max_open_trades`. -Using unlimited stake amount with DCA orders requires you to also implement `custom_stake_amount` callback to avoid allocating all funcds to initial order. +Using unlimited stake amount with DCA orders requires you to also implement `custom_stake_amount` callback to avoid allocating all funds to initial order. !!! Warning Stoploss is still calculated from the initial opening price, not averaged price. @@ -305,8 +305,8 @@ class DigDeeperStrategy(IStrategy): # Allow up to 3 additional increasingly larger buys (4 in total) # Initial buy is 1x # If that falls to -5% profit, we buy 1.25x more, average profit should increase to roughly -2.2% - # If that falles down to -5% again, we buy 1.5x more - # If that falles once again down to -5%, we buy 1.75x more + # If that falls down to -5% again, we buy 1.5x more + # If that falls once again down to -5%, we buy 1.75x more # Total stake for this trade would be 1 + 1.25 + 1.5 + 1.75 = 5.5x of the initial allowed stake. # That is why max_dca_multiplier is 5.5 # Hope you have a deep wallet! diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 22fcc4e9a..c2c698859 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -7,7 +7,7 @@ import traceback from datetime import datetime, timezone from math import isclose from threading import Lock -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List, Optional, Tuple import arrow @@ -650,7 +650,9 @@ class FreqtradeBot(LoggingMixin): logger.exception(f"Could not cancel stoploss order {trade.stoploss_order_id}") return trade - def get_valid_enter_price_and_stake(self, pair, price, stake_amount, trade): + def get_valid_enter_price_and_stake( + self, pair: str, price: Optional[float], stake_amount: float, + trade: Optional[Trade]) -> Tuple[float, float]: if price: enter_limit_requested = price else: diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 18f720782..7bcd9b64e 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -4432,11 +4432,11 @@ def test_position_adjust(mocker, default_conf_usdt, fee) -> None: assert order assert order.order_id == '650' - def make_sure_its_651(*apos, **kwargs): + def make_sure_its_651(*args, **kwargs): - if apos[0] == '650': + if args[0] == '650': return closed_successful_buy_order - if apos[0] == '651': + if args[0] == '651': return open_dca_order_1 return None