Hi Team,
I'm running the following script in Codebook and works fine:
-----
import refinitiv.dataplatform as rdp
import plotly.graph_objects as go
import pandas as pd
import numpy as np
from datetime import datetime
from dateutil.relativedelta import relativedelta
rdp.open_desktop_session('0ca53051de6448719f1835e663f609e83efc0197')
def get_maturity(t, today):
tenor = datetime.strptime(t, '%Y-%m-%d') - today
return tenor.days/365
def date_6M(today):
date = today - relativedelta(months=6)
return datetime.strftime(date, '%Y-%m-%d')
def get_data(chain = '0#ESBMK='):
today = datetime.now()
df_rics,err = rdp.legacy.get_data(chain, 'MATUR_DATE')
rics = df_rics['Instrument'].tolist()
Maturity = list(map(lambda t: get_maturity(t, today), df_rics.MATUR_DATE))
df_history = rdp.legacy.get_timeseries(rics, fields='CLOSE', start_date=date_6M(today))
df_history.dropna(inplace=True)
trace = go.Surface(y=df_history.index, x=Maturity, z=df_history.values, name=chain, showscale=False)
yield_surface = go.Figure()
yield_surface.add_trace(trace)
yield_surface.update_layout(template='plotly_dark', scene=dict(
xaxis=dict(title_text='Tenor', autorange='reversed'),
yaxis=dict(title_text='Date'),
zaxis=dict(title_text='Yield, %')
),
margin=dict(l=5, r=5, b=10, t=10),
)
return yield_surface
get_data("0#ESBMK=")
----
But when I move to Jupyter Notebook usen a APPKEY token is showing the error below: