Recently Tradingview gave us limited options stuff but unfortunately their API makes this very difficult, technically speaking, there should theoretically be a way to get options data from request.quandlor get local real estate data for say, a REIT and then do fun calculations but that data lacks documentation or doesn't work.
Pine Script®
//@version=5
indicator("Combined Macro & Financial Indicator", overlay=false)
// Define constants for index values
ZILLOW_PRICE_INDEX = 1
US_GDP_INDEX = 1
SOYBEAN_FORECAST_INDEX = 1
PRODUCER_LONGS_INDEX = 8
PRODUCER_SHORTS_INDEX = 9
SWAP_LONGS_INDEX = 10
SWAP_SHORTS_INDEX = 11
INFLATION_INDEX = 1
ES1_CLOSE_INDEX = 4
ES1_OPTIONS_INDEX = 1 // Placeholder index for options data
// Zillow Real Estate Data: Median Listing Price
// Source: Zillow database on Nasdaq Data Link
zillow_price = request.quandl("ZILLOW/M00039_MRP", index=ZILLOW_PRICE_INDEX, ignore_invalid_symbol=true)
// World Bank Data: US GDP
// Source: World Bank database on Nasdaq Data Link
world_bank_gdp = request.quandl("WWDI/USA_NY_GDP_MKTP_CN", index=US_GDP_INDEX, ignore_invalid_symbol=true)
// WASDE: Soybean Forecast
// Source: World Agricultural Supply and Demand Estimates (WASDE) on Nasdaq Data Link
wasde_soybean = request.quandl("WASDE/SOYBEAN", index=SOYBEAN_FORECAST_INDEX, ignore_invalid_symbol=true)
// CFTC: Net Positions (e.g., Gold Futures)
// Source: Commodity Futures Trading Commission (CFTC) reports on Nasdaq Data Link
producer_merchant_processor_user_longs = request.quandl("CFTC/088691_F_ALL", index=PRODUCER_LONGS_INDEX, ignore_invalid_symbol=true)
producer_merchant_processor_user_shorts = request.quandl("CFTC/088691_F_ALL", index=PRODUCER_SHORTS_INDEX, ignore_invalid_symbol=true)
swap_dealer_longs = request.quandl("CFTC/088691_F_ALL", index=SWAP_LONGS_INDEX, ignore_invalid_symbol=true)
swap_dealer_shorts = request.quandl("CFTC/088691_F_ALL", index=SWAP_SHORTS_INDEX, ignore_invalid_symbol=true)
// IMF: US Inflation Data
// Source: International Monetary Fund (IMF) data on Nasdaq Data Link
imf_inflation = request.quandl("ODA/USA_PCPIPCH", index=INFLATION_INDEX, ignore_invalid_symbol=true)
// ES1! Data: S&P 500 E-mini Futures Close Price
// Source: S&P 500 E-mini Futures on TradingView (ES1!)
es1_close = request.security("ES1!", "D", close)
// ES1! Options Data: Placeholder for S&P 500 E-mini Futures options data
// Source: Options data on Nasdaq Data Link (if available)
es1_options = request.quandl("CBOE/ES_OPTIONS", index=ES1_OPTIONS_INDEX, ignore_invalid_symbol=true) // Replace "CBOE/ES_OPTIONS" with correct dataset code if available
// Create a table to display the data
table_id = table.new(position.top_right, 10, 2, border_width=1)
// Set table headers
header_bg_color = color.blue
header_text_color = color.white
table.cell(table_id, 0, 0, "Indicator", text_color=header_text_color, bgcolor=header_bg_color)
table.cell(table_id, 0, 1, "Value", text_color=header_text_color, bgcolor=header_bg_color)
// Set table rows
default_text_color = color.black
table.cell(table_id, 1, 0, "Zillow Median Listing Price", text_color=default_text_color)
table.cell(table_id, 1, 1, na(zillow_price) ? "N/A" : str.tostring(zillow_price), text_color=default_text_color)
table.cell(table_id, 2, 0, "World Bank US GDP", text_color=default_text_color)
table.cell(table_id, 2, 1, na(world_bank_gdp) ? "N/A" : str.tostring(world_bank_gdp), text_color=default_text_color)
table.cell(table_id, 3, 0, "WASDE Soybean Forecast", text_color=default_text_color)
table.cell(table_id, 3, 1, na(wasde_soybean) ? "N/A" : str.tostring(wasde_soybean), text_color=default_text_color)
table.cell(table_id, 4, 0, "Producer Merchant Longs", text_color=default_text_color)
table.cell(table_id, 4, 1, na(producer_merchant_processor_user_longs) ? "N/A" : str.tostring(producer_merchant_processor_user_longs), text_color=default_text_color)
table.cell(table_id, 5, 0, "Producer Merchant Shorts", text_color=default_text_color)
table.cell(table_id, 5, 1, na(producer_merchant_processor_user_shorts) ? "N/A" : str.tostring(producer_merchant_processor_user_shorts), text_color=default_text_color)
table.cell(table_id, 6, 0, "Swap Dealer Longs", text_color=default_text_color)
table.cell(table_id, 6, 1, na(swap_dealer_longs) ? "N/A" : str.tostring(swap_dealer_longs), text_color=default_text_color)
table.cell(table_id, 7, 0, "Swap Dealer Shorts", text_color=default_text_color)
table.cell(table_id, 7, 1, na(swap_dealer_shorts) ? "N/A" : str.tostring(swap_dealer_shorts), text_color=default_text_color)
table.cell(table_id, 8, 0, "S&P 500 E-mini Futures Close Price", text_color=default_text_color)
table.cell(table_id, 8, 1, na(es1_close) ? "N/A" : str.tostring(es1_close), text_color=default_text_color)
table.cell(table_id, 9, 0, "S&P 500 E-mini Futures Options Data", text_color=default_text_color)
table.cell(table_id, 9, 1, na(es1_options) ? "N/A" : str.tostring(es1_options), text_color=default_text_color)
// Set the y-axis scale and style for better readability
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)
// Background color for the chart
bgcolor(color.new(color.gray, 90)) // Background color to help distinguish the indicator plots
// Possible Sources and Explanation of Codes
// Zillow: Provides real estate data (e.g., median listing prices) using code "ZILLOW/M00039_MRP"
// World Bank: Uses "WWDI/USA_NY_GDP_MKTP_CN" to get the US GDP
// WASDE: Uses "WASDE/SOYBEAN" to get the forecast data for soybeans
// CFTC: Uses "CFTC/088691_F_ALL" for the Commodity Futures Trading Commission reports (e.g., Gold Futures)
// IMF: Uses "ODA/USA_PCPIPCH" to get US inflation data
// ES1!: Uses "ES1!" for the S&P 500 E-mini Futures close price
// Options Data: Placeholder code "CBOE/ES_OPTIONS" for options data, replace with actual dataset if available
// Notes on NaN Values
// If values are returned as NaN, this could indicate that the data is either not available or the dataset has updated, requiring a different code or index.
// Consider checking the data availability on the Nasdaq Data Link website to verify the dataset codes and indices.
// Max Number of Requests
// Pine Script limits external requests like `request.quandl()` to avoid overwhelming servers. Consider limiting the number of requests or combining data where possible to optimize the use of requests.
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。