Hi,
i am running the following code
ds.get_data(tickers='<.HSI>', fields=['PI','PE'], kind=0)
i keep getting ds is not defined error. no issues if i use ek. but i want to pull data from ds
Thank you
Hi,
i am running the following code
ds.get_data(tickers='<.HSI>', fields=['PI','PE'], kind=0)
i keep getting ds is not defined error. no issues if i use ek. but i want to pull data from ds
Thank you
Thanks for reaching out to us.
You need to import the DatastreamPy package, set a username and password, and then call that function.
import DatastreamPy as DSWS ds = DSWS.Datastream(username = "<username>", password = "<password>) ds.get_data(tickers='<.HSI>', fields=['PI','PE'], kind=0)
The DatastreamPy library is available at https://pypi.org/project/DatastreamPy/.
The output is:
I hope that this information is of help.
@Jirapongse thank you very much for your quick response. Can i check with you for the username and password is there any way i can store it in a notepad and then retreive it with a config parser, just like the method in eikon? i am hoping to not have to put the username and password explicitly in the codebook but rather have it read from a notepad so that username and password is not exposed. Thank you
Yes, you can.
Typically, I stored them in the text file and then set them in the DSWS.Datastream method.
f=open("account.txt","r") row = f.readline() field = row.split(",") username = field[0] password = field[1] ds = DSWS.Datastream(username = username, password = password)
The content in the account.txt is:
<usernmae>,<password>