Client wanted to get the api code for the excel file he provided.(Sheets Historical Data- Cotton Sales and Historical Data- Cotton Purchases)
He also wanted to see the
contract name like Dec26 etc
import lseg.data as ld
ld.open_session()
df = ld.get_history(
universe=[
"CFTCOTUSAMHY1",
"CFTCOTUSAMKY1",
"CFTCOTUSAMNY1",
"CFTCOTUSAMVY1",
"CFTCOTUSAY1",
"CFTCOTUSAMHY2",
"CFTCOTUSAMKY2",
"CFTCOTUSAMNY2",
"CFTCOTUSAMVY2",
"CFTCOTUSAY3",
"CFTCOTUSAY2",
"CFTCOTUSAMHY3",
"CFTCOTUSAMKY3",
"CFTCOTUSAMNY3",
"CFTCOTUSAY4",
"CFTCOTUSAY5",
"CFTCOTUSATOT"
],
fields=["MET_VAL","CLOSE"],
start="2000-01-01",
end="2026-08-26",
interval="1D"
)
print(df)