added stats for long short

This commit is contained in:
Aezo Teo 2021-12-19 23:24:46 +08:00
parent edd80c3006
commit ea418bc9ac
4 changed files with 18 additions and 5 deletions

View File

@ -216,11 +216,14 @@ Once all positions are sold, run `/stop` to completely stop the bot.
### /status ### /status
For each open trade, the bot will send you the following message. For each open trade, the bot will send you the following message.
Enter Tag is configurable via Strategy.
> **Trade ID:** `123` `(since 1 days ago)` > **Trade ID:** `123` `(since 1 days ago)`
> **Current Pair:** CVC/BTC > **Current Pair:** CVC/BTC
> **Open Since:** `1 days ago` > **Direction:** Long
> **Leverage:** 1.0
> **Amount:** `26.64180098` > **Amount:** `26.64180098`
> **Enter Tag:** Awesome Long Signal
> **Open Rate:** `0.00007489` > **Open Rate:** `0.00007489`
> **Current Rate:** `0.00007489` > **Current Rate:** `0.00007489`
> **Current Profit:** `12.95%` > **Current Profit:** `12.95%`
@ -233,8 +236,8 @@ Return the status of all open trades in a table format.
``` ```
ID Pair Since Profit ID Pair Since Profit
---- -------- ------- -------- ---- -------- ------- --------
67 SC/BTC 1 d 13.33% 67 SC/BTC L 1 d 13.33%
123 CVC/BTC 1 h 12.95% 123 CVC/BTC S 1 h 12.95%
``` ```
### /count ### /count

View File

@ -104,6 +104,8 @@ Possible parameters are:
* `trade_id` * `trade_id`
* `exchange` * `exchange`
* `pair` * `pair`
* `is_short`
* `leverage`
* ~~`limit` # Deprecated - should no longer be used.~~ * ~~`limit` # Deprecated - should no longer be used.~~
* `open_rate` * `open_rate`
* `amount` * `amount`
@ -141,6 +143,8 @@ Possible parameters are:
* `trade_id` * `trade_id`
* `exchange` * `exchange`
* `pair` * `pair`
* `is_short`
* `leverage`
* `open_rate` * `open_rate`
* `amount` * `amount`
* `open_date` * `open_date`
@ -152,13 +156,15 @@ Possible parameters are:
* `enter_tag` * `enter_tag`
### Webhooksell ### Webhooksell
# TODO-lev add support for long and short?
The fields in `webhook.webhooksell` are filled when the bot sells a trade. Parameters are filled using string.format. The fields in `webhook.webhooksell` are filled when the bot sells a trade. Parameters are filled using string.format.
Possible parameters are: Possible parameters are:
* `trade_id` * `trade_id`
* `exchange` * `exchange`
* `pair` * `pair`
* `is_short`
* `leverage`
* `gain` * `gain`
* `limit` * `limit`
* `amount` * `amount`

View File

@ -233,6 +233,7 @@ class RPC:
current_rate = NAN current_rate = NAN
trade_profit = trade.calc_profit(current_rate) trade_profit = trade.calc_profit(current_rate)
profit_str = f'{trade.calc_profit_ratio(current_rate):.2%}' profit_str = f'{trade.calc_profit_ratio(current_rate):.2%}'
direction_str = 'S' if trade.is_short else 'L'
if self._fiat_converter: if self._fiat_converter:
fiat_profit = self._fiat_converter.convert_amount( fiat_profit = self._fiat_converter.convert_amount(
trade_profit, trade_profit,
@ -247,7 +248,8 @@ class RPC:
trade.id, trade.id,
trade.pair + ('*' if (trade.open_order_id is not None trade.pair + ('*' if (trade.open_order_id is not None
and trade.close_rate_requested is None) else '') and trade.close_rate_requested is None) else '')
+ ('**' if (trade.close_rate_requested is not None) else ''), + ('**' if (trade.close_rate_requested is not None) else '')
+ f' direction_str',
shorten_date(arrow.get(trade.open_date).humanize(only_distance=True)), shorten_date(arrow.get(trade.open_date).humanize(only_distance=True)),
profit_str profit_str
]) ])

View File

@ -398,6 +398,8 @@ class Telegram(RPCHandler):
lines = [ lines = [
"*Trade ID:* `{trade_id}` `(since {open_date_hum})`", "*Trade ID:* `{trade_id}` `(since {open_date_hum})`",
"*Current Pair:* {pair}", "*Current Pair:* {pair}",
"*Direction:* " + ("`Short`" if r['is_short'] else "`Long`"),
"*Leverage:* `{leverage}`" if r['leverage'] else "",
"*Amount:* `{amount} ({stake_amount} {base_currency})`", "*Amount:* `{amount} ({stake_amount} {base_currency})`",
"*Enter Tag:* `{enter_tag}`" if r['enter_tag'] else "", "*Enter Tag:* `{enter_tag}`" if r['enter_tag'] else "",
"*Open Rate:* `{open_rate:.8f}`", "*Open Rate:* `{open_rate:.8f}`",