alpha-xone / xbbg

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

XBBG: Adding New Mappings #12

Closed Jermaine456 closed 4 years ago

Jermaine456 commented 4 years ago

I’ve been reading through your documentation for xbbg on https://pypi.org/project/xbbg/.

I’m confused following these instructions to add new mappings for more securities when pulling intraday data.

“To add new mappings, define BBG_ROOT in sys path and add assets.yml and exch.yml under BBG_ROOT/markets”.

When I open the .yml files for assets, exchanges and currencies in notepad the following instructions are also given:

“Override or expand this list by providing

os.environ['BBG_ROOT']/markets/assets.yml

os.environ['BBG_ROOT']/markets/ccy.yml

os.environ['BBG_ROOT']/markets/exch.yml “

Would you mind providing example code to show how exactly I’m supposed to do the above?

Many thanks,

alpha-xone commented 4 years ago

Examples can be found in this folder: .yml default values

Jermaine456 commented 4 years ago

What I'm asking for, is how exactly in a script, do I provide "os.environ['BBG_ROOT']/markets/ccy.yml" so that I can add new currencies??

alpha-xone commented 4 years ago

You don't need to write any script. The only thing you need to do, is to create the ccy.yml file in your folder. Content of the file is given in above link.

Jermaine456 commented 4 years ago

which folder? my local environment?

Jermaine456 commented 4 years ago

I've already got the file for the record just wandering how to make sure python registers the changes I've made.

It's currently saved here: C:\anaconda3\Lib\site-packages\xbbg\markets

alpha-xone commented 4 years ago

BBG_ROOT is the system environment variable you defined in your system, for example D:\Data.

Then you create .yml files in D:\Data\markets.

Jermaine456 commented 4 years ago

Ok so I created the system environment variable BBG_root and created the .yml files. I'm trying to add the CAD currency as you can see in below txt file attached but I keep getting "KeyError: 'Cannot find exchange info for CAD Curncy'".

Please advise.

ccy.txt

alpha-xone commented 4 years ago

Put below code in assets.yml:

Curncy:
  - tickers: [CAD]
    exch: CurrencyGeneric
Jermaine456 commented 4 years ago

error still persists. Is there something I'm supposed to put in exch.yml?

Jermaine456 commented 4 years ago

Ignore this all resolved. Thanks!

alpha-xone commented 4 years ago

ok good

drlima commented 4 years ago

Hi. I am with a similar problem here. I want to add Brazilian assets, more specific the ticker 'ODF21 Comdty'. How should I do the mapping?