AI4Finance-Foundation / FinRL

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

Update processor_alpaca.py #1007

Closed lcavalie closed 1 year ago

lcavalie commented 1 year ago

Fix for time zone conversion error Fix issue 981

LunbiWa commented 1 year ago

Hi.

!pip install git+https://github.com/lcavalie/FinRL.git

image

Can you solve the [AttributeError: 'Timedelta' object has no attribute 'delta'] problem reported by colab?

Thanks!

lcavalie commented 1 year ago

Yes, it's common issue if you are running a recent version of Panda where Timedelta does not have a .delta attribute anymore. The purpose of my code is to solve issue 981 which is about filling the dataframe with stock prices at zero caused to the error in timezones between daylight saving time or not daylight saving time. To fix the panda 'object has no attribute' error you need to change the line from: if pd.Timedelta(time_interval).delta < day_delta: to if pd.Timedelta(time_interval).total_seconds() < 27000: as there are 27,000 second during which the market is open.

L

zhumingpassional commented 1 year ago

@lcavalie thanks for your codes.