OPEN-SOURCE SCRIPT
Japan Yen Carry Trade to Risk Ratio Sharpe Ratio By UncleBFM

Step-by-Step Calculation in the ScriptFetch Rates:Pulls rates dynamically using request.security() from user-specified symbols (e.g., TVC:JP10Y for yen, TVC:US10Y for target). If unavailable (NA), uses fallback inputs (e.g., 0.25% for yen, 4.50% for target).
Converts rates to decimals: (target_rate - yen_rate) / 100.
Calculate Carry:Carry = (Target Rate - Yen Rate) / 100
Example: If US 10Y yield is 4.50% and Japan 10Y is 0.25%, carry = (4.50 - 0.25) / 100 = 0.0425 (4.25% annual yield).
Calculate Daily Log Returns:Log Returns = ln(Close / Close[1]), where Close is the current price of the pair (e.g., USDJPY) and Close[1] is the previous day's price.
This measures daily percentage changes in a way suitable for volatility calculations.
Calculate Annualized Volatility:Volatility = Standard Deviation of Log Returns over a lookback period (default 63 days, ~3 months) × √252.
Example: If the standard deviation of USDJPY log returns is 0.005 (0.5% daily), annualized volatility = 0.005 × √252 ≈ 0.0794 (7.94%).
Compute the Ratio:Ratio = Carry / Volatility
Example: Using above, 0.0425 / 0.0794 ≈ 0.535.
If volatility is zero, the ratio is set to NA to avoid division errors.
Plot:Plots the ratio as a line, with optional thresholds (e.g., 0.2 for "high attractiveness") to guide interpretation.
NotesDynamic Rates: Using bond yields (e.g., TVC:JP10Y) or policy rates (e.g., ECONOMICS:JPINTR) makes the indicator responsive to historical and current rate changes, unlike static inputs.
Context: BIS reports use similar ratios to assess carry trade viability. For USDJPY in 2025, with Fed rates around 4.5% and BoJ at 0.25–0.5%, the carry is positive but sensitive to volatility spikes (e.g., during 2024 unwind events).
Usage: Apply to a yen pair chart (e.g., USDJPY, AUDJPY). Adjust symbols for the target currency (e.g., TVC:AU10Y for AUD). The ratio helps compare carry trade profitability across pairs or over time.
Converts rates to decimals: (target_rate - yen_rate) / 100.
Calculate Carry:Carry = (Target Rate - Yen Rate) / 100
Example: If US 10Y yield is 4.50% and Japan 10Y is 0.25%, carry = (4.50 - 0.25) / 100 = 0.0425 (4.25% annual yield).
Calculate Daily Log Returns:Log Returns = ln(Close / Close[1]), where Close is the current price of the pair (e.g., USDJPY) and Close[1] is the previous day's price.
This measures daily percentage changes in a way suitable for volatility calculations.
Calculate Annualized Volatility:Volatility = Standard Deviation of Log Returns over a lookback period (default 63 days, ~3 months) × √252.
Example: If the standard deviation of USDJPY log returns is 0.005 (0.5% daily), annualized volatility = 0.005 × √252 ≈ 0.0794 (7.94%).
Compute the Ratio:Ratio = Carry / Volatility
Example: Using above, 0.0425 / 0.0794 ≈ 0.535.
If volatility is zero, the ratio is set to NA to avoid division errors.
Plot:Plots the ratio as a line, with optional thresholds (e.g., 0.2 for "high attractiveness") to guide interpretation.
NotesDynamic Rates: Using bond yields (e.g., TVC:JP10Y) or policy rates (e.g., ECONOMICS:JPINTR) makes the indicator responsive to historical and current rate changes, unlike static inputs.
Context: BIS reports use similar ratios to assess carry trade viability. For USDJPY in 2025, with Fed rates around 4.5% and BoJ at 0.25–0.5%, the carry is positive but sensitive to volatility spikes (e.g., during 2024 unwind events).
Usage: Apply to a yen pair chart (e.g., USDJPY, AUDJPY). Adjust symbols for the target currency (e.g., TVC:AU10Y for AUD). The ratio helps compare carry trade profitability across pairs or over time.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.