I found the trend by this code. This trend is from Japanese Workers' Pay Day(Every 25th day in a month). '''python import yfinance as yf import matplotlib . pyplot as plt import pandas as pd import seaborn as sns # 分析期間の設定 dateStart = "2015-01-01" dateEnd = "2026-05-23" ticker = "JPY=X" # ドル円 # yfinanceから取得(仕様変更の警告回避のため auto_adjust を明示) df = yf . download ( ticker , start = dateStart , end = dateEnd , auto_adjust = False , progress = False ) # yfinanceの仕様変更(MultiIndex化)に対応して終値を安全に抽出 if isinstance ( df . columns , pd . MultiIndex ): close = df [ "Close" ][ ticker ].dropna() else : close = df [ "Close" ]. dropna () # 前日比の変化率(%)を計算 # ドル円の場合、プラス = ドル買い/円売り、マイナス = ドル売り/円買い daily_return = close . pct_change () * 100 # 分析用のDataFrameを作成 analysis_df = pd . DataFrame ({ "Return" : daily_return }) analysis_df . index = pd . to_datetime ( analysis_df . index ...
Sin Waves and Cos Waves
I wrote some code about Sin waves and Cos waves.
I hope you can enjoy this figures.
import numpy as np
import matplotlib.pyplot as plt
# データ生成
x = np.linspace(-3.15, 3.15, 100)
y1 = np.sin(x)
y2 = -y1
y3 = y1 / 2
y4 = - y3
y5 = y3 / 2
y6 = -y5
y7 = y5 / 2
y8 = -y7
y9 = y7 / 2
y10 = -y9
# グラフ描画
plt.figure(figsize=(8, 6))
plt.plot(x, y1)
plt.plot(x, y2)
plt.plot(x, y3)
plt.plot(x, y4)
plt.plot(x, y5)
plt.plot(x, y6)
plt.plot(x, y7)
plt.plot(x, y8)
plt.plot(x, y9)
plt.plot(x, y10)
plt.xlabel("x")
plt.ylabel("y")
plt.title("Sin Waves")
plt.legend()
plt.grid(True)
plt.show()
# データ生成
x = np.linspace(-3.15, 3.15, 100)
y1 = np.cos(x)
y2 = -y1
y3 = y1 / 2
y4 = - y3
y5 = y3 / 2
y6 = -y5
y7 = y5 / 2
y8 = -y7
y9 = y7 / 2
y10 = -y9
# グラフ描画
plt.figure(figsize=(8, 6))
plt.plot(x, y1)
plt.plot(x, y2)
plt.plot(x, y3)
plt.plot(x, y4)
plt.plot(x, y5)
plt.plot(x, y6)
plt.plot(x, y7)
plt.plot(x, y8)
plt.plot(x, y9)
plt.plot(x, y10)
plt.xlabel("x")
plt.ylabel("y")
plt.title("Cos Waves")
plt.legend()
plt.grid(True)
plt.show()


Comments
Post a Comment