ZhengyaoJiang / PGPortfolio

PGPortfolio: Policy Gradient Portfolio, the source code of "A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem"(https://arxiv.org/pdf/1706.10059.pdf).
GNU General Public License v3.0
1.74k stars 750 forks source link

Exception "Have to be online" raised when training offline #46

Closed jonDel closed 6 years ago

jonDel commented 6 years ago

Command that generate the error: python main.py --mode=train --processes=1

Condition: data offline, using provided Data.db in database folder

Configuration file: ./pgportfolio/net_config.json , 'online' option set to 'False'

Error logs: $ python main.py --mode=train --processes=1 hdf5 is not supported on this machine (please install/reinstall h5py for optimal experience) training at 1 started select coins offline from 2017-04-03 12:28 to 2017-05-03 12:28 Process Process-1: Traceback (most recent call last): File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap self.run() File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run self._target(*self._args, **self._kwargs) File "/home/jon/PGPortfolio/pgportfolio/autotrain/training.py", line 33, in train_one return TraderTrainer(config, save_path=save_path, device=device).train_net(log_file_dir=log_file_dir, index=index) File "/home/jon/PGPortfolio/pgportfolio/learn/tradertrainer.py", line 55, in __init__ self._matrix = DataMatrices.create_from_config(config) File "/home/jon/PGPortfolio/pgportfolio/marketdata/datamatrices.py", line 110, in create_from_config portion_reversed=input_config["portion_reversed"], File "/home/jon/PGPortfolio/pgportfolio/marketdata/datamatrices.py", line 51, in __init__ features=type_list) File "/home/jon/PGPortfolio/pgportfolio/marketdata/globaldatamatrix.py", line 62, in get_global_panel self.update_data(start, end, coin) File "/home/jon/PGPortfolio/pgportfolio/marketdata/globaldatamatrix.py", line 180, in update_data raise Exception("Have to be online") Exception: Have to be online ^CTraceback (most recent call last): File "main.py", line 132, in <module> main() File "main.py", line 56, in main pgportfolio.autotrain.training.train_all(int(options.processes), options.device) File "/home/jon/PGPortfolio/pgportfolio/autotrain/training.py", line 74, in train_all time.sleep(5) KeyboardInterrupt Exception raise: Have to be online

ZhengyaoJiang commented 6 years ago

That indicates the "end_date" in json file is later than the max timestamp in database. The timezone differences might cause the problem. There are two possible solutions:

  1. set "end_date" one day earlier.
  2. set timezone to UTC+0