
DMM FX用の時間帯別勝率ツール
DMM FXからダウンロードできる取引履歴をまとめてブチ込むと、
時間帯別の勝率を出せるツールを作りました。
東京時間午前・午後、欧州時間、NY時間とざっくり分けています。
準備と使い方
決済のみの約定履歴を表示し、統計を取りたい期間のCSVをダウンロードします。DMM FXは取引履歴が100件づつしかダウンロードできないので
頑張ってダウンロードしましょう。

ツール(後述)を起動すると、ファイル選択ダイアログが開きます。
先ほどダウンロードした履歴を選択して(複数選択可能)、開くを押します。

すると、結果がコンソールウィンドウに表示されます。
時間帯・取引回数・勝率・利益など。

このツールを使うにはPythonのインストールと、pandasの追加が必要です。Pythonは、無料でダウンロードできるので検索してインストールしてください。
pandasは、pythonをインストールした後にウインドウズマークをクリックしてcmdとキーを打ち、「pip install pandas」これをコピペしてください。
これで準備完了です。
以下にPythonコードを記載します。
知らないと、なんだコレ面倒くせえってなると思いますけど、
エディタにコピペして.pyと拡張子をつけて保存するだけです。
プログラムから開く→Pythonで使用してください。
import tkinter as tk
from tkinter import filedialog
import pandas as pd
# Function to select multiple files
def select_files():
root = tk.Tk()
root.withdraw() # Hide the main window
file_paths = filedialog.askopenfilenames() # Show the file selection dialog
return file_paths
# Function to categorize the hours into time slots
def categorize_hour(hour):
if 7 <= hour < 12:
return '07-12'
elif 12 <= hour < 16:
return '12-16'
elif 16 <= hour < 21:
return '16-21'
elif 21 <= hour or hour < 5: # 5時までを含むように変更
return '21-5'
else:
return 'other'
# Use the select_files function
file_paths = select_files()
dataframes = [] # List to store DataFrames
for file_path in file_paths:
# Load the CSV file with SHIFT-JIS encoding
df = pd.read_csv(file_path, encoding='SHIFT-JIS')
# Convert the '約定日時' column to datetime
df['約定日時'] = pd.to_datetime(df['約定日時'])
# Remove comma from '決済損益(円)' and convert it to integer
df['決済損益(円)'] = df['決済損益(円)'].str.replace(',', '').astype(int)
# Create a new column '勝ち負け' to show whether the trade is win(1) or loss(0)
df['勝ち負け'] = (df['決済損益(円)'] > 0).astype(int)
# Extract the hour from '約定日時'
df['hour'] = df['約定日時'].dt.hour
# Apply the function to the 'hour' column and create a new column '時間帯'
df['時間帯'] = df['hour'].apply(categorize_hour)
# Append the DataFrame to the list
dataframes.append(df)
# Concatenate all DataFrames
all_data = pd.concat(dataframes, ignore_index=True)
# Count the total number of trades per time slot for all data
total_count = all_data.groupby('時間帯').size()
# Count the number of wins per time slot for all data
win_count = all_data[all_data['勝ち負け'] == 1].groupby('時間帯').size()
# Calculate the win rate per time slot and convert it to percentage
win_rate = win_count / total_count
win_rate_percentage = win_rate.apply(lambda x: f'{x * 100:.2f}%')
# Calculate the total profit per time slot
total_profit = all_data[all_data['決済損益(円)'] > 0].groupby('時間帯')['決済損益(円)'].sum()
# Calculate the total loss per time slot
total_loss = all_data[all_data['決済損益(円)'] < 0].groupby('時間帯')['決済損益(円)'].sum()
# Calculate the net profit per time slot
net_profit = total_profit + total_loss
# Create a DataFrame to hold the results
results = pd.DataFrame({
'取引回数': total_count,
'勝率(%)': win_rate_percentage,
'利益合計(円)': total_profit,
'損失合計(円)': total_loss,
'純利益(円)': net_profit
})
print(results)
input("終了するにはウインドウを閉じてください")
統計を取る時間を変えたい人
if 7 <= hour < 12:
return '07-12'
elif 12 <= hour < 16:
return '12-16'
elif 16 <= hour < 21:
return '16-21'
elif 21 <= hour or hour < 5: # 5時までを含むように変更
return '21-5'
else:
return 'other'
ここをいじると統計を取る時間を変えられます。
他業者の約定履歴CSVがあれば他の業者対応のものもたぶん作れますので、欲しい人がいたらTwitterまで。
お金の有り余ってる億トレはサポート(投げ銭)をお願いします
追記
Pythonとか面倒くさいしわからんという人のためにexe版を用意しました。
https://26.gigafile.nu/0830-b056b79235dca6281233c22add9989b7d
ギガファイル便で30日間残る設定にしたので、だいたい8月末くらいまでは使えるはず。exeをダウンロードしようとしたり、開こうとすると未知のスクリプトでアラートが出ると思うのですが、自己責任で使用してください。

初NOTEなので、スキを押してくれたら震えて喜びます。
よろしくお願いいたします。
いいなと思ったら応援しよう!
