philsv / pycot

Python library for retrieving the CFTC Commitment of Traders reports

Home Page:https://pypi.org/project/pycot-reports/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error on unknown contract

dermatzeimnetz opened this issue · comments

when I request

df = cot_report(financial_report(), "CORN - CHICAGO BOARD OF TRADE")

I have a warning
/home/matze/.local/lib/python3.11/site-packages/pycot/utils.py:15: UserWarning: Could not infer format, so each element will be parsed individually, falling back to dateutil. To ensure parsing is consistent and as-expected, please specify a format.
df["Date"] = pd.to_datetime(df["Date"])

And i have an empty dataframe, hence Corn does not exists as a contract in that report type.
Could you create a function to list all available contracts of a specfied report type?

"CORN - CHICAGO BOARD OF TRADE" is part of the commodity contracts i.e. Disaggregated Report.

I will defently look into improving the error handling here and potentially integrating contract_names.json into the package. But then there needs to be continues monitoring of changes in the contracts. I could implement a user information if the data is no longer up to date.

Will do that in the future. Right now I am a bit busy, won't be able to do it this week.

For now you can find the current report types here: https://github.com/philsv/pycot/blob/main/pycot/extract_report_data.py#L64

Here you will find all contracts and their specific report locations: https://www.cftc.gov/MarketReports/CommitmentsofTraders/index.htm

I've included a function to list all available contract names for a report type in version 0.1.1
https://github.com/philsv/pycot?tab=readme-ov-file#list-available-contracts