Skip to main content

No project description provided

Project description

pycot

pycot is a easy to use python library for interacting with the CFTC Commitment of Traders reports.

Installation

pip install pycot-reports

Requirements

  • pandas
  • requests

How to use

from pycot import legacy_report, disaggregated_report, financial_report

Lets have a look at some examples.

Legacy Report (All Contracts)

from pycot import legacy_report
contract_name = ("FED FUNDS - CHICAGO BOARD OF TRADE", "30-DAY FEDERAL FUNDS - CHICAGO BOARD OF TRADE")
df = legacy_report("legacy_fut", contract_name)

Output Example:

                                            Contract Name  Open Interest  ...  Net Change, Large Spec  Net % of OI, Large Spec
Date                                                                      ...                                                                                                                                      
2023-07-11             FED FUNDS - CHICAGO BOARD OF TRADE      1440370.0  ...                -58101.0                    -11.5
2023-07-03             FED FUNDS - CHICAGO BOARD OF TRADE      1414525.0  ...                -17553.0                     -7.5
2023-06-27             FED FUNDS - CHICAGO BOARD OF TRADE      1746984.0  ...                 12437.0                     -5.1
2023-06-20             FED FUNDS - CHICAGO BOARD OF TRADE      1693141.0  ...                 84512.0                     -6.0
2023-06-13             FED FUNDS - CHICAGO BOARD OF TRADE      1556681.0  ...                 60704.0                    -12.0
...                                                   ...            ...  ...                     ...                      ...
1993-03-23  30-DAY FEDERAL FUNDS - CHICAGO BOARD OF TRADE        11298.0  ...                   106.0                      9.1
1993-03-16  30-DAY FEDERAL FUNDS - CHICAGO BOARD OF TRADE        11015.0  ...                    -8.0                      8.3
1993-03-09  30-DAY FEDERAL FUNDS - CHICAGO BOARD OF TRADE        10651.0  ...                   -51.0                      8.8
1993-03-02  30-DAY FEDERAL FUNDS - CHICAGO BOARD OF TRADE        10902.0  ...                  -190.0                      9.0
1993-02-23  30-DAY FEDERAL FUNDS - CHICAGO BOARD OF TRADE        12460.0  ...                   -83.0                      9.4
...

Disaggregated Report (Commodities)

from pycot import disaggregated_report
contract_name = ("BRENT LAST DAY - NEW YORK MERCANTILE EXCHANGE", "BRENT CRUDE OIL LAST DAY - NEW YORK MERCANTILE EXCHANGE")
df = disaggregated_report("disaggregated_futopt", contract_name)

Output Example:

                                                Contract Name  Open Interest   ...  Net Change Managed Money  Net % of OI Managed Money
Date                                                                           ...                                                                                                                                
2023-07-11      BRENT LAST DAY - NEW YORK MERCANTILE EXCHANGE       138358.0   ...                  -2134.0                        -2.9
2023-07-03      BRENT LAST DAY - NEW YORK MERCANTILE EXCHANGE       130715.0   ...                   9436.0                        -1.4
2023-06-27      BRENT LAST DAY - NEW YORK MERCANTILE EXCHANGE       153190.0   ...                  -6135.0                        -7.4
2023-06-20      BRENT LAST DAY - NEW YORK MERCANTILE EXCHANGE       148800.0   ...                   2367.0                        -3.5
2023-06-13      BRENT LAST DAY - NEW YORK MERCANTILE EXCHANGE       147598.0   ...                  -3872.0                        -5.1
...                                                       ...            ...                            ...                         ...
2011-04-12  BRENT CRUDE OIL LAST DAY - NEW YORK MERCANTILE...        20546.0   ...                   -484.0                        17.1
2011-04-05  BRENT CRUDE OIL LAST DAY - NEW YORK MERCANTILE...        19533.0   ...                    655.0                        20.4
2011-03-29  BRENT CRUDE OIL LAST DAY - NEW YORK MERCANTILE...        18178.0   ...                   -276.0                        18.4
2011-03-15  BRENT CRUDE OIL LAST DAY - NEW YORK MERCANTILE...        20233.0   ...                    231.0                        17.9
2011-03-08  BRENT CRUDE OIL LAST DAY - NEW YORK MERCANTILE...        19639.0   ...                      NaN                        17.3
...

Financial Report (Financial Instruments)

from pycot import financial_report
contract_name = ("UST 10Y NOTE - CHICAGO BOARD OF TRADE", "10-YEAR U.S. TREASURY NOTES - CHICAGO BOARD OF TRADE", "10 YEAR U.S. TREASURY NOTES - CHICAGO BOARD OF TRADE")
df = financial_report("traders_in_financial_futures_fut", contract_name)

Output Example:

df
                                                Contract Name  Open Interest   ...  Net Change Lev Money  Net % of OI Lev Money
Date                                                                           ...                                                                                            
2023-07-11              UST 10Y NOTE - CHICAGO BOARD OF TRADE      4800091.0   ...              155532.0                  -26.8
2023-07-03              UST 10Y NOTE - CHICAGO BOARD OF TRADE      4737762.0   ...                7710.0                  -30.4
2023-06-27              UST 10Y NOTE - CHICAGO BOARD OF TRADE      4663919.0   ...              -51457.0                  -31.1
2023-06-20              UST 10Y NOTE - CHICAGO BOARD OF TRADE      4641767.0   ...              -53136.0                  -30.2
2023-06-13              UST 10Y NOTE - CHICAGO BOARD OF TRADE      4619668.0   ...               69602.0                  -29.1
...                                                       ...            ...   ...                   ...                    ...
2006-07-11  10-YEAR U.S. TREASURY NOTES - CHICAGO BOARD OF...      2112145.0   ...               28199.0                    1.8
2006-07-03  10-YEAR U.S. TREASURY NOTES - CHICAGO BOARD OF...      2136459.0   ...              -18122.0                    0.5
2006-06-27  10-YEAR U.S. TREASURY NOTES - CHICAGO BOARD OF...      2194364.0   ...               13929.0                    1.3
2006-06-20  10-YEAR U.S. TREASURY NOTES - CHICAGO BOARD OF...      2097072.0   ...              -27203.0                    0.6
2006-06-13  10-YEAR U.S. TREASURY NOTES - CHICAGO BOARD OF...      1912279.0   ...                   NaN                    2.2
...

Contract Names

The only tricky part is the contract name.

You can find the contract name in the CFTC Commitment of Traders reports. The contract name is the first column in the report.

You can also find a curated list of contract names in the contract_names.json

Release Shedule

The CFTC releases the reports every Friday at 3:30pm Eastern Time.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycot-reports-0.0.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycot_reports-0.0.2-py2.py3-none-any.whl (7.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pycot-reports-0.0.2.tar.gz.

File metadata

  • Download URL: pycot-reports-0.0.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for pycot-reports-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6e2b0b9a0034d18e5ca171ce0d6c8c2aed08fbc2048d56d1c839d42734431071
MD5 a4be28e1cdd7df376731f2b37d634326
BLAKE2b-256 ab93ead2cc9e239f66ec743923c7d19df72d29f5155ccc8a5f06100a9cacd686

See more details on using hashes here.

File details

Details for the file pycot_reports-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pycot_reports-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dbc5538e2d2d8cfd12ebc895238c5eb3caa27dfd8be3a18e2da09c0850bc0b60
MD5 9209b70550be6b14102bdb4123b029cd
BLAKE2b-256 7efe6ca251b1888de560a8c95d4c06709154bfecedd7212cb6362e8aa6da1870

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page