Closed ahmasoh1992 closed 6 years ago
I would guess the problem is you are not running con.start()
before making your call to ref()
. Please take some time to read the documentation, as both this and #25 are discussed in the tutorial as well as the docstrings of the relevant methods.
I do agree that the error message could be more informative if you have not started a connection already.
Hi Matthew,
I only sent a code snippet above, the full code looks like this:
import pandas as pd
import numpy as np
con = pdblp.BCon(debug=False, port=8194)
con.start()
con = pdblp.BCon(timeout=5000)
str_index = 'SPX Index'
X = con.ref(str_index,'INDX_MWEIGHT_HIST', [('END_DT','19991231'),])
I have read the documentation...but it doesn't seem to want to pull data where the number of stocks per index is greater than a few hundred, for some reason!
Could you set con = pdblp.BCon(debug=True, port=8194)
and include the output from this? Not sure what is going on here since this syntax does not look problematic. Possibly related to hitting BBG terminal data limits since you mention you are pulling data on hundreds of instruments.
Edit: Nvm the syntax does look problematic please see my comment below
Hey Matt,
Thanks for the help. Bit confused myself here.
I don't seem to get any different output when setting the debug=True:
Traceback (most recent call last):
File "<input>", line 10, in <module>
File "C:\Users\sahmad\AppData\Roaming\Python\Python27\site-packages\pdblp\pdblp.py", line 242, in ref
ovrds, [])
File "C:\Users\sahmad\AppData\Roaming\Python\Python27\site-packages\pdblp\pdblp.py", line 116, in _create_req
request = self.refDataService.createRequest(rtype)
AttributeError: 'BCon' object has no attribute 'refDataService'
It's very difficult for me to tell conclusively unless you post short reproducible snippets. For example in your above post you have
import pandas as pd
import numpy as np
con = pdblp.BCon(debug=False, port=8194)
con.start()
con = pdblp.BCon(timeout=5000)
str_index = 'SPX Index'
X = con.ref(str_index,'INDX_MWEIGHT_HIST', [('END_DT','19991231'),])
which first creates a connection and assigns it to con
, con = pdblp.BCon(debug=False, port=8194)
, then appropriately starts the connection con.start()
, then reassigns a new connection to con
, con = pdblp.BCon(timeout=5000)
which you never end up starting. This is what leads me to believe you are not appropriately starting the connection.
Weirdly if I add a con.restart()
For example:
import pandas as pd
import numpy as np
con = pdblp.BCon(debug=False, port=8194)
con.start()
con = pdblp.BCon(timeout=5000)
con.restart()
str_index = 'SPX Index'
X = con.ref(str_index,'INDX_MWEIGHT_HIST', [('END_DT','19991231'),])
Then it works...?
This is not weird at all, this is expected behavior
con = pdblp.BCon(debug=False, port=8194)
con.start()
con = pdblp.BCon(timeout=5000)
con.start()
would also work since you need to start the second connection. In the example
con = pdblp.BCon(debug=False, port=8194)
con.start()
con = pdblp.BCon(timeout=5000)
those two con
variables are different instances, since you have reassigned the value.
This would parallel writing
a = 3
a = 7
clearly a
is not 3
after running this. Equivalently, you have a new connection instance, that generated by running con = pdblp.BCon(timeout=5000)
, that you never start in your previous examples.
Ah thanks Matt! Cheers for the help and awesome library - working like a dream now.
Hey,
If I have a request to pull the historical composition of a dataset, say:
Any help?? Not sure what's going on!