how do i get CF_LAST and CF_CLOSE with lseg.data?

augusto_krappa
augusto_krappa Newcomer
edited May 23 in Refinitiv Data Platform

Im trying like this, but it is not working:

ticker_list = list(tickerStrings)  # Your ticker list   
max_items = 100   
results = []
   
for i in range(0, len(ticker_list), max_items):       
try:           
chunk = ticker_list[i:i + max_items]           
df_chunk = ld.content.pricing.Definition(               
chunk,               
fields=['CF_LAST', 'CF_CLOSE']           
).get_data().data.df           
results.append(df_chunk)       
except Exception as e:           
print(f"Error processing chunk {i//max_items + 1}: {e}")


output:

No user scope for key=/data/pricing/snapshots/v1/, method=GET.

Error processing chunk 1: Insufficient scope for key=/data/pricing/snapshots/v1/, method=GET.Required scopes: {'trapi.data.pricing.read'}Available scopes: {'trapi.streaming.prcperf.read', 'trapi.alerts.history.crud', 'trapi.data.historical-pricing.summaries.read', 'trapi.data.symbology.advanced.read', 'trapi.data.symbology.read', 'trapi.platform.iam.groups', 'trapi.platform.iam.guiss', 'trapi.user-framework.mobile.crud', 'trapi.userdata.lists.read', 'trapi.data.portfolios.write', 'trapi.metadata.read', 'trapi.alerts.publication.crud', 'trapi.metadata.nsa.read', 'trapi.research-analytics.fx-impact-intelligence', 'trapi.data.wealth-clients.wfdca', 'trapi.searchcore.read', 'trapi.graphql.subscriber.access', 'trapi.data.quantitative-analytics.read', 'trapi.synthetic.crud', 'trapi.cfs.claimcheck.read', 'trapi.platform.iam.acl_service', 'trapi.searchcore.metadata.read', 'trapi.searchcore.lookup.read', 'trapi.userdata.lists.write', 'trapi.streaming.synthetic.read', 'trapi.user-framework.workspace.crud', 'trapi.search.explore.read', 'trapi.data.benchmark.bmk_read', 'trapi.data.historical-pricing.events.read', 'trapi.frtb.sentimarization', 'trapi.sdbold', 'trapi.auth.cloud-credentials', 'trapi.data.portfolios.read', 'trapi.commodities.yesenergy.read', 'trapi.alerts.preferences.crud', 'trapi.data.api.msr_read', 'trapi.data.get.data.read', 'trapi.streaming.pricing.read', 'trapi.search.lookup.read', 'trapi.data.average-volume-analytics.ava_read', 'trapi.data.wealth-clients.advisor_dashboard', 'trapi.userdata.portfolio-management.read', 'trapi.alerts.subscription.crud', 'trapi.tradefeedr.basic.read', 'trapi.user-framework.application-metadata.raplib', 'trapi.messenger', 'trapi.search.read', 'trapi.user-framework.workspace.marval', 'trapi.search.metadata.read', 'trapi.user-framework.recently-used.crud'}Missing scopes: {'trapi.data.pricing.read'}Error processing chunk 2: Insufficient scope for key=/data/pricing/snapshots/v1/, method=GET.

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • ps: im not using config file to connect. im connecting calling this function:

    def ld_connect(APP_KEY = os.environ['REFINITIV_EDP_API'], USER = os.environ['REFINITIV_USER'], PASS = os.environ['REFINITIV_PASSWORD']):    session = ld.session.platform.Definition(        app_key = APP_KEY,        grant = ld.session.platform.GrantPassword(            username = USER,            password = PASS        ),        signon_control = True    ).get_session()    session.open()    ld.session.set_default(session)    print("LSEG connected")    return session

    ld_connect()

  • im trying this way also:

    ticker_list = list(tickerStrings)  # Your ticker list    max_items = 100    results = []
        for i in range(0, len(ticker_list), max_items):        try:            chunk = ticker_list[i:i + max_items]            df_chunk = ld.content.pricing.Definition(                          chunk,                          fields=['CF_LAST', 'CF_CLOSE']                          ).get_stream().open(with_updates=False).get_snapshot()            results.append(df_chunk)        except Exception as e:            print(f"Error processing chunk {i//max_items + 1}: {e}")



    output:

    Error processing chunk 1: 'OpenState' object has no attribute 'get_snapshot'Error processing chunk 2: 'OpenState' object has no attribute 'get_snapshot'

  • if i remove the .get_snapshot(), then no df is returned

  • Hello @augusto_krappa

    Your ID does not have the permission to get the real time data. You can reach out to the LSEG account manager to get these additional entitlements.

    I would recommend that, once the permissions are fixed, that you start with the provided Pricing samples for the LD Library.

  • how do i get the prices with 15min delay?

  • Can't request real time or delayed data without the appropriate permissions, Please discuss this with your account manager.

    If you are just testing out the library, the FX instruments like CAD=, GBP=, EUR= are usually available.

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.