mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-13 03:33:55 +00:00
Merge pull request #6363 from stash86/pos_adjust
Change "buy" and "sell" to "entry" and "exit"
This commit is contained in:
commit
5f886e7ffe
|
@ -264,7 +264,7 @@ class RPC:
|
||||||
profitcol += " (" + fiat_display_currency + ")"
|
profitcol += " (" + fiat_display_currency + ")"
|
||||||
|
|
||||||
if self._config.get('position_adjustment_enable', False):
|
if self._config.get('position_adjustment_enable', False):
|
||||||
columns = ['ID', 'Pair', 'Since', profitcol, '# Buys']
|
columns = ['ID', 'Pair', 'Since', profitcol, '# Entries']
|
||||||
else:
|
else:
|
||||||
columns = ['ID', 'Pair', 'Since', profitcol]
|
columns = ['ID', 'Pair', 'Since', profitcol]
|
||||||
return trades_list, columns, fiat_profit_sum
|
return trades_list, columns, fiat_profit_sum
|
||||||
|
|
|
@ -370,21 +370,21 @@ class Telegram(RPCHandler):
|
||||||
else:
|
else:
|
||||||
return "\N{CROSS MARK}"
|
return "\N{CROSS MARK}"
|
||||||
|
|
||||||
def _prepare_buy_details(self, filled_orders, base_currency, is_open):
|
def _prepare_entry_details(self, filled_orders, base_currency, is_open):
|
||||||
"""
|
"""
|
||||||
Prepare details of trade with buy adjustment enabled
|
Prepare details of trade with entry adjustment enabled
|
||||||
"""
|
"""
|
||||||
lines = []
|
lines = []
|
||||||
for x, order in enumerate(filled_orders):
|
for x, order in enumerate(filled_orders):
|
||||||
current_buy_datetime = arrow.get(order["order_filled_date"])
|
cur_entry_datetime = arrow.get(order["order_filled_date"])
|
||||||
cur_buy_amount = order["amount"]
|
cur_entry_amount = order["amount"]
|
||||||
cur_buy_average = order["average"]
|
cur_entry_average = order["average"]
|
||||||
lines.append(" ")
|
lines.append(" ")
|
||||||
if x == 0:
|
if x == 0:
|
||||||
lines.append("*Buy #{}:*".format(x+1))
|
lines.append("*Entry #{}:*".format(x+1))
|
||||||
lines.append("*Buy Amount:* {} ({:.8f} {})"
|
lines.append("*Entry Amount:* {} ({:.8f} {})"
|
||||||
.format(cur_buy_amount, order["cost"], base_currency))
|
.format(cur_entry_amount, order["cost"], base_currency))
|
||||||
lines.append("*Average Buy Price:* {}".format(cur_buy_average))
|
lines.append("*Average Entry Price:* {}".format(cur_entry_average))
|
||||||
else:
|
else:
|
||||||
sumA = 0
|
sumA = 0
|
||||||
sumB = 0
|
sumB = 0
|
||||||
|
@ -392,23 +392,23 @@ class Telegram(RPCHandler):
|
||||||
sumA += (filled_orders[y]["amount"] * filled_orders[y]["average"])
|
sumA += (filled_orders[y]["amount"] * filled_orders[y]["average"])
|
||||||
sumB += filled_orders[y]["amount"]
|
sumB += filled_orders[y]["amount"]
|
||||||
prev_avg_price = sumA/sumB
|
prev_avg_price = sumA/sumB
|
||||||
price_to_1st_buy = ((cur_buy_average - filled_orders[0]["average"])
|
price_to_1st_entry = ((cur_entry_average - filled_orders[0]["average"])
|
||||||
/ filled_orders[0]["average"])
|
/ filled_orders[0]["average"])
|
||||||
minus_on_buy = (cur_buy_average - prev_avg_price)/prev_avg_price
|
minus_on_entry = (cur_entry_average - prev_avg_price)/prev_avg_price
|
||||||
dur_buys = current_buy_datetime - arrow.get(filled_orders[x-1]["order_filled_date"])
|
dur_entry = cur_entry_datetime - arrow.get(filled_orders[x-1]["order_filled_date"])
|
||||||
days = dur_buys.days
|
days = dur_entry.days
|
||||||
hours, remainder = divmod(dur_buys.seconds, 3600)
|
hours, remainder = divmod(dur_entry.seconds, 3600)
|
||||||
minutes, seconds = divmod(remainder, 60)
|
minutes, seconds = divmod(remainder, 60)
|
||||||
lines.append("*Buy #{}:* at {:.2%} avg profit".format(x+1, minus_on_buy))
|
lines.append("*Entry #{}:* at {:.2%} avg profit".format(x+1, minus_on_entry))
|
||||||
if is_open:
|
if is_open:
|
||||||
lines.append("({})".format(current_buy_datetime
|
lines.append("({})".format(cur_entry_datetime
|
||||||
.humanize(granularity=["day", "hour", "minute"])))
|
.humanize(granularity=["day", "hour", "minute"])))
|
||||||
lines.append("*Buy Amount:* {} ({:.8f} {})"
|
lines.append("*Entry Amount:* {} ({:.8f} {})"
|
||||||
.format(cur_buy_amount, order["cost"], base_currency))
|
.format(cur_entry_amount, order["cost"], base_currency))
|
||||||
lines.append("*Average Buy Price:* {} ({:.2%} from 1st buy rate)"
|
lines.append("*Average Entry Price:* {} ({:.2%} from 1st entry rate)"
|
||||||
.format(cur_buy_average, price_to_1st_buy))
|
.format(cur_entry_average, price_to_1st_entry))
|
||||||
lines.append("*Order filled at:* {}".format(order["order_filled_date"]))
|
lines.append("*Order filled at:* {}".format(order["order_filled_date"]))
|
||||||
lines.append("({}d {}h {}m {}s from previous buy)"
|
lines.append("({}d {}h {}m {}s from previous entry)"
|
||||||
.format(days, hours, minutes, seconds))
|
.format(days, hours, minutes, seconds))
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
@ -447,13 +447,13 @@ class Telegram(RPCHandler):
|
||||||
("` (since {open_date_hum})`" if r['is_open'] else ""),
|
("` (since {open_date_hum})`" if r['is_open'] else ""),
|
||||||
"*Current Pair:* {pair}",
|
"*Current Pair:* {pair}",
|
||||||
"*Amount:* `{amount} ({stake_amount} {base_currency})`",
|
"*Amount:* `{amount} ({stake_amount} {base_currency})`",
|
||||||
"*Buy Tag:* `{buy_tag}`" if r['buy_tag'] else "",
|
"*Entry Tag:* `{buy_tag}`" if r['buy_tag'] else "",
|
||||||
"*Sell Reason:* `{sell_reason}`" if r['sell_reason'] else "",
|
"*Exit Reason:* `{sell_reason}`" if r['sell_reason'] else "",
|
||||||
]
|
]
|
||||||
|
|
||||||
if position_adjust:
|
if position_adjust:
|
||||||
max_buy_str = (f"/{max_entries + 1}" if (max_entries > 0) else "")
|
max_buy_str = (f"/{max_entries + 1}" if (max_entries > 0) else "")
|
||||||
lines.append("*Number of Buy(s):* `{num_entries}`" + max_buy_str)
|
lines.append("*Number of Entries:* `{num_entries}`" + max_buy_str)
|
||||||
|
|
||||||
lines.extend([
|
lines.extend([
|
||||||
"*Open Rate:* `{open_rate:.8f}`",
|
"*Open Rate:* `{open_rate:.8f}`",
|
||||||
|
@ -483,7 +483,7 @@ class Telegram(RPCHandler):
|
||||||
else:
|
else:
|
||||||
lines.append("*Open Order:* `{open_order}`")
|
lines.append("*Open Order:* `{open_order}`")
|
||||||
|
|
||||||
lines_detail = self._prepare_buy_details(
|
lines_detail = self._prepare_entry_details(
|
||||||
r['filled_entry_orders'], r['base_currency'], r['is_open'])
|
r['filled_entry_orders'], r['base_currency'], r['is_open'])
|
||||||
lines.extend((lines_detail if (len(r['filled_entry_orders']) > 1) else ""))
|
lines.extend((lines_detail if (len(r['filled_entry_orders']) > 1) else ""))
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
|
||||||
rpc._config['position_adjustment_enable'] = True
|
rpc._config['position_adjustment_enable'] = True
|
||||||
rpc._config['max_entry_position_adjustment'] = 3
|
rpc._config['max_entry_position_adjustment'] = 3
|
||||||
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
|
result, headers, fiat_profit_sum = rpc._rpc_status_table(default_conf['stake_currency'], 'USD')
|
||||||
assert "# Buys" in headers
|
assert "# Entries" in headers
|
||||||
assert len(result[0]) == 5
|
assert len(result[0]) == 5
|
||||||
# 4th column should be 1/4 - as 1 order filled (a total of 4 is possible)
|
# 4th column should be 1/4 - as 1 order filled (a total of 4 is possible)
|
||||||
# 3 on top of the initial one.
|
# 3 on top of the initial one.
|
||||||
|
|
|
@ -260,8 +260,8 @@ def test_telegram_status_multi_entry(default_conf, update, mocker, fee) -> None:
|
||||||
telegram._status(update=update, context=MagicMock())
|
telegram._status(update=update, context=MagicMock())
|
||||||
assert msg_mock.call_count == 4
|
assert msg_mock.call_count == 4
|
||||||
msg = msg_mock.call_args_list[0][0][0]
|
msg = msg_mock.call_args_list[0][0][0]
|
||||||
assert re.search(r'Number of Buy.*2', msg)
|
assert re.search(r'Number of Entries.*2', msg)
|
||||||
assert re.search(r'Average Buy Price', msg)
|
assert re.search(r'Average Entry Price', msg)
|
||||||
assert re.search(r'Order filled at', msg)
|
assert re.search(r'Order filled at', msg)
|
||||||
assert re.search(r'Close Date:', msg) is None
|
assert re.search(r'Close Date:', msg) is None
|
||||||
assert re.search(r'Close Profit:', msg) is None
|
assert re.search(r'Close Profit:', msg) is None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user