From 03b99c867af6571681eb69a20d8a2daed0f2c7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=AE=87=E5=B3=B0?= Date: Mon, 2 Mar 2026 04:08:51 +0800 Subject: [PATCH 1/2] Fix env.reset() to return (obs, info) tuple for Gymnasium/SB3 v2.0+ compatibility Stable Baselines 3 v2.0+ expects env.reset() to return a (obs, info) tuple following the Gymnasium API. Four environments still returned only the observation, causing "too many values to unpack (expected 2)" when used with SB3's DummyVecEnv. Fixed environments: - env_btc_ccxt.py (BitcoinEnv) - env_multiple_crypto.py (CryptoEnv) - env_stocktrading_stoploss.py (StockTradingEnvStopLoss) - env_stocktrading_cashpenalty.py (StockTradingEnvCashpenalty) Fixes #1051 Co-Authored-By: Claude Opus 4.6 (1M context) --- finrl/meta/env_cryptocurrency_trading/env_btc_ccxt.py | 2 +- finrl/meta/env_cryptocurrency_trading/env_multiple_crypto.py | 4 ++-- finrl/meta/env_stock_trading/env_stocktrading_cashpenalty.py | 2 +- finrl/meta/env_stock_trading/env_stocktrading_stoploss.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/finrl/meta/env_cryptocurrency_trading/env_btc_ccxt.py b/finrl/meta/env_cryptocurrency_trading/env_btc_ccxt.py index 40009fbba2..2865fb1e3e 100644 --- a/finrl/meta/env_cryptocurrency_trading/env_btc_ccxt.py +++ b/finrl/meta/env_cryptocurrency_trading/env_btc_ccxt.py @@ -81,7 +81,7 @@ def reset( self.stocks * 2**-4, ) ).astype(np.float32) - return state + return state, {} def step(self, action) -> (np.ndarray, float, bool, None): stock_action = action[0] diff --git a/finrl/meta/env_cryptocurrency_trading/env_multiple_crypto.py b/finrl/meta/env_cryptocurrency_trading/env_multiple_crypto.py index 47307f8a66..344b3c1558 100644 --- a/finrl/meta/env_cryptocurrency_trading/env_multiple_crypto.py +++ b/finrl/meta/env_cryptocurrency_trading/env_multiple_crypto.py @@ -60,7 +60,7 @@ def reset( self.total_asset = self.cash + (self.stocks * self.price_array[self.time]).sum() state = self.get_state() - return state + return state, {} def step(self, actions) -> (np.ndarray, float, bool, None): self.time += 1 @@ -106,7 +106,7 @@ def get_state(self): tech_i = self.tech_array[self.time - i] normalized_tech_i = tech_i * 2**-15 state = np.hstack((state, normalized_tech_i)).astype(np.float32) - return state + return state, {} def close(self): pass diff --git a/finrl/meta/env_stock_trading/env_stocktrading_cashpenalty.py b/finrl/meta/env_stock_trading/env_stocktrading_cashpenalty.py index 54bee281d5..b0d5a9e9cf 100644 --- a/finrl/meta/env_stock_trading/env_stocktrading_cashpenalty.py +++ b/finrl/meta/env_stock_trading/env_stocktrading_cashpenalty.py @@ -160,7 +160,7 @@ def reset( + self.get_date_vector(self.date_index) ) self.state_memory.append(init_state) - return init_state + return init_state, {} def get_date_vector(self, date, cols=None): if (cols is None) and (self.cached_data is not None): diff --git a/finrl/meta/env_stock_trading/env_stocktrading_stoploss.py b/finrl/meta/env_stock_trading/env_stocktrading_stoploss.py index f602c3895a..63feb6cc1e 100644 --- a/finrl/meta/env_stock_trading/env_stocktrading_stoploss.py +++ b/finrl/meta/env_stock_trading/env_stocktrading_stoploss.py @@ -167,7 +167,7 @@ def reset( + self.get_date_vector(self.date_index) ) self.state_memory.append(init_state) - return init_state + return init_state, {} def get_date_vector(self, date, cols=None): if (cols is None) and (self.cached_data is not None): From 0b90be84087e4a2205e305162345e56bc1ca09f8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Mar 2026 20:09:29 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cf58fadab..1f0bb6eaa2 100755 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Key contributors include: - [**Hongyang (Bruce) Yang**](https://www.linkedin.com/in/brucehy/) – research and development on financial reinforcement learning frameworks, market environments, and quantitative trading applications - [other contributors…] - + ## Overview FinRL has three layers: market environments, agents, and applications. For a trading task (on the top), an agent (in the middle) interacts with a market environment (at the bottom), making sequential decisions.