mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-13 03:33:55 +00:00
Merge pull request #186 from glonlas/update_daily_command
Improve /daily command
This commit is contained in:
commit
6729574201
|
@ -223,11 +223,10 @@ def _daily(bot: Bot, update: Update) -> None:
|
||||||
try:
|
try:
|
||||||
timescale = int(update.message.text.replace('/daily', '').strip())
|
timescale = int(update.message.text.replace('/daily', '').strip())
|
||||||
except:
|
except:
|
||||||
send_msg('*Daily <n>:* `must be an integer greater than 0`', bot=bot)
|
timescale = 5
|
||||||
return
|
|
||||||
|
|
||||||
if not (isinstance(timescale, int) and timescale > 0):
|
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
|
return
|
||||||
|
|
||||||
for day in range(0, timescale):
|
for day in range(0, timescale):
|
||||||
|
@ -238,7 +237,7 @@ def _daily(bot: Bot, update: Update) -> None:
|
||||||
curdayprofit = 0
|
curdayprofit = 0
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
curdayprofit += trade.close_profit * trade.stake_amount
|
curdayprofit += trade.close_profit * trade.stake_amount
|
||||||
profit_days[date.fromordinal(today-day)] = curdayprofit
|
profit_days[date.fromordinal(today-day)] = format(curdayprofit, '.8f')
|
||||||
|
|
||||||
stats = []
|
stats = []
|
||||||
for key, value in profit_days.items():
|
for key, value in profit_days.items():
|
||||||
|
@ -518,9 +517,9 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO
|
||||||
|
|
||||||
bot = bot or _UPDATER.bot
|
bot = bot or _UPDATER.bot
|
||||||
|
|
||||||
keyboard = [['/daily', '/status table', '/profit', '/performance', ],
|
keyboard = [['/daily', '/profit', '/balance' ],
|
||||||
['/balance', '/status', '/count'],
|
['/status', '/status table', '/performance'],
|
||||||
['/start', '/stop', '/help']]
|
['/count', '/start', '/stop', '/help']]
|
||||||
|
|
||||||
reply_markup = ReplyKeyboardMarkup(keyboard)
|
reply_markup = ReplyKeyboardMarkup(keyboard)
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,7 @@ def test_daily_handle(
|
||||||
#try invalid data
|
#try invalid data
|
||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
update_state(State.RUNNING)
|
update_state(State.RUNNING)
|
||||||
update.message.text = '/daily'
|
update.message.text = '/daily -2'
|
||||||
_daily(bot=MagicMock(), update=update)
|
_daily(bot=MagicMock(), update=update)
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert 'must be an integer greater than 0' in msg_mock.call_args_list[0][0][0]
|
assert 'must be an integer greater than 0' in msg_mock.call_args_list[0][0][0]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user