AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
10.06k stars 2.42k forks source link

FinRL_StockTrading_Fundamental.ipynb OverflowError: Python int too large to convert to C long #348

Closed t-b-r closed 2 years ago

t-b-r commented 2 years ago

In the FinRL_StockTrading_Fundamental.ipynb notebook, running on Ubuntu installed on Windows 11, Python 3.7.4, when executing the following code:

 **Model 2: DDPG**  
trained_ddpg = agent.train_model(model=model_ddpg, 
                             tb_log_name='ddpg',
                             total_timesteps=50000)

I get the following error:

OverflowError                             Traceback (most recent call last)
<ipython-input-40-87b09b7794a1> in <module>
      1 trained_ddpg = agent.train_model(model=model_ddpg, 
      2                              tb_log_name='ddpg',
----> 3                              total_timesteps=50000)

~/code/finrl/finrl/drl_agents/stablebaselines3/models.py in train_model(self, model, tb_log_name, total_timesteps)
    102             total_timesteps=total_timesteps,
    103             tb_log_name=tb_log_name,
--> 104             callback=TensorboardCallback(),
    105         )
    106         return model

~/programs/miniconda3/lib/python3.7/site-packages/stable_baselines3/ddpg/ddpg.py in learn(self, total_timesteps, callback, log_interval, eval_env, eval_freq, n_eval_episodes, tb_log_name, eval_log_path, reset_num_timesteps)
    137             tb_log_name=tb_log_name,
    138             eval_log_path=eval_log_path,
--> 139             reset_num_timesteps=reset_num_timesteps,
    140         )

~/programs/miniconda3/lib/python3.7/site-packages/stable_baselines3/td3/td3.py in learn(self, total_timesteps, callback, log_interval, eval_env, eval_freq, n_eval_episodes, tb_log_name, eval_log_path, reset_num_timesteps)
    211             tb_log_name=tb_log_name,
    212             eval_log_path=eval_log_path,
--> 213             reset_num_timesteps=reset_num_timesteps,
    214         )
    215 

~/programs/miniconda3/lib/python3.7/site-packages/stable_baselines3/common/off_policy_algorithm.py in learn(self, total_timesteps, callback, log_interval, eval_env, eval_freq, n_eval_episodes, tb_log_name, eval_log_path, reset_num_timesteps)
    357                 learning_starts=self.learning_starts,
    358                 replay_buffer=self.replay_buffer,
--> 359                 log_interval=log_interval,
    360             )
    361 

~/programs/miniconda3/lib/python3.7/site-packages/stable_baselines3/common/off_policy_algorithm.py in collect_rollouts(self, env, callback, train_freq, replay_buffer, action_noise, learning_starts, log_interval)
    569 
    570                 # Rescale and perform action
--> 571                 new_obs, reward, done, infos = env.step(action)
    572 
    573                 self.num_timesteps += 1

~/programs/miniconda3/lib/python3.7/site-packages/stable_baselines3/common/vec_env/base_vec_env.py in step(self, actions)
    160         """
    161         self.step_async(actions)
--> 162         return self.step_wait()
    163 
    164     def get_images(self) -> Sequence[np.ndarray]:

~/programs/miniconda3/lib/python3.7/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py in step_wait(self)
     42         for env_idx in range(self.num_envs):
     43             obs, self.buf_rews[env_idx], self.buf_dones[env_idx], self.buf_infos[env_idx] = self.envs[env_idx].step(
---> 44                 self.actions[env_idx]
     45             )
     46             if self.buf_dones[env_idx]:

~/code/finrl/finrl/neo_finrl/env_stock_trading/env_stocktrading.py in step(self, actions)
    298             for index in buy_index:
    299                 # print('take buy action: {}'.format(actions[index]))
--> 300                 actions[index] = self._buy_stock(index, actions[index])
    301 
    302             self.actions_memory.append(actions)

OverflowError: Python int too large to convert to C long
rayrui312 commented 2 years ago

Thanks for reporting it. We have confirmed this error. We are debugging now.

nivedithaHN commented 2 years ago

Any solution for this problem?