Greeny

COT (Legacy): Commercial Interest

Open Interest for commercial traders from legacy commitment of traders ( COT ) report. For the main symbol but also allows to override it. Also allows to include options in consideration.
Remove from Favorite Scripts Add to Favorite Scripts
study("Commercial Interest", shorttitle="Com Int", precision=0)
force_root = input("", title="Override Product")
is_includeoptions = input(false, type=bool, title="Include Options")

fxroot =
	  ticker == "USDCAD" ? "CD" : 
	  ticker == "USDCAD" ? "CD" : 
	  ticker == "USDCHF" ? "SF" : 
	  ticker == "USDCZK" ? "CZ" : 
	  ticker == "USDHUF" ? "FR" : 
	  ticker == "USDILS" ? "IS" : 
	  ticker == "USDJPY" ? "JY" : 
	  ticker == "USDMXN" ? "MP" : 
	  ticker == "USDNOK" ? "UN" : 
	  ticker == "USDPLN" ? "PZ" : 
	  ticker == "USDRUB" ? "RU" : 
	  ticker == "USDSEK" ? "SE" : 
	  ticker == "USDZAR" ? "RA" : 
	  ticker == "EURUSD" ? "EC" : 
	  ticker == "AUDUSD" ? "AD" : 
	  ticker == "GBPUSD" ? "BP" : 
	  ticker == "NZDUSD" ? "NE" : 
	  ticker == "BRLUSD" ? "BR" : 
	  ""
root = force_root == "" ? fxroot == "" ? syminfo.root : fxroot : force_root
code = root + (is_includeoptions ? "_FO_L_ALL" : "_F_L_ALL")

is_inversed = 
	  ticker == "USDCAD" ? true : 
	  ticker == "USDCAD" ? true : 
	  ticker == "USDCHF" ? true : 
	  ticker == "USDCZK" ? true : 
	  ticker == "USDHUF" ? true : 
	  ticker == "USDILS" ? true : 
	  ticker == "USDJPY" ? true : 
	  ticker == "USDMXN" ? true : 
	  ticker == "USDNOK" ? true : 
	  ticker == "USDPLN" ? true : 
	  ticker == "USDRUB" ? true : 
	  ticker == "USDSEK" ? true : 
	  ticker == "USDZAR" ? true : 
	  false

long_total = security("QUANDL:CFTC/"+code+"|4", "D", close)
short_total = security("QUANDL:CFTC/"+code+"|5", "D", close)

long = is_inversed ? short_total : long_total
short = is_inversed ? long_total : short_total

plot(long, color = green, title="Long")
plot(short, color = red, title="Short")
plot(long-short, color = yellow, title="Net", style=histogram)
hline(0, color=yellow, linestyle=dashed)
Hi Greeny! Same comment as on the Open interest, how do I create the Commercial interest for gold ? W hat is important here is to show the net commercial position as a line. Is it possbile?
+2 Reply
1. Apply this script to the chart
2. Switch the GC1!
3. Go to the indicator settings and change Net style from histogram to line.
+1 Reply
what do you mean apply the scipt to the chart? copy the script and paste it in the pine scipt editor?
Reply
Greeny, can I ask you to TEST something please:

CONTRACT CLU2014 (SEPTEMBER CRUDE_OIL FUTURE)

WHAT IS THE NET COMMERCIAL POSITION (long-short) YOU GET ON THE CHART?

Thank you
Reply
Greeny

seems ok on the 1st check:

CRUDE OIL

NET COMMERCIAL = -404265 contracts

The only thing is that this data refers to the 22nd of July. The new CFTC report of the 29th of July has already been issued. So we have two weeks old data. I'm chacking with Qundnl where are they normally uploading the data. We need to have the results as sson as possible, there could be big chnages in two weeks...


