Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Datastream /
avatar image
Question by danieluphromes · May 14, 2021 at 02:27 PM · pythondatastream-apidsws-apiapi-limits

How can I use Python's Datastream DSWS to collect data above the limit of 50 instruments?

I use Python's DSWS a lot, and often need to collect few data points for many instruments (more than 50). How can I use Python to loop through instruments and get results in one Pandas data-frame?

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

1 Reply

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by jonathan.legrand · May 14, 2021 at 04:39 PM

Hi @danieluphromes,


For - as an e.g. - a string 'tickers_of_interest_str' (see comment) from 2020-01-01 to 2020-03-01 and the default field ('X'), you can use the below:


# We need pandas in addition to DSWS as ds
import pandas

# We need to split our string of instruments as a list
tickers_of_interest_lst = tickers_of_interest_str.split(",")

# Get 1st instrument's data
df = ds.get_data(tickers = tickers_of_interest_lst[0],
                 fields = ['X'],
                 start = '2020-01-01',
                 end = '2020-03-01').T

# Define a function to get chunks of 50 instrument lots
def chunks(lst, n):
    """Yield successive n-sized chunks from lst."""
    _lst = []
    for i in range(0, len(lst), n):
        _lst.append(lst[i:i + n])
    return _lst

# Use the pre-defined function up to the limit of DSWS - i.e.: 50
tickers_of_interest_chunks = chunks(lst = tickers_of_interest_lst[1:], n = 50)

# Now collect all data and append to df
for i in tickers_of_interest_chunks:
    _df = ds.get_data(tickers = ','.join(i),
                      fields = ['X'],
                      start = '2020-01-01',
                      end = '2020-03-01').T
    df = df.append(_df)

df = df.T

display(df)
Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
jonathan.legrand ♦♦ · May 14, 2021 at 04:39 PM 0
Share
tickers_of_interest_str = "US01Y00,US02Y00,US03Y00,US04Y00,US05Y00,US06Y00,US07Y00,US08Y00,US09Y00,US10Y00,US11Y00,US12Y00,US13Y00,US14Y00,US15Y00,US16Y00,US17Y00,US18Y00,US19Y00,US20Y00,US21Y00,US22Y00,US23Y00,US24Y00,US25Y00,US26Y00,US27Y00,US28Y00,US29Y00,US30Y00,US31Y00,US32Y00,US33Y00,US34Y00,US35Y00,US36Y00,US37Y00,US38Y00,US39Y00,US40Y00,US41Y00,US42Y00,US43Y00,US44Y00,US45Y00,US46Y00,US47Y00,US48Y00,US49Y00,US50Y00,UK01Y00,UK02Y00,UK03Y00,UK04Y00,UK05Y00,UK06Y00,UK07Y00,UK08Y00,UK09Y00,UK10Y00,UK11Y00,UK12Y00"

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
9 People are following this question.

Related Questions

DSWS API call based limit

Datastream DSWS Python most efficient way to load data

Is there a way to get the full list of symbols of specific type (e.g. forex, metal, commodity, etc) using python datastream API?

Hi all, I am trying to connect python by pyodbc to sql data base, but I am getting this error: InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

conda package for DSWS scripting api

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges