addressed some issues mentioned in PR

This commit is contained in:
Rahul 2023-02-18 23:50:02 +00:00
parent ade64f25d3
commit 5fb539190d
2 changed files with 17 additions and 13 deletions

View File

@ -20,7 +20,7 @@ from freqtrade.constants import CANCEL_REASON, DATETIME_PRINT_FORMAT, Config
from freqtrade.data.history import load_data from freqtrade.data.history import load_data
from freqtrade.data.metrics import calculate_max_drawdown from freqtrade.data.metrics import calculate_max_drawdown
from freqtrade.enums import (CandleType, ExitCheckTuple, ExitType, SignalDirection, State, from freqtrade.enums import (CandleType, ExitCheckTuple, ExitType, SignalDirection, State,
TradingMode) TradingMode, MarketDirection)
from freqtrade.exceptions import ExchangeError, PricingError from freqtrade.exceptions import ExchangeError, PricingError
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_msecs from freqtrade.exchange import timeframe_to_minutes, timeframe_to_msecs
from freqtrade.loggers import bufferHandler from freqtrade.loggers import bufferHandler
@ -1205,3 +1205,6 @@ class RPC:
'last_process_loc': last_p.astimezone(tzlocal()).strftime(DATETIME_PRINT_FORMAT), 'last_process_loc': last_p.astimezone(tzlocal()).strftime(DATETIME_PRINT_FORMAT),
'last_process_ts': int(last_p.timestamp()), 'last_process_ts': int(last_p.timestamp()),
} }
def _update_market_direction(self, direction: MarketDirection):
self._freqtrade.strategy.market_direction = direction

View File

@ -129,7 +129,7 @@ class Telegram(RPCHandler):
r'/weekly$', r'/weekly \d+$', r'/monthly$', r'/monthly \d+$', r'/weekly$', r'/weekly \d+$', r'/monthly$', r'/monthly \d+$',
r'/forcebuy$', r'/forcelong$', r'/forceshort$', r'/forcebuy$', r'/forcelong$', r'/forceshort$',
r'/forcesell$', r'/forceexit$', r'/forcesell$', r'/forceexit$',
r'/edge$', r'/health$', r'/help$', r'/version$', r'/marketdir$' r'/edge$', r'/health$', r'/help$', r'/version$', r'/marketdir \d+$'
] ]
# Create keys for generation # Create keys for generation
valid_keys_print = [k.replace('$', '') for k in valid_keys] valid_keys_print = [k.replace('$', '') for k in valid_keys]
@ -1690,14 +1690,15 @@ class Telegram(RPCHandler):
""" """
if context.args and len(context.args) == 1: if context.args and len(context.args) == 1:
new_market_dir = context.args[0] new_market_dir = context.args[0]
match new_market_dir: if new_market_dir == "long":
case "long": self._rpc._update_market_direction(MarketDirection.LONG)
self._rpc._freqtrade.strategy.market_direction = MarketDirection.LONG elif new_market_dir == "short":
case "short": self._rpc._update_market_direction(MarketDirection.SHORT)
self._rpc._freqtrade.strategy.market_direction = MarketDirection.SHORT elif new_market_dir == "even":
case "even": self._rpc._update_market_direction(MarketDirection.EVEN)
self._rpc._freqtrade.strategy.market_direction = MarketDirection.EVEN elif new_market_dir == "none":
case "none": self._rpc._update_market_direction(MarketDirection.NONE)
self._rpc._freqtrade.strategy.market_direction = MarketDirection.NONE else:
case _: raise RPCException("Invalid market direction provided")
raise RPCException("Invalid market direction provided") else:
raise RPCException("Invalid usage of command /marketdir.")