PINE LIBRARY

LibraryCOT

מעודכן
Library "LibraryCOT"
This library provides tools to help Pine programmers fetch Commitment of Traders (​COT) data for futures.

rootToCFTCCode(root)
  Accepts a futures root and returns the relevant CFTC code.
  Parameters:
    root: Root prefix of the future's symbol, e.g. "ZC" for "ZC1!"" or "ZCU2021".
  Returns: The <CFTCCode> part of a COT ticker corresponding to `root`, or "" if no CFTC code exists for the `root`.

currencyToCFTCCode(curr)
  Converts a currency string to its corresponding CFTC code.
  Parameters:
    curr: Currency code, e.g., "USD" for US Dollar.
  Returns: The <CFTCCode> corresponding to the currency, if one exists.

optionsToTicker(includeOptions)
  Returns the <includeOptions> part of a COT ticker using the `includeOptions` value supplied, which determines whether options data is to be included.
  Parameters:
    includeOptions: A "bool" value: 'true' if the symbol should include options and 'false' otherwise.
  Returns: The <includeOptions> part of a COT ticker: "FO" for data that includes options and "F" for data that doesn't.

metricNameAndDirectionToTicker(metricName, metricDirection)
  Returns a string corresponding to a metric name and direction, which is one component required to build a valid COT ticker ID.
  Parameters:
    metricName: One of the metric names listed in this library's chart. Invalid values will cause a runtime error.
    metricDirection: Metric direction. Possible values are: "Long", "Short", "Spreading", and "No direction". Valid values vary with metrics. Invalid values will cause a runtime error.
  Returns: The <metricCode><metricDirection> part of a COT ticker ID string, e.g., "OI_OLD" for "Open Interest" and "No direction", or "TC_L" for "Traders Commercial" and "Long".

typeToTicker(metricType)
  Converts a metric type into one component required to build a valid COT ticker ID. See the "Old and Other Futures" section of the CFTC's Explanatory Notes for details on types.
  Parameters:
    metricType: Metric type. Accepted values are: "All", "Old", "Other".
  Returns: The <metricType> part of a COT ticker.

convertRootToCOTCode(mode, convertToCOT)
  Depending on the `mode`, returns a CFTC code using the chart's symbol or its currency information when `convertToCOT = true`. Otherwise, returns the symbol's root or currency information. If no COT data exists, a runtime error is generated.
  Parameters:
    mode: A string determining how the function will work. Valid values are:
"Root": the function extracts the futures symbol root (e.g. "ES" in "ESH2020") and looks for its CFTC code.
"Base currency": the function extracts the first currency in a pair (e.g. "EUR" in "EURUSD") and looks for its CFTC code.
"Currency": the function extracts the quote currency ("JPY" for "TSE:9984" or "USDJPY") and looks for its CFTC code.
"Auto": the function tries the first three modes (Root -> Base Currency -> Currency) until a match is found.
    convertToCOT: "bool" value that, when `true`, causes the function to return a CFTC code. Otherwise, the root or currency information is returned. Optional. The default is `true`.
  Returns: If `convertToCOT` is `true`, the <CFTCCode> part of a COT ticker ID string. If `convertToCOT` is `false`, the root or currency extracted from the current symbol.

COTTickerid(COTType, CTFCCode, includeOptions, metricName, metricDirection, metricType)
  Returns a valid TradingView ticker for the COT symbol with specified parameters.
  Parameters:
    COTType: A string with the type of the report requested with the ticker, one of the following: "Legacy", "Disaggregated", "Financial".
    CTFCCode: The <CFTCCode> for the asset, e.g., wheat futures (root "ZW") have the code "001602".
    includeOptions: A boolean value. 'true' if the symbol should include options and 'false' otherwise.
    metricName: One of the metric names listed in this library's chart.
    metricDirection: Direction of the metric, one of the following: "Long", "Short", "Spreading", "No direction".
    metricType: Type of the metric. Possible values: "All", "Old", and "Other".
  Returns: A ticker ID string usable with `request.security()` to fetch the specified Commitment of Traders data.
הערות שחרור
v2

Update SPX CFTC Code#13874+
הערות שחרור
Added Copper - HG
COTstatistics

ספריית Pine

ברוח TradingView אמיתית, המחבר פרסם קוד Pine זה כספריית קוד פתוח כדי שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומים אחרים בקוד פתוח, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית.


גם על:

כתב ויתור