From da3c42bbbc577ef9a83aa0d257430ab6ff9bd00a Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Sat, 11 Nov 2023 15:16:40 +0900 Subject: [PATCH] add entries, exits, and mix_tags API endpoints --- docs/rest-api.md | 3 +++ freqtrade/rpc/api_server/api_v1.py | 11 +++++++++++ scripts/rest_client.py | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/docs/rest-api.md b/docs/rest-api.md index 666056a65..ff111c2ce 100644 --- a/docs/rest-api.md +++ b/docs/rest-api.md @@ -141,6 +141,9 @@ python3 scripts/rest_client.py --config rest_config.json [optional par | `logs` | Shows last log messages. | `status` | Lists all open trades. | `count` | Displays number of trades used and available. +| `entries [pair]` | Shows profit statistics for each enter tags for given pair (or all pairs if pair isn't given). Pair is optional. +| `exits [pair]` | Shows profit statistics for each exit reasons for given pair (or all pairs if pair isn't given). Pair is optional. +| `mix_tags [pair]` | Shows profit statistics for each combinations of enter tag + exit reasons for given pair (or all pairs if pair isn't given). Pair is optional. | `locks` | Displays currently locked pairs. | `delete_lock ` | Deletes (disables) the lock by id. | `profit` | Display a summary of your profit/loss from close trades and some stats about your performance. diff --git a/freqtrade/rpc/api_server/api_v1.py b/freqtrade/rpc/api_server/api_v1.py index 8b1bb2a48..ed2746d40 100644 --- a/freqtrade/rpc/api_server/api_v1.py +++ b/freqtrade/rpc/api_server/api_v1.py @@ -82,6 +82,17 @@ def balance(rpc: RPC = Depends(get_rpc), config=Depends(get_config)): def count(rpc: RPC = Depends(get_rpc)): return rpc._rpc_count() +@router.get('/entries', tags=['info', 'trading']) +def entries(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)): + return rpc._rpc_enter_tag_performance(pair) + +@router.get('/exits', tags=['info', 'trading']) +def exits(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)): + return rpc._rpc_exit_reason_performance(pair) + +@router.get('/mix_tags', tags=['info', 'trading']) +def mix_tags(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)): + return rpc._rpc_mix_tag_performance(pair) @router.get('/performance', response_model=List[PerformanceEntry], tags=['info']) def performance(rpc: RPC = Depends(get_rpc)): diff --git a/scripts/rest_client.py b/scripts/rest_client.py index dfe50cc2c..5970b0c5b 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -112,6 +112,30 @@ class FtRestClient: """ return self._get("count") + def entries(self, pair=None): + """Returns List of dicts containing all Trades, based on buy tag performance + Can either be average for all pairs or a specific pair provided + + :return: json object + """ + return self._get("entries", params={"pair": pair} if pair else None) + + def exits(self, pair=None): + """Returns List of dicts containing all Trades, based on exit reason performance + Can either be average for all pairs or a specific pair provided + + :return: json object + """ + return self._get("exits", params={"pair": pair} if pair else None) + + def mix_tags(self, pair=None): + """Returns List of dicts containing all Trades, based on entry_tag + exit_reason performance + Can either be average for all pairs or a specific pair provided + + :return: json object + """ + return self._get("mix_tags", params={"pair": pair} if pair else None) + def locks(self): """Return current locks