alpha-xone / xbbg

An intuitive Bloomberg API
https://xbbg.readthedocs.io/
Apache License 2.0
246 stars 52 forks source link

Does xbbg cache each request? #36

Closed julius-datajunkie closed 3 years ago

julius-datajunkie commented 3 years ago

Hi, I am trying to understand when I make repeated calls like this:

blp.bdib("ESA Index", dt="2020-01-25", session="allday", ref="CME", cache=True)

vs

blp.bdib("ESA Index", dt="2020-01-25", session="allday", ref="CME")

Does it cache the result of these calls? Does the cache argument doing anything?

Thanks!

alpha-xone commented 3 years ago

If you define BBG_ROOT in your path, xbbg will cache each call to a cached file. By default cache=True - it means xbbg loads cached file if available.

If you use cache=False, it will reload data from Bloomberg and save / override to your locally cached file.

julius-datajunkie commented 3 years ago

Hi Alpha-xone, Thanks for the prompt reply. I have retried to set the BBG_ROOT variable per your suggestion.

import os
os.environ["BBG_ROOT"] = r"C:\Users\abc\bbg_data"

then I ran my code as:

blp.bdh(["XU1 Index", "XU2 Index"], ["PX_LAST"], start_date="2020-01-15")

But I see no files been generated under the folder as set for BBG_ROOT. Morever, when I tried to run the following:

blp.bdib("ESA Index", dt="2020-01-25", session="allday", ref="CME")

It returns the error: OperationalError: unable to open database file.

alpha-xone commented 3 years ago

Not familiar with this error. But you need to assign BBG_ROOT in the system, not in the console.

tagomatech commented 3 years ago

Hi. For some reason, I'm also unable to get blp.bdib working.

For example, (Windows user here) I defined properly the BBG_ROOT environment variable, and amended assets.yml and exch.yml to be able to pull Euronext commodities futures series. blp.bdh and blp.bdtick work perfectly well, but blp.bdib returns me OperationalError: unable to open database file whatever the kwargs I may try out.

The example provided in XBBG documentation blp.bdib(ticker='BHP AU Equity', dt='2018-10-17').tail() gets me the same error message.

I'll continue to dig as I need those data (!), but any help is much welcome indeed!

Many thanks. tag

tagomatech commented 3 years ago

Hi. For some reason, I'm also unable to get blp.bdib working.

For example, (Windows user here) I defined properly the BBG_ROOT environment variable, and amended assets.yml and exch.yml to be able to pull Euronext commodities futures series. blp.bdh and blp.bdtick work perfectly well, but blp.bdib returns me OperationalError: unable to open database file whatever the kwargs I may try out.

The example provided in XBBG documentation blp.bdib(ticker='BHP AU Equity', dt='2018-10-17').tail() gets me the same error message.

I'll continue to dig as I need those data (!), but any help is much welcome indeed!

Many thanks. tag

Ok, so I got it working. It was a simple sqlite3 connection issue, more specifically with the command with db.SQLite(f'{data_path}/Logs/xbbg.db') as con: in \xbbg\core\trials.py

The thing is that I hadn't any Logsfolder. So I manually created one, \xbbg\markets\Logs (location depending on BBG_ROOT).

The code examples in my previous post now work just fine.

Maybe @shadow-of-life-bravo can see whether this would also solve his issue?

Thank you. tag

alpha-xone commented 3 years ago

Thanks for the info. It is fixed in version 0.7.6a8.