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.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.