def init_session(): cfg = cp.ConfigParser() """ The cfg file must be specify in absolute path to the file, otherwise Excel file cannot read it. """ cfg_location = 'C:\\drive_d\\Project\\Code\\xlwings_project\\notebook' + '\\rdp.cfg' # Change it to match your machine folder. cfg.read(cfg_location) session = rdp.open_platform_session( cfg['rdp']['app_key'], rdp.GrantPassword(username=cfg['rdp']['username'], password=cfg['rdp']['password'])) #print(session.get_open_state()) return session
@author: umern """ from itertools import count import matplotlib.pyplot as plt import pandas as pd from matplotlib.animation import FuncAnimation import time import refinitiv.dataplatform as rdp import configparser as cp config = cp.ConfigParser() config.read("config.cfg") rdp.open_platform_session( config['session']['app_key'], rdp.GrantPassword(username=config['session']['user'], password=config['session']['password'])) # Back fill tick history global bid_list, ask_list ric = 'EUR=' ticks = 100 df = rdp.get_historical_price_events(ric, fields=['BID', 'ASK'], count=ticks) bid_list = pd.to_numeric(df['BID']).to_list() ask_list = pd.to_numeric(df['ASK']).to_list() bid_list.reverse() ask_list.reverse() # Live prices streaming_prices = rdp.StreamingPrices(universe=[ric], fields=['BID', 'ASK']) streaming_prices.open()
print('Loading input portfolio...') workbook = load_workbook(filename=INPUT_PORTFOLIO) sheet = workbook.active data = sheet.values cols = next(data) data = list(data) inputdf = pd.DataFrame(data, columns=cols) inputdf.dropna(inplace=True) print(inputdf.head()) # Create an RDP session and get data print('Logging into RDP...') session = rdp.open_platform_session( APP_KEY, rdp.GrantPassword(username=RDP_LOGIN, password=RDP_PASSWORD)) print('Getting ESG data for portfolio...') endpoint = rdp.Endpoint(session=rdp.get_default_session(), url="data/datagrid/beta1/") instrs = inputdf['Instrument'].values.tolist() response = endpoint.send_request(method=rdp.Endpoint.RequestMethod.POST, body_parameters={ "fields": [ "TR.TRESGScore", "TR.TRBCEconomicSector", "TR.ExchangeCountry", "TR.ExchangeRegion"