Update buy_tag column to long_tag
This commit is contained in:
parent
a0ef89d910
commit
2a678bdbb4
@ -31,6 +31,7 @@ BT_DATA_COLUMNS = ['pair', 'stake_amount', 'amount', 'open_date', 'close_date',
|
||||
'profit_ratio', 'profit_abs', 'sell_reason',
|
||||
'initial_stop_loss_abs', 'initial_stop_loss_ratio', 'stop_loss_abs',
|
||||
'stop_loss_ratio', 'min_rate', 'max_rate', 'is_open', 'buy_tag']
|
||||
# TODO-lev: usage of the above might need compatibility code (buy_tag, is_short?, ...?)
|
||||
|
||||
|
||||
def get_latest_optimize_filename(directory: Union[Path, str], variant: str) -> str:
|
||||
|
@ -15,7 +15,7 @@ class SignalTagType(Enum):
|
||||
"""
|
||||
Enum for signal columns
|
||||
"""
|
||||
BUY_TAG = "buy_tag"
|
||||
LONG_TAG = "long_tag"
|
||||
SHORT_TAG = "short_tag"
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ LONG_IDX = 5
|
||||
ELONG_IDX = 6 # Exit long
|
||||
SHORT_IDX = 7
|
||||
ESHORT_IDX = 8 # Exit short
|
||||
BUY_TAG_IDX = 9
|
||||
ENTER_TAG_IDX = 9
|
||||
SHORT_TAG_IDX = 10
|
||||
|
||||
|
||||
@ -454,7 +454,8 @@ class Backtesting:
|
||||
|
||||
if stake_amount and (not min_stake_amount or stake_amount > min_stake_amount):
|
||||
# Enter trade
|
||||
has_buy_tag = len(row) >= BUY_TAG_IDX + 1
|
||||
# TODO-lev: SHORT_TAG ...
|
||||
has_buy_tag = len(row) >= ENTER_TAG_IDX + 1
|
||||
trade = LocalTrade(
|
||||
pair=pair,
|
||||
open_rate=row[OPEN_IDX],
|
||||
@ -464,7 +465,7 @@ class Backtesting:
|
||||
fee_open=self.fee,
|
||||
fee_close=self.fee,
|
||||
is_open=True,
|
||||
buy_tag=row[BUY_TAG_IDX] if has_buy_tag else None,
|
||||
buy_tag=row[ENTER_TAG_IDX] if has_buy_tag else None,
|
||||
exchange=self._exchange_name,
|
||||
is_short=(direction == 'short'),
|
||||
)
|
||||
|
@ -519,7 +519,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
dataframe[SignalType.EXIT_LONG.value] = 0
|
||||
dataframe[SignalType.ENTER_SHORT.value] = 0
|
||||
dataframe[SignalType.EXIT_SHORT.value] = 0
|
||||
dataframe[SignalTagType.BUY_TAG.value] = None
|
||||
dataframe[SignalTagType.LONG_TAG.value] = None
|
||||
dataframe[SignalTagType.SHORT_TAG.value] = None
|
||||
|
||||
# Other Defs in strategy that want to be called every loop here
|
||||
@ -690,7 +690,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
enter_tag_value: Optional[str] = None
|
||||
if enter_long == 1 and not any([exit_long, enter_short]):
|
||||
enter_signal = SignalDirection.LONG
|
||||
enter_tag_value = latest.get(SignalTagType.BUY_TAG.value, None)
|
||||
enter_tag_value = latest.get(SignalTagType.LONG_TAG.value, None)
|
||||
if enter_short == 1 and not any([exit_short, enter_long]):
|
||||
enter_signal = SignalDirection.SHORT
|
||||
enter_tag_value = latest.get(SignalTagType.SHORT_TAG.value, None)
|
||||
|
@ -167,7 +167,7 @@ def test__pprint_dict():
|
||||
|
||||
def test_get_strategy_filename(default_conf):
|
||||
|
||||
x = HyperoptTools.get_strategy_filename(default_conf, CURRENT_TEST_STRATEGY)
|
||||
x = HyperoptTools.get_strategy_filename(default_conf, 'StrategyTestV3')
|
||||
assert isinstance(x, Path)
|
||||
assert x == Path(__file__).parents[1] / 'strategy/strats/strategy_test_v3.py'
|
||||
|
||||
|
@ -59,7 +59,7 @@ def test_returns_latest_signal(ohlcv_history):
|
||||
assert _STRATEGY.get_exit_signal('ETH/BTC', '5m', mocked_history, True) == (False, False)
|
||||
mocked_history.loc[1, 'exit_long'] = 0
|
||||
mocked_history.loc[1, 'enter_long'] = 1
|
||||
mocked_history.loc[1, 'buy_tag'] = 'buy_signal_01'
|
||||
mocked_history.loc[1, 'long_tag'] = 'buy_signal_01'
|
||||
|
||||
assert _STRATEGY.get_entry_signal(
|
||||
'ETH/BTC', '5m', mocked_history) == (SignalDirection.LONG, 'buy_signal_01')
|
||||
|
Loading…
Reference in New Issue
Block a user