polakowo / vectorbt

Find your trading edge, using the fastest engine for backtesting, algorithmic trading, and research.
https://vectorbt.dev
Other
4.21k stars 609 forks source link

Can't import into Google Colab #425

Open Ron-27 opened 2 years ago

Ron-27 commented 2 years ago

While trying to import into Google Colab using import vectorbt as vbt whenPyYAML version 6 is used, I get the error message:

[/usr/local/lib/python3.7/dist-packages/distributed/config.py](https://localhost:8080/#) in <module>()
     18 
     19 with open(fn) as f:
---> 20     defaults = yaml.load(f)
     21 
     22 dask.config.update_defaults(defaults)

TypeError: load() missing 1 required positional argument: 'Loader'

Is there anyway to use vectorbt with PyYAML 6 ?

polakowo commented 2 years ago

@Ron-27 vectorbt doesn't require PyYAML. A bit of googling helps: https://stackoverflow.com/a/69565230

Ron-27 commented 2 years ago

Yes, I saw this thread, but I'm using it with alpaca-trade-api, which uses PyYAML 6. For some reason when installing vectorbt it installs earlier version of PyYAML and won't import if it's an updated version of PyYAML. In summary, I can't use these two libraries together on Google Colab because I get the above error while trying to import vectorbt

dev590t commented 2 years ago

@Ron-27

For some reason when installing vectorbt it installs earlier version of PyYAML

vectorbt still use alpaca-trade-api 1.4, that maybe explain why it install earlier version of pyyaml.

I can't use these two libraries together on Google Colab

267 propose !pip install dateparser --upgrade:

!pip install alpaca-trade-api>=2.1.0
!pip install vectorbt==0.23.3
!pip install dateparser --upgrade
import vectorbt as vbt

No run for me.

267 propose to force pyyaml==5.4.1:

!pip install alpaca-trade-api>=2.1.0
!pip install vectorbt==0.23.3
!pip install pyyaml==5.4.1
import vectorbt as vbt

That solves the issue. But that can raise resolution conflict with other package during the installation

For the moment, I haven't find other better solution