FinRL icon indicating copy to clipboard operation
FinRL copied to clipboard

FinRL Paper Trading demo bug

Open olistokes opened this issue 1 year ago • 3 comments

I get the following errors when I run FinRL Paper trading demo. Please can you help?

TypeError Traceback (most recent call last) in <cell line: 1>() ----> 1 train (start_date = '2022-12-04', 2 end_date = '2022-12-24', 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

I'm running windows 10, python 3.10, on google chrome

olistokes avatar Jan 31 '24 20:01 olistokes

most probably You used the environment which returns 5 values from step method and 2 values from reset method. change this code return state, reward, done, False, dict() to return state, reward, done, dict()

and from the reset function return only state return self.get_state(price) please check the code.

it must resolve the error. from new update gymnasium returns 5 values but elegantrl still returns 4.

let me know if you still get the error.

krishdotn1 avatar Feb 05 '24 10:02 krishdotn1

Krish,

Hi - thanks so much for your help. I'm still struggling a little with where to locate the code you are referring to? I'm new to coding so bear with me please. I have searched for the code you referred to but can't find it in the runtime? Can you be more specific on its location? Oli


From: Krish Nandan Das @.> Sent: 05 February 2024 10:07 To: AI4Finance-Foundation/FinRL @.> Cc: olistokes @.>; Author @.> Subject: Re: [AI4Finance-Foundation/FinRL] FinRL Paper Trading demo bug (Issue #1164)

most probably You used the environment which returns 5 values from step method and 2 values from reset method. change this code return state, reward, done, False, dict() to return state, reward, done, dict()

and from the reset function return only state return self.get_state(price) please check the code.

it must resolve the error. from new update gymnasium returns 5 values but elegantrl still returns 4.

let me know if you still get the error.

— Reply to this email directly, view it on GitHubhttps://github.com/AI4Finance-Foundation/FinRL/issues/1164#issuecomment-1926623828, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFQDLWVKMULYUYEXGJU2PYTYSCVM5AVCNFSM6AAAAABCTW3VYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRWGYZDGOBSHA. You are receiving this because you authored the thread.Message ID: @.***>

olistokes avatar Feb 05 '24 21:02 olistokes

image

in the above-marked file. you will find the reset method it returns 2 values change it to return self.get_state(price) image

same with the step method return state, reward, done, dict()

krishdotn1 avatar Feb 06 '24 06:02 krishdotn1