AI4Finance-Foundation / FinRL

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

FinRL_PaperTrading_Demo.ipynb fails to run: ModuleNotFoundError: No module named 'elegantrl.train.run_tutorial' #412

Closed marcipops closed 2 years ago

marcipops commented 2 years ago

From Colab, running FinRL_PaperTrading_Demo.ipynb notebook, has just started failing with this error:

ModuleNotFoundError Traceback (most recent call last)

in () ----> 1 from finrl.train import train 2 from finrl.test import test 3 from finrl.apps.config import DOW_30_TICKER 4 from finrl.apps.config import TECHNICAL_INDICATORS_LIST 5 from finrl.finrl_meta.env_stock_trading.env_stocktrading_np import StockTradingEnv 1 frames /usr/local/lib/python3.7/dist-packages/finrl/drl_agents/elegantrl/models.py in () 7 from elegantrl.agents.AgentA2C import AgentA2C 8 from elegantrl.train.config import Arguments ----> 9 from elegantrl.train.run_tutorial import train_and_evaluate 10 11 MODELS = {"ddpg": AgentDDPG, "td3": AgentTD3, "sac": AgentSAC, "ppo": AgentPPO, "a2c": AgentA2C} ModuleNotFoundError: No module named 'elegantrl.train.run_tutorial'
benwaldner commented 2 years ago

yes

benwaldner commented 2 years ago

The error must come from elegant RL recent changes.

I am got this error installing the lib on the file that worked yesterday:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. google-colab 1.0.0 requires requests~=2.23.0, but you have requests 2.27.1 which is incompatible. datascience 0.10.6 requires folium==0.2.1, but you have folium 0.8.3 which is incompatible. Successfully installed PyYAML-5.4.1 aiodns-3.0.0 aiohttp-3.7.4 aiohttp-cors-0.7.0 aioredis-1.3.1 aiosignal-1.2.0 alpaca-trade-api-1.4.3 async-timeout-3.0.1 blessed-1.19.0 box2d-py-2.3.8 ccxt-1.61.51 cfgv-3.3.1 colorful-0.5.4 cryptography-36.0.1 deprecated-1.2.13 distlib-0.3.4 elegantrl-0.3.2 empyrical-0.5.5 exchange-calendars-3.5 finrl-0.3.3 frozenlist-1.2.0 gpustat-1.0.0b1 gputil-1.4.0 hiredis-2.0.0 identify-2.4.1 int-date-0.2.0 jqdatasdk-1.8.10 lxml-4.7.1 lz4-3.1.10 mock-4.0.3 msgpack-1.0.2 multidict-5.2.0 nodeenv-1.6.0 opencensus-0.8.0 opencensus-context-0.1.2 platformdirs-2.4.1 ply-3.11 pre-commit-2.16.0 psycopg2-binary-2.9.3 py-spy-0.3.11 pybullet-3.2.1 pycares-4.1.2 pyfolio-0.9.2+75.g4b901f6 pyluach-1.3.0 pymysql-1.0.2 ray-1.9.1 redis-4.1.0 requests-2.27.1 stable-baselines3-1.3.0 stockstats-0.3.2 tensorboardX-2.4.1 thriftpy2-0.4.14 virtualenv-20.13.0 websocket-client-1.2.3 websockets-9.1 wrds-3.1.1 yarl-1.6.3 yfinance-0.1.68

Todays error code when installing it should be (it looks identical to me):

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. google-colab 1.0.0 requires requests~=2.23.0, but you have requests 2.27.1 which is incompatible. datascience 0.10.6 requires folium==0.2.1, but you have folium 0.8.3 which is incompatible. Successfully installed PyYAML-5.4.1 aiodns-3.0.0 aiohttp-3.7.4 aiohttp-cors-0.7.0 aioredis-1.3.1 aiosignal-1.2.0 alpaca-trade-api-1.4.3 async-timeout-3.0.1 blessed-1.19.0 box2d-py-2.3.8 ccxt-1.61.51 cfgv-3.3.1 colorful-0.5.4 cryptography-36.0.1 deprecated-1.2.13 distlib-0.3.4 elegantrl-0.3.2 empyrical-0.5.5 exchange-calendars-3.5 finrl-0.3.3 frozenlist-1.2.0 gpustat-1.0.0b1 gputil-1.4.0 hiredis-2.0.0 identify-2.4.1 int-date-0.2.0 jqdatasdk-1.8.10 lxml-4.7.1 lz4-3.1.10 mock-4.0.3 msgpack-1.0.2 multidict-5.2.0 nodeenv-1.6.0 opencensus-0.8.0 opencensus-context-0.1.2 platformdirs-2.4.1 ply-3.11 pre-commit-2.16.0 psycopg2-binary-2.9.3 py-spy-0.3.11 pybullet-3.2.1 pycares-4.1.2 pyfolio-0.9.2+75.g4b901f6 pyluach-1.3.0 pymysql-1.0.2 ray-1.9.1 redis-4.1.0 requests-2.27.1 stable-baselines3-1.3.0 stockstats-0.3.2 tensorboardX-2.4.1 thriftpy2-0.4.14 virtualenv-20.13.0 websocket-client-1.2.3 websockets-9.1 wrds-3.1.1 yarl-1.6.3 yfinance-0.1.68

marcipops commented 2 years ago

