Library "LibraryCOT_NZ" 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 (simple string): 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(currency) Converts a currency string to its corresponding CFTC code. Parameters: currency (simple string) 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 (simple bool): 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 (simple string): One of the metric names listed in this library's chart. Invalid values will cause a runtime error. metricDirection (simple string): 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 (simple string): 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 (simple string): 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 (simple bool): "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, CFTCCode, includeOptions, metricName, metricDirection, metricType) Returns a valid TradingView ticker for the COT symbol with specified parameters. Parameters: COTType (simple string): A string with the type of the report requested with the ticker, one of the following: "Legacy", "Disaggregated", "Financial". CFTCCode (simple string) includeOptions (simple bool): A boolean value. 'true' if the symbol should include options and 'false' otherwise. metricName (simple string): One of the metric names listed in this library's chart. metricDirection (simple string): Direction of the metric, one of the following: "Long", "Short", "Spreading", "No direction". metricType (simple string): 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.
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ.
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.