question

Upvotes
Accepted
19 2 3 6

data stream navigator

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

#technologydatastream-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
86.2k 292 53 79

@ken03

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:

1682043639804.png

I hope that this information is of help.


1682043639804.png (17.6 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
19 2 3 6

@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

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@ken03

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>

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.