rpc: fstrings
This commit is contained in:
parent
adbffc69e1
commit
df68b0990f
@ -74,34 +74,33 @@ class RPC(object):
|
|||||||
# calculate profit and send message to user
|
# calculate profit and send message to user
|
||||||
current_rate = self._freqtrade.exchange.get_ticker(trade.pair, False)['bid']
|
current_rate = self._freqtrade.exchange.get_ticker(trade.pair, False)['bid']
|
||||||
current_profit = trade.calc_profit_percent(current_rate)
|
current_profit = trade.calc_profit_percent(current_rate)
|
||||||
fmt_close_profit = '{:.2f}%'.format(
|
fmt_close_profit = (f'{round(trade.close_profit * 100, 2):.2f}%'
|
||||||
round(trade.close_profit * 100, 2)
|
if trade.close_profit else None)
|
||||||
) if trade.close_profit else None
|
market_url = self._freqtrade.exchange.get_pair_detail_url(trade.pair)
|
||||||
message = "*Trade ID:* `{trade_id}`\n" \
|
trade_date = arrow.get(trade.open_date).humanize()
|
||||||
"*Current Pair:* [{pair}]({market_url})\n" \
|
open_rate = trade.open_rate
|
||||||
"*Open Since:* `{date}`\n" \
|
close_rate = trade.close_rate
|
||||||
"*Amount:* `{amount}`\n" \
|
amount = round(trade.amount, 8)
|
||||||
"*Open Rate:* `{open_rate:.8f}`\n" \
|
current_profit = round(current_profit * 100, 2)
|
||||||
"*Close Rate:* `{close_rate}`\n" \
|
if order:
|
||||||
"*Current Rate:* `{current_rate:.8f}`\n" \
|
order_type = order['type']
|
||||||
"*Close Profit:* `{close_profit}`\n" \
|
order_side = order['side']
|
||||||
"*Current Profit:* `{current_profit:.2f}%`\n" \
|
order_rem = order['remaining']
|
||||||
"*Open Order:* `{open_order}`"\
|
open_order = f'({order_type} {order_side} rem={order_rem:.8f})'
|
||||||
.format(
|
else:
|
||||||
trade_id=trade.id,
|
open_order = None
|
||||||
pair=trade.pair,
|
|
||||||
market_url=self._freqtrade.exchange.get_pair_detail_url(trade.pair),
|
message = f"*Trade ID:* `{trade.id}`\n" \
|
||||||
date=arrow.get(trade.open_date).humanize(),
|
f"*Current Pair:* [{trade.pair}]({market_url})\n" \
|
||||||
open_rate=trade.open_rate,
|
f"*Open Since:* `{trade_date}`\n" \
|
||||||
close_rate=trade.close_rate,
|
f"*Amount:* `{amount}`\n" \
|
||||||
current_rate=current_rate,
|
f"*Open Rate:* `{open_rate:.8f}`\n" \
|
||||||
amount=round(trade.amount, 8),
|
f"*Close Rate:* `{close_rate}`\n" \
|
||||||
close_profit=fmt_close_profit,
|
f"*Current Rate:* `{current_rate:.8f}`\n" \
|
||||||
current_profit=round(current_profit * 100, 2),
|
f"*Close Profit:* `{fmt_close_profit}`\n" \
|
||||||
open_order='({} {} rem={:.8f})'.format(
|
f"*Current Profit:* `{current_profit:.2f}%`\n" \
|
||||||
order['type'], order['side'], order['remaining']
|
f"*Open Order:* `{open_order}`"\
|
||||||
) if order else None,
|
|
||||||
)
|
|
||||||
result.append(message)
|
result.append(message)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -116,11 +115,12 @@ class RPC(object):
|
|||||||
for trade in trades:
|
for trade in trades:
|
||||||
# calculate profit and send message to user
|
# calculate profit and send message to user
|
||||||
current_rate = self._freqtrade.exchange.get_ticker(trade.pair, False)['bid']
|
current_rate = self._freqtrade.exchange.get_ticker(trade.pair, False)['bid']
|
||||||
|
trade_perc = (100 * trade.calc_profit_percent(current_rate))
|
||||||
trades_list.append([
|
trades_list.append([
|
||||||
trade.id,
|
trade.id,
|
||||||
trade.pair,
|
trade.pair,
|
||||||
shorten_date(arrow.get(trade.open_date).humanize(only_distance=True)),
|
shorten_date(arrow.get(trade.open_date).humanize(only_distance=True)),
|
||||||
'{:.2f}%'.format(100 * trade.calc_profit_percent(current_rate))
|
f'{trade_perc:.2f}%'
|
||||||
])
|
])
|
||||||
|
|
||||||
columns = ['ID', 'Pair', 'Since', 'Profit']
|
columns = ['ID', 'Pair', 'Since', 'Profit']
|
||||||
@ -148,7 +148,7 @@ class RPC(object):
|
|||||||
.all()
|
.all()
|
||||||
curdayprofit = sum(trade.calc_profit() for trade in trades)
|
curdayprofit = sum(trade.calc_profit() for trade in trades)
|
||||||
profit_days[profitday] = {
|
profit_days[profitday] = {
|
||||||
'amount': format(curdayprofit, '.8f'),
|
'amount': f'{curdayprofit:.8f}',
|
||||||
'trades': len(trades)
|
'trades': len(trades)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user