I'm not an expert at this, so not sure whether I'm looking in the right place. https://github.com/AI4Finance-Foundation/ElegantRL/tree/master/elegantrl/train Files have been updated 5 hours ago, and the folder 3 hours ago. config is in there but I can't see the module named 'run_tutorial' - has this been removed? Thanks for your help!

benwaldner commented 2 years ago

Yes, it was deleted from what I can say. But probably there are more modules missing. In the worst case one could fork an older version of ElegantRL and import the old version of it.

Please have a look: @supersglzc

marcipops commented 2 years ago

Agree benwaldner. I don't know how to get to an older version of Elegant RL that has been deemed "working". Not sure how change/release control works in this community. Can the latest changes be rolled back?

benwaldner commented 2 years ago

I did an update in the Slack channel. Hopefully someone will see the issue.

benwaldner commented 2 years ago

The issue is the refactory commit on ElegantRL. I forked finrl, changed the imports in setup.py to a stable version of an older fork of elegantRL and it works.

YangletLiu commented 2 years ago

Noted. Yes, we are actively updating. The framework is improving a lot, in order to solve challenging trading tasks.

marcipops commented 2 years ago

Hi XiaoYangLiu-FinRL on a constructive note, is there any way that you could enforce more modularity and encapsulate those changes please, so that the main files like FinRL_PaperTrading_Demo.ipynb in FinRL folder that people are using don't keep breaking?

Maybe the only other alternative is for the users of those main files is to take a copy of all the repos (due to the cross-dependencies) so they are stable for our development and work locally, but that then defeats the intent of this collaborative development.

Look forward to the fix for this issue, and your thoughts on release control going forward, so we can get our projects moving again.

Many thanks :)

YangletLiu commented 2 years ago

Currently, I do not have a good solution yet. The "intent" was to achieve a "plug-and-play" style, which turns out to causing these breakings.

The major issue could be: 1). We finished the FinRL framework first, then split it into FinRL_Meta, ElegantRL, and even some cloud solutions. 2). We did not fully fix all APIs in the very beginning, they are slightly changing on a weekly basis.

I should take the main responsibility. However, I do foresee the great potential of the tech roadmap ahead. A good thing is we have a team working on fixing the issues, developing new powerful optimization skills.

marcipops commented 2 years ago

OK understood Xiao-Yang Liu - this is a complex and rapidly evolving project, with huge potential (that's why we are all keen to use), but recognize it has its challenges until at least its modular interfaces are stable.

On this issue #412, I have been spending all afternoon with benwaldner (thanks to his support), in trying to do a work around.

Would you be able to get us going with at least fix to this issue (Issue #412) and we can then get moving with our projects.

Much appreciated

From: Xiao-Yang Liu @.> Sent: 06 January 2022 18:58 To: AI4Finance-Foundation/FinRL @.> Cc: marcipops @.>; Author @.> Subject: Re: [AI4Finance-Foundation/FinRL] FinRL_PaperTrading_Demo.ipynb fails to run: ModuleNotFoundError: No module named 'elegantrl.train.run_tutorial' (Issue #412)

Currently, I do not have a good solution yet. The "intent" was to achieve a "plug-and-play" style, which turns out to causing these breakings.

The major issue could be: 1). We finished the FinRL framework first, then split it into FinRL_Meta, ElegantRL, and even some cloud solutions. 2). We did not fully fix all APIs in the very beginning, they are slightly changing on a weekly basis.

I should take the main responsibility. However, I do foresee the great potential of the tech roadmap ahead. A good thing is we have a team working on fixing the issues, developing new powerful optimization skills.

- Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAI4Finance-Foundation%2FFinRL%2Fissues%2F412%23issuecomment-1006837680&data=04%7C01%7C%7C7e115bf3d9e349855bc808d9d1467801%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770922868539372%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=3yfk653gJcVJm3WXOGCcEg6UdW7NTJxLRO6b6dFypbQ%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAG7HSZNBTCTFVX52DSWRUE3UUXQ3XANCNFSM5LL4I2GQ&data=04%7C01%7C%7C7e115bf3d9e349855bc808d9d1467801%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770922868539372%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=mmw8G0FFQYplhPLBykSAJQenU7KKmRD3a1%2FN60k0vzQ%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C7e115bf3d9e349855bc808d9d1467801%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770922868539372%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=AnhIcCLjqNd8J3MTQT7xf1%2FTVEKBoNAu6NC5jlu8oLw%3D&reserved=0 or Androidhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7C7e115bf3d9e349855bc808d9d1467801%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770922868539372%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=t73OH2ZppFAcBw8cFhLICduzXeoGfw9Ql4mmqjc8XLA%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.**@.>>

marcipops commented 2 years ago

As a workaround, whilst the team are fixing this issue #412 (which Jingyang Rui confirmed was potentially due to an issue with elegantrl), he recommended to replace drl_lib='elegantrl' with drl_lib='stable-baselines3' or 'rllib'. I am retrying with stable_baselines3, and is working so far, albeit very slow to train. Hope that helps ppl in the interim.

rayrui312 commented 2 years ago

It is updated and should fix the issue with ElegantRL. You may have a try.

marcipops commented 2 years ago

I have tried and it works in Colab - but not in Ubuntu 18, through WLS on Windows 10, Python 3.9 as reported in issue #423. However as this issue #412 works, will close it.