bpsmith / tia

Toolkit for integration and analysis
BSD 3-Clause "New" or "Revised" License
404 stars 165 forks source link

change currency of current data #49

Open larryx2000 opened 5 years ago

larryx2000 commented 5 years ago

Can someone tell me how to change currency when I request current data? I can do it using get_historical

sids = ['IBM US Equity'] now = datetime.datetime.now() sids.get_historical(['CUR_MKT_CAP'],now,now,currency="JPY")

but since I have quite a big number of securities and I'm only interested in current data, I would like to avoid using get_historical. I tried the following

sids.get_attributes(['CUR_MKT_CAP'],currency='JPY')

but it still retrieve the data in USD (i.e. the local currency)

dpsugasa commented 5 years ago

I would use .getReferenceData. that should work. I can't test because my BBG license is expired, but that is how you get current data.

On Thu, Dec 13, 2018 at 2:10 PM larryx2000 notifications@github.com wrote:

Can someone tell me how to change currency when I request current data? I can do it using get_historical

sids = ['IBM US Equity'] now = datetime.datetime.now() sids.get_historical(['CUR_MKT_CAP'],now,now,currency="JPY")

but since I have quite a big number of securities and I'm only interested in current data, I would like to avoid using get_historical. I tried the following

sids.get_attributes(['CUR_MKT_CAP'],currency='JPY')

but it still retrieve the data in USD (i.e. the local currency)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bpsmith/tia/issues/49, or mute the thread https://github.com/notifications/unsubscribe-auth/AZekSHaUwr63-JcOKeouLAXbJXsGYeEQks5u4l_ogaJpZM4ZRtJ- .

larryx2000 commented 5 years ago

Thanks for your help dpsugasa. I'm using tia.py and there is no attribute .getReferenceData in tia.bbg.datagr. Am I missing something trivial?

dpsugasa commented 5 years ago

Sorry Larry, I answered this from my phone so I was shooting from memory. Let me take a closer look today and come back when I am in front of python.

On Fri, 14 Dec 2018, 09:33 larryx2000 <notifications@github.com wrote:

Thanks for your help dpsugasa. I'm using tia.py and there is no attribute .getReferenceData in tia.bbg.datagr. Am I missing something trivial?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bpsmith/tia/issues/49#issuecomment-447268752, or mute the thread https://github.com/notifications/unsubscribe-auth/AZekSK16EMb9OjoQMVmByCk6tWKs09H8ks5u43B3gaJpZM4ZRtJ- .

dpsugasa commented 5 years ago

Larry,

see this example:

https://github.com/bpsmith/tia/blob/master/examples/v

LocalTerminal.get_reference_data()

Sorry for the confusion. Let me know if you need further info.

On Fri, Dec 14, 2018 at 9:42 AM Dustin Sugasa dustin.sugasa@gmail.com wrote:

Sorry Larry, I answered this from my phone so I was shooting from memory. Let me take a closer look today and come back when I am in front of python.

On Fri, 14 Dec 2018, 09:33 larryx2000 <notifications@github.com wrote:

Thanks for your help dpsugasa. I'm using tia.py and there is no attribute .getReferenceData in tia.bbg.datagr. Am I missing something trivial?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bpsmith/tia/issues/49#issuecomment-447268752, or mute the thread https://github.com/notifications/unsubscribe-auth/AZekSK16EMb9OjoQMVmByCk6tWKs09H8ks5u43B3gaJpZM4ZRtJ- .

larryx2000 commented 5 years ago

dpsugasa,

thanks a lot for that!

Unfortunately using get_reference_data() doesn't seem to solve problem:

mv_usd2 = LocalTerminal.get_reference_data(universe,['CUR_MKT_CAP'],currency='USD')
mv_usd2 = mv_usd2.as_frame()

mv_usd3 = LocalTerminal.get_historical(universe,['CUR_MKT_CAP'],now,now,currency='USD')
mv_usd3 = mv_usd3.as_frame()

mv_usd2 has the market cap data in Local Currency, while mv_usd3 has the correct market cap in USD. it seems that I have to get the data using get_historical.

txu2014 commented 5 years ago

You need CRNCY_ADJ_MKT_CAP with EQY_FUND_CRNCY to convert the currency.
LocalTerminal.get_reference_data(universe,['CRNCY_ADJ_MKT_CAP'],EQY_FUND_CRNCY='USD').as_frame() bbg help says;

For current market cap value with currency adjusted, please refer to Currency Adj Market Cap (RR910, CRNCY_ADJ_MKT_CAP).