AI4Finance-Foundation / FinRL-Tutorials

Tutorials. Please star.
https://ai4finance.org
MIT License
848 stars 349 forks source link

error in FinRL-Tutorials/3-Practical/FinRL_PaperTrading_Demo.ipynb #57

Open Kadokoda opened 1 year ago

Kadokoda commented 1 year ago

FinRL-Tutorials/3-Practical/FinRL_PaperTrading_Demo.ipynb In Part 2: Train the agent Train (https://colab.research.google.com/github/AI4Finance-Foundation/FinRL-Tutorials/blob/master/3-Practical/FinRL_PaperTrading_Demo.ipynb#scrollTo=BxcNI2fdNjip&line=1&uniqifier=1)

I run this: train(start_date = '2022-08-25', end_date = '2022-08-31', ticker_list = ticker_list, data_source = 'alpaca', time_interval= '1Min', technical_indicator_list= INDICATORS, drl_lib='elegantrl', env=env, model_name='ppo', if_vix=True, API_KEY = API_KEY, API_SECRET = API_SECRET, API_BASE_URL = API_BASE_URL, erl_params=ERL_PARAMS, cwd='./papertrading_erl', #current_working_dir break_step=1e5)

And got error.

Alpaca successfully connected

AttributeError Traceback (most recent call last) in <cell line: 1>() ----> 1 train(start_date = '2022-08-25', 2 end_date = '2022-08-31', 3 ticker_list = ticker_list, 4 data_source = 'alpaca', 5 time_interval= '1Min',

2 frames /usr/local/lib/python3.9/site-packages/finrl/meta/data_processors/processor_alpaca.py in download_data(self, ticker_list, start_date, end_date, time_interval) 50 # filter opening time of the New York Stock Exchange (NYSE) (from 9:30 am to 4:00 pm) if time_interval < 1D 51 day_delta = 86400000000000 # pd.Timedelta('1D').delta == 86400000000000 ---> 52 if pd.Timedelta(time_interval).delta < day_delta: 53 NYSE_open_hour = "14:30" # in UTC 54 NYSE_close_hour = "20:59" # in UTC

AttributeError: 'Timedelta' object has no attribute 'delta'

leeallen00 commented 1 year ago

data = DP.download_data(start_date = '2021-10-04', end_date = '2021-10-08', ticker_list = ticker_list, time_interval= '1Min')

/usr/local/lib/python3.9/site-packages/finrl/meta/data_processors/processor_alpaca.py in download_data(self, ticker_list, start_date, end_date, time_interval) 50 # filter opening time of the New York Stock Exchange (NYSE) (from 9:30 am to 4:00 pm) if time_interval < 1D 51 day_delta = 86400000000000 # pd.Timedelta('1D').delta == 86400000000000 ---> 52 if pd.Timedelta(time_interval).delta < day_delta: 53 NYSE_open_hour = "14:30" # in UTC 54 NYSE_close_hour = "20:59" # in UTC

AttributeError: 'Timedelta' object has no attribute 'delta'

uday-uppal commented 1 year ago

I ran the same jupyter notebook in google colab and ran into the following error. Kindly help with it.

Alpaca successfully connected

TypeError Traceback (most recent call last) in <cell line: 1>() ----> 1 train(start_date = '2022-08-25', 2 end_date = '2022-08-31', 3 ticker_list = ticker_list, 4 data_source = 'alpaca', 5 time_interval= '1Min',

2 frames in train(start_date, end_date, ticker_list, data_source, time_interval, technical_indicator_list, drl_lib, env, model_name, if_vix, **kwargs) 58 ) 59 model = agent.get_model(model_name, model_kwargs=erl_params) ---> 60 trained_model = agent.train_model( 61 model=model, cwd=cwd, total_timesteps=break_step 62 )

in train_model(self, model, cwd, total_timesteps) 75 model.cwd = cwd 76 model.break_step = total_timesteps ---> 77 train_agent(model) 78 79 @staticmethod

in train_agent(args) 308 env = build_env(args.env_class, args.env_args) 309 agent = args.agent_class(args.net_dims, args.state_dim, args.action_dim, gpu_id=args.gpu_id, args=args) --> 310 agent.states = env.reset()[np.newaxis, :] 311 312 evaluator = Evaluator(eval_env=build_env(args.env_class, args.env_args),

TypeError: tuple indices must be integers or slices, not tuple