Align interfaces and strategy templates

This commit is contained in:
Matthias 2022-05-07 11:55:49 +02:00
parent 3f68c3b68e
commit f1a72e448a
7 changed files with 20 additions and 15 deletions

View File

@ -656,7 +656,7 @@ class DigDeeperStrategy(IStrategy):
# This is called when placing the initial order (opening trade)
def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
proposed_stake: float, min_stake: float, max_stake: float,
proposed_stake: float, min_stake: Optional[float], max_stake: float,
entry_tag: Optional[str], side: str, **kwargs) -> float:
# We need to leave most of the funds for possible further DCA orders
@ -664,7 +664,7 @@ class DigDeeperStrategy(IStrategy):
return proposed_stake / self.max_dca_multiplier
def adjust_trade_position(self, trade: Trade, current_time: datetime,
current_rate: float, current_profit: float, min_stake: float,
current_rate: float, current_profit: float, min_stake: Optional[float],
max_stake: float, **kwargs):
"""
Custom trade adjustment logic, returning the stake amount that a trade should be increased.

View File

@ -199,7 +199,7 @@ New string argument `side` - which can be either `"long"` or `"short"`.
``` python hl_lines="4"
class AwesomeStrategy(IStrategy):
def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
proposed_stake: float, min_stake: float, max_stake: float,
proposed_stake: float, min_stake: Optional[float], max_stake: float,
entry_tag: Optional[str], **kwargs) -> float:
# ...
return proposed_stake
@ -208,7 +208,7 @@ class AwesomeStrategy(IStrategy):
``` python hl_lines="4"
class AwesomeStrategy(IStrategy):
def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
proposed_stake: float, min_stake: float, max_stake: float,
proposed_stake: float, min_stake: Optional[float], max_stake: float,
entry_tag: Optional[str], side: str, **kwargs) -> float:
# ...
return proposed_stake

View File

@ -429,7 +429,7 @@ class IStrategy(ABC, HyperStrategyMixin):
return self.custom_sell(pair, trade, current_time, current_rate, current_profit, **kwargs)
def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
proposed_stake: float, min_stake: float, max_stake: float,
proposed_stake: float, min_stake: Optional[float], max_stake: float,
entry_tag: Optional[str], side: str, **kwargs) -> float:
"""
Customize stake size for each new trade.
@ -447,8 +447,9 @@ class IStrategy(ABC, HyperStrategyMixin):
return proposed_stake
def adjust_trade_position(self, trade: Trade, current_time: datetime,
current_rate: float, current_profit: float, min_stake: float,
max_stake: float, **kwargs) -> Optional[float]:
current_rate: float, current_profit: float,
min_stake: Optional[float], max_stake: float,
**kwargs) -> Optional[float]:
"""
Custom trade adjustment logic, returning the stake amount that a trade should be increased.
This means extra buy orders with additional fees.

View File

@ -6,7 +6,7 @@ import numpy as np # noqa
import pandas as pd # noqa
from pandas import DataFrame # noqa
from datetime import datetime # noqa
from typing import Optional # noqa
from typing import Optional, Union # noqa
from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter,
IStrategy, IntParameter)

View File

@ -13,7 +13,7 @@ def bot_loop_start(self, **kwargs) -> None:
pass
def custom_entry_price(self, pair: str, current_time: 'datetime', proposed_rate: float,
entry_tag: Optional[str], **kwargs) -> float:
entry_tag: 'Optional[str]', side: str, **kwargs) -> float:
"""
Custom entry price logic, returning the new entry price.
@ -80,8 +80,8 @@ def custom_exit_price(self, pair: str, trade: 'Trade',
return proposed_rate
def custom_stake_amount(self, pair: str, current_time: 'datetime', current_rate: float,
proposed_stake: float, min_stake: float, max_stake: float,
side: str, entry_tag: Optional[str], **kwargs) -> float:
proposed_stake: float, min_stake: Optional[float], max_stake: float,
entry_tag: 'Optional[str]', side: str, **kwargs) -> float:
"""
Customize stake size for each new trade.
@ -244,8 +244,8 @@ def check_exit_timeout(self, pair: str, trade: 'Trade', order: 'Order',
return False
def adjust_trade_position(self, trade: 'Trade', current_time: 'datetime',
current_rate: float, current_profit: float, min_stake: float,
max_stake: float, **kwargs) -> Optional[float]:
current_rate: float, current_profit: float, min_stake: Optional[float],
max_stake: float, **kwargs) -> 'Optional[float]':
"""
Custom trade adjustment logic, returning the stake amount that a trade should be increased.
This means extra buy orders with additional fees.

View File

@ -1,6 +1,7 @@
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
from datetime import datetime
from typing import Optional
import talib.abstract as ta
from pandas import DataFrame
@ -151,7 +152,8 @@ class StrategyTestV2(IStrategy):
return dataframe
def adjust_trade_position(self, trade: Trade, current_time: datetime, current_rate: float,
current_profit: float, min_stake: float, max_stake: float, **kwargs):
current_profit: float,
min_stake: Optional[float], max_stake: float, **kwargs):
if current_profit < -0.0075:
orders = trade.select_filled_orders('buy')

View File

@ -1,6 +1,7 @@
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
from datetime import datetime
from typing import Optional
import talib.abstract as ta
from pandas import DataFrame
@ -185,7 +186,8 @@ class StrategyTestV3(IStrategy):
return 3.0
def adjust_trade_position(self, trade: Trade, current_time: datetime, current_rate: float,
current_profit: float, min_stake: float, max_stake: float, **kwargs):
current_profit: float,
min_stake: Optional[float], max_stake: float, **kwargs):
if current_profit < -0.0075:
orders = trade.select_filled_orders(trade.entry_side)