Heerozh / spectre

GPU-accelerated Factors analysis library and Backtester
GNU General Public License v3.0
642 stars 108 forks source link

How to use it on gogle colab? #14

Open rrfaria opened 3 years ago

rrfaria commented 3 years ago

What I did: I followed readme and added initial code but it isn't works

!pip install --no-deps git+git://github.com/Heerozh/spectre.git
!pip install pytorch torchvision torchaudio
!pip install pyarrow pandas tqdm plotly requests

by default cudatoolkit is already installed on colab then I imported the code:

from spectre.data import YahooDownloader
YahooDownloader.ingest(start_date="2011", save_to="/content/prices/yahoo", symbols=None, skip_exists=True)

and the errors shows:

Download prices from yahoo...
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-14-db2629264a25> in <module>()
      1 from spectre.data import YahooDownloader
----> 2 YahooDownloader.ingest(start_date="2011", save_to="/content/prices/yahoo", symbols=None, skip_exists=True)

6 frames
/usr/local/lib/python3.7/dist-packages/pandas/io/html.py in _parse_tables(self, doc, match, attrs)
    545 
    546         if not tables:
--> 547             raise ValueError("No tables found")
    548 
    549         result = []

ValueError: No tables found

if I use:

YahooDownloader.ingest(start_date="2011", save_to="/content/prices/yahoo", symbols=['EURUSD=X'], skip_exists=True)

ERROR:

Download prices from yahoo...
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-cd5640dd3574> in <module>()
      1 from spectre.data import YahooDownloader
----> 2 YahooDownloader.ingest(start_date="2011", save_to="/content/prices/yahoo", symbols=['EURUSD=X'], skip_exists=True)

/usr/local/lib/python3.7/dist-packages/spectre/data/yahoo.py in ingest(cls, start_date, save_to, symbols, skip_exists)
     47         # CrumbStore
     48         m = re.search('"CrumbStore":{"crumb":"(.*?)"}', page.text)
---> 49         crumb = m.group(1)
     50         crumb = crumb.encode('ascii').decode('unicode-escape')
     51 

AttributeError: 'NoneType' object has no attribute 'group'
Heerozh commented 3 years ago

problem is downloading data from Yahoo, not related to colab. It seems that Yahoo changed his API.

Yahoo often changes his methods to prevent others from downloading, you better find other ways to get data.

rrfaria commented 3 years ago

The best lib and still working for yahoo https://github.com/ranaroussi/yfinance