Crude
+1 Reply
I have the same number.
Agree, quandl needs to adjust their update policy for this datasets. I'll try to contact them also.
+1 Reply
great, the results are issued by CFTC on friday. In reality they refer to the data collected on the previous tuesday, but nothing we can do here this is how CFTC works. If we can have the data the same day (friday) or saturday it's ok. I have tried to use the code for the GRAINS (wheat, soybeans, corn etc) but it doesn't work. Is it the same for you? Try for example ZSU2104 (September Soybean)
+1 Reply
HI Greeny,

how can I get the chart from CME contracts such as grains (soybean, wheat, corn etc) or live stock (such as live cattle, hogs etc). If I use this code the vhart doen't appear. I have talked to the quandl (thay could have choosen and easier name..:) and they said all the data is there ready
+2 Reply
sorry for the typos .. I'm on the train..
Reply
http://ppt.cc/v3Gb
maybe you want this
my english is very poor,sorry
+1 Reply
LEONES PRO futures168
yes but here is better, don't want to jump from on platform to another I have already 3 platf..I don't undestand why the code doesn't owrk on the all the commodities, it seems that the values are not taken from quandl
+1 Reply
Those have different symbology. For such cases you can override root in the indicator inputs.
You may check roots on the quandl here http://www.quandl.com/CFTC. For example to get a wheat root
1. Go to quandl and type 'wheat'
2. Find the dataset you need and notice it's code 'CFTC/MW_F_ALL'
3. So the root for wheat is MY (between 'CFTC/' and '_')
4. Go to indicator inputs and set Override Product as MW
+1 Reply
Here's the full list for all products available on quandl.com
0D - Mini Eur 3.5%foil Rtd Cal Swap
7K - Eurobob Oxy Nwe Crk Spr
A6 - Grp 3 Ulsd Vs Heating Oil Spr
ADB - Ad Hub Da Off-peak Monthly
ADP - Nyiso Zone A
AEC - Aeco Fin Basis
ALQ - Algonquin City-gates Financial Basis
ANO - Natural Gas Pipeline, Texok (basis)
API - Henry Hub - Tailgate, Louisiana (index)
APO - Nyiso Zone A (off-peak)
B0P - Mt Belvieu Propane (opis) Swap
B6 - Pjm N Ill Hub 5 Off Peak Swap
BO - Soybean Oil
BZC - Brent Crude Oil Last Day
C - Corn
C2 - Colorado Interstate - Mainline (basis)
CB - Butter (cash Settled)
CC - Cocoa
CGM - Henry Hub - Tailgate, Louisiana (basis)
CI3 - Miso Cinergy Hub (real-time Lmp)
CL - Crude Oil, Light Sweet
CSC - Cheese (cash-settled)
CT - Cotton No. 2
CU - Chicago Ethanol Swap
D0 - Mt Belv Norm Butane Opis Swap
D2 - Nyiso Zone G5 Mw Off Peak Swap
DA - Milk, Class Iii
DDO - Aep Dayton Hub (real Time Lmp)
DGD - Chicago Fin Basis
DK - Cme Milk Iv
DOM - Dominion - South Point (basis)
E4 - Pjm Western Off Peak Day Ahead
EDN - Ercot - North Zone
EH - Cbt Ethanol
EN1 - Naphtha Crack Spr Swap
FC - Feeder Cattle
FO - 3.5% Fuel Oil Rdam Crack Spr
GC - Gold
GCU - Gulf No6 Fo 3% V Eur 3.5% Rdam
GDP - Nyiso Zone G
H - Natural Gas Ice Henry Hub
HG - Copper-grade #1
HO - #2 Heating Oil, Ny Harbor-ulsd
HP - Henry Hub Penultimate Fin
HXS - Hsc Fin Basis
IC10 - Texas Eastern- M3 Zone (delivered) (basis)
IC11 - Transcontinental Gas- Station 85 (zone 4)
IC12 - Transcontinental Gas - Zone 6 (ny) (basis)
IC15 - N. Illinois Hub Day Ahead Lmp, Off Peak Monthly
IC19 - Pjm Ppl Zone Day Ahead, Off-peak Monthly
IC2 - Columbia Gulf Transmission Co. - Mainline Pool
IC3 - El Paso-san Juan Basin,blanco Pool Primary Only-ba
IC4 - Michigan Consolidated Citygate (generic) (basis)
IC9 - Pacific Gas Transmission - Malin (basis)
ICE1 - Columbia Gas Co. - Tco Pool (appalachia) (basis)
J4 - Pjm Western Peak Day Ahead
JCD - Pjm Jcpl Zone Day-ahead Off-peak
K3 - Nyiso Zone A 5 Mw Peak Swap
K4 - Nyiso Zone A 5mw Off Peak Swap
KC - Coffee C
KS - Sing Jet Kero Swap
KW - Wheat-hrw
L1 - Pjm Western Peak Real Time
LB - Random Length Lumber
LC - Live Cattle
LH - Lean Hogs
LT - Up Down Gc Ulsd Vs Ho Spr Swap
ME - Gulf Jet Ny Heat Oil Spr Swap
MF - Gulf # 6 Fuel 3.0% Sulfur Swap
MFF - Coal (api 4) Fob Rich Bay Fut
MJN - Mini Japan C&f Naphtha Swap Fu
MM - Ny Res Fuel 1.0% Sulfur Swap
MNC - Mini Eur Naphtha Cif Nwe Swap
MTF - Coal (api 2) Cif Ara Swap Fut
MTI - Texas Eastern- M3 Zone (delivered)
MTS - Mini Sing 380 Fuel Oil Swap
NE1 - Nepool Mh Da Lmp Offpk Mon Min
NE4 - Nepool Mass Hub (day-ahead Lmp)
NG - Natural Gas
NI4 - Northern Illinois Hub (real Time Lmp)
NN - Henry Hub Swap
NN1 - Henry Hub Last Day Fin
NOD - Nyiso Zone G (off-peak)
NP - Henry Hub Penultimate Gas Swap
NWR - Nwp Rockies Fin Basis
O - Oats
OF - Mini Sing Fueloil 180 Cal Swap
OJ - Frzn Concentrated Orange Juice
OMI - Pjm Wh Real Time Mini Off-peak
PA - Palladium
PA1 - Pjm Aep Day Hub 5 Mw Peak Swap
PAN - Panhandle Eastern- Pool Gas (basis)
PER - El Paso - Permian Basin (basis)
PFP - Pjm Wh Real Time Peak
PGE - Pg&e Citygate Fin Basis
PH - Natural Gas Penultimate Ice
PJC - Pjm Western Hub (day-ahead)
PJD - Pjm Western Hub (day-ahead Off Peak)
PL - Platinum
PMI - Pjm Western Hub Mini (real Time Lmp)
PN1 - Pjm N Ill Hub 5 Mw Peak Swap
PNO - Pjm N Ill Off Peak Day Ahead
PNP - Pjm N Ill Peak Day Ahead
PPF - Pjm Pepco Day-ahead
PPP - Pjm Ppl Zone Day Ahead, Peak Monthly
R09 - Mt Belv Nat Gasoline Opis Swap
RB - Gasoline Blendstock (rbob)
RK - Sing Jet Kero Gasoil Spr Swap
RLX - Rbob Calendar Swap
RR - Rough Rice
S - Soybeans
SB - Sugar No. 11
SCI - Socal (index)
SCL - Socal Border Fin Basis
SDP - Sp15 Fin Da Peak Fixed
SE - Sing 380 Fuel Oil Swap
SHS - Houston Ship Channel (index)
SI - Silver
SM - Soybean Meal
T3 - Nyiso Zone G 5 Mw Peak Swap
TPB - Transco Zone 6 Basis
U3 - Iso New Eng Hub Off Peak Swap
U6 - Iso New Eng Int Hub Peak Swap
UA - Sing Fuel Oil 180 Cal Swap
UF - Eur 3.5% Fuel Oil Rtd Cal Swap
VDP - Palo Verde
VP - Pjm Aep Dayton Off Peak Swap
VR - Ny 1% V Gulf 3% Fuel Oil Spr
W - Wheat-srw
WAH - Waha Fin Basis
WAY - Wti Crude Oil Calendar Swap
IC8 - Northwest Pipeline Corp. - Rocky Mountains
IC5 - Natural Gas Pipeline-mid-continent Pool Pin (basis
MDC - Mid-c Financial Peak
MXO - Mid-c Financial Off-peak
BGY - Pjm Bge Zone Day Ahead, Peak Monthly
BGZ - Pjm Bge Zone Day Ahead Off Peak Monthly
PPH - Pjm Pepco Day-ahead Off-peak
LY - Gulf Coast Ulsd Crack Spr Swap
PJM - Pjm Electricity Monthly
ODP - Pjm Wh Off Peak Real Time
WOL - Pjm Western Hub Real 50mw Off
PCP - Pjm Peco Zone Off-peak Monthly
JCB - Pjm Jcpl Zone Day-ahead
PCO - Pjm Peco Zone (da Lmp) Peak Monthly
CIS - Chicago Citygate (index)
NVE - Northern Natural Gas - Ventura (basis)
T - Crude Oil, Light Sweet
MW - Wheat
IC13 - Waha Hub - West Texas Delivered/buyer's Index
NJY - Nyiso Zone J
SON - Sonat - Tier 1 Pool (zone 0)
6T - In Delivery Month Eua
XPU - Ercot - North Monthly Off-peak
1N - Singapore Mogus 92 Swap Future
D3 - Nyiso Zone J 5 Mw Peak Swap
D4 - Nyiso Zone J5 Mw Off Peak Swap
H4 - Mw Cinrgy 5 Off Peak Real-time
JP - Pjm Cal Month Off Pk Lmp Swap
NFC - 1% Fuel Oil Nwe Crack Spr
NJO - Nyiso Zone J (off-peak)
PAP - Pjm Aep Peak Day Ahead
QVP - Palo Verde (off-peak)
RBB1 - Rbob Gasoline/brent Crack Sprd
RLX1 - Rbob Up-down Cal Swap
UN - European Naphtha Cal Swap
CAL - Calif Carbon Allowance-2013
Z9 - Aep Dayton Peakcal Month Lmp 5
ALI - Natural Gas Index: Algonquin City Gates
EIS - Pg&e - Citygate (index)
IC7 - Northwest Pipeline - Canadian Border (basis)
PIS - Panhandle Eastern- Pool Gas (index)
EW - East West Fuel Oil Spr Swap
HR - Hot Rolled Coil Steel
JA - Japan C&f Naphtha Swap
KI - Iso New England Lmp Swap
QXB - Csx Coal Swap
SD - Sing 180 380 Fuel Oil Spr Swap
ADD - Ad Hub Da Peak Monthly
ADO - Aep Dayton Hub (real Time Lmp Off-peak)
CI2 - Misco Cinergy Hub Real Time Peak
IC14 - Misco Cinergy Day Ahead Lmp, Peak Monthly
IC16 - N. Illinois Hub Day Ahead Lmp, Peak Monthly
IC17 - Nepool Mass Hub (day-ahead Lmp Off-peak)
IC18 - Northern Illinois Hub (real Time Lmp Off-peak)
IOP - Cin Hub Real Time Off-peak
MCD - Cin Hub Da Off-peak
NE2 - Nepool Mh Da Lmp Peak Mon Mini
NP1 - N Path 15 Ez Gen Hub Da Peak
NP2 - Npath 15 Ez Gen Hub Da Offpeak
OFP - Sp15 Fin Da Lpm Off-peak
PSA - Psa-pjm Pseg Zone Day-ahead
PSB - Psb-pjm Pseg Zone Day-ahead Off-peak
BH - No. 2 Heating Oil, N.y. Harbor
IC6 - Northern Natural Gas - Demarcation Pool (basis)
PEB - Pjm Eastern Hub Day-ahead
SG - Sing Gasoil Swap
QLD - Central Appalachian Coal
WS - Wti Crude Oil Financial
YK - Mini Soybeans
MG - Gulf # 6 Fuel Oil Crack Swap
UM - North Ill Cal Month Lmp Opt
WOR - Pjm Western Off Peak Real Time
MPD - Mid-c Financial Peak Otc
OMC - Mid-c Financial Off-peak Otc
PMX - Pjm Wh Real Time Peak Otc
PWC - Pjm Wh Off Peak Real Time Otc
1R - Mt Belvieu Ethane Opis Swap
Z1 - Ethanol T2 Fob Incl Duty Swap
LE - Fame Biodiesel V Gasoil Spr Sp
EZ - New York Ethanol Swap
QP - Powder River Basin Coal Swap
CAM - 1000 California Carbon Allowance
BZ - Brent Financial
B3 - North Ill Cal Month Lmp Swap
GE1 - Gulf Coast Jet Fuel Cal Swap
KH - Nyiso Zone G Lbmp Swap
R7 - Aep Dayton Cal Month Lmp Swap
UY - Ny Ulsd Vs Heating Oil Spr Swp
GCI - Gulf#6 Fueloil Brent Crack Swp
CY - Brent (ice) Calendar Swap
FI - Fuel Oil Cargoes B Platts Swap
KB - Nyiso Zone A Lbmp Swap
KI1 - Iso New Eng Off Pk Lmp Swap
BI - Dubai Crude Oil Calendar Swap
DBO - Brent-dubai Swap
GZ - Gasoil Crack Spr Swap
HA - Nymex Heating Oil/rdam Gasoil
NW - Waha Basis Swap
PH1 - Panhandle Basis Swap
GLI - Gasoil (ice) Swap
L6 - Pjm Pseg Peak Day Ahead
UF1 - Eur 1% Fuel Oil Nwe Cal Swap
W6 - Pjm Pseg Off Peak Day Ahead
NH - Houston Ship Ch Basis Swap
GA - Sing Gasoil/rdam Gasoil Swap
NR - Nw Pipe Rockies Basis Swap
PD - Ngpl Texok Basis Swap
TC - Tco Basis Swap
OY - Cinergy Cal Month Lmp Swap
EJ - Cinergy Off Peak Lmp Swap
NX - M-3 Basis Swap
R8 - Pjm Pepco Peak Day Ahead
CFF - Carbon Financial Instrument
SOC - Sulfur Financial Instrument
HB - Henry Hub Basis Swap
NF - Michcon Basis Swap
NL - Ngpl Midcon Basis Swap
EN - Naptha Crack Spr Swap
JA1 - Japan C&f Naptha Swap
JC - Jet Cif Nwe/gasoil Fut
J2 - Pjm Jcpl Peak Day Ahead
8C - Mt Belvieu Ethane 5 Dec Swap
8J - Mt Belv Norm Butane 5 Dec Swap
8O - Mt Belvieu Propane 5 Dec Swap
R0 - Mt Belv Nat Gasoline 5 Dec Swp
Q8 - Pjm Pepco Off Peak Day Ahead
RUN - Rggi Co2 Allowance
RBB - Rbob Crack Spread Swap
3M - Mt Belvieu Normal Butane Swap
7Q - Mt Belvieu Nat Gasoline Swap
B0 - Mt Belvieu Propane Swap
T1 - Crude Oil, Light Sweet
+4 Reply
Is there a way to add the EURGBP pair to this? I tried editing the code by adding to the fxroot variable but it doesn't display (other pairs work). The CFTC code is #299741
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
日本
한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out