added new text
This commit is contained in:
parent
1a74ede126
commit
72af1912ca
@ -5,6 +5,7 @@ from freqtrade.enums.exitchecktuple import ExitCheckTuple
|
|||||||
from freqtrade.enums.exittype import ExitType
|
from freqtrade.enums.exittype import ExitType
|
||||||
from freqtrade.enums.hyperoptstate import HyperoptState
|
from freqtrade.enums.hyperoptstate import HyperoptState
|
||||||
from freqtrade.enums.marginmode import MarginMode
|
from freqtrade.enums.marginmode import MarginMode
|
||||||
|
from freqtrade.enums.marketstatetype import MarketDirection
|
||||||
from freqtrade.enums.ordertypevalue import OrderTypeValues
|
from freqtrade.enums.ordertypevalue import OrderTypeValues
|
||||||
from freqtrade.enums.pricetype import PriceType
|
from freqtrade.enums.pricetype import PriceType
|
||||||
from freqtrade.enums.rpcmessagetype import NO_ECHO_MESSAGES, RPCMessageType, RPCRequestType
|
from freqtrade.enums.rpcmessagetype import NO_ECHO_MESSAGES, RPCMessageType, RPCRequestType
|
||||||
@ -12,4 +13,3 @@ from freqtrade.enums.runmode import NON_UTIL_MODES, OPTIMIZE_MODES, TRADING_MODE
|
|||||||
from freqtrade.enums.signaltype import SignalDirection, SignalTagType, SignalType
|
from freqtrade.enums.signaltype import SignalDirection, SignalTagType, SignalType
|
||||||
from freqtrade.enums.state import State
|
from freqtrade.enums.state import State
|
||||||
from freqtrade.enums.tradingmode import TradingMode
|
from freqtrade.enums.tradingmode import TradingMode
|
||||||
from freqtrade.enums.marketstatetype import MarketDirection
|
|
||||||
|
@ -9,18 +9,3 @@ class MarketDirection(Enum):
|
|||||||
SHORT = "short"
|
SHORT = "short"
|
||||||
EVEN = "even"
|
EVEN = "even"
|
||||||
NONE = ''
|
NONE = ''
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def string_to_enum(label : str) -> str:
|
|
||||||
match label:
|
|
||||||
case "long":
|
|
||||||
return MarketDirection.LONG
|
|
||||||
case "short":
|
|
||||||
return MarketDirection.SHORT
|
|
||||||
case "even":
|
|
||||||
return MarketDirection.EVEN
|
|
||||||
case 'none':
|
|
||||||
return MarketDirection.NONE
|
|
||||||
case _:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
@ -1689,7 +1689,15 @@ class Telegram(RPCHandler):
|
|||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
if context.args and len(context.args) == 1:
|
if context.args and len(context.args) == 1:
|
||||||
market_dir = MarketDirection.string_to_enum(context.args[0])
|
new_market_dir = context.args[0]
|
||||||
if market_dir:
|
match new_market_dir:
|
||||||
self._rpc._freqtrade.strategy.market_direction = market_dir
|
case "long":
|
||||||
|
self._rpc._freqtrade.strategy.market_direction = MarketDirection.LONG
|
||||||
|
case "short":
|
||||||
|
self._rpc._freqtrade.strategy.market_direction = MarketDirection.SHORT
|
||||||
|
case "even":
|
||||||
|
self._rpc._freqtrade.strategy.market_direction = MarketDirection.EVEN
|
||||||
|
case "none":
|
||||||
|
self._rpc._freqtrade.strategy.market_direction = MarketDirection.NONE
|
||||||
|
case _:
|
||||||
|
raise RPCException("Invalid market direction provided")
|
||||||
|
@ -12,8 +12,8 @@ from pandas import DataFrame
|
|||||||
|
|
||||||
from freqtrade.constants import Config, IntOrInf, ListPairsWithTimeframes
|
from freqtrade.constants import Config, IntOrInf, ListPairsWithTimeframes
|
||||||
from freqtrade.data.dataprovider import DataProvider
|
from freqtrade.data.dataprovider import DataProvider
|
||||||
from freqtrade.enums import (CandleType, ExitCheckTuple, ExitType, MarketDirection, RunMode, SignalDirection,
|
from freqtrade.enums import (CandleType, ExitCheckTuple, ExitType, MarketDirection, RunMode,
|
||||||
SignalTagType, SignalType, TradingMode)
|
SignalDirection, SignalTagType, SignalType, TradingMode)
|
||||||
from freqtrade.exceptions import OperationalException, StrategyError
|
from freqtrade.exceptions import OperationalException, StrategyError
|
||||||
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_next_date, timeframe_to_seconds
|
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_next_date, timeframe_to_seconds
|
||||||
from freqtrade.misc import remove_entry_exit_signals
|
from freqtrade.misc import remove_entry_exit_signals
|
||||||
|
@ -20,7 +20,7 @@ from telegram.error import BadRequest, NetworkError, TelegramError
|
|||||||
from freqtrade import __version__
|
from freqtrade import __version__
|
||||||
from freqtrade.constants import CANCEL_REASON
|
from freqtrade.constants import CANCEL_REASON
|
||||||
from freqtrade.edge import PairInfo
|
from freqtrade.edge import PairInfo
|
||||||
from freqtrade.enums import ExitType, RPCMessageType, RunMode, SignalDirection, State
|
from freqtrade.enums import ExitType, MarketDirection, RPCMessageType, RunMode, SignalDirection, State
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.freqtradebot import FreqtradeBot
|
from freqtrade.freqtradebot import FreqtradeBot
|
||||||
from freqtrade.loggers import setup_logging
|
from freqtrade.loggers import setup_logging
|
||||||
@ -2394,3 +2394,15 @@ def test__send_msg_keyboard(default_conf, mocker, caplog) -> None:
|
|||||||
assert log_has("using custom keyboard from config.json: "
|
assert log_has("using custom keyboard from config.json: "
|
||||||
"[['/daily', '/stats', '/balance', '/profit', '/profit 5'], ['/count', "
|
"[['/daily', '/stats', '/balance', '/profit', '/profit 5'], ['/count', "
|
||||||
"'/start', '/reload_config', '/help']]", caplog)
|
"'/start', '/reload_config', '/help']]", caplog)
|
||||||
|
|
||||||
|
|
||||||
|
def test_change_market_direction(default_conf, mocker, update) -> None:
|
||||||
|
telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||||
|
assert telegram._rpc._freqtrade.strategy.market_direction == MarketDirection.NONE
|
||||||
|
context = MagicMock()
|
||||||
|
context.args = ["long"]
|
||||||
|
telegram._changemarketdir(update, context)
|
||||||
|
assert telegram._rpc._freqtrade.strategy.market_direction == MarketDirection.LONG
|
||||||
|
context = MagicMock()
|
||||||
|
context.args = ["invalid"]
|
||||||
|
assert telegram._rpc._freqtrade.strategy.market_direction == MarketDirection.LONG
|
||||||
|
Loading…
Reference in New Issue
Block a user