From 08748dd0214b0368f73aa8e82931d9487cca54dd Mon Sep 17 00:00:00 2001 From: Joe Schr <8218910+TheJoeSchr@users.noreply.github.com> Date: Wed, 11 Jan 2023 21:07:03 +0100 Subject: [PATCH 1/4] fix "--version": needs to change working directory before calling `git`. otherwise it would display git commit id from the directory where you are calling `freqtrade` from instead of freqtrade's current commit id --- freqtrade/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/freqtrade/__init__.py b/freqtrade/__init__.py index 5430cd2d0..09bfaab20 100644 --- a/freqtrade/__init__.py +++ b/freqtrade/__init__.py @@ -3,11 +3,13 @@ __version__ = '2023.1.dev' if 'dev' in __version__: try: + import os import subprocess + freqtrade_basedir = os.path.dirname(os.path.abspath(__file__)) __version__ = __version__ + '-' + subprocess.check_output( ['git', 'log', '--format="%h"', '-n 1'], - stderr=subprocess.DEVNULL).decode("utf-8").rstrip().strip('"') + stderr=subprocess.DEVNULL, cwd=freqtrade_basedir).decode("utf-8").rstrip().strip('"') except Exception: # pragma: no cover # git not available, ignore From 9d647fd19388068b493e6ce7367a18b46914da68 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 11 Jan 2023 22:07:20 +0100 Subject: [PATCH 2/4] Fix websockets for dataframes with NaT entreis --- freqtrade/misc.py | 2 ++ tests/test_misc.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/freqtrade/misc.py b/freqtrade/misc.py index 93e8da6dd..34df3185b 100644 --- a/freqtrade/misc.py +++ b/freqtrade/misc.py @@ -269,6 +269,8 @@ def dataframe_to_json(dataframe: pd.DataFrame) -> str: def default(z): if isinstance(z, pd.Timestamp): return z.timestamp() * 1e3 + if z is pd.NaT: + return 'NaT' raise TypeError return str(orjson.dumps(dataframe.to_dict(orient='split'), default=default), 'utf-8') diff --git a/tests/test_misc.py b/tests/test_misc.py index 2da45bad9..596c7bd51 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -5,6 +5,7 @@ from copy import deepcopy from pathlib import Path from unittest.mock import MagicMock +import pandas as pd import pytest from freqtrade.misc import (dataframe_to_json, decimals_per_coin, deep_merge_dicts, file_dump_json, @@ -231,3 +232,7 @@ def test_dataframe_json(ohlcv_history): assert len(ohlcv_history) == len(dataframe) assert_frame_equal(ohlcv_history, dataframe) + ohlcv_history.at[1, 'date'] = pd.NaT + json = dataframe_to_json(ohlcv_history) + + dataframe = json_to_dataframe(json) From 1cf69f139c23ef37cb3258bc2c8ab6fd844b6cae Mon Sep 17 00:00:00 2001 From: Joe Schr <8218910+TheJoeSchr@users.noreply.github.com> Date: Thu, 12 Jan 2023 19:27:41 +0100 Subject: [PATCH 3/4] refactor "--version" to use "pathlib" instead of "os" --- freqtrade/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/freqtrade/__init__.py b/freqtrade/__init__.py index 09bfaab20..18b6c9130 100644 --- a/freqtrade/__init__.py +++ b/freqtrade/__init__.py @@ -2,10 +2,10 @@ __version__ = '2023.1.dev' if 'dev' in __version__: + from pathlib import Path try: - import os import subprocess - freqtrade_basedir = os.path.dirname(os.path.abspath(__file__)) + freqtrade_basedir = Path(__file__).parent __version__ = __version__ + '-' + subprocess.check_output( ['git', 'log', '--format="%h"', '-n 1'], @@ -15,7 +15,6 @@ if 'dev' in __version__: # git not available, ignore try: # Try Fallback to freqtrade_commit file (created by CI while building docker image) - from pathlib import Path versionfile = Path('./freqtrade_commit') if versionfile.is_file(): __version__ = f"docker-{__version__}-{versionfile.read_text()[:8]}" From bfd7803fd86639344647d32f32bf765b3c1f407d Mon Sep 17 00:00:00 2001 From: Robert Caulk Date: Thu, 12 Jan 2023 22:18:22 +0100 Subject: [PATCH 4/4] Update freqai-reinforcement-learning.md --- docs/freqai-reinforcement-learning.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/freqai-reinforcement-learning.md b/docs/freqai-reinforcement-learning.md index a09b4c5d0..4442a2f4f 100644 --- a/docs/freqai-reinforcement-learning.md +++ b/docs/freqai-reinforcement-learning.md @@ -58,11 +58,12 @@ where `ReinforcementLearner` will use the templated `ReinforcementLearner` from Most of the function remains the same as for typical Regressors, however, the function above shows how the strategy must pass the raw price data to the agent so that it has access to raw OHLCV in the training environment: ```python + def feature_engineering_standard(): # The following features are necessary for RL models - informative[f"%-{pair}raw_close"] = informative["close"] - informative[f"%-{pair}raw_open"] = informative["open"] - informative[f"%-{pair}raw_high"] = informative["high"] - informative[f"%-{pair}raw_low"] = informative["low"] + informative[f"%-raw_close"] = informative["close"] + informative[f"%-raw_open"] = informative["open"] + informative[f"%-raw_high"] = informative["high"] + informative[f"%-raw_low"] = informative["low"] ``` Finally, there is no explicit "label" to make - instead it is necessary to assign the `&-action` column which will contain the agent's actions when accessed in `populate_entry/exit_trends()`. In the present example, the neutral action to 0. This value should align with the environment used. FreqAI provides two environments, both use 0 as the neutral action.