The Commitments of Traders (COT) is a market report by the Commodity Futures Trading Commission (CFTC), listing the holdings of participants in futures of financial instruments, metals, and other commodities. It is believed by some traders to give insight into the upcoming development of those markets. The CFTC releases a new report every Friday at 3:30 p.m. Eastern Time, and the report reflects the commitments of traders on the prior Tuesday.
The following functions return selected parts of the COT report, and work likewise in backtest and live trading:
Handle | Dataset handle for storing the report. Every report needs a dedicated handle. |
Code | The Quandl code number of the report; normally 6 digits or letters. Can be looked up under https://www.quandl.com/data/CFTC-Commodity-Futures-Trading-Commission-Reports. The "CTFC/" prefix and "_F_ALL" suffix of the Quandl database are automatically added. |
Field | The field of the report: 1 = open interest, 2 = producer long positions, 3 = producer short positions, 4 = swap dealer long positions, 5 = swap dealer short positions, 6 = noncommercials long positions, 7 = noncommercials short positions. |
TimePeriod | The number of bars for calculating the index. |
#include <contract.c> // Database symbols and codes below are just for illustration. // Current available symbols can be found on the Quandl / NASDAQ website. function run() { StartDate = 2015; EndDate = 2018; BarPeriod = 1440; LookBack = 12*20; set(PLOTNOW); if(is(INITRUN)) { assetAdd("GOLD"); int Handle = assetHistory("CHRIS/CME_GC1",FROM_QUANDL|VOLATILE); // load gold futures history if(Handle) dataSave(Handle,"GOLD.t6"); } asset("GOLD"); string COT_Code = "CFTC/088691_F_ALL"; var Ind = COT_CommercialIndex(1,COT_Code,6*20); // gold COT report plot("Fast Index",Ind,NEW,RED); var Ind2 = COT_CommercialIndex(1,COT_Code,12*20); plot("Slow Index",Ind2,0,BLUE); }