Skip to content

Commit

Permalink
Merge pull request #186 from glonlas/update_daily_command
Browse files Browse the repository at this point in the history
Improve  /daily command
  • Loading branch information
shusso committed Dec 15, 2017
2 parents bfb3e09 + 2a2af48 commit 6729574
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions freqtrade/rpc/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,10 @@ def _daily(bot: Bot, update: Update) -> None:
try:
timescale = int(update.message.text.replace('/daily', '').strip())
except:
send_msg('*Daily <n>:* `must be an integer greater than 0`', bot=bot)
return
timescale = 5

if not (isinstance(timescale, int) and timescale > 0):
send_msg('*Daily <n>:* `must be an integer greater than 0`', bot=bot)
send_msg('*Daily [n]:* `must be an integer greater than 0`', bot=bot)
return

for day in range(0, timescale):
Expand All @@ -238,7 +237,7 @@ def _daily(bot: Bot, update: Update) -> None:
curdayprofit = 0
for trade in trades:
curdayprofit += trade.close_profit * trade.stake_amount
profit_days[date.fromordinal(today-day)] = curdayprofit
profit_days[date.fromordinal(today-day)] = format(curdayprofit, '.8f')

stats = []
for key, value in profit_days.items():
Expand Down Expand Up @@ -518,9 +517,9 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO

bot = bot or _UPDATER.bot

keyboard = [['/daily', '/status table', '/profit', '/performance', ],
['/balance', '/status', '/count'],
['/start', '/stop', '/help']]
keyboard = [['/daily', '/profit', '/balance' ],
['/status', '/status table', '/performance'],
['/count', '/start', '/stop', '/help']]

reply_markup = ReplyKeyboardMarkup(keyboard)

Expand Down
2 changes: 1 addition & 1 deletion freqtrade/tests/test_rpc_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_daily_handle(
#try invalid data
msg_mock.reset_mock()
update_state(State.RUNNING)
update.message.text = '/daily'
update.message.text = '/daily -2'
_daily(bot=MagicMock(), update=update)
assert msg_mock.call_count == 1
assert 'must be an integer greater than 0' in msg_mock.call_args_list[0][0][0]
Expand Down

0 comments on commit 6729574

Please sign in to comment.