クロス円の値動きを見ていると、USDJPYに引かれているのかドルストレートに引かれているのか、数値的に解釈するために、各通貨間の相関係数を計算するコードを作成した。
from datetime import datetime
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import yfinance as yf
from statsmodels.tsa.stattools import adfuller
import plotly.express as px
USDJPY = "USDJPY=X"
EURUSD = "EURUSD=X"
GBPUSD = "GBPUSD=X"
AUDUSD = "AUDUSD=X"
USDCHF = "USDCHF=X"
EURGBP = "EURGBP=X"
EURJPY = "EURJPY=X"
GBPJPY = "GBPJPY=X"
AUDJPY = "AUDJPY=X"
NZDJPY = "NZDJPY=X"
CHFJPY = "CHFJPY=X"
ZARJPY = "ZARJPY=X"
EURCHF = "EURCHF=X"
START_DAY = "2023-01-01"
END_DAY = "2023-01-11"
usdjpy = yf.download(USDJPY, start=START_DAY,end=END_DAY)
eurusd = yf.download(EURUSD, start=START_DAY,end=END_DAY)
gbpusd = yf.download(GBPUSD, start=START_DAY,end=END_DAY)
audusd = yf.download(AUDUSD, start=START_DAY,end=END_DAY)
usdchf = yf.download(USDCHF, start=START_DAY,end=END_DAY)
eurgbp = yf.download(EURGBP, start=START_DAY,end=END_DAY)
eurjpy = yf.download(EURJPY, start=START_DAY,end=END_DAY)
gbpjpy = yf.download(GBPJPY, start=START_DAY,end=END_DAY)
audjpy = yf.download(AUDJPY, start=START_DAY,end=END_DAY)
nzdjpy = yf.download(NZDJPY, start=START_DAY,end=END_DAY)
chfjpy = yf.download(CHFJPY, start=START_DAY,end=END_DAY)
zarjpy = yf.download(ZARJPY, start=START_DAY,end=END_DAY)
eurchf = yf.download(EURCHF, start=START_DAY,end=END_DAY)
alldata = pd.concat([usdjpy.Close,eurusd.Close,gbpusd.Close,audusd.Close,
usdchf.Close,eurgbp.Close,eurjpy.Close,gbpjpy.Close,
audjpy.Close,nzdjpy.Close,chfjpy.Close,zarjpy.Close,
eurchf.Close],axis=1)
alldata.columns = ('USD/JPY','EUR/USD','GBP/USD','AUD/USD',
'USD/CHF','EUR/GBP','EUR/JPY','GBP/JPY',
'AUD/JPY','NZD/JPY','CHF/JPY','ZAR/JPY',
'EUR/CHF')
alldata.dropna()
correlation_coefficients = alldata.corr()
fig,ax = plt.subplots(figsize=(18,6))
plt.rcParams['font.size'] = 10.5
plt.rcParams["figure.figsize"] = (20,3)
sns.heatmap(correlation_coefficients, vmax=1, vmin=-1, cmap='seismic',
square=True, annot=True, xticklabels=1, yticklabels=1)
plt.xlim([0, correlation_coefficients.shape[0]])
plt.ylim([0, correlation_coefficients.shape[0]])
plt.show()
2023年の最初から現在までのdataを解析すると、クロス円はUSDJPYよりもドルストレートの値動きに引きずられていると考えられる。