question

Upvotes
Accepted
9 1 8 13

Get data from python datastream api

import DatastreamPy as dsws
ds=dsws.Datastream(username='****',password='****')

d = ds.get_data (tickers='BARC', fields=['P'], start='2018-01-01', end='2023-03-01', freq='W')

How can I retrieve price data from "d". I intend to store it in database but am not able to access data.

d returns None

python#technologydatastream-apidatastream
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.

Hi @vishal.kak ,

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?

If so please can you click the 'Accept' text on the left side of the appropriate reply? This will guide all community members who have a similar question.

Thanks,
AHS

@vishal.kak

Hi,

Please be informed that a reply has been verified as correct in answering the question, and marked as such.

Thanks,

AHS

Upvote
Accepted
22.1k 59 14 21

I tried the query and the dataframe d is not None.

>>> d = ds.get_data (tickers='BARC', fields=['P'], start='2018-01-01', end='2023-03-01', freq='W')
>>> d
Instrument    BARC
Field            P
Currency         £
Dates
2018-01-01  203.13
2018-01-08  200.10
...            ...
2023-02-20  175.88
2023-02-27  172.64

[270 rows x 1 columns]

>>> d.info()
<class 'pandas.core.frame.DataFrame'>
Index: 270 entries, 2018-01-01 to 2023-02-27
Data columns (total 1 columns):
 #   Column        Non-Null Count  Dtype
---  ------        --------------  -----
 0   (BARC, P, £)  270 non-null    float64
dtypes: float64(1)

You can get the series data from it by accessing it like this -

>>> d['BARC', 'P', '£']
Dates
2018-01-01    203.13
2018-01-08    200.10
               ...
2023-02-20    175.88
2023-02-27    172.64
Name: (BARC, P, £), Length: 270, dtype: float64


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.

Upvote
5.8k 21 2 6

Hi @vishal.kak ,

We have a python & datastream tutorial article too, 'Estimating Monthly GDP via the Expenditure Approach and the Holt Winters Model', if that interest 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.

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.